You can interact with this notebook online: Launch notebook
How to Access Physical Quantities¶
In order to compute the synthetic spectrum, TARDIS must either be told or must calculate many physical properties of the model. To understand and test the code it can be important to look at these values. One easy way to do this is to run TARDIS in an interactive mode and then inspect the model properties.
Running an interactive Python session¶
[1]:
# Download the atomic data
from tardis.io.atom_data import download_atom_data
download_atom_data('kurucz_cd23_chianti_H_He_latest')
# Download the example configuration file
!curl -O https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/tardis_example.yml
Atomic Data kurucz_cd23_chianti_H_He_latest already exists in /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He_latest.h5. Will not download - override with force_download=True.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 987 100 987 0 0 17273 0 --:--:-- --:--:-- --:--:-- 17315
[2]:
from tardis import run_tardis
simulation = run_tardis('tardis_example.yml')
Auto-detected Sphinx build environment
Auto-detected Sphinx build environment
Initializing tabulator and plotly panel extensions for widgets to work
Embedding the final state for Jupyter environments
If all goes well, the simulation should run as usual. Afterwards, the information from the simulation will all exist in Simulation
and can be examined. Some examples for useful/interesting quantities are given below (but much more information is available: contact us via tardis-sn-users if you need further help).
Examples of finding physical quantities¶
For example, two of our important quantities are the parameters of the radiation field model, \(T_{\rm rad}\) and \(W\). These exist as numpy.ndarray
Thus simulation.plasma.t_rad
will give you a list of the \(T_{\rm rad}\)-values for the model zones in cgs units.
[3]:
simulation.plasma.t_rad
[3]:
array([11069.39398096, 11217.36671066, 11332.60184044, 11426.22631754,
11491.48972523, 11516.91377885, 11462.16807103, 11333.41619011,
11369.28853392, 11281.15653031, 11196.95437013, 11081.40565856,
11005.00279487, 10899.22884746, 10800.99123096, 10723.69631975,
10615.8274979 , 10529.75048763, 10441.74294229, 10354.82768508])
Similarly, the \(W\)-values can be accessed using simulation.plasma.w
[4]:
simulation.plasma.w
[4]:
array([0.46662935, 0.35416247, 0.28001569, 0.2281332 , 0.19311512,
0.16757667, 0.15009942, 0.13811674, 0.12336904, 0.11380625,
0.10634533, 0.10168536, 0.09617056, 0.09178887, 0.08740182,
0.08316363, 0.0804724 , 0.07785579, 0.07505503, 0.07241463])
Several important quantities that were setup when the model was defined by the configuration file are located in the model
section of the simulation. For example, the inner and outer velocity boundaries of the zones in the model is given by simulation.simulation_state.v_inner.cgs
and simulation.simulation_state.v_outer.cgs
respectively. These exist as Astropy Quantities.
[5]:
simulation.simulation_state.v_inner.cgs
[5]:
[6]:
simulation.simulation_state.v_outer.cgs
[6]:
The average density in the zones is given by simulation.simulation_state.density.cgs
. These also exist as Astropy Quantities.
[7]:
simulation.simulation_state.density.cgs
[7]:
Many other interesting quantities are stored in the plasma
. For example the calculated ion populations and level populations is given by simulation.plasma.ion_number_density
and simulation.plasma.level_number_density
respectively.
[8]:
simulation.plasma.ion_number_density
[8]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
atomic_number | ion_number | ||||||||||||||||||||
8 | 0 | 9.816659e+02 | 4.604150e+02 | 2.316153e+02 | 1.226249e+02 | 6.876536e+01 | 4.137050e+01 | 2.811893e+01 | 2.144973e+01 | 1.328381e+01 | 9.865431e+00 | 7.388643e+00 | 5.861030e+00 | 4.455958e+00 | 3.577868e+00 | 2.876588e+00 | 2.266979e+00 | 1.892041e+00 | 1.543745e+00 | 1.276175e+00 | 1.063504e+00 |
1 | 5.392045e+08 | 4.093079e+08 | 3.138516e+08 | 2.428781e+08 | 1.895662e+08 | 1.491939e+08 | 1.185039e+08 | 9.496466e+07 | 7.636813e+07 | 6.198194e+07 | 5.060933e+07 | 4.158729e+07 | 3.433233e+07 | 2.850228e+07 | 2.377296e+07 | 1.991404e+07 | 1.675988e+07 | 1.416038e+07 | 1.201152e+07 | 1.022703e+07 | |
2 | 2.227084e+05 | 3.669784e+05 | 5.361457e+05 | 7.245227e+05 | 8.893827e+05 | 9.599717e+05 | 8.046942e+05 | 5.308615e+05 | 5.936509e+05 | 4.446343e+05 | 3.358960e+05 | 2.273113e+05 | 1.746121e+05 | 1.205867e+05 | 8.492438e+04 | 6.413167e+04 | 4.307064e+04 | 3.115373e+04 | 2.224782e+04 | 1.586440e+04 | |
3 | 2.647301e-08 | 1.246274e-07 | 4.275557e-07 | 1.192008e-06 | 2.580870e-06 | 3.993551e-06 | 3.210557e-06 | 1.387352e-06 | 2.300471e-06 | 1.357052e-06 | 8.133745e-07 | 3.657353e-07 | 2.262683e-07 | 1.060832e-07 | 5.204906e-08 | 3.038471e-08 | 1.309125e-08 | 6.789233e-09 | 3.394767e-09 | 1.684833e-09 | |
4 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
20 | 16 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 |
17 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | |
18 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | |
19 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | |
20 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 |
94 rows × 20 columns
[9]:
simulation.plasma.level_number_density
[9]:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
atomic_number | ion_number | level_number | ||||||||||||||||||||
8 | 0 | 0 | 513.445731 | 240.317130 | 120.699354 | 63.818960 | 35.755733 | 21.503678 | 14.626899 | 11.177758 | 6.918919 | 5.144761 | 3.857656 | 3.065011 | 2.332715 | 1.875793 | 1.510194 | 1.191434 | 0.995876 | 0.813525 | 0.673345 | 0.561813 |
1 | 301.794933 | 141.292782 | 70.978993 | 37.535838 | 21.032516 | 12.649615 | 8.603512 | 6.573251 | 4.069034 | 3.025174 | 2.267998 | 1.801603 | 1.370966 | 1.102206 | 0.887213 | 0.699841 | 0.584845 | 0.477673 | 0.395292 | 0.329756 | ||
2 | 99.703863 | 46.684336 | 23.454164 | 12.404158 | 6.950783 | 4.180498 | 2.843209 | 2.172054 | 1.344602 | 0.999593 | 0.749354 | 0.595201 | 0.452902 | 0.364085 | 0.293043 | 0.231140 | 0.193141 | 0.157736 | 0.130522 | 0.108874 | ||
3 | 65.279128 | 31.396434 | 16.098614 | 8.653707 | 4.903727 | 2.962089 | 1.995840 | 1.491081 | 0.928849 | 0.679922 | 0.502120 | 0.390556 | 0.293022 | 0.230930 | 0.182412 | 0.141734 | 0.115935 | 0.093056 | 0.075627 | 0.061953 | ||
4 | 1.270507 | 0.630131 | 0.330744 | 0.181135 | 0.103967 | 0.063113 | 0.042073 | 0.030639 | 0.019224 | 0.013825 | 0.010035 | 0.007620 | 0.005626 | 0.004334 | 0.003351 | 0.002559 | 0.002043 | 0.001607 | 0.001280 | 0.001027 | ||
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
20 | 16 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
17 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | |
18 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | |
19 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | |
20 | 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
4435 rows × 20 columns
These are stored as Pandas DataFrames
. An index can be supplied to obtain the population in a particular zone. E.g., for the ion populations of the innermost zone (index = 0), we will use simulation.plasma.ion_number_density[0]
[10]:
simulation.plasma.ion_number_density[0]
[10]:
atomic_number ion_number
8 0 9.816659e+02
1 5.392045e+08
2 2.227084e+05
3 2.647301e-08
4 0.000000e+00
...
20 16 0.000000e+00
17 0.000000e+00
18 0.000000e+00
19 0.000000e+00
20 0.000000e+00
Name: 0, Length: 94, dtype: float64
Ion populations for a particular ionization stage of a particular element can be accessed by specifying an appropriate tuple (𝑍,𝐶), which identifies the element (via atomic number 𝑍 ) and the charge (via the ion charge 𝐶 ). Thus, simulation.plasma.ion_number_density.loc[14,1]
will identify the ion popuations for Si II (𝑍=14,𝐶=1) in all the zones.
[11]:
simulation.plasma.ion_number_density.loc[14,1]
[11]:
0 70825.681873
1 31990.969562
2 15613.549042
3 8050.728970
4 4419.989679
5 2626.941022
6 1804.879104
7 1423.919182
8 867.376865
9 658.766974
10 504.180713
11 412.993680
12 320.355705
13 264.989338
14 219.028071
15 176.358495
16 151.869698
17 127.029477
18 107.751281
19 92.134805
Name: (14, 1), dtype: float64
The above examples can be combined to obtain e.g. the Si II population in the innermost zone can be obtained by simulation.plasma.ion_number_density[0].loc[14,1]
[12]:
simulation.plasma.ion_number_density[0].loc[14,1]
[12]:
np.float64(70825.68187285573)
The level populations are stored (and can be accessed) in a similar way - a third label can be used to pick out a particular atomic level. E.g., to pull out the population of the ground state (index 0) of Si II we can use simulation.plasma.level_number_density.loc[14,1,0]
[13]:
simulation.plasma.level_number_density.loc[14,1,0]
[13]:
0 23978.146383
1 10819.001844
2 5275.816671
3 2718.409555
4 1491.703522
5 886.391767
6 609.267293
7 481.139206
8 293.005484
9 222.682912
10 170.534002
11 139.807671
12 108.506435
13 89.819711
14 74.290737
15 59.849006
16 51.575235
17 43.163557
18 36.633579
19 31.341378
Name: (14, 1, 0), dtype: float64
Notes¶
If you prefer to work in SI units, all the Astropy Quantities may instead by accessed with “xxx.si”.
Information that is not stored as Astropy Quantities (e.g. the ion and level populations used in the example above) are usually stored in cgs units (i.e. cm−3 for the populations).