This notebook is available at https://github.com/tardis-sn/tardis/tree/master/docs/development/profiling_example.ipynb


Basic Profile of TARDIS

A profile is a set of statistics that describes how often and for how long various parts of the program execute (cProfile). A majority of TARDIS can be profiled, however, some code is Numba code, which cannot be profiled. This is because Numba compiles these functions directly to machine code; the python interpreter doesn’t see these functions and therefore it doesn’t read them.

This notebook uses snakeviz, which is a graphical viewer for the output of cProfile, to visualize the results and make them interactive. In order to use SnakeViz, you must first download it via pip. The first cell loads SnakeViz and gets the notebook ready to run TARDIS.

[1]:
%load_ext snakeviz

from tardis import run_tardis
from tardis.io.atom_data.util import download_atom_data
download_atom_data('kurucz_cd23_chianti_H_He')
/usr/share/miniconda3/envs/tardis/lib/python3.7/importlib/_bootstrap.py:219: QAWarning: pyne.data is not yet QA compliant.
  return f(*args, **kwds)
[tardis.io.config_internal][WARNING]  Configuration File /home/runner/.astropy/config/tardis_internal_config.yml does not exist - creating new one from default (config_internal.py:22)
CRITICAL:root:
********************************************************************************

TARDIS will download different kinds of data (e.g. atomic) to its data directory /home/runner/Downloads/tardis-data

TARDIS DATA DIRECTORY not specified in /home/runner/.astropy/config/tardis_internal_config.yml:

ASSUMING DEFAULT DATA DIRECTORY /home/runner/Downloads/tardis-data
 YOU CAN CHANGE THIS AT ANY TIME IN /home/runner/.astropy/config/tardis_internal_config.yml

********************************************************************************


[tardis.io.atom_data.atom_web_download][INFO   ]  Downloading atomic data from https://media.githubusercontent.com/media/tardis-sn/tardis-refdata/master/atom_data/kurucz_cd23_chianti_H_He.h5 to /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5 (atom_web_download.py:46)
INFO:tardis.io.atom_data.atom_web_download:Downloading atomic data from https://media.githubusercontent.com/media/tardis-sn/tardis-refdata/master/atom_data/kurucz_cd23_chianti_H_He.h5 to /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5

I am telling the cell below to use snakeviz on the function below, which is a run of TARDIS in its enteriety. An option is to add the -t flag, which will tell it to display the HTML in a new tab, instead of embedding it.

[2]:
%%snakeviz

run_tardis('tardis_example.yml')
[tardis.plasma.standard_plasmas][INFO   ]
        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5 (standard_plasmas.py:91)
INFO:tardis.plasma.standard_plasmas:
        Reading Atomic Data from kurucz_cd23_chianti_H_He.h5
[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)
INFO:tardis.io.atom_data.util:
        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
[tardis.io.atom_data.base][INFO   ]
        Reading Atom Data with:
        UUID = 6f7b09e887a311e7a06b246e96350010
        MD5  = 864f1753714343c41f99cb065710cace  (base.py:189)
INFO:tardis.io.atom_data.base:
        Reading Atom Data with:
        UUID = 6f7b09e887a311e7a06b246e96350010
        MD5  = 864f1753714343c41f99cb065710cace
[tardis.io.atom_data.base][INFO   ]
        Non provided atomic data:
        synpp_refs, photoionization_data, yg_data, two_photon_data (base.py:193)
INFO:tardis.io.atom_data.base:
        Non provided atomic data:
        synpp_refs, photoionization_data, yg_data, two_photon_data
[tardis.simulation.base][INFO   ]
        Starting iteration 1 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 1 of 20
[py.warnings         ][WARNING]  /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/astropy/units/equivalencies.py:124: RuntimeWarning: divide by zero encountered in double_scalars
  (si.m, si.Hz, lambda x: _si.c.value / x),
 (warnings.py:110)
WARNING:py.warnings:/usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/astropy/units/equivalencies.py:124: RuntimeWarning: divide by zero encountered in double_scalars
  (si.m, si.Hz, lambda x: _si.c.value / x),

[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:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 7.942e+42 erg / s
        Luminosity absorbed  = 2.659e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
[py.warnings         ][WARNING]  /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/traitlets/traitlets.py:3036: 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)
WARNING:py.warnings:/usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/traitlets/traitlets.py:3036: 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,

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   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 9933.952 K
        Expected t_inner for next iteration = 11472.471 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 9933.952 K
        Expected t_inner for next iteration = 11472.471 K

[tardis.simulation.base][INFO   ]
        Starting iteration 2 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 2 of 20
