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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10fe61a481fdc708424c4c9c717672261d21efc55ddd4fa10f1b9de59126a879
|
|
| MD5 |
05f9785508aa0aa5823db8fc5cce1164
|
|
| BLAKE2b-256 |
5c3e8ad9b2fbbe1e478a6b1e67c7fdba55b3ad2c5af63e7b3c7bb02df74b16fd
|
Provenance
The following attestation bundles were made for olfarve-1.0.0.tar.gz:
Publisher:
publish.yml on aschet/pyolfarve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
olfarve-1.0.0.tar.gz -
Subject digest:
10fe61a481fdc708424c4c9c717672261d21efc55ddd4fa10f1b9de59126a879 - Sigstore transparency entry: 2341129503
- Sigstore integration time:
-
Permalink:
aschet/pyolfarve@23d71a61a2f223e56b35a893c544f37b6f9f2385 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/aschet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@23d71a61a2f223e56b35a893c544f37b6f9f2385 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d588eb9c513e20fa5ebe887bdd61c10809852fa8478681b067e9ab2c1be1d83e
|
|
| MD5 |
54fc81ee64607a0eeeff29c6986d4214
|
|
| BLAKE2b-256 |
688ac9da358f845ea8c0c44d24fbfd7c4e8c8b20e3733c86da53f65b9e65e05f
|
Provenance
The following attestation bundles were made for olfarve-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on aschet/pyolfarve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
olfarve-1.0.0-py3-none-any.whl -
Subject digest:
d588eb9c513e20fa5ebe887bdd61c10809852fa8478681b067e9ab2c1be1d83e - Sigstore transparency entry: 2341129510
- Sigstore integration time:
-
Permalink:
aschet/pyolfarve@23d71a61a2f223e56b35a893c544f37b6f9f2385 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/aschet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@23d71a61a2f223e56b35a893c544f37b6f9f2385 -
Trigger Event:
release
-
Statement type: