optmat.datasets#
Curated datasets: literature values with their provenance and conditions.
A source is one paper (or one compilation, theory table or database); its record,
data/sources/<source>.toml, holds the citation, where the values are in the paper
library, how they were measured or computed, and one entry per dataset: a set of
values of one quantity for one material. A dataset’s values are either extracted from
a library table into data/values/<family>/<material>/<source>__<dataset>.csv (the
family is the quantity’s; optmat.vocabulary) by that source’s script under
tools/extract/, or, when they exist only in the text, listed in the record with
their page.
The files keep the values as printed. Everything that turns them into physics happens here, once:
units and printed scale factors are applied;
wavelengths (and wavenumbers) in standard air become vacuum wavelengths;
corrections of printed values (errata) are applied, each checked against the value it corrects;
quantities that determine the polarizability (a refractivity at a stated state, a polarizability, a molar refractivity) are converted to the per-particle polarizability through Lorentz-Lorenz with the number density the source meant.
Quantities that constrain dispersion only indirectly (phase-matching density ratios, group delays, oscillator strengths, Cauchy moments) are loaded and kept, but have no polarizability of their own; the fitting layer gives them forward models.
Module Attributes
The curated data shipped with the package. |
|
The extracted data files, |
|
The abscissa cell of a wavelength the source does not give. |
Functions
|
Return where a dataset's file lives. |
|
Return the curated datasets, optionally for one material or one quantity. |
|
Load one source record and its datasets. |
|
Parse a dataset's state. |
|
Return every curated source, by id. |
Classes
|
Values of one quantity for one material from one source, as printed. |
|
A correction of one printed value, with its justification. |
|
One source of values: its citation, provenance and datasets. |
|
How the uncertainty of a dataset's values is stated. |
- optmat.datasets.DATA_DIRECTORY: Final = PosixPath('/home/docs/checkouts/optmat/checkouts/7/src/optmat/data')#
The curated data shipped with the package.
- class optmat.datasets.Dataset(source, id, material, quantity, unit, scale, abscissa, abscissa_unit, wavelength_medium, state, density, uncertainty, use, reproduced_from, table, notes, parameters, excluded_rows, rows, abscissae, values, sigmas, columns=<factory>, column_units=<factory>, digitised='')[source]#
Bases:
objectValues of one quantity for one material from one source, as printed.
- Attributes:
- sourcestr
The source id.
- idstr
The dataset id, unique within its source.
- materialstr
The material’s id (
optmat.materials).- quantitystr
What the values are: “refractivity” (
n - 1), “polarizability”, “molar_refractivity”, “refractivity_per_density” ((n - 1) / N), or a quantity with no polarizability of its own (e.g. “phase_match_density_ratio”, “group_delay_dispersion”, “oscillator_strength”, “cauchy_moment”).- unitstr
The unit of the values after
scale: “1” for dimensionless, a polarizability unit (“au”, “angstrom3”, “cm3”, “SI”), “cm3/mol”, “cm3” (for a refractivity per density) or a quantity-specific unit.- scalefloat
The printed values times
scaleare inunit.- abscissastr
What the
xcolumn is (ABSCISSAE): “wavelength” (a wavelength, wavenumber or photon energy; “inf” is the static limit and “not stated” a wavelength the source does not give), “order”, “temperature”, “pressure”, “density”, “intensity”, “duration”, “field”, “label” or “none”.- abscissa_unitstr
The unit of the
xcolumn: for a wavelength “m”, “nm”, “um”, “angstrom”, a wavenumber (“cm-1”, “um-1”) or a photon energy (“eV”, “hartree”, “rydberg”); “” for a label or none.- wavelength_mediumstr
“vacuum”, or “standard_air” (15 degrees C, 101 325 Pa, Edlen 1966) for wavelengths and wavenumbers measured in air.
- stateState or None
The state the values refer to or are reduced to; None for per-particle quantities.
- densitystr
How the source related the values to its state: “real” (real-gas density), “ideal” (ideal-gas density) or “unknown”.
- uncertaintyUncertainty
How the uncertainty is stated.
- usestr
“primary” (enters fits), “reproduced” (a copy of another source’s values; never fitted beside the original), “check” (compared, not fitted) or “excluded”.
- reproduced_fromtuple of str
Source ids (or citations, for sources outside the library) of reproduced values.
- tablestr
The library table id, or “text” with the page in
notes, or, for values read from a figure, the library figure id.- notesstr
Anything else a reader needs.
- parametersdict
Quantity-specific metadata (the reference material of a ratio, the harmonic of a phase-matching measurement, the length a group delay refers to, …); see the data-format page of the manual.
beyond_resonance = truemarks values on the far side of a resonance, where n - 1 may be negative.- excluded_rowsdict of str to str
Rows of the file left out of the dataset, each with the reason (the paper’s own exclusions, points marked extrapolated, …).
- rowstuple of str
Row ids.
- abscissaetuple of str
The
xcolumn, as printed (after errata).- valuestuple of str
Value column, as printed (after errata).
- sigmastuple of str
Per-point uncertainty column, as printed, or empty strings.
- columnsdict of str to tuple of str
Extra per-row columns, as printed (after errata):
x_upper, the upper edge of an interval, in the abscissa’s unit; or a per-row condition in the unit ofcolumn_units.- column_unitsdict of str to str
The unit of each extra column (
x_upper’s is the abscissa’s).- digitisedstr
“” for values printed as numbers; “vector” for values read from a figure’s vector drawing in the PDF (the coordinates of its markers and lines, the axes calibrated from the drawing’s own ticks); “raster” for values read from a figure’s image. Figure data are used only where the source prints no number; they state their digitising uncertainty, and raster data never enter a fit.
- abscissa_values()[source]#
Return the abscissa as numbers in SI (a wavelength as printed).
- Returns:
- numpy.ndarray
A temperature in K, a pressure in Pa, a density in m^-3, an intensity in W/m^2, a field in V/m, an order as printed; a wavelength, wavenumber or energy in its printed unit (use
vacuum_wavelength()for the vacuum wavelength).
- Raises:
- DataError
If the abscissa is a label or none.
- angular_frequency()[source]#
Return the angular frequencies
2 pi c / lambda_vac.- Returns:
- numpy.ndarray
Angular frequency of each value, rad/s; 0 for a static value.
- column_values(name)[source]#
Return an extra column as numbers, as printed.
- Parameters:
- namestr
The column (
x_upper, or a per-row condition).
- Returns:
- numpy.ndarray
The column, in its unit (
x_upperin the abscissa’s).
- Raises:
- DataError
If the dataset has no such column.
- standard_uncertainty()[source]#
Return each value’s stated uncertainty as one standard deviation.
Per-point, relative and absolute statements are combined in quadrature.
- Returns:
- numpy.ndarray
One-sigma uncertainty in
unit; NaN where none is stated.
- uncertainty: Uncertainty#
- class optmat.datasets.Erratum(dataset, row, column, printed, corrected, reason, evidence)[source]#
Bases:
objectA correction of one printed value, with its justification.
- Attributes:
- datasetstr
The dataset id within the source.
- rowstr
The row id in the data file; “” for a correction of the whole dataset.
- columnstr
“x” (the abscissa), “value”, “sigma” or an extra column of the file; or, with
row = "", “scale” (a misprinted column factor).- printedstr
The value as printed (and as extracted or recorded); checked on loading.
- correctedstr
The corrected value, in the printed unit.
- reasonstr
Why the printed value is wrong.
- evidencestr
How the correction was established.
- optmat.datasets.NOT_STATED: Final = 'not stated'#
The abscissa cell of a wavelength the source does not give.
- class optmat.datasets.Source(id, citation, doi, library, identity, kind, technique, notes, entries, errata, formulas=())[source]#
Bases:
objectOne source of values: its citation, provenance and datasets.
A dataset is built, and its data file read, when it is first asked for (
datasetsbuilds them all,dataset()one), so the record’s citation, errata and formulas cost no data file.- Attributes:
- idstr
The source id, the record’s file stem.
- citationstr
The citation as it should be printed.
- doistr
The DOI, or “” if the work has none.
- librarystr
The paper-library directory, or “” if the work is not in the library.
- identitystr
The library’s bibliographic status of the record (“VALIDATED”, …).
- kindstr
“measurement”, “theory”, “compilation”, “fit” or “database”.
- techniquestr
How the values were obtained.
- notesstr
Anything else a reader needs.
- entriestuple of dict
The record’s dataset entries, as recorded (
[[datasets]]).- erratatuple of Erratum
The corrections applied.
- formulastuple of dict
The source’s published formulas, as recorded (
[[formulas]]); the ones with aformare built into models byoptmat.gas.models.formulas.
- dataset(dataset_id)[source]#
Return one dataset, reading only its data file.
- Parameters:
- dataset_idstr
The dataset’s id within the source.
- Returns:
- Dataset
The dataset, errata applied; the same object on every call.
- Raises:
- KeyError
If the source has no such dataset.
- DataError
If its entry or data file is malformed.
- class optmat.datasets.Uncertainty(relative=None, absolute=None, column=False, level='not stated', systematic_relative=None, relative_rows=<factory>)[source]#
Bases:
objectHow the uncertainty of a dataset’s values is stated.
- Attributes:
- relativefloat or None
Per-point relative uncertainty, at
level.- absolutefloat or None
Per-point absolute uncertainty in the printed unit (before
scale), atlevel.- columnbool
True if the data file carries a per-point
sigmacolumn in the printed unit.- levelstr
The confidence level as stated (“1 sigma”, “probable error”, “90 % confidence”, “95 % confidence”, “99 % confidence”, “2 sigma”, “3 sigma”, “rms”, “bound”), or “not stated”.
- systematic_relativefloat or None
A stated relative systematic uncertainty common to every point (a scale error), as one standard deviation; the prior of the dataset’s scale in a fit.
- relative_rowsdict of str to float
Per-row relative uncertainties that replace
relativefor those rows (a source that states a larger error near a resonance, say).
- optmat.datasets.VALUES_DIRECTORY: Final = PosixPath('/home/docs/checkouts/optmat/checkouts/7/src/optmat/data/values')#
The extracted data files,
<family>/<material>/<source>__<dataset>.csv.
- optmat.datasets.data_file(quantity, file)[source]#
Return where a dataset’s file lives.
- Parameters:
- quantitystr
The dataset’s quantity, whose family is the directory.
- filestr
The record’s
file,<material>/<source>__<dataset>.csv.
- Returns:
- pathlib.Path
data/values/<family>/<file>.
- Raises:
- DataError
If the quantity is unknown.
- optmat.datasets.datasets(material=None, *, quantity=None)[source]#
Return the curated datasets, optionally for one material or one quantity.
- Parameters:
- materialstr, optional
Only this material: its id or an alias (a gas species such as
"He", or"SiO2").- quantitystr, optional
Only this quantity (e.g. “refractivity”).
- Returns:
- tuple of Dataset
The matching datasets, in source order.
Examples
>>> all(d.material == "He" for d in datasets("He")) True
- optmat.datasets.load_source(path, *, defer=False)[source]#
Load one source record and its datasets.
- Parameters:
- pathpathlib.Path
The record,
data/sources/<source>.toml.- deferbool, optional
Build each dataset, and read its data file, only when it is first asked for, as the catalogue does; a malformed dataset then raises there. By default every dataset is built and checked here.
- Returns:
- Source
The source, with its datasets read (unless deferred) and errata applied.
- Raises:
- DataError
If the record or a data file is malformed or inconsistent.
- optmat.datasets.parse_state(spec, where)[source]#
Parse a dataset’s state.
- Parameters:
- specobject
A state name, a table with a pressure and a temperature, or None.
- wherestr
The dataset, for error messages.
- Returns:
- State or None
The state, or None if none is given.
- Raises:
- DataError
If the state is unknown or incomplete.