[py.warnings         ][WARNING]  /usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/astropy/units/equivalencies.py:124: RuntimeWarning: divide by zero encountered in double_scalars
  (si.m, si.Hz, lambda x: _si.c.value / x),
 (warnings.py:110)
WARNING:py.warnings:/usr/share/miniconda3/envs/tardis/lib/python3.7/site-packages/astropy/units/equivalencies.py:124: RuntimeWarning: divide by zero encountered in double_scalars
  (si.m, si.Hz, lambda x: _si.c.value / x),

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

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.01e+04 1.15e+04 0.507 0.546
5 1.02e+04 1.15e+04 0.197 0.223
10 1.01e+04 1.13e+04 0.117 0.135
15 9.87e+03 1.1e+04 0.0869 0.101
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11472.471 K
        Expected t_inner for next iteration = 9960.403 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11472.471 K
        Expected t_inner for next iteration = 9960.403 K

[tardis.simulation.base][INFO   ]
        Starting iteration 3 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 3 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.168e+42 erg / s
        Luminosity absorbed  = 2.550e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.168e+42 erg / s
        Luminosity absorbed  = 2.550e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.05e+04 0.546 0.442
5 1.15e+04 1.08e+04 0.223 0.165
10 1.13e+04 1.07e+04 0.135 0.101
15 1.1e+04 1.02e+04 0.101 0.0781
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 9960.403 K
        Expected t_inner for next iteration = 11342.715 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 9960.403 K
        Expected t_inner for next iteration = 11342.715 K

[tardis.simulation.base][INFO   ]
        Starting iteration 4 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 4 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.356e+43 erg / s
        Luminosity absorbed  = 4.460e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.356e+43 erg / s
        Luminosity absorbed  = 4.460e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.05e+04 1.16e+04 0.442 0.498
5 1.08e+04 1.17e+04 0.165 0.201
10 1.07e+04 1.14e+04 0.101 0.127
15 1.02e+04 1.1e+04 0.0781 0.0953
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11342.715 K
        Expected t_inner for next iteration = 10026.022 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11342.715 K
        Expected t_inner for next iteration = 10026.022 K

[tardis.simulation.base][INFO   ]
        Starting iteration 5 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 5 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.318e+42 erg / s
        Luminosity absorbed  = 2.681e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.318e+42 erg / s
        Luminosity absorbed  = 2.681e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.16e+04 1.06e+04 0.498 0.444
5 1.17e+04 1.09e+04 0.201 0.162
10 1.14e+04 1.07e+04 0.127 0.101
15 1.1e+04 1.03e+04 0.0953 0.0769
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10026.022 K
        Expected t_inner for next iteration = 11314.135 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10026.022 K
        Expected t_inner for next iteration = 11314.135 K

[tardis.simulation.base][INFO   ]
        Starting iteration 6 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 6 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.343e+43 erg / s
        Luminosity absorbed  = 4.402e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.343e+43 erg / s
        Luminosity absorbed  = 4.402e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.06e+04 1.15e+04 0.444 0.51
5 1.09e+04 1.17e+04 0.162 0.201
10 1.07e+04 1.14e+04 0.101 0.127
15 1.03e+04 1.1e+04 0.0769 0.0955
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11314.135 K
        Expected t_inner for next iteration = 10047.862 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11314.135 K
        Expected t_inner for next iteration = 10047.862 K

[tardis.simulation.base][INFO   ]
        Starting iteration 7 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 7 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.399e+42 erg / s
        Luminosity absorbed  = 2.700e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.399e+42 erg / s
        Luminosity absorbed  = 2.700e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.06e+04 0.51 0.443
5 1.17e+04 1.1e+04 0.201 0.158
10 1.14e+04 1.07e+04 0.127 0.102
15 1.1e+04 1.03e+04 0.0955 0.0768
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10047.862 K
        Expected t_inner for next iteration = 11284.172 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10047.862 K
        Expected t_inner for next iteration = 11284.172 K

[tardis.simulation.base][INFO   ]
        Starting iteration 8 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 8 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.334e+43 erg / s
        Luminosity absorbed  = 4.312e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.334e+43 erg / s
        Luminosity absorbed  = 4.312e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.06e+04 1.15e+04 0.443 0.502
5 1.1e+04 1.17e+04 0.158 0.197
10 1.07e+04 1.14e+04 0.102 0.124
15 1.03e+04 1.1e+04 0.0768 0.0941
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11284.172 K
        Expected t_inner for next iteration = 10056.590 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11284.172 K
        Expected t_inner for next iteration = 10056.590 K

