You can interact with this notebook online: Launch interactive version

Storing Simulations to HDF

You can ask TARDIS to store the state of each iteration of the simulation you are running. We show examples of how this is done:

Initialize the simulation with the tardis_example.yml configuration file.

[1]:
from tardis import run_tardis
from tardis.io.atom_data.util import download_atom_data

# We download the atomic data needed to run the simulation
download_atom_data('kurucz_cd23_chianti_H_He')

# We run the simulation
simulation = run_tardis('tardis_example.yml')
/usr/share/miniconda3/envs/tardis/lib/python3.8/site-packages/setuptools_scm/git.py:105: UserWarning: "/home/runner/work/tardis/tardis" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
[tardis.plasma.standard_plasmas][INFO   ]

        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (standard_plasmas.py:93)
[tardis.io.atom_data.util][INFO   ]

        Atom Data kurucz_cd23_chianti_H_He.h5 not found in local path.
        Exists in TARDIS Data repo /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5 (util.py:33)
[tardis.io.atom_data.base][INFO   ]
        Reading Atom Data with: UUID = 6f7b09e887a311e7a06b246e96350010 MD5  = 864f1753714343c41f99cb065710cace  (base.py:249)
[tardis.io.atom_data.base][INFO   ]
        Non provided Atomic Data: synpp_refs, photoionization_data, yg_data, two_photon_data (base.py:253)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in true_divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in true_divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 1 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 7.942e+42 erg / s
        Luminosity absorbed  = 2.659e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 9.93e+03 1.01e+04 0.4 0.507
5 9.85e+03 1.02e+04 0.211 0.197
10 9.78e+03 1.01e+04 0.143 0.117
15 9.71e+03 9.87e+03 0.105 0.0869
[tardis.simulation.base][INFO   ]

        Current t_inner = 9933.952 K
        Expected t_inner for next iteration = 10703.212 K
 (base.py:542)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in true_divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 2 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.071e+43 erg / s
        Luminosity absorbed  = 3.576e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.01e+04 1.08e+04 0.507 0.525
5 1.02e+04 1.1e+04 0.197 0.203
10 1.01e+04 1.08e+04 0.117 0.125
15 9.87e+03 1.05e+04 0.0869 0.0933
[tardis.simulation.base][INFO   ]

        Current t_inner = 10703.212 K
        Expected t_inner for next iteration = 10673.712 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 3 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.074e+43 erg / s
        Luminosity absorbed  = 3.391e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.08e+04 1.1e+04 0.525 0.483
5 1.1e+04 1.12e+04 0.203 0.189
10 1.08e+04 1.1e+04 0.125 0.118
15 1.05e+04 1.06e+04 0.0933 0.0895
[tardis.simulation.base][INFO   ]

        Current t_inner = 10673.712 K
        Expected t_inner for next iteration = 10635.953 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 4 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.058e+43 erg / s
        Luminosity absorbed  = 3.352e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.483 0.469
5 1.12e+04 1.12e+04 0.189 0.182
10 1.1e+04 1.1e+04 0.118 0.113
15 1.06e+04 1.07e+04 0.0895 0.0861
[tardis.simulation.base][INFO   ]

        Current t_inner = 10635.953 K
        Expected t_inner for next iteration = 10638.407 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 5 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.055e+43 erg / s
        Luminosity absorbed  = 3.399e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.469 0.479
5 1.12e+04 1.13e+04 0.182 0.178
10 1.1e+04 1.1e+04 0.113 0.113
15 1.07e+04 1.07e+04 0.0861 0.0839
[tardis.simulation.base][INFO   ]

        Current t_inner = 10638.407 K
        Expected t_inner for next iteration = 10650.202 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 6 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.398e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.479 0.47
5 1.13e+04 1.12e+04 0.178 0.185
10 1.1e+04 1.11e+04 0.113 0.112
15 1.07e+04 1.07e+04 0.0839 0.0856
[tardis.simulation.base][INFO   ]

        Current t_inner = 10650.202 K
        Expected t_inner for next iteration = 10645.955 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 7 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.382e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.47 0.47
