{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Quickstart for Carsus\n", "\n", "In this guide you will learn how to create atomic data files suitable for [TARDIS](https://github.com/tardis-sn/tardis).\n", "\n", "
\n", "\n", "**Note:**\n", "\n", "Get familiar with the [Notation in Carsus](development/notation.rst) and learn how to correctly select ions.\n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Atomic Weights and Ionization Energies (NIST)\n", "\n", "Download atomic weights and ionization energies from the National Institute of Standards and Technology (NIST)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.nist import NISTWeightsComp, NISTIonizationEnergies" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "atomic_weights = NISTWeightsComp()\n", "ionization_energies = NISTIonizationEnergies('H-Zn')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Levels, Lines, Collisions & Cross-sections\n", "\n", "Carsus supports three sources of energy levels and spectral lines: **GFALL**, **CHIANTI** and **CMFGEN**.\n", "\n", "### GFALL\n", "\n", "The Robert Kurucz's Atomic Linelist (GFALL) reader is the main source of **levels and lines**.\n", "\n", "
\n", "\n", "**Warning:**\n", " \n", "Creating a `GFALLReader` instance is **required**.\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!wget -qO /tmp/gfall.dat https://media.githubusercontent.com/media/tardis-sn/carsus-db/master/gfall/gfall_latest.dat" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.kurucz import GFALLReader\n", "\n", "gfall_reader = GFALLReader('H-Zn',\n", " '/tmp/gfall.dat')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### CHIANTI\n", "\n", "The Chianti Atomic Database reader provides levels and lines but also **collision strengths**.\n", "\n", "
\n", "\n", "**Note:**\n", "\n", "Creating a `ChiantiReader` instance is **optional**. \n", "\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.chianti_ import ChiantiReader\n", "\n", "chianti_reader = ChiantiReader('H-He', \n", " collisions=True, \n", " priority=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By default `priority` parameter is set to `10`. Increase this value if you want to keep CHIANTI levels and lines over GFALL." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### CMFGEN\n", "\n", "The atomic database of [CMFGEN](http://kookaburra.phyast.pitt.edu/hillier/web/CMFGEN.htm) is a source of levels, lines and (optionally) **ionization energies**, **photoionization cross-sections** and **collisions**.\n", "\n", "
\n", " \n", "**Note:**\n", "\n", "Creating a `CMFGENReader` instance is **optional**. \n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "**Warning:**\n", " \n", "Cross-sections require data from `H 0`, use this the reader with enough `priority` to select levels from this ion.\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.cmfgen import CMFGENReader\n", "\n", "cmfgen_reader = CMFGENReader.from_config('Si 0-1', \n", " '/tmp/atomic', \n", " priority=30,\n", " ionization_energies=True,\n", " cross_sections=True,\n", " collisions=False,\n", " temperature_grid=None,\n", " drop_mismatched_labels=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Zeta Data\n", "\n", "Long & Knigge's ground state recombinations fractions ($\\zeta$)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.zeta import KnoxLongZeta\n", "\n", "zeta_data = KnoxLongZeta()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Nuclear decay data\n", "\n", "Carsus also supports the decay radiation data of all the nuclides at the [NNDC Archives](https://www.nndc.bnl.gov/ensdfarchivals/). The ENSDF data is stored in CSV format in the repository [carsus-data-nndc](https://github.com/tardis-sn/carsus-data-nndc).\n", "\n", "### NNDC\n", "\n", "The NNDCReader instance looks for the `carsus-data-nndc` repository in the local system at the path specified by the argument `dirname`. If the data is to be downloaded from the Github repository directly , the `remote` argument should be set to `True`.\n", "\n", "
\n", " \n", "**Note:**\n", "\n", "Creating a `NNDCReader` instance is **optional**. \n", "\n", "
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from carsus.io.nuclear import NNDCReader\n", "\n", "nndc_reader = NNDCReader(remote=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Create an Atomic Data File\n", "\n", "Finally, create a `TARDISAtomData` object and dump the data with the `to_hdf` method." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "from carsus.io.output import TARDISAtomData\n", "\n", "atom_data = TARDISAtomData(atomic_weights,\n", " ionization_energies,\n", " gfall_reader,\n", " zeta_data,\n", " chianti_reader,\n", " cmfgen_reader,\n", " nndc_reader)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "atom_data.to_hdf('kurucz_cd23_chianti_He_cmfgen_H_Si_I-II.h5')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You are done! Now you can use your file to run TARDIS simulations." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Metadata\n", "\n", "Carsus stores metadata inside the HDF5 files to ensure reproducibility. This metadata includes a checksum for each stored table, version number or checksum of selected datasets, and versions of relevant packages. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "store = pd.HDFStore('kurucz_cd23_chianti_He_cmfgen_H_Si_I-II.h5', key='metadata')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "store[\"metadata\"]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "store.root._v_attrs" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.15" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 2 }