tardis.io.model.csvy package¶
Submodules¶
Module contents¶
- class tardis.io.model.csvy.CSVYData(model_config: ~tardis.io.configuration.config_reader.Configuration, velocity: ~numpy.ndarray, density: ~numpy.ndarray | None, mass_fractions: ~pandas.core.frame.DataFrame = <factory>, isotope_mass_fractions: ~pandas.core.frame.DataFrame = <factory>, raw_csv_data: ~pandas.core.frame.DataFrame | None = None)[source]¶
Bases:
objectData structure for CSVY model data.
- Parameters:
- model_configConfiguration
Validated configuration object from the CSVY file.
- velocitynp.ndarray
Velocity array for the model shells.
- densitynp.ndarray or None
Density array for the model shells.
- mass_fractionspd.DataFrame, optional
Mass fractions DataFrame with atomic_number as index.
- isotope_mass_fractionspd.DataFrame, optional
Isotope mass fractions DataFrame with MultiIndex of (atomic_number, mass_number).
- raw_csv_datapd.DataFrame or None, optional
Raw CSV data from the CSVY file.
- isotope_mass_fractions: DataFrame¶
- mass_fractions: DataFrame¶
- model_config: Configuration¶
- to_geometry(time_explosion: Quantity | None = None)[source]¶
Construct a HomologousRadial1DGeometry object from this CSVYData.
- Parameters:
- time_explosionastropy.units.Quantity, optional
Time of explosion. If None, attempts to extract from model_config.
- Returns:
- HomologousRadial1DGeometry
The geometry object constructed from the CSVY data.
- tardis.io.model.csvy.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.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.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.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).