5 1.12e+04 1.13e+04 0.185 0.178
10 1.11e+04 1.11e+04 0.112 0.112
15 1.07e+04 1.07e+04 0.0856 0.086
[tardis.simulation.base][INFO   ]

        Current t_inner = 10645.955 K
        Expected t_inner for next iteration = 10642.050 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 8 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.062e+43 erg / s
        Luminosity absorbed  = 3.350e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 4/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.11e+04 0.47 0.472
5 1.13e+04 1.14e+04 0.178 0.175
10 1.11e+04 1.11e+04 0.112 0.111
15 1.07e+04 1.07e+04 0.086 0.084
[tardis.simulation.base][INFO   ]

        Current t_inner = 10642.050 K
        Expected t_inner for next iteration = 10636.106 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 9 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.052e+43 erg / s
        Luminosity absorbed  = 3.411e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 5/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.11e+04 0.472 0.469
5 1.14e+04 1.15e+04 0.175 0.17
10 1.11e+04 1.11e+04 0.111 0.109
15 1.07e+04 1.08e+04 0.084 0.0822
[tardis.simulation.base][INFO   ]

        Current t_inner = 10636.106 K
        Expected t_inner for next iteration = 10654.313 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 10 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.070e+43 erg / s
        Luminosity absorbed  = 3.335e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.1e+04 0.469 0.475
5 1.15e+04 1.14e+04 0.17 0.177
10 1.11e+04 1.11e+04 0.109 0.112
15 1.08e+04 1.06e+04 0.0822 0.0878
[tardis.simulation.base][INFO   ]

        Current t_inner = 10654.313 K
        Expected t_inner for next iteration = 10628.190 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 11 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.053e+43 erg / s
        Luminosity absorbed  = 3.363e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.475 0.472
5 1.14e+04 1.12e+04 0.177 0.184
10 1.11e+04 1.1e+04 0.112 0.114
15 1.06e+04 1.06e+04 0.0878 0.0859
[tardis.simulation.base][INFO   ]

        Current t_inner = 10628.190 K
        Expected t_inner for next iteration = 10644.054 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 12 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.056e+43 erg / s
        Luminosity absorbed  = 3.420e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.11e+04 0.472 0.467
5 1.12e+04 1.13e+04 0.184 0.176
10 1.1e+04 1.11e+04 0.114 0.11
15 1.06e+04 1.08e+04 0.0859 0.0821
[tardis.simulation.base][INFO   ]

        Current t_inner = 10644.054 K
        Expected t_inner for next iteration = 10653.543 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 13 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.062e+43 erg / s
        Luminosity absorbed  = 3.406e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.11e+04 0.467 0.466
5 1.13e+04 1.13e+04 0.176 0.18
10 1.11e+04 1.11e+04 0.11 0.111
15 1.08e+04 1.08e+04 0.0821 0.0841
[tardis.simulation.base][INFO   ]

        Current t_inner = 10653.543 K
        Expected t_inner for next iteration = 10647.277 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 14 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.063e+43 erg / s
        Luminosity absorbed  = 3.369e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.11e+04 0.466 0.469
5 1.13e+04 1.13e+04 0.18 0.182
10 1.11e+04 1.1e+04 0.111 0.113
15 1.08e+04 1.07e+04 0.0841 0.0854
[tardis.simulation.base][INFO   ]

        Current t_inner = 10647.277 K
        Expected t_inner for next iteration = 10638.875 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 15 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.053e+43 erg / s
        Luminosity absorbed  = 3.417e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.1e+04 0.469 0.484
5 1.13e+04 1.13e+04 0.182 0.181
10 1.1e+04 1.1e+04 0.113 0.113
15 1.07e+04 1.07e+04 0.0854 0.0858
[tardis.simulation.base][INFO   ]

        Current t_inner = 10638.875 K
        Expected t_inner for next iteration = 10655.125 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 16 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.059e+43 erg / s
        Luminosity absorbed  = 3.445e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 4/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.1e+04 0.484 0.472
5 1.13e+04 1.13e+04 0.181 0.177
10 1.1e+04 1.1e+04 0.113 0.113
15 1.07e+04 1.06e+04 0.0858 0.0858
[tardis.simulation.base][INFO   ]

        Current t_inner = 10655.125 K
        Expected t_inner for next iteration = 10655.561 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 17 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.067e+43 erg / s
        Luminosity absorbed  = 3.372e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 1.11e+04 0.472 0.468
