opencr.data.checks
Checks of data before it enters a model.
Every importer runs these checks, and check_network_data runs them on a
whole network. A check returns a list of problems as sentences (empty when the
data are fine); raise_problems turns a non-empty list into a
DataError.
Attributes
| Name | Description |
|---|---|
REQUIRED_PROVENANCE | No description. |
Classes
| Name | Description |
|---|---|
DataError | Data failed a check; problems lists every problem found. |
Functions
| Name | Description |
|---|---|
check_cross_section | Check a cross-section table (eV, m^2). |
check_levels | Check the levels of one or more species. |
check_network_data | Check the data of every reaction and level of a network. |
check_provenance | Check that the fields required of a provenance are filled. |
check_rate_table | Check a rate-coefficient table (eV, SI). |
raise_problems | Raise DataError if problems is not empty. |
REQUIRED_PROVENANCEattributemodule attribute#
REQUIRED_PROVENANCE = ('reference', 'units', 'licence')DataErrorclass#
class DataError(problems: Sequence[str])Bases: ValueError
Data failed a check; problems lists every problem found.
check_cross_sectionfunction#
def check_cross_section(energy: Iterable[float], sigma: Iterable[float], threshold: float = 0.0, name: str = 'cross section', max_sigma: float = 1e-14, strict_threshold: bool = True) -> list[str]Check a cross-section table (eV, m^2).
Problems: arrays of different shapes or fewer than two points, missing
or infinite values, energies not increasing, negative energies or cross
sections, a negative threshold, a non-zero cross section below the
threshold (unless strict_threshold is false: plasmacoll sets a cross
section to zero below its threshold whatever the table says), and values
above max_sigma (1e-14 m^2 by default, a hint that the table is in cm^2).
check_levelsfunction#
def check_levels(states: Sequence[State]) -> list[str]Check the levels of one or more species.
Problems: repeated names, missing or infinite energies, and, per species,
a ground state not at the lowest energy among states ordered by their
principal quantum number n (energies must increase with n).
check_network_datafunction#
def check_network_data(network: ReactionNetwork, required: Sequence[str] = REQUIRED_PROVENANCE) -> list[str]Check the data of every reaction and level of a network.
The levels (check_levels), every cross section and rate table, and
the provenance of every reaction that is not a detailed balance.
check_provenancefunction#
def check_provenance(provenance: Provenance | None, name: str = 'data', required: Sequence[str] = REQUIRED_PROVENANCE) -> list[str]Check that the fields required of a provenance are filled.
reference needs a citation, licence a value other than
"unknown"; any other field must be non-empty.
check_rate_tablefunction#
def check_rate_table(temperatures: Iterable[float], values: Iterable[float], name: str = 'rate table') -> list[str]Check a rate-coefficient table (eV, SI).
Problems: arrays of different shapes or fewer than two points, missing or infinite values, temperatures not positive and increasing, negative rates.
raise_problemsfunction#
def raise_problems(problems: Sequence[str]) -> NoneRaise DataError if problems is not empty.