You can interact with this notebook online: Launch notebook

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.11/site-packages/setuptools_scm/git.py:162: UserWarning: "/home/runner/work/tardis/tardis" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
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.simulation.base][INFO   ]

        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (base.py:681)
[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:36)
[tardis.io.atom_data.base][INFO   ]
        Reading Atom Data with: UUID = 6f7b09e887a311e7a06b246e96350010 MD5  = 864f1753714343c41f99cb065710cace  (base.py:258)
[tardis.io.atom_data.base][INFO   ]
        Non provided Atomic Data: synpp_refs, photoionization_data, yg_data, two_photon_data, linelist (base.py:262)
[tardis.model.parse_input][WARNING]
        Number of density points larger than number of shells. Assuming inner point irrelevant (parse_input.py:143)
[tardis.model.matter.decay][INFO   ]
        Decaying abundances for 1123200.0 seconds (decay.py:101)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in 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 divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 1 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 3 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 4 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 10 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 11 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 12 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 13 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 15 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 3/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 17 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

        Starting iteration 18 of 20 (base.py:398)
[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:580)
[tardis.simulation.base][INFO   ]
        Iteration converged 1/4 consecutive times. (base.py:268)
[tardis.simulation.base][INFO   ]

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

        Plasma stratification: (base.py:548)
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:575)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/plasma/properties/radiative_properties.py:93: RuntimeWarning: invalid value encountered in divide
  (g_lower * n_upper) / (g_upper * n_lower)
 (warnings.py:109)
[tardis.simulation.base][INFO   ]

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

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

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:274: 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(buf, os.path.join(path, key))
 (warnings.py:109)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:288: 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, os.path.join(path, "scalars"))
 (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/transport/transport_state/emitted_packet_mask',
 '/simulation/transport/transport_state/j_estimator',
 '/simulation/transport/transport_state/last_interaction_in_nu',
 '/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/montecarlo_virtual_luminosity',
 '/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/transport/transport_state/spectrum_virtual/_frequency',
 '/simulation/transport/transport_state/spectrum_virtual/luminosity',
 '/simulation/transport/transport_state/spectrum_virtual/luminosity_density_lambda',
 '/simulation/transport/transport_state/spectrum_virtual/scalars',
 '/simulation/transport/transport_state/spectrum_virtual/wavelength',
 '/simulation/transport/transport_state/spectrum_reabsorbed/_frequency',
 '/simulation/transport/transport_state/spectrum_reabsorbed/luminosity',
 '/simulation/transport/transport_state/spectrum_reabsorbed/luminosity_density_lambda',
 '/simulation/transport/transport_state/spectrum_reabsorbed/scalars',
 '/simulation/transport/transport_state/spectrum_reabsorbed/wavelength',
 '/simulation/transport/transport_state/spectrum/_frequency',
 '/simulation/transport/transport_state/spectrum/luminosity',
 '/simulation/transport/transport_state/spectrum/luminosity_density_lambda',
 '/simulation/transport/transport_state/spectrum/scalars',
 '/simulation/transport/transport_state/spectrum/wavelength',
 '/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/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/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:274: 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(buf, os.path.join(path, key))
 (warnings.py:109)
[py.warnings         ][WARNING]
        /home/runner/work/tardis/tardis/tardis/io/util.py:288: 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, os.path.join(path, "scalars"))
 (warnings.py:109)
[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/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)
[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/nlte_excitation_species',
 '/plasma/nlte_ionization_species',
 '/plasma/scalars',
 '/plasma/t_rad',
 '/plasma/w']

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/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_estimator',
 '/transport/transport_state/last_interaction_in_nu',
 '/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/montecarlo_virtual_luminosity',
 '/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',
 '/transport/transport_state/spectrum_virtual/_frequency',
 '/transport/transport_state/spectrum_virtual/luminosity',
 '/transport/transport_state/spectrum_virtual/luminosity_density_lambda',
 '/transport/transport_state/spectrum_virtual/scalars',
 '/transport/transport_state/spectrum_virtual/wavelength',
 '/transport/transport_state/spectrum_reabsorbed/_frequency',
 '/transport/transport_state/spectrum_reabsorbed/luminosity',
 '/transport/transport_state/spectrum_reabsorbed/luminosity_density_lambda',
 '/transport/transport_state/spectrum_reabsorbed/scalars',
 '/transport/transport_state/spectrum_reabsorbed/wavelength',
 '/transport/transport_state/spectrum/_frequency',
 '/transport/transport_state/spectrum/luminosity',
 '/transport/transport_state/spectrum/luminosity_density_lambda',
 '/transport/transport_state/spectrum/scalars',
 '/transport/transport_state/spectrum/wavelength']