5 1.13e+04 1.14e+04 0.177 0.175
10 1.1e+04 1.11e+04 0.113 0.11
15 1.06e+04 1.08e+04 0.0858 0.0816
[tardis.simulation.base][INFO   ]

        Current t_inner = 10655.561 K
        Expected t_inner for next iteration = 10636.536 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 18 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.057e+43 erg / s
        Luminosity absorbed  = 3.365e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.11e+04 0.468 0.464
5 1.14e+04 1.13e+04 0.175 0.177
10 1.11e+04 1.1e+04 0.11 0.113
15 1.08e+04 1.07e+04 0.0816 0.0848
[tardis.simulation.base][INFO   ]

        Current t_inner = 10636.536 K
        Expected t_inner for next iteration = 10641.692 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 19 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.056e+43 erg / s
        Luminosity absorbed  = 3.405e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:259)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:515)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 1.11e+04 0.464 0.466
5 1.13e+04 1.13e+04 0.177 0.177
10 1.1e+04 1.11e+04 0.113 0.111
15 1.07e+04 1.07e+04 0.0848 0.0853
[tardis.simulation.base][INFO   ]

        Current t_inner = 10641.692 K
        Expected t_inner for next iteration = 10650.463 K
 (base.py:542)
[tardis.simulation.base][INFO   ]

        Starting iteration 20 of 20 (base.py:378)
[tardis.simulation.base][INFO   ]

        Luminosity emitted   = 1.061e+43 erg / s
        Luminosity absorbed  = 3.401e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:547)
[tardis.simulation.base][INFO   ]

        Simulation finished in 20 iterations
        Simulation took 49.39 s
 (base.py:468)

You can now use the to_hdf method, to save properties to a HDF file.

Parameters

file_path: Path where the HDF file should be stored. (Required)
path: Path inside the HDF store to store the elements. (Optional)
name: Name of the group inside HDF store, under which properties will be saved.(Optional) overwrite: If the HDF file already exists, do you overwrite the existing file (Optional, default False)

Note

Throughout this notebook, we set overwrite=True so that the notebook can be run repeatedly if needed.

[2]:
simulation.to_hdf('/tmp/full_example.hdf', overwrite=True)

