tardis.io.model.artis.readers module

tardis.io.model.artis.readers.read_artis_density(fname: str | Path, legacy_return: bool = True) tuple[Quantity, Quantity, Quantity] | tuple[Quantity, Quantity, Quantity, DataFrame][source]

Read an ARTIS density file.

The file is expected to have:
  • First line: number of shells (ignored beyond reading the integer).

  • Second line: time of the model in days, which is then converted to seconds.

  • Remaining lines: columns containing cell_id, velocity (km/s), log10(density), and mass fractions of Ni56, Co56, Fe52, and Cr48.

Parameters:
fnamestr or pathlib.Path

Path to the ARTIS density file.

legacy_returnbool, optional

If True, returns (time_of_model, velocity, mean_density). If False, returns (time_of_model, velocity, mean_density, isotope_mass_fractions). Default is True.

Returns:
time_of_modelastropy.units.Quantity

The time at which the model is valid, in seconds.

velocityastropy.units.Quantity

The velocity array in cm/s.

mean_densityastropy.units.Quantity

The array of mean densities in g/cm^3, excluding the first (central) value.

isotope_mass_fractionspandas.DataFrame, optional

Mass fractions for Ni56, Co56, Fe52, and Cr48 if legacy_return=False. The DataFrame has a MultiIndex of (Z, A) for rows and the cell_id for columns.

Notes

The first density (i.e., the center of the model) is not used in the returned arrays.

tardis.io.model.artis.readers.read_artis_mass_fractions(fname: str | Path, normalize: bool = True) DataFrame[source]

Reads mass fractions from an ARTIS abundance file.

The file must have shell indices in the first column, followed by columns for each element. Each row generally corresponds to one shell.

Parameters:
fnamestr or pathlib.Path

Path to the ARTIS abundance file.

normalizebool, optional

If True, normalizes each row so the sum of mass fractions is 1. Default is True.

Returns:
pandas.DataFrame

A DataFrame with ‘atomic_number’ as its index and ‘cell_index’ as columns, holding the mass fractions for each element and shell.

tardis.io.model.artis.readers.read_artis_model(density_fname: str | Path, abundance_fname: str | Path) ArtisData[source]

Read density and abundance files, combine them, and return a single model dataset.

Parameters:
density_fnamestr or pathlib.Path

Path to the ARTIS density file.

abundance_fnamestr or pathlib.Path

Path to the ARTIS abundance file.

Returns:
ArtisData

Combined data with time_of_model, velocity, mean_density, and mass_fractions.