You can interact with this notebook online: Launch interactive version
Accessing 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.
Runing in interactive Python session¶
[1]:
# Download the atomic data
from tardis.io.atom_data.util import download_atom_data
download_atom_data('kurucz_cd23_chianti_H_He')
# Download the example configuration file
!curl -O https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/tardis_example.yml
/usr/share/miniconda3/envs/tardis/lib/python3.7/importlib/_bootstrap.py:219: QAWarning: pyne.data is not yet QA compliant.
return f(*args, **kwds)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 980 100 980 0 0 57647 0 --:--:-- --:--:-- --:--:-- 57647
[2]:
from tardis import run_tardis
simulation = run_tardis('tardis_example.yml')
[py.warnings ][WARNING] /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/traitlets/traitlets.py:3050: FutureWarning: --rc={'figure.dpi': 96} for dict-traits is deprecated in traitlets 5.0. You can pass --rc <key=value> ... multiple times to add items to a dict.
FutureWarning,
(warnings.py:110)
[py.warnings ][WARNING] /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/tardis-2021.12.21.0.dev129+g098e24fc-py3.7.egg/tardis/plasma/properties/radiative_properties.py:92: RuntimeWarning: invalid value encountered in true_divide
(g_lower * n_upper) / (g_upper * n_lower)
(warnings.py:110)
[py.warnings ][WARNING] /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/tardis-2021.12.21.0.dev129+g098e24fc-py3.7.egg/tardis/plasma/properties/radiative_properties.py:92: RuntimeWarning: invalid value encountered in true_divide
(g_lower * n_upper) / (g_upper * n_lower)
(warnings.py:110)
[py.warnings ][WARNING] /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/tardis-2021.12.21.0.dev129+g098e24fc-py3.7.egg/tardis/plasma/properties/radiative_properties.py:92: RuntimeWarning: invalid value encountered in true_divide
(g_lower * n_upper) / (g_upper * n_lower)
(warnings.py:110)
[py.warnings ][WARNING] /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/tardis-2021.12.21.0.dev129+g098e24fc-py3.7.egg/tardis/plasma/properties/radiative_properties.py:92: RuntimeWarning:
invalid value encountered in true_divide
(warnings.py:110)
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.33089377, 11165.15751924, 11272.62783772, 11372.4522524 ,
11332.02806881, 11329.6435672 , 11294.51865104, 11261.56893248,
11241.47812926, 11148.97525325, 11071.52917648, 11004.68560208,
10946.39979159, 10861.42744062, 10784.4789371 , 10655.55794227,
10586.11909387, 10567.9967492 , 10435.71120389, 10305.7063164 ])
Similarly, the \(W\)-values can be accessed using simulation.plasma.w
[4]:
simulation.plasma.w
[4]:
array([0.46583111, 0.35821399, 0.28478501, 0.23131748, 0.20190424,
0.17672918, 0.15768939, 0.14187896, 0.1281619 , 0.11908551,
0.11148042, 0.10454478, 0.09806677, 0.09312254, 0.08822151,
0.08534236, 0.08173657, 0.07726564, 0.07559528, 0.07395579])
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.model.v_inner.cgs
and simulation.model.v_outer.cgs
respectively. These exist as Astropy Quantities.
[5]:
simulation.model.v_inner.cgs
[5]:
[6]:
simulation.model.v_outer.cgs
[6]:
The average density in the zones is given by simulation.model.density.cgs
. These also exist as Astropy Quantities.
[7]:
simulation.model.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.817541e+02 | 4.952192e+02 | 2.514676e+02 | 1.318559e+02 | 8.523577e+01 | 5.320207e+01 | 3.527606e+01 | 2.366975e+01 | 1.582107e+01 | 1.185305e+01 | 8.815497e+00 | 6.540669e+00 | 4.850194e+00 | 3.782471e+00 | 2.948439e+00 | 2.514696e+00 | 1.980990e+00 | 1.454287e+00 | 1.288493e+00 | 1.151839e+00 |
1 | 5.392046e+08 | 4.093669e+08 | 3.139475e+08 | 2.429934e+08 | 1.899227e+08 | 1.496264e+08 | 1.188395e+08 | 9.507571e+07 | 7.657002e+07 | 6.213943e+07 | 5.072480e+07 | 4.163973e+07 | 3.436439e+07 | 2.851733e+07 | 2.377784e+07 | 1.992820e+07 | 1.676439e+07 | 1.415556e+07 | 1.201203e+07 | 1.022981e+07 | |
2 | 2.226602e+05 | 3.079859e+05 | 4.402008e+05 | 6.091628e+05 | 5.329124e+05 | 5.275052e+05 | 4.690734e+05 | 4.198082e+05 | 3.917586e+05 | 2.871442e+05 | 2.204204e+05 | 1.748728e+05 | 1.425520e+05 | 1.055346e+05 | 8.003898e+04 | 4.996889e+04 | 3.855664e+04 | 3.597715e+04 | 2.173746e+04 | 1.307832e+04 | |
3 | 2.645841e-08 | 7.972540e-08 | 2.585740e-07 | 7.655780e-07 | 6.973306e-07 | 8.635538e-07 | 8.070076e-07 | 7.611136e-07 | 7.934242e-07 | 4.430639e-07 | 2.767649e-07 | 1.870047e-07 | 1.346884e-07 | 7.544950e-08 | 4.473829e-08 | 1.606762e-08 | 9.868697e-09 | 9.803360e-09 | 3.199626e-09 | 1.029618e-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.492299 | 258.671585 | 131.154368 | 68.674580 | 44.418418 | 27.725805 | 18.392821 | 12.346995 | 8.255151 | 6.192690 | 4.610677 | 3.424086 | 2.541173 | 1.984107 | 1.548271 | 1.322879 | 1.043126 | 0.765974 | 0.679901 | 0.608892 |
1 | 301.822270 | 152.069720 | 77.118971 | 40.387920 | 26.120864 | 16.304473 | 10.815431 | 7.259908 | 4.853770 | 3.640496 | 2.710091 | 2.012378 | 1.493315 | 1.165766 | 0.909554 | 0.776946 | 0.612557 | 0.449788 | 0.399136 | 0.357352 | ||
2 | 99.712889 | 50.243057 | 25.481864 | 13.346116 | 8.631325 | 5.387607 | 3.573725 | 2.398818 | 1.603757 | 1.202786 | 0.895333 | 0.664793 | 0.493296 | 0.385068 | 0.300418 | 0.256590 | 0.202288 | 0.148533 | 0.131791 | 0.117980 | ||
3 | 65.284281 | 33.474270 | 17.306588 | 9.224554 | 5.923827 | 3.696062 | 2.436586 | 1.626021 | 1.083219 | 0.799011 | 0.586431 | 0.430088 | 0.315682 | 0.242490 | 0.186407 | 0.155243 | 0.120705 | 0.088307 | 0.076267 | 0.066442 | ||
4 | 1.270591 | 0.664649 | 0.351282 | 0.191034 | 0.121690 | 0.075890 | 0.049677 | 0.032930 | 0.021848 | 0.015812 | 0.011419 | 0.008257 | 0.005985 | 0.004514 | 0.003411 | 0.002760 | 0.002112 | 0.001539 | 0.001289 | 0.001088 | ||
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
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.817541e+02
1 5.392046e+08
2 2.226602e+05
3 2.645841e-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 70833.163502
1 34861.243842
2 17211.393526
3 8779.777647
4 5721.865657
5 3563.344668
6 2378.033763
7 1604.932782
8 1074.816738
9 824.622359
10 625.499897
11 471.990280
12 355.146037
13 283.454849
14 225.652192
15 199.786180
16 160.473228
17 118.252827
18 108.994959
19 101.321273
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]:
70833.16350200445
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 23980.690090
1 11794.195085
2 5818.333741
3 2965.794314
4 1933.426172
5 1204.080564
6 803.766453
7 542.594090
8 363.426957
9 279.017554
10 211.760752
11 159.866349
12 120.339508
13 96.103679
14 76.546076
15 67.830067
16 54.507573
17 40.171395
18 37.057825
19 34.476854
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).