Quickstart for Carsus

In this guide you will learn how to create atomic data files suitable for TARDIS.

Note:

Get familiar with the Notation in Carsus and learn how to correctly select ions.

Atomic Weights and Ionization Energies (NIST)

Download atomic weights and ionization energies from the National Institute of Standards and Technology (NIST).

[1]:
from carsus.io.nist import NISTWeightsComp, NISTIonizationEnergies
 ChiantiPy version 0.8.4
 found PyQt5 widgets
 using PyQt5 widgets
[2]:
atomic_weights = NISTWeightsComp()
ionization_energies = NISTIonizationEnergies('H-Zn')
[ carsus.io.nist.weightscomp][   INFO] - Downloading data from the NIST Atomic Weights and Isotopic Compositions Database. (weightscomp.py:49)
[  carsus.io.nist.ionization][   INFO] - Downloading ionization energies from the NIST Atomic Spectra Database. (ionization.py:64)

Levels, Lines, Collisions & Cross-sections

Carsus supports three sources of energy levels and spectral lines: GFALL, CHIANTI and CMFGEN.

GFALL

The Robert Kurucz’s Atomic Linelist (GFALL) reader is the main source of levels and lines.

Warning:

Creating a GFALLReader instance is required.

[3]:
!wget -qO /tmp/gfall.dat https://media.githubusercontent.com/media/tardis-sn/carsus-db/master/gfall/gfall_latest.dat
[4]:
from carsus.io.kurucz import GFALLReader

gfall_reader = GFALLReader('H-Zn',
                           '/tmp/gfall.dat')
[     carsus.io.kurucz.gfall][WARNING] - A specific combination to identify unique levels from GFALL data has not been given. Defaulting to ["energy", "j"]. (gfall.py:93)

CHIANTI

The Chianti Atomic Database reader provides levels and lines but also collision strengths.

Note:

Creating a ChiantiReader instance is optional.

[5]:
from carsus.io.chianti_ import ChiantiReader

chianti_reader = ChiantiReader('H-He',
                               collisions=True,
                               priority=20)

By default priority parameter is set to 10. Increase this value if you want to keep CHIANTI levels and lines over GFALL.

CMFGEN

The atomic database of CMFGEN is a source of levels, lines and (optionally) ionization energies, photoionization cross-sections and collisions.

Note:

Creating a CMFGENReader instance is optional.

Warning:

Cross-sections require data from H 0, use this the reader with enough priority to select levels from this ion.

[6]:
from carsus.io.cmfgen import CMFGENReader

cmfgen_reader = CMFGENReader.from_config('Si 0-1',
                                         '/tmp/atomic',
                                         priority=30,
                                         ionization_energies=True,
                                         cross_sections=True,
                                         collisions=False,
                                         temperature_grid=None,
                                         drop_mismatched_labels=True)
[      carsus.io.cmfgen.base][WARNING] - Selecting H 0 from CMFGEN (required to ingest cross-sections). (base.py:543)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for H 0. (base.py:557)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for Si 0. (base.py:557)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for Si 1. (base.py:557)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for H 0. (base.py:820)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for Si 0. (base.py:820)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for Si 1. (base.py:820)

Zeta Data

Long & Knigge’s ground state recombinations fractions (\(\zeta\)).

[7]:
from carsus.io.zeta import KnoxLongZeta

zeta_data = KnoxLongZeta()

Create an Atomic Data File

Finally, create a TARDISAtomData object and dump the data with the to_hdf method.

[8]:
from carsus.io.output import TARDISAtomData

atom_data = TARDISAtomData(atomic_weights,
                           ionization_energies,
                           gfall_reader,
                           zeta_data,
                           chianti_reader,
                           cmfgen_reader)
[      carsus.io.output.base][   INFO] - Ingesting energy levels. (base.py:327)
[     carsus.io.kurucz.gfall][   INFO] - Parsing GFALL from: /tmp/gfall.dat (gfall.py:146)
[      carsus.io.output.base][   INFO] - GFALL selected species: Li 0, Li 1, Be 0, Be 1, Be 2, B 0, B 1, B 2, B 3, C 0, C 1, C 2, C 3, N 0, N 1, N 2, N 3, N 4, N 5, O 0, O 1, O 2, O 3, O 4, O 5, F 0, F 1, F 2, F 3, F 4, F 5, Ne 0, Ne 1, Ne 2, Ne 3, Ne 4, Ne 5, Na 0, Na 1, Na 2, Na 3, Na 4, Na 5, Mg 0, Mg 1, Mg 2, Mg 3, Mg 4, Mg 5, Al 0, Al 1, Al 2, Al 3, Al 4, Al 5, Si 2, Si 3, Si 4, Si 5, P 0, P 1, P 2, P 3, P 4, P 5, S 0, S 1, S 2, S 3, S 4, S 5, Cl 0, Cl 1, Cl 2, Cl 3, Cl 4, Ar 0, Ar 1, Ar 2, Ar 3, Ar 4, K 0, K 1, K 2, K 3, K 4, Ca 0, Ca 1, Ca 2, Ca 3, Ca 4, Ca 5, Ca 6, Ca 7, Ca 8, Sc 0, Sc 1, Sc 2, Sc 3, Sc 4, Sc 5, Sc 6, Sc 7, Sc 8, Ti 0, Ti 1, Ti 2, Ti 3, Ti 4, Ti 5, Ti 6, Ti 7, Ti 8, V 0, V 1, V 2, V 3, V 4, V 5, V 6, V 7, V 8, Cr 0, Cr 1, Cr 2, Cr 3, Cr 4, Cr 5, Cr 6, Cr 7, Cr 8, Mn 0, Mn 1, Mn 2, Mn 3, Mn 4, Mn 5, Mn 6, Mn 7, Mn 8, Fe 0, Fe 1, Fe 2, Fe 3, Fe 4, Fe 5, Fe 6, Fe 7, Fe 8, Co 0, Co 1, Co 2, Co 3, Co 4, Co 5, Co 6, Co 7, Co 8, Ni 0, Ni 1, Ni 2, Ni 3, Ni 4, Ni 5, Ni 6, Ni 7, Ni 8, Cu 0, Cu 1, Zn 0, Zn 1, Zn 2. (base.py:361)
[      carsus.io.output.base][   INFO] - Chianti selected species: He 0, He 1. (base.py:365)
[      carsus.io.output.base][   INFO] - CMFGEN selected species: H 0, Si 0, Si 1. (base.py:369)
[  carsus.io.nist.ionization][WARNING] - Set `J=0` for ground state of species `Fe 6`. (ionization.py:167)
[      carsus.io.output.base][   INFO] - Ingesting transition lines. (base.py:423)
[     carsus.io.kurucz.gfall][   INFO] - Extracting line data: atomic_number, ion_charge, energy_lower, j_lower, energy_upper, j_upper, wavelength, loggf. (gfall.py:341)
[      carsus.io.output.base][   INFO] - Matching levels and lines. (base.py:462)
[                py.warnings][WARNING] - /usr/share/miniconda3/envs/carsus/lib/python3.7/site-packages/pandas/core/series.py:679: RuntimeWarning: divide by zero encountered in log10
  result = getattr(ufunc, method)(*inputs, **kwargs)
 (warnings.py:110)
