Skip to main content

pyolfarve

Øl farve ("beer color") renders SRM and EBC beer color values as sRGB colors, following the spectral model described by A. J. de Lange, "Color," in Brewing Materials and Processes, Elsevier, 2016, pp. 199-249.

Given a color value and an optical path length (the width of the glass the beer is viewed through), the sample's spectral transmittance is derived from its absorption coefficient at 430 nm via the Beer-Lambert law, integrated against the CIE 1931 color matching functions of the 2 degree standard colorimetric observer under illuminant D65, and the resulting XYZ tristimulus values are transformed to sRGB.

Installation

pip install olfarve

The package requires Python 3.10 or newer and has no runtime dependencies.

Usage

import olfarve

olfarve.srm_to_srgb(10).to_hex()
olfarve.ebc_to_srgb(20).to_hex()

# The default path length is 5 cm, the width of a typical sample glass
olfarve.srm_to_srgb(10, path_length_cm=1.0).to_hex()

# Results are SRGBColor named tuples of gamma encoded components in [0, 1]
color = olfarve.srm_to_srgb(10)
color.r, color.g, color.b
color.to_rgb8()

# Or start from an absorbance measured at 430 nm
olfarve.absorption_to_srgb(0.7874)

Command line

Installing the package provides an olfarve command. It takes one or more color values and prints them as CSV:

olfarve 1 2 10
1,#fae8b6
2,#f4d180
10,#ba5b00

Pick a scale and a path length:

olfarve --scale ebc --path-length 1.0 8 20 40

Run olfarve --help for the full list of options. The module is also executable via python -m olfarve.

Development

python -m venv .venv && . .venv/bin/activate
pip install -e . --group dev
pytest
ruff check .
mypy

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

olfarve-1.0.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

olfarve-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file olfarve-1.0.0.tar.gz.

File metadata

  • Download URL: olfarve-1.0.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for olfarve-1.0.0.tar.gz
Algorithm Hash digest
SHA256 10fe61a481fdc708424c4c9c717672261d21efc55ddd4fa10f1b9de59126a879
MD5 05f9785508aa0aa5823db8fc5cce1164
BLAKE2b-256 5c3e8ad9b2fbbe1e478a6b1e67c7fdba55b3ad2c5af63e7b3c7bb02df74b16fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for olfarve-1.0.0.tar.gz:

Publisher: publish.yml on aschet/pyolfarve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file olfarve-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: olfarve-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for olfarve-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d588eb9c513e20fa5ebe887bdd61c10809852fa8478681b067e9ab2c1be1d83e
MD5 54fc81ee64607a0eeeff29c6986d4214
BLAKE2b-256 688ac9da358f845ea8c0c44d24fbfd7c4e8c8b20e3733c86da53f65b9e65e05f

See more details on using hashes here.

Provenance

The following attestation bundles were made for olfarve-1.0.0-py3-none-any.whl:

Publisher: publish.yml on aschet/pyolfarve

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page