You can interact with this notebook online: Launch notebook

How to Store 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 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')
Atomic Data kurucz_cd23_chianti_H_He already exists in /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.
[tardis.io.model.parse_atom_data][INFO   ]

        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (parse_atom_data.py:40)
[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:34)
[tardis.io.atom_data.base][INFO   ]
        Reading Atom Data with: UUID = 6f7b09e887a311e7a06b246e96350010 MD5  = 864f1753714343c41f99cb065710cace  (base.py:262)
[tardis.io.atom_data.base][INFO   ]
        Non provided Atomic Data: synpp_refs, photoionization_data, yg_data, two_photon_data, linelist_atoms, linelist_molecules (base.py:266)
[tardis.io.model.parse_density_configuration][WARNING]
        Number of density points larger than number of shells. Assuming inner point irrelevant (parse_density_configuration.py:114)
[tardis.model.matter.decay][INFO   ]
        Decaying abundances for 1123200.0 seconds (decay.py:101)
[tardis.simulation.base][INFO   ]

        Starting iteration 1 of 20 (base.py:450)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/transport/montecarlo/montecarlo_main_loop.py:123: NumbaTypeSafetyWarning: unsafe cast from uint64 to int64. Precision may be lost.
  vpacket_collection = vpacket_collections[i]
 (warnings.py:112)
[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:663)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 9.93e+03 K 1.01e+04 K 0.4 0.507
5 9.85e+03 K 1.02e+04 K 0.211 0.197
10 9.78e+03 K 1.01e+04 K 0.143 0.117
15 9.71e+03 K 9.87e+03 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 2 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.01e+04 K 1.08e+04 K 0.507 0.525
5 1.02e+04 K 1.1e+04 K 0.197 0.203
10 1.01e+04 K 1.08e+04 K 0.117 0.125
15 9.87e+03 K 1.05e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 3 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.08e+04 K 1.1e+04 K 0.525 0.483
5 1.1e+04 K 1.12e+04 K 0.203 0.189
10 1.08e+04 K 1.1e+04 K 0.125 0.118
15 1.05e+04 K 1.06e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 4 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 2/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.483 0.469
5 1.12e+04 K 1.12e+04 K 0.189 0.182
10 1.1e+04 K 1.1e+04 K 0.118 0.113
15 1.06e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 5 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.469 0.479
5 1.12e+04 K 1.13e+04 K 0.182 0.178
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 6 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 4/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.479 0.47
5 1.13e+04 K 1.12e+04 K 0.178 0.185
10 1.1e+04 K 1.11e+04 K 0.113 0.112
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 7 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 5/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.47 0.47
5 1.12e+04 K 1.13e+04 K 0.185 0.178
10 1.11e+04 K 1.11e+04 K 0.112 0.112
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 8 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 6/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.47 0.472
5 1.13e+04 K 1.14e+04 K 0.178 0.175
10 1.11e+04 K 1.11e+04 K 0.112 0.111
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 9 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 7/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.472 0.469
5 1.14e+04 K 1.15e+04 K 0.175 0.17
10 1.11e+04 K 1.11e+04 K 0.111 0.109
15 1.07e+04 K 1.08e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 10 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 8/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.1e+04 K 0.469 0.475
5 1.15e+04 K 1.14e+04 K 0.17 0.177
10 1.11e+04 K 1.11e+04 K 0.109 0.112
15 1.08e+04 K 1.06e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 11 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 9/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.475 0.472
5 1.14e+04 K 1.12e+04 K 0.177 0.184
10 1.11e+04 K 1.1e+04 K 0.112 0.114
15 1.06e+04 K 1.06e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 12 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 10/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.472 0.467
5 1.12e+04 K 1.13e+04 K 0.184 0.176
10 1.1e+04 K 1.11e+04 K 0.114 0.11
15 1.06e+04 K 1.08e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 13 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 11/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.467 0.466
5 1.13e+04 K 1.13e+04 K 0.176 0.18
10 1.11e+04 K 1.11e+04 K 0.11 0.111
15 1.08e+04 K 1.08e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 14 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 12/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.466 0.469
5 1.13e+04 K 1.13e+04 K 0.18 0.182
10 1.11e+04 K 1.1e+04 K 0.111 0.113
15 1.08e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 15 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 13/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.1e+04 K 0.469 0.484
5 1.13e+04 K 1.13e+04 K 0.182 0.181
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 16 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 14/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.1e+04 K 0.484 0.472
5 1.13e+04 K 1.13e+04 K 0.181 0.177
10 1.1e+04 K 1.1e+04 K 0.113 0.113
15 1.07e+04 K 1.06e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 17 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 15/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.1e+04 K 1.11e+04 K 0.472 0.468
5 1.13e+04 K 1.14e+04 K 0.177 0.175
10 1.1e+04 K 1.11e+04 K 0.113 0.11
15 1.06e+04 K 1.08e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 18 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 16/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.468 0.464
5 1.14e+04 K 1.13e+04 K 0.175 0.177
10 1.11e+04 K 1.1e+04 K 0.11 0.113
15 1.08e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Starting iteration 19 of 20 (base.py:450)
[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:663)
[tardis.simulation.base][INFO   ]
        Iteration converged 17/4 consecutive times. (base.py:262)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:631)