[tardis.simulation.base][INFO   ]
        Starting iteration 9 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 9 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.442e+42 erg / s
        Luminosity absorbed  = 2.693e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.442e+42 erg / s
        Luminosity absorbed  = 2.693e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.06e+04 0.502 0.443
5 1.17e+04 1.1e+04 0.197 0.161
10 1.14e+04 1.07e+04 0.124 0.102
15 1.1e+04 1.04e+04 0.0941 0.0753
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10056.590 K
        Expected t_inner for next iteration = 11264.873 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10056.590 K
        Expected t_inner for next iteration = 11264.873 K

[tardis.simulation.base][INFO   ]
        Starting iteration 10 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 10 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.327e+43 erg / s
        Luminosity absorbed  = 4.253e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.327e+43 erg / s
        Luminosity absorbed  = 4.253e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.06e+04 1.15e+04 0.443 0.505
5 1.1e+04 1.17e+04 0.161 0.197
10 1.07e+04 1.15e+04 0.102 0.122
15 1.04e+04 1.11e+04 0.0753 0.0933
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11264.873 K
        Expected t_inner for next iteration = 10062.930 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11264.873 K
        Expected t_inner for next iteration = 10062.930 K

[tardis.simulation.base][INFO   ]
        Starting iteration 11 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 11 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.521e+42 erg / s
        Luminosity absorbed  = 2.645e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.521e+42 erg / s
        Luminosity absorbed  = 2.645e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.06e+04 0.505 0.444
5 1.17e+04 1.1e+04 0.197 0.162
10 1.15e+04 1.09e+04 0.122 0.0958
15 1.11e+04 1.05e+04 0.0933 0.0744
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10062.930 K
        Expected t_inner for next iteration = 11220.057 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10062.930 K
        Expected t_inner for next iteration = 11220.057 K

[tardis.simulation.base][INFO   ]
        Starting iteration 12 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 12 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.302e+43 erg / s
        Luminosity absorbed  = 4.230e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.302e+43 erg / s
        Luminosity absorbed  = 4.230e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.06e+04 1.16e+04 0.444 0.486
5 1.1e+04 1.18e+04 0.162 0.19
10 1.09e+04 1.14e+04 0.0958 0.121
15 1.05e+04 1.11e+04 0.0744 0.089
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11220.057 K
        Expected t_inner for next iteration = 10121.498 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11220.057 K
        Expected t_inner for next iteration = 10121.498 K

[tardis.simulation.base][INFO   ]
        Starting iteration 13 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 13 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.695e+42 erg / s
        Luminosity absorbed  = 2.731e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.695e+42 erg / s
        Luminosity absorbed  = 2.731e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.16e+04 1.07e+04 0.486 0.438
5 1.18e+04 1.1e+04 0.19 0.162
10 1.14e+04 1.08e+04 0.121 0.101
15 1.11e+04 1.04e+04 0.089 0.0767
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10121.498 K
        Expected t_inner for next iteration = 11171.296 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10121.498 K
        Expected t_inner for next iteration = 11171.296 K

[tardis.simulation.base][INFO   ]
        Starting iteration 14 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 14 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.284e+43 erg / s
        Luminosity absorbed  = 4.115e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.284e+43 erg / s
        Luminosity absorbed  = 4.115e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.07e+04 1.15e+04 0.438 0.495
5 1.1e+04 1.17e+04 0.162 0.191
10 1.08e+04 1.14e+04 0.101 0.12
15 1.04e+04 1.1e+04 0.0767 0.0918
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11171.296 K
        Expected t_inner for next iteration = 10145.811 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11171.296 K
        Expected t_inner for next iteration = 10145.811 K

[tardis.simulation.base][INFO   ]
        Starting iteration 15 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 15 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.705e+42 erg / s
        Luminosity absorbed  = 2.828e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.705e+42 erg / s
        Luminosity absorbed  = 2.828e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.07e+04 0.495 0.449
5 1.17e+04 1.1e+04 0.191 0.163
10 1.14e+04 1.09e+04 0.12 0.0997
15 1.1e+04 1.05e+04 0.0918 0.0768
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10145.811 K
        Expected t_inner for next iteration = 11191.850 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10145.811 K
        Expected t_inner for next iteration = 11191.850 K

[tardis.simulation.base][INFO   ]
        Starting iteration 16 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 16 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.284e+43 erg / s
        Luminosity absorbed  = 4.234e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.284e+43 erg / s
        Luminosity absorbed  = 4.234e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.07e+04 1.15e+04 0.449 0.495
