Created
August 9, 2019 00:26
-
-
Save epassaro/0ce7f2509a797d3f4fd57daacdac954f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"/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)\n", | |
" \" (e.g. in jupyter console)\", TqdmExperimentalWarning)\n" | |
] | |
} | |
], | |
"source": [ | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"from carsus import init_db\n", | |
"from carsus.model import Atom, Ion, Level, Line\n", | |
"from carsus.io.output import AtomData\n", | |
"from carsus.io.nist import NISTIonizationEnergiesIngester\n", | |
"from carsus.io.kurucz import GFALLIngester, GFALLReader\n", | |
"\n", | |
"import warnings\n", | |
"warnings.simplefilter('ignore')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Initializing the database at sqlite://\n", | |
"Ingesting basic atomic data\n", | |
"Downloading ionization energies from the NIST Atomic Spectra Database\n", | |
"Ingesting ionization energies from nist-asd\n", | |
"Ingesting ground levels from nist-asd\n" | |
] | |
} | |
], | |
"source": [ | |
"session = init_db()\n", | |
"\n", | |
"ioniz_energies_ingester = NISTIonizationEnergiesIngester(session, spectra=\"Li-Si\")\n", | |
"ioniz_energies_ingester.ingest(ionization_energies=True, ground_levels=True)\n", | |
"session.commit()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;33mWARNING\u001b[0m] A specific combination to identify unique levels from the gfall data has not been given. Defaulting to [\"energy\", \"j\"]. (\u001b[1mgfall.py\u001b[0m:72)\n", | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m ] Parsing GFALL ../gfall.dat (\u001b[1mgfall.py\u001b[0m:120)\n", | |
"Ingesting levels from ku_latest\n", | |
"Ingesting levels for Li 0\n", | |
"Ingesting levels for Li 1\n", | |
"Ingesting levels for Be 0\n", | |
"Ingesting levels for Be 1\n", | |
"Ingesting levels for Be 2\n", | |
"Ingesting levels for B 0\n", | |
"Ingesting levels for B 1\n", | |
"Ingesting levels for B 2\n", | |
"Ingesting levels for B 3\n", | |
"Ingesting levels for C 0\n", | |
"Ingesting levels for C 1\n", | |
"Ingesting levels for C 2\n", | |
"Ingesting levels for C 3\n", | |
"Ingesting levels for N 0\n", | |
"Ingesting levels for N 1\n", | |
"Ingesting levels for N 2\n", | |
"Ingesting levels for N 3\n", | |
"Ingesting levels for N 4\n", | |
"Ingesting levels for N 5\n", | |
"Ingesting levels for O 0\n", | |
"Ingesting levels for O 1\n", | |
"Ingesting levels for O 2\n", | |
"Ingesting levels for O 3\n", | |
"Ingesting levels for O 4\n", | |
"Ingesting levels for O 5\n", | |
"Ingesting levels for F 0\n", | |
"Ingesting levels for F 1\n", | |
"Ingesting levels for F 2\n", | |
"Ingesting levels for F 3\n", | |
"Ingesting levels for F 4\n", | |
"Ingesting levels for F 5\n", | |
"Ingesting levels for Ne 0\n", | |
"Ingesting levels for Ne 1\n", | |
"Ingesting levels for Ne 2\n", | |
"Ingesting levels for Ne 3\n", | |
"Ingesting levels for Ne 4\n", | |
"Ingesting levels for Ne 5\n", | |
"Ingesting levels for Na 0\n", | |
"Ingesting levels for Na 1\n", | |
"Ingesting levels for Na 2\n", | |
"Ingesting levels for Na 3\n", | |
"Ingesting levels for Na 4\n", | |
"Ingesting levels for Na 5\n", | |
"Ingesting levels for Mg 0\n", | |
"Ingesting levels for Mg 1\n", | |
"Ingesting levels for Mg 2\n", | |
"Ingesting levels for Mg 3\n", | |
"Ingesting levels for Mg 4\n", | |
"Ingesting levels for Mg 5\n", | |
"Ingesting levels for Al 0\n", | |
"Ingesting levels for Al 1\n", | |
"Ingesting levels for Al 2\n", | |
"Ingesting levels for Al 3\n", | |
"Ingesting levels for Al 4\n", | |
"Ingesting levels for Al 5\n", | |
"Ingesting levels for Si 0\n", | |
"Ingesting levels for Si 1\n", | |
"Ingesting levels for Si 2\n", | |
"Ingesting levels for Si 3\n", | |
"Ingesting levels for Si 4\n", | |
"Ingesting levels for Si 5\n", | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m ] Extracting line data: atomic_number, ion_charge, energy_lower, j_lower, energy_upper, j_upper, wavelength, loggf (\u001b[1mgfall.py\u001b[0m:296)\n", | |
"Ingesting lines from ku_latest\n", | |
"Ingesting lines for Li 0\n", | |
"Ingesting lines for Li 1\n", | |
"Ingesting lines for Be 0\n", | |
"Ingesting lines for Be 1\n", | |
"Ingesting lines for Be 2\n", | |
"Ingesting lines for B 0\n", | |
"Ingesting lines for B 1\n", | |
"Ingesting lines for B 2\n", | |
"Ingesting lines for B 3\n", | |
"Ingesting lines for C 0\n", | |
"Ingesting lines for C 1\n", | |
"Ingesting lines for C 2\n", | |
"Ingesting lines for C 3\n", | |
"Ingesting lines for N 0\n", | |
"Ingesting lines for N 1\n", | |
"Ingesting lines for N 2\n", | |
"Ingesting lines for N 3\n", | |
"Ingesting lines for N 4\n", | |
"Ingesting lines for N 5\n", | |
"Ingesting lines for O 0\n", | |
"Ingesting lines for O 1\n", | |
"Ingesting lines for O 2\n", | |
"Ingesting lines for O 3\n", | |
"Ingesting lines for O 4\n", | |
"Ingesting lines for O 5\n", | |
"Ingesting lines for F 0\n", | |
"Ingesting lines for F 1\n", | |
"Ingesting lines for F 2\n", | |
"Ingesting lines for F 3\n", | |
"Ingesting lines for F 4\n", | |
"Ingesting lines for F 5\n", | |
"Ingesting lines for Ne 0\n", | |
"Ingesting lines for Ne 1\n", | |
"Ingesting lines for Ne 2\n", | |
"Ingesting lines for Ne 3\n", | |
"Ingesting lines for Ne 4\n", | |
"Ingesting lines for Ne 5\n", | |
"Ingesting lines for Na 0\n", | |
"Ingesting lines for Na 1\n", | |
"Ingesting lines for Na 2\n", | |
"Ingesting lines for Na 3\n", | |
"Ingesting lines for Na 4\n", | |
"Ingesting lines for Na 5\n", | |
"Ingesting lines for Mg 0\n", | |
"Ingesting lines for Mg 1\n", | |
"Ingesting lines for Mg 2\n", | |
"Ingesting lines for Mg 3\n", | |
"Ingesting lines for Mg 4\n", | |
"Ingesting lines for Mg 5\n", | |
"Ingesting lines for Al 0\n", | |
"Ingesting lines for Al 1\n", | |
"Ingesting lines for Al 2\n", | |
"Ingesting lines for Al 3\n", | |
"Ingesting lines for Al 4\n", | |
"Ingesting lines for Al 5\n", | |
"Ingesting lines for Si 0\n", | |
"Ingesting lines for Si 1\n", | |
"Ingesting lines for Si 2\n", | |
"Ingesting lines for Si 3\n", | |
"Ingesting lines for Si 4\n", | |
"Ingesting lines for Si 5\n" | |
] | |
} | |
], | |
"source": [ | |
"gfall_ingester = GFALLIngester(session, fname=\"../gfall.dat\", ions=\"Li-Si\")\n", | |
"gfall_ingester.ingest(levels=True, lines=True)\n", | |
"session.commit()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"atom_data = AtomData(session, selected_atoms=\"Li-Si\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(8033, 4)" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"atom_data._get_all_levels_data().shape" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from carsus.io.kurucz.gfall import GFALL" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;33mWARNING\u001b[0m] A specific combination to identify unique levels from the gfall data has not been given. Defaulting to [\"energy\", \"j\"]. (\u001b[1mgfall.py\u001b[0m:72)\n", | |
"Downloading ionization energies from the NIST Atomic Spectra Database\n", | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m ] Parsing GFALL gfall.dat (\u001b[1mgfall.py\u001b[0m:120)\n", | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m ] Extracting line data: atomic_number, ion_charge, energy_lower, j_lower, energy_upper, j_upper, wavelength, loggf (\u001b[1mgfall.py\u001b[0m:296)\n" | |
] | |
} | |
], | |
"source": [ | |
"x = GFALL('gfall.dat', 'Li-Si')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(7162, 3)" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"atom_data.levels_prepared.shape" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"energy 7162\n", | |
"g 7162\n", | |
"metastable 7162\n", | |
"dtype: int64" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"atom_data.levels_prepared.eq(x.levels_prepared).sum()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(41362, 8)" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"atom_data.lines_prepared.shape" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 11, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"line_id 41362\n", | |
"wavelength 41362\n", | |
"f_ul 41362\n", | |
"f_lu 41362\n", | |
"nu 41362\n", | |
"B_lu 41362\n", | |
"B_ul 41362\n", | |
"A_ul 41362\n", | |
"dtype: int64" | |
] | |
}, | |
"execution_count": 11, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"atom_data.lines_prepared.eq(x.lines_prepared).sum()" | |
] | |
} | |
], | |
"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.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment