Created
August 20, 2019 02:51
-
-
Save epassaro/d946594c91a2631f85ec6c20f4be14e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Creating a TARDIS atomic file\n", | |
"\n", | |
"Import the following classes:" | |
] | |
}, | |
{ | |
"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": [ | |
"from carsus.io.nist import NISTIonizationEnergies\n", | |
"from carsus.io.kurucz import GFALLReader\n", | |
"from carsus.io.output import TARDISAtomData" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Get ionization energies from NIST and create a `gfall_reader` instance." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Downloading ionization energies from the NIST Atomic Spectra Database\n" | |
] | |
} | |
], | |
"source": [ | |
"ionization_energies = NISTIonizationEnergies('H-Zn')" | |
] | |
}, | |
{ | |
"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:68)\n" | |
] | |
} | |
], | |
"source": [ | |
"gfall_reader = GFALLReader('gfall.dat')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Then create a `TARDISAtomData` object passing the `gfall_reader`, `ionization_energies` and the selected ions:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[\u001b[1mcarsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m ] Parsing GFALL gfall.dat (\u001b[1mgfall.py\u001b[0m:116)\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:292)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /home/epassaro/Desktop/gsoc/notebooks/carsus/io/output/base.py:132: PerformanceWarning: indexing past lexsort depth may impact performance.\n", | |
" df = gf.lines.loc[ion]\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /home/epassaro/Desktop/gsoc/notebooks/carsus/io/output/base.py:132: PerformanceWarning: indexing past lexsort depth may impact performance.\n", | |
" df = gf.lines.loc[ion]\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /home/epassaro/Desktop/gsoc/notebooks/carsus/io/output/base.py:139: PerformanceWarning: indexing past lexsort depth may impact performance.\n", | |
" ['atomic_number', 'ion_number']).loc[ion]\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /home/epassaro/Desktop/gsoc/notebooks/carsus/io/output/base.py:139: PerformanceWarning: indexing past lexsort depth may impact performance.\n", | |
" ['atomic_number', 'ion_number']).loc[ion]\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /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\n", | |
"of pandas will change to not sort by default.\n", | |
"\n", | |
"To accept the future behavior, pass 'sort=False'.\n", | |
"\n", | |
"To retain the current behavior and silence the warning, pass 'sort=True'.\n", | |
"\n", | |
" sort=sort)\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n", | |
"[\u001b[1mpy.warnings \u001b[0m][\u001b[1;33mWARNING\u001b[0m] /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\n", | |
"of pandas will change to not sort by default.\n", | |
"\n", | |
"To accept the future behavior, pass 'sort=False'.\n", | |
"\n", | |
"To retain the current behavior and silence the warning, pass 'sort=True'.\n", | |
"\n", | |
" sort=sort)\n", | |
" (\u001b[1mwarnings.py\u001b[0m:99)\n" | |
] | |
} | |
], | |
"source": [ | |
"atom_data = TARDISAtomData(gfall_reader, ionization_energies, ions='H-Zn')" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Finally, dump the object attributes to an HDF5 file." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"atom_data.to_hdf('kurucz_H-Zn.h5')" | |
] | |
} | |
], | |
"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