#!/usr/bin/env python # coding: utf-8 # ### Quickstart for TARDIS ### # Every simulation run requires the atomic database (for more info refer to [atomic data](../atomic/atomic_data.rst) ) and a configuration file (more info at [configuration](../configuration/index.rst) ). # You can obtain a copy of the atomic database from the # (https://github.com/tardis-sn/tardis-refdata) repository # (`atom_data` subfolder). We recommended to use the # `kurucz_cd23_chianti_H_He.h5` dataset (which is auto-downloaded in the second cell already). The configuration file for this quickstart is `tardis_example.yml`, which can be downloaded [here](https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/models/examples/tardis_example.yml)), though this file is auto-downloaded in the third cell. # # After the [installation](../installation.rst), start a Jupyter server executing `jupyter notebook` on the command line in a directory that contains this quickstart. # In[1]: from tardis import run_tardis from tardis.io.atom_data.util import download_atom_data # #### Downloading the atomic data #### # In[2]: # the data is automatically downloaded download_atom_data('kurucz_cd23_chianti_H_He') # #### Downloading the example file #### # In[3]: get_ipython().system('curl -O https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/models/examples/tardis_example.yml') # #### Running the simulation (long output) #### # In[4]: #TARDIS now uses the data in the data repo sim = run_tardis('tardis_example.yml') # #### Plotting the Spectrum #### # In[5]: get_ipython().run_line_magic('pylab', 'inline') spectrum = sim.runner.spectrum spectrum_virtual = sim.runner.spectrum_virtual spectrum_integrated = sim.runner.spectrum_integrated figure(figsize=(10,6)) plot(spectrum.wavelength, spectrum.luminosity_density_lambda, label='normal packets') plot(spectrum.wavelength, spectrum_virtual.luminosity_density_lambda, label='virtual packets') plot(spectrum.wavelength, spectrum_integrated.luminosity_density_lambda, label='formal integral') xlabel('Wavelength [$\AA$]') ylabel('Luminosity [erg/s/$\AA$]') legend() xlim(3000, 9000) # In[ ]: