Skip to content

Validation fixes, ReSpecTh time shifts and speciation export - #145

Merged
kyleniemeyer merged 13 commits into
pr-omethe-us:mainfrom
LekiaAnonim:fix/validation-and-speciation-timeshift
Nov 13, 2026
Merged

kyleniemeyer merged 13 commits into
pr-omethe-us:mainfrom
LekiaAnonim:fix/validation-and-speciation-timeshift

Conversation

@LekiaAnonim

Copy link
Copy Markdown
Contributor

What this changes

Ten commits on top of main (0223292). They come from the ReSpecTh conversion work for ChemKED-database and are what its files need to pass validation.

Validation:

  • Rejects negative temperature and concentration values given as plain numbers.
  • Checks temperature on the absolute scale, so values in degC and degF are accepted.
  • Accepts an absolute uncertainty of exactly zero.
  • Compares the journal and author names from CrossRef after unescaping HTML entities (CrossRef returns Energy & Fuels).
  • Strips a resolver prefix from a DOI written as a URL (https://doi.org/...).

ReSpecTh conversion:

  • Normalizes numeric values and page ranges.
  • Unescapes HTML entities in journal and author names taken from CrossRef.
  • Reads ReSpecTh time shifts and the per-row uncertainty meaning of speciation profiles.
  • Converts common profile uncertainties to the units of the profile.
  • New: writes ChemKED speciation measurements to ReSpecTh XML.

Tests

New and changed tests are in tests/test_chemked.py, tests/test_converters.py, tests/test_validation.py and tests/test_respecth_fixtures.py.

Why now

The ChemKED-database pull-request check will install PyKED from main of this repository. The PyPI release 0.5.0 (1db5495) accepts chemked-version only up to 0.5.0a0 and only ignition delay files. With these commits on main, the check validates the ChemKED 0.5.0 files of ChemKED-database, including the speciation files with time shifts.

convert_to_ReSpecTh now writes a ChemKED speciation measurement as the
ReSpecTh speciation type its apparatus and swept axis call for: jet
stirred reactor, burner stabilized flame speciation, concentration time
profile (shock tube or flow reactor against time), or outlet
concentration measurement. It is the inverse of get_speciation_datapoints:
each datapoint becomes a dataGroup with the independent variables, one
column per concentration profile, conditions of that datapoint alone,
auxiliary profiles and per-row uncertainties as columns. Shared
conditions, the initial composition and uncertainties that describe a
whole profile or quantity become common properties; an uncertainty the
datapoints do not share is a column with one repeated value. The
reference is written as ReSpecTh 2 details, so reading it back needs no
DOI look-up.

All 576 speciation files of ChemKED-database round-trip through
ReSpecTh to an equal dict.

get_value_metadata now keeps the bound of a common uncertainty, which
was read as symmetric so a lower bound overwrote the upper one. No file
in the local ReSpecTh corpus has a one-sided common uncertainty.
The speciation reader dropped the timeshift element, and of a varying
uncertainty column it kept only the values: their name, kind, sourcetype
and method were lost, and the values were scaled by the profile's unit
factor rather than their own, so an evaluated standard deviation in mole
fraction on a ppm profile came out 1e6 too small.

- timeshift is read into the time-shift of every speciation datapoint,
  and "half increase" is an allowed time-shift type, as ReSpecTh uses it.
- A profile's uncertainty mapping says what the last value of each row
  is with the fields of one kind given without a value, such as
  evaluated-standard-deviation-type, -sourcetype and -method. A plain
  absolute uncertainty needs none, and stays the default meaning. The
  validator accepts such fields only when the rows end with a value,
  and requires the -type.
- An absolute uncertainty about a profile is converted from its own
  units to the profile's kind; a relative one is not rescaled.
- convert_to_ReSpecTh writes the row column as the profile describes it,
  so it stays the inverse of the reader.
A common uncertainty about a concentration profile was scaled to its own
kind, not the profile's, so an evaluated standard deviation in mole
fraction stayed a mole fraction on a mole percent profile, and on a
mol/cm3 profile.

It is now converted with uncertainty_factor, like a dataGroup column. An
uncertainty that cannot be stated in the profile's units, such as a mole
fraction about a concentration, which would need the density of the
mixture, is dropped with a warning, in a column as well as common. It is
not given to the inlet amount of the species instead.
@kyleniemeyer

Copy link
Copy Markdown
Member

@LekiaAnonim are the changes proposed here necessary for the validation checks in pr-omethe-us/ChemKED-database#46 to pass?

@LekiaAnonim

Copy link
Copy Markdown
Contributor Author

@LekiaAnonim are the changes proposed here necessary for the validation checks in pr-omethe-us/ChemKED-database#46 to pass?

Yes, especially for converted ReSpecTh files

kyleniemeyer and others added 3 commits November 13, 2026 10:47
The ruff-format pre-commit hook rejects any commit touching these files
as they stand. Layout only, with no change in behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An uncertainty is a span, but Pint converts a quantity in an offset unit
as a point on the scale. So an uncertainty of 10 degC about a temperature
in kelvin was loaded as 283.15 K, a temperature in degC with an
uncertainty of 10 K failed to load because the uncertainty became
-263.15 degC, and a negative uncertainty such as -5 degC passed the sign
check in validation as 268.15 K. The larger of two asymmetric bounds was
also chosen by comparing them as temperatures.

The new _as_difference restates a quantity in an offset unit in Pint's
delta unit, which converts as a span. Validation checks the sign of an
absolute uncertainty or evaluated standard deviation as a span, and
DataPoint converts absolute uncertainties, the bounds it compares, and
absolute evaluated standard deviations the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pint 0.26 is the first release that reads a value written as a string in
an offset unit, such as "25 degC"; earlier releases take it for 25
multiplied by degC and raise OffsetUnitCalculusError. The loader parses
values in that string form, so with Pint 0.24 (the last release for
Python 3.10) or 0.25 (the last for Python 3.11) a file with a
temperature in degC or degF failed to load, and the new tests of
uncertainties in those units failed on the Python 3.10 and 3.11 CI jobs.

Pint 0.26 itself requires Python 3.12, so Python 3.10 and 3.11 are
dropped: requires-python, the classifiers, the CI matrix and the ruff
target move to 3.12, and pint is required at >=0.26 so an older Pint
already installed on Python 3.12 or later is upgraded rather than kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyleniemeyer
kyleniemeyer merged commit 2fa29da into pr-omethe-us:main Nov 13, 2026
5 checks passed
kyleniemeyer added a commit that referenced this pull request Nov 13, 2026
The normalize_doi, normalize_value, and value_with_units imports added in
#145 were out of order, which ruff reports as I001. The ruff-format
pre-commit hook also rejects any commit touching the file until it is
formatted. Layout only, with no change in behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kyleniemeyer added a commit that referenced this pull request Nov 13, 2026
Both were committed unformatted in #144 and #145, so the ruff-format
pre-commit hook would reject the next commit touching either one. With
these, the whole repository passes ruff format. Layout only, with no
change in behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kyleniemeyer added a commit that referenced this pull request Nov 16, 2026
PR #145 added the made-up DOI 10.1021/mock.escaped to CROSSREF_RESPONSES
for the HTML-unescaping tests. The live API contract tests check every
DOI in CROSSREF_RESPONSES against the real CrossRef API, which returns
404 for it, so the weekly run has failed since #145 was merged.

Move it to a new CROSSREF_SYNTHETIC_RESPONSES, which the mock serves
alongside CROSSREF_RESPONSES but the contract tests do not check, as
CROSSREF_INVALID_DOIS already keeps the DOIs that should look invalid.
CONTRIBUTING.md says where a made-up record goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kyleniemeyer added a commit that referenced this pull request Nov 16, 2026
The default test run and the CI checks on pull requests both skip the
live API contract tests, so a problem they would catch, such as the
made-up DOI #145 added to the mock data, surfaces only in the weekly run
after it is merged. Ask contributors to run pytest -m live_api before
submitting any pull request, whatever it changes, since the tests are
there to catch errors no one expected. Say so in the pull request
checklist and the live API section of CONTRIBUTING.md, and in the same
section of the development docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants