from tardis import run_tardis
from tardis.io.atom_data.util import download_atom_data

"""
Explanation: Quickstart for TARDIS
Every simulation run requires the atomic database (for more info refer to atomic data ) and a configuration file (more info at configuration ).
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), though this file is auto-downloaded in the third cell.
After the installation, start a Jupyter server executing jupyter notebook on the command line in a directory that contains this quickstart.
End of explanation
"""


# the data is automatically downloaded
download_atom_data('kurucz_cd23_chianti_H_He')

"""
Explanation: Downloading the atomic data
End of explanation
"""


!curl -O https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/models/examples/tardis_example.yml

"""
Explanation: Downloading the example file
End of explanation
"""


#TARDIS now uses the data in the data repo
sim = run_tardis('tardis_example.yml')

"""
Explanation: Running the simulation (long output)
End of explanation
"""


%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)

"""
Explanation: Plotting the Spectrum
End of explanation
"""


