Skip to content
Projects

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

NameDescription
REQUIRED_PROVENANCENo description.

Classes

NameDescription
DataErrorData failed a check; problems lists every problem found.

Functions

NameDescription
check_cross_sectionCheck a cross-section table (eV, m^2).
check_levelsCheck the levels of one or more species.
check_network_dataCheck the data of every reaction and level of a network.
check_provenanceCheck that the fields required of a provenance are filled.
check_rate_tableCheck a rate-coefficient table (eV, SI).
raise_problemsRaise 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.

problemsattributeinstance attribute#

problems = list(problems)

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]) -> None

Raise DataError if problems is not empty.