Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiindex dataframe #2552

Merged
12 changes: 6 additions & 6 deletions tardis/energy_input/gamma_ray_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import astropy.units as u
import radioactivedecay as rd


from tardis.energy_input.energy_source import (
get_nuclear_lines_database,
)
from tardis.energy_input.util import KEV_ERG

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -119,8 +116,8 @@ def create_isotope_decay_df(cumulative_decay_df, gamma_ray_lines):
----------
cumulative_decay_df : pd.DataFrame
total decays for x g of isotope for time 't'
gamma_ray_lines : str
path to the atomic data file.
gamma_ray_lines : pd.DataFrame
gamma ray lines from nndc stored as a pandas dataframe.

Returns
-------
Expand Down Expand Up @@ -165,5 +162,8 @@ def create_isotope_decay_df(cumulative_decay_df, gamma_ray_lines):
isotope_decay_df["energy_per_channel_keV"]
* isotope_decay_df["number_of_decays"]
)
isotope_decay_df["decay_energy_erg"] = (
isotope_decay_df["decay_energy_keV"] * KEV_ERG
)

return isotope_decay_df
13 changes: 7 additions & 6 deletions tardis/energy_input/tests/test_gamma_ray_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def gamma_ray_test_composition(gamma_ray_simulation_state):

Returns
-------
Tardis model state
raw_isotopic_mass_fraction: Raw isotopic mass fraction
cell_masses: Mass of the cell
"""

raw_isotopic_mass_fraction = (
Expand All @@ -89,7 +90,7 @@ def test_calculate_cell_masses(gamma_ray_simulation_state):
"""Function to test calculation of shell masses.
Parameters
----------
simulation_setup: A simulation setup which returns a model.
gamma_ray_simulation_state: Tardis simulation state.
"""
volume = 2.70936170e39 * u.cm**3
density = 5.24801665e-09 * u.g / u.cm**3
Expand All @@ -108,7 +109,7 @@ def test_isotope_dicts(gamma_ray_test_composition, nuclide_name):
Function to test if the right names for the isotopes are present as dictionary keys.
Parameters
----------
simulation_setup: A simulation setup which returns a model.
gamma_ray_test_composition: Function holding the composition.
nuclide_name: Name of the nuclide.
"""
raw_isotopic_mass_fraction, cell_masses = gamma_ray_test_composition
Expand All @@ -124,7 +125,7 @@ def test_inventories_dict(gamma_ray_test_composition, nuclide_name):
Function to test if the inventories dictionary is created correctly.
Parameters
----------
simulation_setup: A simulation setup which returns a model.
gamma_ray_test_composition: Function holding the composition.
nuclide_name: Name of the nuclide.
"""

Expand Down Expand Up @@ -156,7 +157,7 @@ def test_mass_energy_conservation(
Function to test if the mass-energy conservation is satisfied.
Parameters
----------
simulation_setup: A simulation setup which returns a model.
gamma_ray_test_composition: Function holding the composition.
atomic_dataset: Tardis atomic-nuclear dataset
nuclide_name: Name of the nuclide."""

Expand Down Expand Up @@ -207,7 +208,7 @@ def test_activity(gamma_ray_test_composition, nuclide_name):
Function to test the decay of an atom in radioactivedecay with an analytical solution.
Parameters
----------
simulation_setup: A simulation setup which returns a model.
gamma_ray_test_composition: Function holding the composition.
nuclide_name: Name of the nuclide.
"""
# setup of decay test
Expand Down
1 change: 1 addition & 0 deletions tardis/energy_input/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
KEV2ERG = (1000 * u.eV).to("erg").value
C_CGS = const.c.cgs.value
H_CGS_KEV = const.h.to("keV s").value
KEV_ERG = (1 * u.keV).to("erg").value


@njit(**njit_dict_no_parallel)
Expand Down
Loading