{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Quickstart for TARDIS" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Every simulation run requires [atomic data](io/configuration/components/atomic/atomic_data.rst) and a [configuration file](io/configuration/index.rst). \n", "\n", "## Atomic Data\n", "\n", "We recommend using the [kurucz_cd23_chianti_H_He.h5](https://dev.azure.com/tardis-sn/TARDIS/_apis/git/repositories/tardis-refdata/items?path=atom_data/kurucz_cd23_chianti_H_He.h5&resolveLfs=true) dataset." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tardis.io.atom_data.util import download_atom_data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "download_atom_data('kurucz_cd23_chianti_H_He')" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "You can also obtain a copy of the atomic data from the [tardis-refdata](https://github.com/tardis-sn/tardis-refdata/tree/master/atom_data) repository." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Example Configuration File\n", "\n", "The configuration file [tardis_example.yml](https://github.com/tardis-sn/tardis/tree/master/docs/tardis_example.yml) is used throughout this Quickstart." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!wget -q -nc https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/tardis_example.yml" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!cat tardis_example.yml" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Running the Simulation\n", "\n", "To run the simulation, import the `run_tardis` function and create the `sim` object. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from tardis import run_tardis" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "**Note:**\n", "\n", "Get more information about the [progress bars](io/output/progress_bars.rst), [logging configuration](io/optional/tutorial_logging_configuration.ipynb), and [convergence plots](io/visualization/tutorial_convergence_plot.ipynb). \n", " \n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim = run_tardis(\"tardis_example.yml\", \n", " virtual_packet_logging=True,\n", " show_convergence_plots=True,\n", " export_convergence_plots=True,\n", " log_level=\"INFO\") " ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting the Spectrum\n", "\n", "Finally, plot the generated spectrum with `matplotlib`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "spectrum = sim.transport.transport_state.spectrum\n", "spectrum_virtual = sim.transport.transport_state.spectrum_virtual\n", "spectrum_integrated = sim.transport.transport_state.spectrum_integrated" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "plt.figure(figsize=(10, 6.5))\n", "\n", "spectrum.plot(label=\"Normal packets\")\n", "spectrum_virtual.plot(label=\"Virtual packets\")\n", "spectrum_integrated.plot(label='Formal integral')\n", "\n", "plt.xlim(500, 9000)\n", "plt.title(\"TARDIS example model spectrum\")\n", "plt.xlabel(\"Wavelength [$\\AA$]\")\n", "plt.ylabel(\"Luminosity density [erg/s/$\\AA$]\")\n", "plt.legend()\n", "plt.show()" ] } ], "metadata": { "interpreter": { "hash": "14c438b85bc0c5441332c56c5d68185f391ef15672c5492b27fc26d9164316c1" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 4 }