tardis.io.model.csvy.readers module

tardis.io.model.csvy.readers.load_csv_from_csvy(fpath: str | Path) DataFrame | None[source]

Load only the CSV data from a CSVY file.

Parameters:
fnamestr or pathlib.Path

Path to csvy file.

Returns:
datapandas.DataFrame or None

CSV data from csvy file, or None if no CSV data is present.

tardis.io.model.csvy.readers.load_csvy(fname: str | Path) CSVYData[source]

Load CSVY file and return a CSVYData dataclass object.

This function extracts velocity, density, and mass fractions from the CSVY file and constructs a CSVYData object. Velocity and density can be defined either in the YAML metadata or in the CSV data section.

Parameters:
fnamestr or pathlib.Path

Path to csvy file.

Returns:
CSVYData

Dataclass containing YAML metadata, velocity, density, and mass fractions.

tardis.io.model.csvy.readers.load_yaml_from_csvy(fpath: str | Path) dict[source]

Load only the YAML metadata from a CSVY file.

Parameters:
fnamestr or pathlib.Path

Path to csvy file.

Returns:
dict

YAML metadata dictionary from the csvy file.

Raises:
AssertionError

If the first line is not the YAML delimiter ‘—‘.

ValueError

If the closing YAML delimiter ‘—’ is not found.

tardis.io.model.csvy.readers.parse_csv_mass_fractions(csvy_data: DataFrame) tuple[Index, DataFrame, DataFrame][source]

Parse the CSV data part of a CSVY model file and extract mass fractions.

This function filters out columns that are not mass fractions and separates elemental and isotopic mass fractions.

Parameters:
csvy_datapandas.DataFrame

CSV data from CSVY file containing mass fraction columns.

Returns:
indexpandas.Index

Index of atomic numbers for elemental mass fractions.

mass_fractionspandas.DataFrame

DataFrame of elemental mass fractions with atomic_number as index.

isotope_mass_fractionspandas.DataFrame

DataFrame of isotopic mass fractions with MultiIndex of (atomic_number, mass_number).