5 1.1e+04 1.18e+04 0.163 0.184
10 1.09e+04 1.14e+04 0.0997 0.122
15 1.05e+04 1.11e+04 0.0768 0.0898
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11191.850 K
        Expected t_inner for next iteration = 10164.556 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11191.850 K
        Expected t_inner for next iteration = 10164.556 K

[tardis.simulation.base][INFO   ]
        Starting iteration 17 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 17 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.803e+42 erg / s
        Luminosity absorbed  = 2.816e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.803e+42 erg / s
        Luminosity absorbed  = 2.816e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.15e+04 1.07e+04 0.495 0.439
5 1.18e+04 1.11e+04 0.184 0.16
10 1.14e+04 1.1e+04 0.122 0.0962
15 1.11e+04 1.05e+04 0.0898 0.0763
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10164.556 K
        Expected t_inner for next iteration = 11150.010 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10164.556 K
        Expected t_inner for next iteration = 11150.010 K

[tardis.simulation.base][INFO   ]
        Starting iteration 18 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 18 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.271e+43 erg / s
        Luminosity absorbed  = 4.117e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.271e+43 erg / s
        Luminosity absorbed  = 4.117e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.07e+04 1.14e+04 0.439 0.492
5 1.11e+04 1.17e+04 0.16 0.186
10 1.1e+04 1.15e+04 0.0962 0.117
15 1.05e+04 1.11e+04 0.0763 0.0876
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 11150.010 K
        Expected t_inner for next iteration = 10180.809 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 11150.010 K
        Expected t_inner for next iteration = 10180.809 K

[tardis.simulation.base][INFO   ]
        Starting iteration 19 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 19 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 8.820e+42 erg / s
        Luminosity absorbed  = 2.873e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 8.820e+42 erg / s
        Luminosity absorbed  = 2.873e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Plasma stratification: (base.py:430)
INFO:tardis.simulation.base:
        Plasma stratification:
Shell No. t_rad next_t_rad w next_w
0 1.14e+04 1.07e+04 0.492 0.441
5 1.17e+04 1.11e+04 0.186 0.161
10 1.15e+04 1.09e+04 0.117 0.1
15 1.11e+04 1.05e+04 0.0876 0.0765
[tardis.simulation.base][INFO   ]  None (base.py:433)
INFO:tardis.simulation.base:None
[tardis.simulation.base][INFO   ]
        Current t_inner = 10180.809 K
        Expected t_inner for next iteration = 11157.125 K
 (base.py:448)
INFO:tardis.simulation.base:
        Current t_inner = 10180.809 K
        Expected t_inner for next iteration = 11157.125 K

[tardis.simulation.base][INFO   ]
        Starting iteration 20 of 20 (base.py:325)
INFO:tardis.simulation.base:
        Starting iteration 20 of 20
[tardis.simulation.base][INFO   ]
        Luminosity emitted   = 1.272e+43 erg / s
        Luminosity absorbed  = 4.149e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s
 (base.py:453)
INFO:tardis.simulation.base:
        Luminosity emitted   = 1.272e+43 erg / s
        Luminosity absorbed  = 4.149e+42 erg / s
        Luminosity requested = 1.059e+43 erg / s

[tardis.simulation.base][INFO   ]
        Simulation finished in 20 iterations
        Simulation took 44.35 s
 (base.py:384)
INFO:tardis.simulation.base:
        Simulation finished in 20 iterations
        Simulation took 44.35 s


*** Profile stats marshalled to file '/tmp/tmp0w1yutlo'.
Embedding SnakeViz in this document...

As SnakeViz uses a web browser to create the HTML to display, when this notebook is run the HTML isn’t viewable. In order to view this a picture of the HTML output is saved and displayed below.

The SnakeViz visualization gives two things. At the top is a stack trace, where you can see which functions call others, and how long those functions take in respect to the caller function. At the bottom is all of the information that cProfile provides.

The bottom left montecarlo_radial1d is montecarlo_main_loop. This function does a majority of the computation, yet there is nothing below it. This is because it, and all the functions that it calls, are Numba functions. montecarlo_main_loop is visible as montecarlo_radial1d calls it, but the functions that it calls are not visible as it is a Numba function.

If the SnakeViz is run again without restarting the kernel, then the times will decrease and more time will be spent in montecarlo_main_loop relative to montecarlo_radial1d, as the Numba functions will have all compiled.

If you run this notebook the HTML from cell 2 will be displayed at the bottom without issue; the lower cell is just a solution to display the SnakeViz output without having access to the HTML.

../_images/tardis_prof.png