# The commented out code below shows an example of to_hdf with more parameters
#simulation.to_hdf(file_path='/tmp/full_example.hdf', path='/', name='simulation')
[py.warnings         ][WARNING]
        /usr/share/miniconda3/envs/tardis/lib/python3.8/site-packages/pandas/core/generic.py:2490: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block0_values] [items->Int64Index([0], dtype='int64')]

  pytables.to_hdf(
 (warnings.py:109)
[py.warnings         ][WARNING]
        /usr/share/miniconda3/envs/tardis/lib/python3.8/site-packages/pandas/core/generic.py:2490: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->values] [items->None]

  pytables.to_hdf(
 (warnings.py:109)

Open the stored HDF file with pandas and print a list of its entries using the keys() method:

[3]:
import pandas as pd

data = pd.HDFStore('/tmp/full_example.hdf', overwrite=True)

data.keys()
[3]:
['/simulation/iterations_electron_densities',
 '/simulation/iterations_t_inner',
 '/simulation/iterations_t_rad',
 '/simulation/iterations_w',
 '/simulation/runner/emitted_packet_mask',
 '/simulation/runner/j_estimator',
 '/simulation/runner/last_interaction_in_nu',
 '/simulation/runner/last_interaction_type',
 '/simulation/runner/last_line_interaction_in_id',
 '/simulation/runner/last_line_interaction_out_id',
 '/simulation/runner/last_line_interaction_shell_id',
 '/simulation/runner/montecarlo_virtual_luminosity',
 '/simulation/runner/nu_bar_estimator',
 '/simulation/runner/output_energy',
 '/simulation/runner/output_nu',
 '/simulation/runner/packet_luminosity',
 '/simulation/runner/scalars',
 '/simulation/runner/spectrum_virtual/_frequency',
 '/simulation/runner/spectrum_virtual/luminosity',
 '/simulation/runner/spectrum_virtual/luminosity_density_lambda',
 '/simulation/runner/spectrum_virtual/scalars',
 '/simulation/runner/spectrum_virtual/wavelength',
 '/simulation/runner/spectrum_reabsorbed/_frequency',
 '/simulation/runner/spectrum_reabsorbed/luminosity',
 '/simulation/runner/spectrum_reabsorbed/luminosity_density_lambda',
 '/simulation/runner/spectrum_reabsorbed/scalars',
 '/simulation/runner/spectrum_reabsorbed/wavelength',
 '/simulation/runner/spectrum/_frequency',
 '/simulation/runner/spectrum/luminosity',
 '/simulation/runner/spectrum/luminosity_density_lambda',
 '/simulation/runner/spectrum/scalars',
 '/simulation/runner/spectrum/wavelength',
 '/simulation/plasma/abundance',
 '/simulation/plasma/atomic_mass',
 '/simulation/plasma/beta_rad',
 '/simulation/plasma/beta_sobolev',
 '/simulation/plasma/continuum_interaction_species',
 '/simulation/plasma/density',
 '/simulation/plasma/electron_densities',
 '/simulation/plasma/excitation_energy',
 '/simulation/plasma/f_lu',
 '/simulation/plasma/g',
 '/simulation/plasma/g_electron',
 '/simulation/plasma/general_level_boltzmann_factor',
 '/simulation/plasma/ion_number_density',
 '/simulation/plasma/ionization_data',
 '/simulation/plasma/j_blues',
 '/simulation/plasma/level_boltzmann_factor',
 '/simulation/plasma/level_number_density',
 '/simulation/plasma/levels',
 '/simulation/plasma/lines',
 '/simulation/plasma/lines_lower_level_index',
 '/simulation/plasma/lines_upper_level_index',
 '/simulation/plasma/macro_atom_data',
 '/simulation/plasma/metastability',
 '/simulation/plasma/nu',
 '/simulation/plasma/number_density',
 '/simulation/plasma/partition_function',
 '/simulation/plasma/phi',
 '/simulation/plasma/scalars',
 '/simulation/plasma/selected_atoms',
 '/simulation/plasma/stimulated_emission_factor',
 '/simulation/plasma/t_electrons',
 '/simulation/plasma/t_rad',
 '/simulation/plasma/tau_sobolevs',
 '/simulation/plasma/transition_probabilities',
 '/simulation/plasma/w',
 '/simulation/plasma/wavelength_cm',
 '/simulation/model/r_inner',
 '/simulation/model/scalars',
 '/simulation/model/t_radiative',
 '/simulation/model/v_inner',
 '/simulation/model/v_outer',
 '/simulation/model/w',
 '/simulation/model/homologous_density/density_0',
 '/simulation/model/homologous_density/scalars']

Access model.homologous_density.density_0 under simulation, which is a one-dimensional array

[4]:
print(data['/simulation/model/homologous_density/density_0'])
0     1970.527174
1       13.360318
2       10.146658
3        7.786621
4        6.033444
5        4.717122
6        3.718946
7        2.954982
8        2.365191
9        1.906156
10       1.546154
11       1.261789
12       1.035646
13       0.854653
14       0.708918
15       0.590901
16       0.494811
17       0.416168
18       0.351490
19       0.298047
20       0.253691
dtype: float64

Scalars are stored in a scalars pandas.Series for every module. For example to access model.t_inner under simulation, one would need to do the following.

[5]:
print(data['/simulation/model/scalars']['t_inner'])
10650.463255529794

Breakdown of the various to_hdf methods

Every module in TARDIS has its own to_hdf method responsible to store its own data to an HDF file.

Plasma

The following call will store every plasma property to /tmp/plasma_output.hdf under /parent/plasma

[6]:
simulation.plasma.to_hdf('/tmp/plasma_output.hdf', path='parent', overwrite=True)
[7]:
import pandas

plasma_data = pandas.HDFStore('/tmp/plasma_output.hdf')

plasma_data.keys()
[7]:
['/parent/plasma/abundance',
 '/parent/plasma/atomic_mass',
 '/parent/plasma/beta_rad',
 '/parent/plasma/beta_sobolev',
 '/parent/plasma/continuum_interaction_species',
 '/parent/plasma/density',
 '/parent/plasma/electron_densities',
 '/parent/plasma/excitation_energy',
 '/parent/plasma/f_lu',
 '/parent/plasma/g',
 '/parent/plasma/g_electron',
 '/parent/plasma/general_level_boltzmann_factor',
 '/parent/plasma/ion_number_density',
 '/parent/plasma/ionization_data',
 '/parent/plasma/j_blues',
 '/parent/plasma/level_boltzmann_factor',
 '/parent/plasma/level_number_density',
 '/parent/plasma/levels',
 '/parent/plasma/lines',
 '/parent/plasma/lines_lower_level_index',
 '/parent/plasma/lines_upper_level_index',
 '/parent/plasma/macro_atom_data',
 '/parent/plasma/metastability',
 '/parent/plasma/nu',
 '/parent/plasma/number_density',
 '/parent/plasma/partition_function',
 '/parent/plasma/phi',
 '/parent/plasma/scalars',
 '/parent/plasma/selected_atoms',
 '/parent/plasma/stimulated_emission_factor',
 '/parent/plasma/t_electrons',
 '/parent/plasma/t_rad',
 '/parent/plasma/tau_sobolevs',
 '/parent/plasma/transition_probabilities',
 '/parent/plasma/w',
 '/parent/plasma/wavelength_cm']

Plasma’s to_hdf method can also accept a collection parameter which can specify which types of plasma properties will be stored. For example if we wanted to only store Input plasma properties, we would do the following:

[8]:
from tardis.plasma.properties.base import Input
simulation.plasma.to_hdf('/tmp/plasma_input_output.hdf', collection=[Input], overwrite=True)
[9]:
import pandas

plasma_input_data = pandas.HDFStore('/tmp/plasma_input_output.hdf')

plasma_input_data.keys()
[9]:
['/plasma/abundance',
 '/plasma/continuum_interaction_species',
 '/plasma/density',
 '/plasma/scalars',
 '/plasma/t_rad',
 '/plasma/w']

Model

The following call will store properties of the Radial1DModel to /tmp/model_output.hdf under /model.

[10]:
simulation.model.to_hdf('/tmp/model_output.hdf', overwrite=True)
[11]:
import pandas

model_data = pandas.HDFStore('/tmp/model_output.hdf')

model_data.keys()
[11]:
['/model/r_inner',
 '/model/scalars',
 '/model/t_radiative',
 '/model/v_inner',
 '/model/v_outer',
 '/model/w',
 '/model/homologous_density/density_0',
 '/model/homologous_density/scalars']

MontecarloRunner

The following call will store properties of the MontecarloRunner to /tmp/runner_output.hdf under /runner.

[12]:
simulation.runner.to_hdf('/tmp/runner_output.hdf', overwrite=True)
[13]:
import pandas

runner_data = pandas.HDFStore('/tmp/runner_output.hdf')

runner_data.keys()
[13]:
['/runner/emitted_packet_mask',
 '/runner/j_estimator',
 '/runner/last_interaction_in_nu',
 '/runner/last_interaction_type',
 '/runner/last_line_interaction_in_id',
 '/runner/last_line_interaction_out_id',
 '/runner/last_line_interaction_shell_id',
 '/runner/montecarlo_virtual_luminosity',
 '/runner/nu_bar_estimator',
 '/runner/output_energy',
 '/runner/output_nu',
 '/runner/packet_luminosity',
 '/runner/scalars',
 '/runner/spectrum_virtual/_frequency',
 '/runner/spectrum_virtual/luminosity',
 '/runner/spectrum_virtual/luminosity_density_lambda',
 '/runner/spectrum_virtual/scalars',
 '/runner/spectrum_virtual/wavelength',
 '/runner/spectrum_reabsorbed/_frequency',
 '/runner/spectrum_reabsorbed/luminosity',
 '/runner/spectrum_reabsorbed/luminosity_density_lambda',
 '/runner/spectrum_reabsorbed/scalars',
 '/runner/spectrum_reabsorbed/wavelength',
 '/runner/spectrum/_frequency',
 '/runner/spectrum/luminosity',
 '/runner/spectrum/luminosity_density_lambda',
 '/runner/spectrum/scalars',
 '/runner/spectrum/wavelength']