Skip to content

Commit

Permalink
Refactor ARTIS density and mass fractions readers for consistency and…
Browse files Browse the repository at this point in the history
… clarity
  • Loading branch information
wkerzendorf committed Feb 23, 2025
1 parent 63fb37e commit a82fc72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tardis/io/model/readers/artis.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ def read_artis_density(fname, legacy_return=True):
isotope_mass_fractions.columns.name = "cell_index"

if legacy_return:
return time_of_model, velocity, mean_density
return time_of_model, velocity, mean_density[1:]
else:
return time_of_model, velocity, mean_density, isotope_mass_fractions


def read_artis_mass_fractions(fname, normalize=True):
"""
Reads mass fractions from an artis abundance file named e.g. 'artis_abundances.dat'.
Reads mass fractions from an ARTIS abundance file named e.g. 'artis_abundances.dat'.
Each row typically corresponds to one shell. The first column is shell index,
followed by columns for each element.
Parameters
----------
fname : str
filename or path to artis abundances
filename or path to ARTIS abundances
Returns
-------
Expand Down
3 changes: 2 additions & 1 deletion tardis/io/model/readers/tests/test_artis_readers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import numpy.testing as npt
import pytest
from astropy import units as u

from tardis.io.model.readers.artis import (
Expand Down Expand Up @@ -62,7 +63,7 @@ def test_artis_model_reader(example_model_file_dir):


def test_simple_legacy_read_artis_density(artis_density_fname: str):
time_of_model, velocity, mean_density, isotope_mass_fractions = read_artis_density(
time_of_model, velocity, mean_density = read_artis_density(
artis_density_fname, legacy_return=True
)

Expand Down

0 comments on commit a82fc72

Please sign in to comment.