[      carsus.io.output.base][   INFO] - Ingesting collisional strengths. (base.py:616)
[      carsus.io.output.base][   INFO] - Matching collisions and levels. (base.py:628)
[      carsus.io.output.base][   INFO] - Ingesting photoionization cross-sections. (base.py:696)
[      carsus.io.output.base][   INFO] - Matching levels and cross sections. (base.py:699)
[      carsus.io.output.base][   INFO] - Finished. (base.py:107)
[9]:
atom_data.to_hdf('kurucz_cd23_chianti_He_cmfgen_H_Si_I-II.h5')
[                py.warnings][WARNING] - /usr/share/miniconda3/envs/carsus/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3552: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->values] [items->None]

  exec(code_obj, self.user_global_ns, self.user_ns)
 (warnings.py:110)
[                py.warnings][WARNING] - /usr/share/miniconda3/envs/carsus/lib/python3.7/site-packages/pyarrow/serialization.py:165: FutureWarning: The SparseDataFrame class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version
  if isinstance(obj, pd.SparseDataFrame):
 (warnings.py:110)
[                py.warnings][WARNING] - /usr/share/miniconda3/envs/carsus/lib/python3.7/site-packages/pyarrow/serialization.py:176: FutureWarning: The SparseSeries class is removed from pandas. Accessing it from the top-level namespace will also be removed in the next version
  if isinstance(obj, pd.SparseSeries):
 (warnings.py:110)
[      carsus.io.output.base][   INFO] - Signing TARDISAtomData. (base.py:1095)
[      carsus.io.output.base][   INFO] - Format Version: 1.0 (base.py:1096)
[      carsus.io.output.base][   INFO] - MD5: df7bf97f462720b3c672e99e51e92f6c (base.py:1097)
[      carsus.io.output.base][   INFO] - UUID1: 9026f56865eb11edaee3000d3af1bcc3 (base.py:1098)

You are done! Now you can use your file to run TARDIS simulations.

Metadata

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.

[10]:
import pandas as pd
[11]:
store = pd.HDFStore('kurucz_cd23_chianti_He_cmfgen_H_Si_I-II.h5', key='metadata')
[12]:
store["metadata"]
[12]:
value
field key
format version 1.0
md5sum atom_data 634785f05c4868f929c85c02828d4ef8
collisions_data 0f19bec97c3b770c6ed7e78be2cd1efd
collisions_metadata 2139b8beb1db60823290c24aa0d5a464
ionization_data 6aa1b44c09a4825ea72ced37f33bf00d
levels_data aa695d9348461d452e04970959f7ec32
lines_data aa58ecd7e85a89016d03e513df973995
lines_metadata 736d8321848fa598443cbd807732a8dc
macro_atom_data 1244eb0abb974e485ca387639c78d545
macro_atom_references 4e6ae567911277dc6883a9a815b23163
photoionization_data c25d0b8fc1b34a8d77ceffc90da8fead
zeta_data f2496cec5c219dfb6d637df8e92fd3f0
datasets nist_weights 4.1
nist_spectra 5.10
gfall 2704fbda0b8cba61bb70426234224464
zeta a1d4bed2982e8d6a4f8b0076bf637e49
chianti 9.0.1
cmfgen 2016.11.15
software python 3.7.12
carsus 0.1.dev690+g4aa55e4
astropy 3.2.3
numpy 1.15.4
pandas 1.0.5
pyarrow 0.14.1
tables 3.6.1
ChiantiPy 0.8.4
[13]:
store.root._v_attrs
[13]:
/._v_attrs (AttributeSet), 8 attributes:
   [CLASS := 'GROUP',
    DATE := '2022-11-16T20:16:32.859756+00:00',
    FORMAT_VERSION := '1.0',
    MD5 := 'df7bf97f462720b3c672e99e51e92f6c',
    PYTABLES_FORMAT_VERSION := '2.1',
    TITLE := '',
    UUID1 := '9026f56865eb11edaee3000d3af1bcc3',
    VERSION := '1.0']