Shell No. t_rad next_t_rad w next_w
0 1.11e+04 K 1.11e+04 K 0.464 0.466
5 1.13e+04 K 1.13e+04 K 0.177 0.177
10 1.1e+04 K 1.11e+04 K 0.113 0.111
15 1.07e+04 K 1.07e+04 K 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:658)
[tardis.simulation.base][INFO   ]

        Simulation finished in 19 iterations
        Simulation took 46.35 s
 (base.py:548)
[tardis.simulation.base][INFO   ]

        Starting iteration 20 of 20 (base.py:450)
[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:663)

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]
        /home/runner/work/tardis/tardis/tardis/io/util.py:289: 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->Index([0], dtype='int64')]

  data.to_hdf(buf, key=os.path.join(path, key))
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:276: 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->Index([0], dtype='int64')]

  pd.DataFrame(value).to_hdf(
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:292: 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]

  pd.Series(scalars).to_hdf(buf, key=os.path.join(path, "scalars"))
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/spectrum/formal_integral.py:384: UserWarning: The number of interpolate_shells was not specified. The value was set to 80.
  warnings.warn(
 (warnings.py:112)

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/transport/transport_state/emitted_packet_mask',
 '/simulation/transport/transport_state/j_blue_estimator',
 '/simulation/transport/transport_state/j_estimator',
 '/simulation/transport/transport_state/last_interaction_in_nu',
 '/simulation/transport/transport_state/last_interaction_in_r',
 '/simulation/transport/transport_state/last_interaction_type',
 '/simulation/transport/transport_state/last_line_interaction_in_id',
 '/simulation/transport/transport_state/last_line_interaction_out_id',
 '/simulation/transport/transport_state/last_line_interaction_shell_id',
 '/simulation/transport/transport_state/nu_bar_estimator',
 '/simulation/transport/transport_state/output_energy',
 '/simulation/transport/transport_state/output_nu',
 '/simulation/transport/transport_state/packet_luminosity',
 '/simulation/transport/transport_state/scalars',
 '/simulation/spectrum_solver/montecarlo_virtual_luminosity',
 '/simulation/spectrum_solver/spectrum_virtual_packets/_frequency',
 '/simulation/spectrum_solver/spectrum_virtual_packets/luminosity',
 '/simulation/spectrum_solver/spectrum_virtual_packets/luminosity_density_lambda',
 '/simulation/spectrum_solver/spectrum_virtual_packets/scalars',
 '/simulation/spectrum_solver/spectrum_virtual_packets/wavelength',
 '/simulation/spectrum_solver/spectrum_real_packets_reabsorbed/_frequency',
 '/simulation/spectrum_solver/spectrum_real_packets_reabsorbed/luminosity',
 '/simulation/spectrum_solver/spectrum_real_packets_reabsorbed/luminosity_density_lambda',
 '/simulation/spectrum_solver/spectrum_real_packets_reabsorbed/scalars',
 '/simulation/spectrum_solver/spectrum_real_packets_reabsorbed/wavelength',
 '/simulation/spectrum_solver/spectrum_real_packets/_frequency',
 '/simulation/spectrum_solver/spectrum_real_packets/luminosity',
 '/simulation/spectrum_solver/spectrum_real_packets/luminosity_density_lambda',
 '/simulation/spectrum_solver/spectrum_real_packets/scalars',
 '/simulation/spectrum_solver/spectrum_real_packets/wavelength',
 '/simulation/spectrum_solver/spectrum_integrated/_frequency',
 '/simulation/spectrum_solver/spectrum_integrated/luminosity',
 '/simulation/spectrum_solver/spectrum_integrated/luminosity_density_lambda',
 '/simulation/spectrum_solver/spectrum_integrated/scalars',
 '/simulation/spectrum_solver/spectrum_integrated/wavelength',
 '/simulation/simulation_state/abundance',
 '/simulation/simulation_state/density',
 '/simulation/simulation_state/dilution_factor',
 '/simulation/simulation_state/r_inner',
 '/simulation/simulation_state/scalars',
 '/simulation/simulation_state/t_radiative',
 '/simulation/simulation_state/v_inner',
 '/simulation/simulation_state/v_outer',
 '/simulation/plasma/beta_rad',
 '/simulation/plasma/beta_sobolev',
 '/simulation/plasma/continuum_interaction_species',
 '/simulation/plasma/dilute_planckian_radiation_field',
 '/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/nlte_excitation_species',
 '/simulation/plasma/nlte_ionization_species',
 '/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']

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

