rizer.io.cross_sections.load_cross_sections#

Classes#

CrossSectionData

Dataclass to handle cross section information for each reaction.

Functions#

group_by_equation(→ dict[str, list[T]])

Group items by their equation attribute, preserving first-seen order.

load_cross_sections_summary_yaml() → dict[str, ...)

Load the yaml file containing the link between equation and alias for each database.

raise_type_error_on_isinstance(variable_to_test, ...)

filter_cross_sections_to_load(→ dict[str, dict[str, ...)

Filter the cross section to load, after a deepcopy.

load_cross_sections_data(→ list[CrossSectionData])

Load cross section data.

Module Contents#

rizer.io.cross_sections.load_cross_sections.group_by_equation[T: _HasEquation](items: list[T]) → dict[str, list[T]]#

Group items by their equation attribute, preserving first-seen order.

Shared by cross-section grouping here and, for the rate-fit types, rizer.kinetics.fit.rate_fit_common.group_and_sort_rates_by_equation.

Parameters:

items (list) – Items exposing an equation: str attribute.

Returns:

Dictionnary where equation are mapped to the corresponding items, in the order they appear in items.

Return type:

dict

class rizer.io.cross_sections.load_cross_sections.CrossSectionData#

Dataclass to handle cross section information for each reaction.

species_name: str#
equation: str#
database: str#
equation_alias: str#
df: rizer.io.cross_sections.lxcat.Collision#
rizer.io.cross_sections.load_cross_sections.load_cross_sections_summary_yaml(path_to_cross_sections_yaml: pathlib.Path = get_path_to_data('cross_sections', 'lxcat_cross_sections', 'cross_sections_summary.yaml')) → dict[str, dict[str, dict[str, str]]]#

Load the yaml file containing the link between equation and alias for each database.

Parameters:

path_to_cross_sections_yaml (pathlib.Path, optional) – Path to yaml file. See ./data/cross_sections/lxcat_cross_sections/cross_sections_summary.yaml for more.

Returns:

Example given:

# Name of the species, and the folder as well. {“H2”: # The reaction as it will appear in the kinetic scheme. {“e- + H2 => e- + e- + H2+”: # The name of the file/database, with the corresponding process name in that file. {“Biagi.txt”: “H2 -> +ionized H2”}}}

Return type:

dict of str to dict of str to dict of str to str

rizer.io.cross_sections.load_cross_sections.raise_type_error_on_isinstance(variable_to_test, expected_type, name_of_variable)#
rizer.io.cross_sections.load_cross_sections.filter_cross_sections_to_load(data: dict[str, dict[str, dict[str, str]]], species_to_keep: str | list[str] | None = None, species_to_remove: str | list[str] | None = None, equations_to_keep: str | list[str] | None = None, equations_to_remove: str | list[str] | None = None) → dict[str, dict[str, dict[str, str]]]#

Filter the cross section to load, after a deepcopy.

Can be useful, to avoid loading all the data if only a subsection is required.

Parameters:
  • data (dict of str to dict of str to dict of str to str) – See load_cross_sections_summary_yaml.

  • species_to_keep (str or list of str or None, optional) – Keep only the species provided, by default None. If None, keep all. If not None, cannot be set at the same time as species_to_remove.

  • species_to_remove (str or list of str or None, optional) – Remove the species provided, by default None. If None, no species are removed. If not None, cannot be set at the same time as species_to_keep.

  • equations_to_keep (str or list of str or None, optional) – Keep only the equation provided, by default None. If None, keep all. If not None, cannot be set at the same time as equations_to_remove.

  • equations_to_remove (str or list of str or None, optional) – Remove the equation provided, by default None. If None, no equation are removed If not None, cannot be set at the same time as equations_to_keep.

Returns:

See load_cross_sections_summary_yaml.

Return type:

dict of str to dict of str to dict of str to str

rizer.io.cross_sections.load_cross_sections.load_cross_sections_data(data: dict[str, dict[str, dict[str, str]]]) → list[CrossSectionData]#

Load cross section data.

Parsing is done using rizer.io.cross_sections.lxcat.LXCat class.

Parameters:

data (dict of str to dict of str to dict of str to str) – See load_cross_sections_summary_yaml.

Returns:

Loaded cross section information.

Return type:

list of CrossSectionData