JANAF Thermochemical Tables Wrapper
janaf is a Python wrapper for the NIST-JANAF Thermochemical Tables, providing programmatic access to thermodynamic data for various chemical species. The current version is 1.2.1, with releases occurring a few times a year, often including dependency updates and minor feature enhancements.
Common errors
-
ModuleNotFoundError: No module named 'janaf'
cause The `janaf` package is not installed in your current Python environment.fixInstall the package using pip: `pip install janaf` -
AttributeError: 'Table' object has no attribute 'to_xarray'
cause You are trying to use the `to_xarray()` method, but the `xarray` optional dependency is not installed.fixInstall `janaf` with the `xarray` extra: `pip install "janaf[xarray]"` or install `xarray` directly: `pip install xarray`. -
ValueError: No data found for species 'MY_INVALID_SPECIES'
cause The species name provided to `janaf.get_table()` does not exactly match an entry in the NIST-JANAF Thermochemical Tables that `janaf` has access to.fixVerify the exact species name and casing against standard NIST-JANAF nomenclature. For example, use 'H2O' instead of 'WATER'. -
TypeError: cannot convert float NaN to integer
cause After `janaf` v1.1.0, missing data points are no longer imputed and appear as `NaN`. If your downstream code expects non-`NaN` numerical values or attempts to convert `NaN` floats to integers, this error can occur.fixExplicitly handle `NaN` values in the DataFrame returned by `get_table()`. Use methods like `.dropna()`, `.fillna()`, or ensure type conversions are robust to `NaN`.
Warnings
- breaking Python 3.8 support was dropped in `janaf` v1.2.1. If you are using Python 3.8 or older, you must either upgrade your Python version or pin `janaf` to a version older than 1.2.1.
- breaking As of v1.1.0, `janaf` no longer performs runtime imputation of missing data points (e.g., for `cp0/R`). If your code relied on these estimated values for certain species or temperature ranges, you might now encounter `NaN` values where data was previously provided.
- gotcha The `Table.to_xarray()` method requires the optional `xarray` dependency to be installed. If `xarray` is not installed, calling this method will result in an `AttributeError`.
Install
-
pip install janaf -
pip install "janaf[xarray]"
Imports
- get_table
from janaf import get_table
- constants
from janaf import constants
Quickstart
from janaf import get_table
# Get thermochemical data for Water
water_table = get_table("H2O")
# Access data as a pandas DataFrame
print("\nWater Table (first 5 rows):\n", water_table.df.head())
# Access specific properties
print(f"\nEnthalpy (H) at 298.15 K: {water_table.df.loc[298.15, 'H/RT']} RT")
# Get data for another species
oxygen_table = get_table("O2")
print("\nOxygen Table (first 5 rows):\n", oxygen_table.df.head())