[4]:
print(data['/simulation/simulation_state/density'])
0     7.542804e-14
1     5.728475e-14
2     4.396074e-14
3     3.406287e-14
4     2.663135e-14
5     2.099596e-14
6     1.668287e-14
7     1.335311e-14
8     1.076154e-14
9     8.729085e-15
10    7.123652e-15
11    5.846921e-15
12    4.825093e-15
13    4.002324e-15
14    3.336039e-15
15    2.793540e-15
16    2.349550e-15
17    1.984397e-15
18    1.682677e-15
19    1.432260e-15
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/simulation_state/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)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:289: 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->Index([0], dtype='int64')]

  data.to_hdf(buf, key=os.path.join(path, key))
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:276: 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->Index([0], dtype='int64')]

  pd.DataFrame(value).to_hdf(
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:292: 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]

  pd.Series(scalars).to_hdf(buf, key=os.path.join(path, "scalars"))
 (warnings.py:112)
[7]:
import pandas

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

plasma_data.keys()
[7]:
['/parent/plasma/beta_rad',
 '/parent/plasma/beta_sobolev',
 '/parent/plasma/continuum_interaction_species',
 '/parent/plasma/dilute_planckian_radiation_field',
 '/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/nlte_excitation_species',
 '/parent/plasma/nlte_ionization_species',
 '/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)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:289: 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->Index([0], dtype='int64')]

  data.to_hdf(buf, key=os.path.join(path, key))
 (warnings.py:112)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:292: 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]

  pd.Series(scalars).to_hdf(buf, key=os.path.join(path, "scalars"))
 (warnings.py:112)
[9]:
import pandas

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

plasma_input_data.keys()
[9]:
['/plasma/continuum_interaction_species',
 '/plasma/dilute_planckian_radiation_field',
 '/plasma/j_blues',
 '/plasma/nlte_excitation_species',
 '/plasma/nlte_ionization_species',
 '/plasma/number_density',
 '/plasma/scalars']

Model

The following call will store properties of the SimulationState to /tmp/model_output.hdf under /simulation_state.

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

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

model_data.keys()
[11]:
['/simulation_state/abundance',
 '/simulation_state/density',
 '/simulation_state/dilution_factor',
 '/simulation_state/r_inner',
 '/simulation_state/scalars',
 '/simulation_state/t_radiative',
 '/simulation_state/v_inner',
 '/simulation_state/v_outer']

MontecarloTransport

The following call will store properties of the MontecarloTransport to /tmp/transport_output.hdf under /transport.

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

transport_data = pandas.HDFStore('/tmp/transport_output.hdf')

transport_data.keys()
[13]:
['/transport/transport_state/emitted_packet_mask',
 '/transport/transport_state/j_blue_estimator',
 '/transport/transport_state/j_estimator',
 '/transport/transport_state/last_interaction_in_nu',
 '/transport/transport_state/last_interaction_in_r',
 '/transport/transport_state/last_interaction_type',
 '/transport/transport_state/last_line_interaction_in_id',
 '/transport/transport_state/last_line_interaction_out_id',
 '/transport/transport_state/last_line_interaction_shell_id',
 '/transport/transport_state/nu_bar_estimator',
 '/transport/transport_state/output_energy',
 '/transport/transport_state/output_nu',
 '/transport/transport_state/packet_luminosity',
 '/transport/transport_state/scalars']