In [1]:
import numpy as np
import pandas as pd
from carsus import init_db
from carsus.model import Atom, Ion, Level, Line
from carsus.io.output import AtomData
from carsus.io.nist import NISTIonizationEnergiesIngester, NISTWeightsCompIngester
from carsus.io.kurucz import GFALLIngester
session = init_db()
/home/epassaro/miniconda3/envs/carsus/lib/python3.6/site-packages/tqdm/autonotebook/__init__.py:18: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
  " (e.g. in jupyter console)", TqdmExperimentalWarning)
Initializing the database at sqlite://
Ingesting basic atomic data

This is the usual SQL stuff

In [2]:
weightscomp_ingester = NISTWeightsCompIngester(session)
weightscomp_ingester.ingest()
session.commit()
Downloading data from the NIST Atomic Weights and Isotopic Compositions database.
Ingesting atomic weights from nist
In [3]:
ioniz_energies_ingester = NISTIonizationEnergiesIngester(session, spectra="Si")
ioniz_energies_ingester.ingest(ionization_energies=True, ground_levels=True)
session.commit()
Downloading ionization energies from the NIST Atomic Spectra Database
Ingesting ionization energies from nist-asd
Ingesting ground levels from nist-asd
In [4]:
gfall_ingester = GFALLIngester(session, fname="../gfall.dat", ions="Si 1-2")
gfall_ingester.ingest(levels=True, lines=True)
session.commit()
[carsus.io.kurucz.gfall][WARNING]  A specific combination to identify unique levels from the gfall data has not been given. Defaulting to ["energy", "j"]. (gfall.py:71)
[carsus.io.kurucz.gfall][INFO   ]  Parsing GFALL ../gfall.dat (gfall.py:119)
Ingesting levels from ku_latest
Ingesting levels for Si 1
Ingesting levels for Si 2
[carsus.io.kurucz.gfall][INFO   ]  Extracting line data: atomic_number, ion_charge, energy_lower, j_lower, energy_upper, j_upper, wavelength, loggf (gfall.py:295)
Ingesting lines from ku_latest
Ingesting lines for Si 1
Ingesting lines for Si 2
In [5]:
atom_data = AtomData(session, selected_atoms='Si')
In [6]:
atom_data.levels.head(10)
[py.warnings         ][WARNING]  /home/epassaro/miniconda3/envs/carsus/lib/python3.6/site-packages/pandas/core/frame.py:6692: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  sort=sort)
 (warnings.py:99)
[py.warnings         ][WARNING]  /home/epassaro/miniconda3/envs/carsus/lib/python3.6/site-packages/pandas/core/frame.py:6692: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  sort=sort)
 (warnings.py:99)
Out[6]:
atomic_number energy g ion_number level_id level_number metastable
0 14 0.000000 1 0 1 0 True
1 14 0.000000 2 1 15 0 True
2 14 0.035613 4 1 16 1 True
3 14 5.309535 2 1 17 2 True
4 14 5.322966 4 1 18 3 True
5 14 5.344700 6 1 19 4 True
6 14 6.857485 4 1 20 5 False
7 14 6.859448 6 1 21 6 False
8 14 8.121023 2 1 22 7 False
9 14 9.505292 2 1 23 8 False

Now we try to replicate the same DataFrame with our new class

In [7]:
from carsus.io.kurucz.gfall import GFALL
In [8]:
x = GFALL('./gfall.dat', ions='Si 1-2')
[carsus.io.kurucz.gfall][WARNING]  A specific combination to identify unique levels from the gfall data has not been given. Defaulting to ["energy", "j"]. (gfall.py:71)
Downloading ionization energies from the NIST Atomic Spectra Database
[carsus.io.kurucz.gfall][INFO   ]  Parsing GFALL ./gfall.dat (gfall.py:119)
[py.warnings         ][WARNING]  /home/epassaro/miniconda3/envs/carsus/lib/python3.6/site-packages/pandas/core/frame.py:6692: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  sort=sort)
 (warnings.py:99)
[py.warnings         ][WARNING]  /home/epassaro/miniconda3/envs/carsus/lib/python3.6/site-packages/pandas/core/frame.py:6692: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.

To accept the future behavior, pass 'sort=False'.

To retain the current behavior and silence the warning, pass 'sort=True'.

  sort=sort)
 (warnings.py:99)
In [9]:
x.levels.head(10)
Out[9]:
atomic_number energy g ion_number level_id level_number metastable
0 14 0.000000 1 0 1 0 False
1 14 0.000000 2 1 15 0 False
2 14 0.035613 4 1 16 1 False
3 14 5.309535 2 1 17 2 False
4 14 5.322966 4 1 18 3 False
5 14 5.344700 6 1 19 4 False
6 14 6.857485 4 1 20 5 False
7 14 6.859448 6 1 21 6 False
8 14 8.121023 2 1 22 7 False
9 14 9.505292 2 1 23 8 False
In [10]:
atom_data.levels.eq(x.levels).sum()
Out[10]:
atomic_number    272
energy           272
g                272
ion_number       272
level_id         272
level_number     272
metastable       247
dtype: int64