Created
March 11, 2025 14:04
-
-
Save epassaro/81737257b3deb6aaac5a1de287d3ecd8 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": [ | |
| "# CMFGEN levels and lines\n", | |
| "---\n", | |
| "\n", | |
| "My approach is to do exactly the same I did for the Chianti levels and lines: try to mimic the table generated by `GFALLReader` for energy levels and lines." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import warnings\n", | |
| "warnings.simplefilter('ignore') # Make this notebook easier to read" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| " ChiantiPy version 0.8.4 \n", | |
| " found PyQt5 widgets\n", | |
| " using PyQt5 widgets\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "import numpy as np\n", | |
| "import astropy.units as u\n", | |
| "import astropy.constants as const\n", | |
| "from carsus.io.kurucz import GFALLReader\n", | |
| "from carsus.io.cmfgen import CMFGENEnergyLevelsParser, CMFGENOscillatorStrengthsParser" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "Let's make example tables for `Si I`, and `II`." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "[\u001b[1m carsus.io.kurucz.gfall\u001b[0m][\u001b[1;33mWARNING\u001b[0m] - A specific combination to identify unique levels from GFALL data has not been given. Defaulting to [\"energy\", \"j\"]. (\u001b[1mgfall.py\u001b[0m:86)\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "gfall_reader = GFALLReader('Si 0-2', fname='/home/epassaro/Desktop/gfall.dat')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "To avoid writing an interface module between `carsus` and CMFGEN database (some sort of `ChiantiPy`) my approach is to pass a list of tuples `(ion, parser)` as a parameter, for example:" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "si_0_lvl = CMFGENEnergyLevelsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/I/23nov11/SiI_OSC')\n", | |
| "si_0_osc = CMFGENOscillatorStrengthsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/I/23nov11/SiI_OSC')\n", | |
| "\n", | |
| "si_1_lvl = CMFGENEnergyLevelsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/II/16sep15/si2_osc_kurucz')\n", | |
| "si_1_osc = CMFGENOscillatorStrengthsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/II/16sep15/si2_osc_kurucz')\n", | |
| "\n", | |
| "si_2_lvl = CMFGENEnergyLevelsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/III/5dec96b/osc_op_split_rev.dat')\n", | |
| "si_2_osc = CMFGENOscillatorStrengthsParser('/home/epassaro/Desktop/tardis-sn/atomic_data/CMFGEN/atomic/SIL/III/5dec96b/osc_op_split_rev.dat')\n", | |
| "\n", | |
| "# This should work for now, a dict of dicts:\n", | |
| "cmfgen_data = {'Si 0': {'levels': si_0_lvl, 'lines': si_0_osc}, \n", | |
| " 'Si 1': {'levels': si_1_lvl, 'lines': si_1_osc},\n", | |
| " 'Si 2': {'levels': si_2_lvl, 'lines': si_2_osc},}" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "## Quick note on _f_ values\n", | |
| "\n", | |
| "_Radiative Processes in Astrophysics_ by George B. Rybicki, Alan P. Lightman - Eq. 10.34:\n", | |
| "\n", | |
| "$ g_u A_{ul} = - \\frac{8 \\pi^2 e^2 \\nu_{ul}^{2}}{m c^3} g_u f_{ul} = \\frac{8 \\pi^2 e^2 \\nu_{ul}^{2}}{m c^3} g_l f_{lu} $\n", | |
| "\n", | |
| "$ g_u A_{ul} = \\frac{8 \\pi^2 e^2 \\nu_{ul}^{2}}{m c^3} g_l f_{lu} $\n", | |
| "\n", | |
| "$ g_u A_{ul} = \\frac{8 \\pi^2 e^2}{m c \\lambda_{ul}^{2}} g_l f_{lu} $\n", | |
| "\n", | |
| "$ g_u A_{ul} = \\frac{E_{pref}}{\\lambda_{ul}^2} g_l f_{lu} $\n", | |
| "\n", | |
| "$ f_{lu} = \\frac{g_u}{g_l}\\frac{A_{ul} \\lambda_{ul}^2}{E_{pref}} $" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "levels = cmfgen_data['Si 1']['levels'].base\n", | |
| "levels['atomic_number'] = 14\n", | |
| "levels['ion_charge'] = 1\n", | |
| "#levels['ID'] = levels['ID'].apply(np.abs) # Negative ID's (theoretical?)\n", | |
| "levels = levels.set_index(['atomic_number', 'ion_charge', 'ID'])\n", | |
| "\n", | |
| "lines = cmfgen_data['Si 1']['lines'].base\n", | |
| "lines['atomic_number'] = 14\n", | |
| "lines['ion_charge'] = 1\n", | |
| "lines = lines.set_index(['atomic_number', 'ion_charge', 'i', 'j'])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "si_levels_test = levels.loc[(14,1)]\n", | |
| "si_lines_test = lines.loc[(14,1)]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "si_lines_test['g_lower'] = si_levels_test['g'].reindex(si_lines_test.index, level=0).values\n", | |
| "si_lines_test['g_upper'] = si_levels_test['g'].reindex(si_lines_test.index, level=1).values\n", | |
| "si_lines_test['energy_lower'] = si_levels_test['E(cm^-1)'].reindex(si_lines_test.index, level=0).values\n", | |
| "si_lines_test['energy_upper'] = si_levels_test['E(cm^-1)'].reindex(si_lines_test.index, level=1).values" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "si_lines_test = si_lines_test[['f', 'A', 'Lam(A)', 'energy_lower', 'energy_upper', 'g_lower', 'g_upper']]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>f</th>\n", | |
| " <th>A</th>\n", | |
| " <th>Lam(A)</th>\n", | |
| " <th>energy_lower</th>\n", | |
| " <th>energy_upper</th>\n", | |
| " <th>g_lower</th>\n", | |
| " <th>g_upper</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>i</th>\n", | |
| " <th>j</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">1</th>\n", | |
| " <th>3</th>\n", | |
| " <td>5.741000e-06</td>\n", | |
| " <td>7.023000e+03</td>\n", | |
| " <td>2335.123</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42824.29</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>3.564000e-08</td>\n", | |
| " <td>2.191000e+01</td>\n", | |
| " <td>2329.231</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42932.62</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>6</th>\n", | |
| " <td>7.638000e-04</td>\n", | |
| " <td>7.793000e+05</td>\n", | |
| " <td>1808.013</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>55309.35</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>8</th>\n", | |
| " <td>1.279000e-01</td>\n", | |
| " <td>3.661000e+08</td>\n", | |
| " <td>1526.707</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>65500.47</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>9</th>\n", | |
| " <td>1.062000e-01</td>\n", | |
| " <td>4.162000e+08</td>\n", | |
| " <td>1304.370</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>76665.35</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>153</th>\n", | |
| " <th>157</th>\n", | |
| " <td>3.250000e-06</td>\n", | |
| " <td>3.251000e+00</td>\n", | |
| " <td>81665.986</td>\n", | |
| " <td>134079.00</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">154</th>\n", | |
| " <th>156</th>\n", | |
| " <td>6.605000e-07</td>\n", | |
| " <td>5.173000e-01</td>\n", | |
| " <td>92279.015</td>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>6.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>157</th>\n", | |
| " <td>4.129000e-08</td>\n", | |
| " <td>4.907000e-02</td>\n", | |
| " <td>91754.062</td>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">155</th>\n", | |
| " <th>156</th>\n", | |
| " <td>7.673000e-06</td>\n", | |
| " <td>5.243000e-01</td>\n", | |
| " <td>255100.000</td>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>6.0</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>157</th>\n", | |
| " <td>6.744000e-07</td>\n", | |
| " <td>7.134000e-02</td>\n", | |
| " <td>251100.000</td>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>4196 rows × 7 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " f A Lam(A) energy_lower energy_upper \\\n", | |
| "i j \n", | |
| "1 3 5.741000e-06 7.023000e+03 2335.123 0.00 42824.29 \n", | |
| " 4 3.564000e-08 2.191000e+01 2329.231 0.00 42932.62 \n", | |
| " 6 7.638000e-04 7.793000e+05 1808.013 0.00 55309.35 \n", | |
| " 8 1.279000e-01 3.661000e+08 1526.707 0.00 65500.47 \n", | |
| " 9 1.062000e-01 4.162000e+08 1304.370 0.00 76665.35 \n", | |
| "... ... ... ... ... ... \n", | |
| "153 157 3.250000e-06 3.251000e+00 81665.986 134079.00 135303.50 \n", | |
| "154 156 6.605000e-07 5.173000e-01 92279.015 134213.63 135297.30 \n", | |
| " 157 4.129000e-08 4.907000e-02 91754.062 134213.63 135303.50 \n", | |
| "155 156 7.673000e-06 5.243000e-01 255100.000 134905.28 135297.30 \n", | |
| " 157 6.744000e-07 7.134000e-02 251100.000 134905.28 135303.50 \n", | |
| "\n", | |
| " g_lower g_upper \n", | |
| "i j \n", | |
| "1 3 2.0 2.0 \n", | |
| " 4 2.0 4.0 \n", | |
| " 6 2.0 4.0 \n", | |
| " 8 2.0 2.0 \n", | |
| " 9 2.0 2.0 \n", | |
| "... ... ... \n", | |
| "153 157 4.0 4.0 \n", | |
| "154 156 6.0 6.0 \n", | |
| " 157 6.0 4.0 \n", | |
| "155 156 4.0 6.0 \n", | |
| " 157 4.0 4.0 \n", | |
| "\n", | |
| "[4196 rows x 7 columns]" | |
| ] | |
| }, | |
| "execution_count": 9, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "si_lines_test" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "I'll try to re-calculate _f_'s." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "einstein_pf = 8*np.pi**2*const.e.gauss**2/(const.m_e.cgs*const.c).cgs" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "si_lines_test['lambda'] = si_lines_test['Lam(A)']*u.angstrom.to('cm')\n", | |
| "si_lines_test['f_check'] = si_lines_test['g_upper']*si_lines_test['A']/einstein_pf/si_lines_test['g_lower']\\\n", | |
| " *(si_lines_test['lambda']**2)\n", | |
| "si_lines_test = si_lines_test.drop(columns=['lambda'])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>f</th>\n", | |
| " <th>A</th>\n", | |
| " <th>Lam(A)</th>\n", | |
| " <th>energy_lower</th>\n", | |
| " <th>energy_upper</th>\n", | |
| " <th>g_lower</th>\n", | |
| " <th>g_upper</th>\n", | |
| " <th>f_check</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>i</th>\n", | |
| " <th>j</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">1</th>\n", | |
| " <th>3</th>\n", | |
| " <td>5.741000e-06</td>\n", | |
| " <td>7.023000e+03</td>\n", | |
| " <td>2335.123</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42824.29</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>5.741164e-06</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>3.564000e-08</td>\n", | |
| " <td>2.191000e+01</td>\n", | |
| " <td>2329.231</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42932.62</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>3.564144e-08</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>6</th>\n", | |
| " <td>7.638000e-04</td>\n", | |
| " <td>7.793000e+05</td>\n", | |
| " <td>1808.013</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>55309.35</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>7.638279e-04</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>8</th>\n", | |
| " <td>1.279000e-01</td>\n", | |
| " <td>3.661000e+08</td>\n", | |
| " <td>1526.707</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>65500.47</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>1.279290e-01</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>9</th>\n", | |
| " <td>1.062000e-01</td>\n", | |
| " <td>4.162000e+08</td>\n", | |
| " <td>1304.370</td>\n", | |
| " <td>0.00</td>\n", | |
| " <td>76665.35</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>1.061601e-01</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>153</th>\n", | |
| " <th>157</th>\n", | |
| " <td>3.250000e-06</td>\n", | |
| " <td>3.251000e+00</td>\n", | |
| " <td>81665.986</td>\n", | |
| " <td>134079.00</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>3.250552e-06</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">154</th>\n", | |
| " <th>156</th>\n", | |
| " <td>6.605000e-07</td>\n", | |
| " <td>5.173000e-01</td>\n", | |
| " <td>92279.015</td>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>6.603986e-07</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>157</th>\n", | |
| " <td>4.129000e-08</td>\n", | |
| " <td>4.907000e-02</td>\n", | |
| " <td>91754.062</td>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>4.128889e-08</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">155</th>\n", | |
| " <th>156</th>\n", | |
| " <td>7.673000e-06</td>\n", | |
| " <td>5.243000e-01</td>\n", | |
| " <td>255100.000</td>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>6.0</td>\n", | |
| " <td>7.672728e-06</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>157</th>\n", | |
| " <td>6.744000e-07</td>\n", | |
| " <td>7.134000e-02</td>\n", | |
| " <td>251100.000</td>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>6.743484e-07</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>4196 rows × 8 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " f A Lam(A) energy_lower energy_upper \\\n", | |
| "i j \n", | |
| "1 3 5.741000e-06 7.023000e+03 2335.123 0.00 42824.29 \n", | |
| " 4 3.564000e-08 2.191000e+01 2329.231 0.00 42932.62 \n", | |
| " 6 7.638000e-04 7.793000e+05 1808.013 0.00 55309.35 \n", | |
| " 8 1.279000e-01 3.661000e+08 1526.707 0.00 65500.47 \n", | |
| " 9 1.062000e-01 4.162000e+08 1304.370 0.00 76665.35 \n", | |
| "... ... ... ... ... ... \n", | |
| "153 157 3.250000e-06 3.251000e+00 81665.986 134079.00 135303.50 \n", | |
| "154 156 6.605000e-07 5.173000e-01 92279.015 134213.63 135297.30 \n", | |
| " 157 4.129000e-08 4.907000e-02 91754.062 134213.63 135303.50 \n", | |
| "155 156 7.673000e-06 5.243000e-01 255100.000 134905.28 135297.30 \n", | |
| " 157 6.744000e-07 7.134000e-02 251100.000 134905.28 135303.50 \n", | |
| "\n", | |
| " g_lower g_upper f_check \n", | |
| "i j \n", | |
| "1 3 2.0 2.0 5.741164e-06 \n", | |
| " 4 2.0 4.0 3.564144e-08 \n", | |
| " 6 2.0 4.0 7.638279e-04 \n", | |
| " 8 2.0 2.0 1.279290e-01 \n", | |
| " 9 2.0 2.0 1.061601e-01 \n", | |
| "... ... ... ... \n", | |
| "153 157 4.0 4.0 3.250552e-06 \n", | |
| "154 156 6.0 6.0 6.603986e-07 \n", | |
| " 157 6.0 4.0 4.128889e-08 \n", | |
| "155 156 4.0 6.0 7.672728e-06 \n", | |
| " 157 4.0 4.0 6.743484e-07 \n", | |
| "\n", | |
| "[4196 rows x 8 columns]" | |
| ] | |
| }, | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "si_lines_test" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "## Write CMFGENReader class" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd\n", | |
| "from carsus.util import parse_selected_species\n", | |
| "\n", | |
| "class CMFGENReader:\n", | |
| " \"\"\" Docstring \"\"\"\n", | |
| "\n", | |
| " def __init__(self, data, priority=10):\n", | |
| " \"\"\" Docstring \"\"\"\n", | |
| "\n", | |
| " self.priority = priority\n", | |
| " self._get_levels_lines(data)\n", | |
| " \n", | |
| " def _get_levels_lines(self, data):\n", | |
| " \"\"\" Docstring \"\"\"\n", | |
| "\n", | |
| " lvl_list = []\n", | |
| " lns_list = []\n", | |
| " for ion, parser in data.items():\n", | |
| "\n", | |
| " atomic_number = parse_selected_species(ion)[0][0]\n", | |
| " ion_charge = parse_selected_species(ion)[0][1]\n", | |
| " \n", | |
| " lvl = parser['levels'].base\n", | |
| " # some ID's have negative values (theoretical?)\n", | |
| " lvl.loc[ lvl['ID'] < 0, 'method'] = 'theor'\n", | |
| " lvl.loc[ lvl['ID'] > 0, 'method'] = 'meas'\n", | |
| " lvl['ID'] = lvl['ID'].apply(np.abs)\n", | |
| " lvl_id = lvl.set_index('ID')\n", | |
| " lvl['atomic_number'] = atomic_number\n", | |
| " lvl['ion_charge'] = ion_charge\n", | |
| " lvl_list.append(lvl)\n", | |
| "\n", | |
| " lns = parser['lines'].base\n", | |
| " lns = lns.set_index(['i', 'j'])\n", | |
| " lns['energy_lower'] = lvl_id['E(cm^-1)'].reindex(lns.index, level=0).values\n", | |
| " lns['energy_upper'] = lvl_id['E(cm^-1)'].reindex(lns.index, level=1).values\n", | |
| " lns['g_lower'] = lvl_id['g'].reindex(lns.index, level=0).values\n", | |
| " lns['g_upper'] = lvl_id['g'].reindex(lns.index, level=1).values\n", | |
| " lns['j_lower'] = (lns['g_lower'] -1)/2\n", | |
| " lns['j_upper'] = (lns['g_upper'] -1)/2\n", | |
| " lns['atomic_number'] = atomic_number\n", | |
| " lns['ion_charge'] = ion_charge\n", | |
| " lns = lns.reset_index()\n", | |
| " lns_list.append(lns)\n", | |
| "\n", | |
| " levels = pd.concat(lvl_list)\n", | |
| " levels['priority'] = self.priority\n", | |
| " levels = levels.reset_index(drop=False)\n", | |
| " levels = levels.rename(columns={'Configuration': 'label', \n", | |
| " 'E(cm^-1)': 'energy', \n", | |
| " 'index': 'level_index'})\n", | |
| " levels['j'] = (levels['g'] -1)/2\n", | |
| " levels = levels.set_index(['atomic_number', 'ion_charge', 'level_index'])\n", | |
| " levels = levels[['energy', 'j', 'label', 'method', 'priority']]\n", | |
| " \n", | |
| " lines = pd.concat(lns_list)\n", | |
| " lines = lines.rename(columns={'Lam(A)': 'wavelength'})\n", | |
| " lines['wavelength'] = lines['wavelength'].apply(lambda x: (x*u.AA).to('nm').value)\n", | |
| " lines['level_index_lower'] = lines['i'] -1\n", | |
| " lines['level_index_upper'] = lines['j'] -1\n", | |
| " lines['gf'] = lines['f']*lines['g_lower']\n", | |
| " lines = lines.set_index(['atomic_number', 'ion_charge', 'level_index_lower', 'level_index_upper'])\n", | |
| " lines = lines[['energy_lower', 'energy_upper', 'gf', 'j_lower', 'j_upper', 'wavelength']]\n", | |
| "\n", | |
| " self.levels = levels\n", | |
| " self.lines = lines\n", | |
| "\n", | |
| " return" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "cmfgen_reader = CMFGENReader(cmfgen_data)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>energy_lower</th>\n", | |
| " <th>energy_upper</th>\n", | |
| " <th>gf</th>\n", | |
| " <th>j_lower</th>\n", | |
| " <th>j_upper</th>\n", | |
| " <th>wavelength</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>level_index_lower</th>\n", | |
| " <th>level_index_upper</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">0</th>\n", | |
| " <th>2</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42824.29</td>\n", | |
| " <td>1.148200e-05</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>233.5123</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42932.62</td>\n", | |
| " <td>7.128000e-08</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>232.9231</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>55309.35</td>\n", | |
| " <td>1.527600e-03</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>180.8013</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>7</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>65500.47</td>\n", | |
| " <td>2.558000e-01</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>152.6707</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>8</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>76665.35</td>\n", | |
| " <td>2.124000e-01</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>130.4370</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>152</th>\n", | |
| " <th>156</th>\n", | |
| " <td>134079.00</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>1.300000e-05</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>8166.5986</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">153</th>\n", | |
| " <th>155</th>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>3.963000e-06</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>9227.9015</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>156</th>\n", | |
| " <td>134213.63</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>2.477400e-07</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>9175.4062</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"2\" valign=\"top\">154</th>\n", | |
| " <th>155</th>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>3.069200e-05</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>25510.0000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>156</th>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>2.697600e-06</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>25110.0000</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>4196 rows × 6 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " energy_lower energy_upper gf \\\n", | |
| "level_index_lower level_index_upper \n", | |
| "0 2 0.00 42824.29 1.148200e-05 \n", | |
| " 3 0.00 42932.62 7.128000e-08 \n", | |
| " 5 0.00 55309.35 1.527600e-03 \n", | |
| " 7 0.00 65500.47 2.558000e-01 \n", | |
| " 8 0.00 76665.35 2.124000e-01 \n", | |
| "... ... ... ... \n", | |
| "152 156 134079.00 135303.50 1.300000e-05 \n", | |
| "153 155 134213.63 135297.30 3.963000e-06 \n", | |
| " 156 134213.63 135303.50 2.477400e-07 \n", | |
| "154 155 134905.28 135297.30 3.069200e-05 \n", | |
| " 156 134905.28 135303.50 2.697600e-06 \n", | |
| "\n", | |
| " j_lower j_upper wavelength \n", | |
| "level_index_lower level_index_upper \n", | |
| "0 2 0.5 0.5 233.5123 \n", | |
| " 3 0.5 1.5 232.9231 \n", | |
| " 5 0.5 1.5 180.8013 \n", | |
| " 7 0.5 0.5 152.6707 \n", | |
| " 8 0.5 0.5 130.4370 \n", | |
| "... ... ... ... \n", | |
| "152 156 1.5 1.5 8166.5986 \n", | |
| "153 155 2.5 2.5 9227.9015 \n", | |
| " 156 2.5 1.5 9175.4062 \n", | |
| "154 155 1.5 2.5 25510.0000 \n", | |
| " 156 1.5 1.5 25110.0000 \n", | |
| "\n", | |
| "[4196 rows x 6 columns]" | |
| ] | |
| }, | |
| "execution_count": 15, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "cmfgen_reader.lines.loc[14,1]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 16, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "[\u001b[1m carsus.io.kurucz.gfall\u001b[0m][\u001b[1;37mINFO\u001b[0m] - Parsing GFALL: /home/epassaro/Desktop/gfall.dat (\u001b[1mgfall.py\u001b[0m:137)\n", | |
| "[\u001b[1m carsus.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:341)\n" | |
| ] | |
| }, | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>energy_lower</th>\n", | |
| " <th>energy_upper</th>\n", | |
| " <th>gf</th>\n", | |
| " <th>j_lower</th>\n", | |
| " <th>j_upper</th>\n", | |
| " <th>wavelength</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>level_index_lower</th>\n", | |
| " <th>level_index_upper</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">0.0</th>\n", | |
| " <th>2.0</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42824.29</td>\n", | |
| " <td>1.819701e-05</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>233.4407</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3.0</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>42932.62</td>\n", | |
| " <td>6.165950e-10</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>232.8517</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>5.0</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>55309.35</td>\n", | |
| " <td>7.943282e-03</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>180.8013</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>7.0</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>65500.47</td>\n", | |
| " <td>2.582260e-01</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>152.6707</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>8.0</th>\n", | |
| " <td>0.00</td>\n", | |
| " <td>76665.35</td>\n", | |
| " <td>3.775722e-01</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>130.4370</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"3\" valign=\"top\">105.0</th>\n", | |
| " <th>129.0</th>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>153093.60</td>\n", | |
| " <td>2.511886e+00</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>549.6507</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>130.0</th>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>153184.30</td>\n", | |
| " <td>1.258925e+00</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>546.9233</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>131.0</th>\n", | |
| " <td>134905.28</td>\n", | |
| " <td>153233.30</td>\n", | |
| " <td>1.584893e-01</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>0.5</td>\n", | |
| " <td>545.4611</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>106.0</th>\n", | |
| " <th>138.0</th>\n", | |
| " <td>135297.30</td>\n", | |
| " <td>155665.90</td>\n", | |
| " <td>5.011872e-02</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>3.5</td>\n", | |
| " <td>490.8147</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>107.0</th>\n", | |
| " <th>134.0</th>\n", | |
| " <td>135303.50</td>\n", | |
| " <td>155571.70</td>\n", | |
| " <td>2.511886e-01</td>\n", | |
| " <td>1.5</td>\n", | |
| " <td>2.5</td>\n", | |
| " <td>493.2460</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>919 rows × 6 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " energy_lower energy_upper gf \\\n", | |
| "level_index_lower level_index_upper \n", | |
| "0.0 2.0 0.00 42824.29 1.819701e-05 \n", | |
| " 3.0 0.00 42932.62 6.165950e-10 \n", | |
| " 5.0 0.00 55309.35 7.943282e-03 \n", | |
| " 7.0 0.00 65500.47 2.582260e-01 \n", | |
| " 8.0 0.00 76665.35 3.775722e-01 \n", | |
| "... ... ... ... \n", | |
| "105.0 129.0 134905.28 153093.60 2.511886e+00 \n", | |
| " 130.0 134905.28 153184.30 1.258925e+00 \n", | |
| " 131.0 134905.28 153233.30 1.584893e-01 \n", | |
| "106.0 138.0 135297.30 155665.90 5.011872e-02 \n", | |
| "107.0 134.0 135303.50 155571.70 2.511886e-01 \n", | |
| "\n", | |
| " j_lower j_upper wavelength \n", | |
| "level_index_lower level_index_upper \n", | |
| "0.0 2.0 0.5 0.5 233.4407 \n", | |
| " 3.0 0.5 1.5 232.8517 \n", | |
| " 5.0 0.5 1.5 180.8013 \n", | |
| " 7.0 0.5 0.5 152.6707 \n", | |
| " 8.0 0.5 0.5 130.4370 \n", | |
| "... ... ... ... \n", | |
| "105.0 129.0 1.5 2.5 549.6507 \n", | |
| " 130.0 1.5 1.5 546.9233 \n", | |
| " 131.0 1.5 0.5 545.4611 \n", | |
| "106.0 138.0 2.5 3.5 490.8147 \n", | |
| "107.0 134.0 1.5 2.5 493.2460 \n", | |
| "\n", | |
| "[919 rows x 6 columns]" | |
| ] | |
| }, | |
| "execution_count": 16, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "gfall_reader.lines.loc[14,1].sort_values(by=['level_index_lower','level_index_upper'])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 17, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>energy</th>\n", | |
| " <th>j</th>\n", | |
| " <th>label</th>\n", | |
| " <th>method</th>\n", | |
| " <th>priority</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>atomic_number</th>\n", | |
| " <th>ion_charge</th>\n", | |
| " <th>level_index</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"11\" valign=\"top\">14</th>\n", | |
| " <th rowspan=\"5\" valign=\"top\">0</th>\n", | |
| " <th>192</th>\n", | |
| " <td>63165.238000</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>3s2_3p(2P)8p_(1/2,1/2)e[1]</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>193</th>\n", | |
| " <td>63179.346000</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>3s2_3p(2P)8p_(1/2,3/2)e[1]</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>196</th>\n", | |
| " <td>63257.586000</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>3s2_3p_8p_3Pe[0]</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>199</th>\n", | |
| " <td>63446.059000</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>3s2_3p(2P)8p_(3/2,3/2)e[1]</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>200</th>\n", | |
| " <td>63447.654000</td>\n", | |
| " <td>3.0</td>\n", | |
| " <td>3s2_3p_8p_3De[3]</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">1</th>\n", | |
| " <th>138</th>\n", | |
| " <td>131188.819452</td>\n", | |
| " <td>675.5</td>\n", | |
| " <td>3s2_26w_2W</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>139</th>\n", | |
| " <td>131236.026570</td>\n", | |
| " <td>728.5</td>\n", | |
| " <td>3s2_27w_2W</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>140</th>\n", | |
| " <td>131278.266670</td>\n", | |
| " <td>783.5</td>\n", | |
| " <td>3s2_28w_2W</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>141</th>\n", | |
| " <td>131316.212901</td>\n", | |
| " <td>840.5</td>\n", | |
| " <td>3s2_29w_2W</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>142</th>\n", | |
| " <td>131350.428122</td>\n", | |
| " <td>899.5</td>\n", | |
| " <td>3s2_30w_2W</td>\n", | |
| " <td>theor</td>\n", | |
| " <td>10</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>225 rows × 5 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " energy j \\\n", | |
| "atomic_number ion_charge level_index \n", | |
| "14 0 192 63165.238000 1.0 \n", | |
| " 193 63179.346000 1.0 \n", | |
| " 196 63257.586000 0.0 \n", | |
| " 199 63446.059000 1.0 \n", | |
| " 200 63447.654000 3.0 \n", | |
| "... ... ... \n", | |
| " 1 138 131188.819452 675.5 \n", | |
| " 139 131236.026570 728.5 \n", | |
| " 140 131278.266670 783.5 \n", | |
| " 141 131316.212901 840.5 \n", | |
| " 142 131350.428122 899.5 \n", | |
| "\n", | |
| " label method \\\n", | |
| "atomic_number ion_charge level_index \n", | |
| "14 0 192 3s2_3p(2P)8p_(1/2,1/2)e[1] theor \n", | |
| " 193 3s2_3p(2P)8p_(1/2,3/2)e[1] theor \n", | |
| " 196 3s2_3p_8p_3Pe[0] theor \n", | |
| " 199 3s2_3p(2P)8p_(3/2,3/2)e[1] theor \n", | |
| " 200 3s2_3p_8p_3De[3] theor \n", | |
| "... ... ... \n", | |
| " 1 138 3s2_26w_2W theor \n", | |
| " 139 3s2_27w_2W theor \n", | |
| " 140 3s2_28w_2W theor \n", | |
| " 141 3s2_29w_2W theor \n", | |
| " 142 3s2_30w_2W theor \n", | |
| "\n", | |
| " priority \n", | |
| "atomic_number ion_charge level_index \n", | |
| "14 0 192 10 \n", | |
| " 193 10 \n", | |
| " 196 10 \n", | |
| " 199 10 \n", | |
| " 200 10 \n", | |
| "... ... \n", | |
| " 1 138 10 \n", | |
| " 139 10 \n", | |
| " 140 10 \n", | |
| " 141 10 \n", | |
| " 142 10 \n", | |
| "\n", | |
| "[225 rows x 5 columns]" | |
| ] | |
| }, | |
| "execution_count": 17, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "cmfgen_reader.levels.loc[ cmfgen_reader.levels['method'] == 'theor' ]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 18, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<style scoped>\n", | |
| " .dataframe tbody tr th:only-of-type {\n", | |
| " vertical-align: middle;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe tbody tr th {\n", | |
| " vertical-align: top;\n", | |
| " }\n", | |
| "\n", | |
| " .dataframe thead th {\n", | |
| " text-align: right;\n", | |
| " }\n", | |
| "</style>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th>energy_lower</th>\n", | |
| " <th>energy_upper</th>\n", | |
| " <th>gf</th>\n", | |
| " <th>j_lower</th>\n", | |
| " <th>j_upper</th>\n", | |
| " <th>wavelength</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>atomic_number</th>\n", | |
| " <th>ion_charge</th>\n", | |
| " <th>level_index_lower</th>\n", | |
| " <th>level_index_upper</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"11\" valign=\"top\">14</th>\n", | |
| " <th rowspan=\"5\" valign=\"top\">0</th>\n", | |
| " <th rowspan=\"5\" valign=\"top\">0</th>\n", | |
| " <th>7</th>\n", | |
| " <td>0.000</td>\n", | |
| " <td>39760.285000</td>\n", | |
| " <td>0.314770</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>251.4316</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>9</th>\n", | |
| " <td>0.000</td>\n", | |
| " <td>40991.884000</td>\n", | |
| " <td>0.002924</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>243.8768</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>10</th>\n", | |
| " <td>0.000</td>\n", | |
| " <td>45276.188000</td>\n", | |
| " <td>0.086298</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>220.7978</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>27</th>\n", | |
| " <td>0.000</td>\n", | |
| " <td>50566.397000</td>\n", | |
| " <td>0.050933</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>197.7598</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>31</th>\n", | |
| " <td>0.000</td>\n", | |
| " <td>53387.334000</td>\n", | |
| " <td>0.007551</td>\n", | |
| " <td>0.0</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>187.3103</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <th>...</th>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " <td>...</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th rowspan=\"5\" valign=\"top\">2</th>\n", | |
| " <th>137</th>\n", | |
| " <th>140</th>\n", | |
| " <td>258468.937</td>\n", | |
| " <td>259826.935000</td>\n", | |
| " <td>8.250000</td>\n", | |
| " <td>1.0</td>\n", | |
| " <td>2.0</td>\n", | |
| " <td>7363.7811</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>139</th>\n", | |
| " <th>141</th>\n", | |
| " <td>259647.332</td>\n", | |
| " <td>259927.712000</td>\n", | |
| " <td>17.205000</td>\n", | |
| " <td>7.0</td>\n", | |
| " <td>10.0</td>\n", | |
| " <td>35670.0000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>141</th>\n", | |
| " <th>144</th>\n", | |
| " <td>259927.712</td>\n", | |
| " <td>259944.675000</td>\n", | |
| " <td>1.249920</td>\n", | |
| " <td>10.0</td>\n", | |
| " <td>13.0</td>\n", | |
| " <td>589500.0000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>143</th>\n", | |
| " <th>146</th>\n", | |
| " <td>259943.677</td>\n", | |
| " <td>260263.134788</td>\n", | |
| " <td>2.166300</td>\n", | |
| " <td>4.0</td>\n", | |
| " <td>37.0</td>\n", | |
| " <td>31300.0000</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>144</th>\n", | |
| " <th>145</th>\n", | |
| " <td>259944.675</td>\n", | |
| " <td>260263.134688</td>\n", | |
| " <td>6.498900</td>\n", | |
| " <td>13.0</td>\n", | |
| " <td>112.0</td>\n", | |
| " <td>31400.0000</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "<p>27626 rows × 6 columns</p>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " energy_lower \\\n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 0.000 \n", | |
| " 9 0.000 \n", | |
| " 10 0.000 \n", | |
| " 27 0.000 \n", | |
| " 31 0.000 \n", | |
| "... ... \n", | |
| " 2 137 140 258468.937 \n", | |
| " 139 141 259647.332 \n", | |
| " 141 144 259927.712 \n", | |
| " 143 146 259943.677 \n", | |
| " 144 145 259944.675 \n", | |
| "\n", | |
| " energy_upper \\\n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 39760.285000 \n", | |
| " 9 40991.884000 \n", | |
| " 10 45276.188000 \n", | |
| " 27 50566.397000 \n", | |
| " 31 53387.334000 \n", | |
| "... ... \n", | |
| " 2 137 140 259826.935000 \n", | |
| " 139 141 259927.712000 \n", | |
| " 141 144 259944.675000 \n", | |
| " 143 146 260263.134788 \n", | |
| " 144 145 260263.134688 \n", | |
| "\n", | |
| " gf \\\n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 0.314770 \n", | |
| " 9 0.002924 \n", | |
| " 10 0.086298 \n", | |
| " 27 0.050933 \n", | |
| " 31 0.007551 \n", | |
| "... ... \n", | |
| " 2 137 140 8.250000 \n", | |
| " 139 141 17.205000 \n", | |
| " 141 144 1.249920 \n", | |
| " 143 146 2.166300 \n", | |
| " 144 145 6.498900 \n", | |
| "\n", | |
| " j_lower \\\n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 0.0 \n", | |
| " 9 0.0 \n", | |
| " 10 0.0 \n", | |
| " 27 0.0 \n", | |
| " 31 0.0 \n", | |
| "... ... \n", | |
| " 2 137 140 1.0 \n", | |
| " 139 141 7.0 \n", | |
| " 141 144 10.0 \n", | |
| " 143 146 4.0 \n", | |
| " 144 145 13.0 \n", | |
| "\n", | |
| " j_upper \\\n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 1.0 \n", | |
| " 9 1.0 \n", | |
| " 10 1.0 \n", | |
| " 27 1.0 \n", | |
| " 31 1.0 \n", | |
| "... ... \n", | |
| " 2 137 140 2.0 \n", | |
| " 139 141 10.0 \n", | |
| " 141 144 13.0 \n", | |
| " 143 146 37.0 \n", | |
| " 144 145 112.0 \n", | |
| "\n", | |
| " wavelength \n", | |
| "atomic_number ion_charge level_index_lower level_index_upper \n", | |
| "14 0 0 7 251.4316 \n", | |
| " 9 243.8768 \n", | |
| " 10 220.7978 \n", | |
| " 27 197.7598 \n", | |
| " 31 187.3103 \n", | |
| "... ... \n", | |
| " 2 137 140 7363.7811 \n", | |
| " 139 141 35670.0000 \n", | |
| " 141 144 589500.0000 \n", | |
| " 143 146 31300.0000 \n", | |
| " 144 145 31400.0000 \n", | |
| "\n", | |
| "[27626 rows x 6 columns]" | |
| ] | |
| }, | |
| "execution_count": 18, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "cmfgen_reader.lines" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "---\n", | |
| "## Notes\n", | |
| "\n", | |
| "Should be a good idea assert if `i-j` values in oscillator strengths table match with energy levels labels." | |
| ] | |
| } | |
| ], | |
| "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.11" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment