{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## VALD\n", "VALD is a database of atomic and molecular transitions used to create accurate synthetic spectra of many astrophysical systems. More information, as well as linelists can be downloaded from the [VALD website](http://vald.astro.uu.se/~vald/php/vald.ph).\n", "\n", "In this example, data was downloaded from the [VALD website](http://vald.astro.uu.se/) and extracted to /tmp/vald_sample_linelist.dat" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "**_NOTE:_** " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from carsus.io.vald import VALDReader" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "vald_reader = VALDReader(fname='/tmp/vald_sample_linelist.dat')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Table information is parsed to a dataframe which can be accesed via the .vald attribute. The column information is described in https://articles.adsabs.harvard.edu/pdf/1995A%26AS..112..525P and is as follows:\n", "\n", "Wavelength - either air or vacuum and in nanometers or angstroms: Wavelength of the line\n", "\n", "log_gf: Log10 of the oscillator strength times the degeneracy of the lower level\n", "\n", "e_low: Excitation energy of the lower level in ergs\n", "\n", "j_lo: Principal quantum number of the lower level\n", "\n", "e_up: Excitation energy of the upper level in ergs\n", "\n", "j_up: Principal quantum number of the upper level\n", "\n", "lande_lower: Lande factor of the lower level\n", "\n", "lande_upper: Lande factor of the upper level\n", "\n", "lande_mean: Mean lande factor\n", "\n", "rad: log10 of the radiation damping constant in $(4\\pi s)^{-1}$\n", "\n", "stark: log10 of the Stark damping constant at 10,000K in $(4\\pi s N_e)^{-1}$\n", "\n", "waals: log10 of the Van Der Waals damping constant at 10,000K in $(4\\pi s N_H)^{-1}$" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[1m carsus.io.vald.vald\u001b[0m][ \u001b[1;37mINFO\u001b[0m] - Parsing VALD from: /tmp/vald_sample_linelist.dat (\u001b[1mvald.py\u001b[0m:163)\n", "[\u001b[1m carsus.io.vald.vald\u001b[0m][ \u001b[1;37mINFO\u001b[0m] - Found wavelength column header: WL_air(A) (\u001b[1mvald.py\u001b[0m:181)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
elm_ionWL_air(A)log_gfe_lowj_loe_upj_uplande_lowerlande_upperlande_meanradstarkwaals
0'TiO 1'4100.0002-11.4720.201131.03.224232.099.099.099.06.9620.00.0
1'TiO 1'4100.0003-4.0370.743916.03.767015.099.099.099.07.2640.00.0
2'TiO 1'4100.0005-10.1880.624488.03.647587.099.099.099.06.9110.00.0
3'TiO 1'4100.0005-9.9150.060130.03.083231.099.099.099.04.8300.00.0
4'TiO 1'4100.0008-0.3141.8211139.04.8443139.099.099.099.07.8740.00.0
..........................................
46858'TiO 1'4109.9989-2.3192.1318161.05.1476161.099.099.099.07.9200.00.0
46859'TiO 1'4109.9991-2.2760.377344.03.393143.099.099.099.07.2960.00.0
46860'TiO 1'4109.9995-2.4982.6005135.05.6163134.099.099.099.07.4220.00.0
46861'TiO 1'4110.0000-6.4290.618875.03.634676.099.099.099.07.4590.00.0
46862'TiO 1'4110.0000-5.6380.454456.03.470255.099.099.099.07.2890.00.0
\n", "

46863 rows × 13 columns

\n", "
" ], "text/plain": [ " elm_ion WL_air(A) log_gf e_low j_lo e_up j_up lande_lower \\\n", "0 'TiO 1' 4100.0002 -11.472 0.2011 31.0 3.2242 32.0 99.0 \n", "1 'TiO 1' 4100.0003 -4.037 0.7439 16.0 3.7670 15.0 99.0 \n", "2 'TiO 1' 4100.0005 -10.188 0.6244 88.0 3.6475 87.0 99.0 \n", "3 'TiO 1' 4100.0005 -9.915 0.0601 30.0 3.0832 31.0 99.0 \n", "4 'TiO 1' 4100.0008 -0.314 1.8211 139.0 4.8443 139.0 99.0 \n", "... ... ... ... ... ... ... ... ... \n", "46858 'TiO 1' 4109.9989 -2.319 2.1318 161.0 5.1476 161.0 99.0 \n", "46859 'TiO 1' 4109.9991 -2.276 0.3773 44.0 3.3931 43.0 99.0 \n", "46860 'TiO 1' 4109.9995 -2.498 2.6005 135.0 5.6163 134.0 99.0 \n", "46861 'TiO 1' 4110.0000 -6.429 0.6188 75.0 3.6346 76.0 99.0 \n", "46862 'TiO 1' 4110.0000 -5.638 0.4544 56.0 3.4702 55.0 99.0 \n", "\n", " lande_upper lande_mean rad stark waals \n", "0 99.0 99.0 6.962 0.0 0.0 \n", "1 99.0 99.0 7.264 0.0 0.0 \n", "2 99.0 99.0 6.911 0.0 0.0 \n", "3 99.0 99.0 4.830 0.0 0.0 \n", "4 99.0 99.0 7.874 0.0 0.0 \n", "... ... ... ... ... ... \n", "46858 99.0 99.0 7.920 0.0 0.0 \n", "46859 99.0 99.0 7.296 0.0 0.0 \n", "46860 99.0 99.0 7.422 0.0 0.0 \n", "46861 99.0 99.0 7.459 0.0 0.0 \n", "46862 99.0 99.0 7.289 0.0 0.0 \n", "\n", "[46863 rows x 13 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vald_reader.vald_raw" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The reader parses the raw data and splits it into two linelist dataframes, either atomic or molecular. \n", "\n", "Linelists only carry along the specific relevant information necessary to compute opacities. They can be accesed with the .linelist_atoms or .linelist_molecules attributes.\n", "\n", "Note that the wavelengths here are reformated to Angstroms and in vacuum wavelengths." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[\u001b[1m py.warnings\u001b[0m][\u001b[1;33mWARNING\u001b[0m] - /home/shield90/miniconda3/envs/carsus/lib/python3.7/site-packages/pandas/core/indexing.py:845: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " self.obj[key] = _infer_fill_value(value)\n", " (\u001b[1mwarnings.py\u001b[0m:110)\n", "[\u001b[1m py.warnings\u001b[0m][\u001b[1;33mWARNING\u001b[0m] - /home/shield90/miniconda3/envs/carsus/lib/python3.7/site-packages/pandas/core/indexing.py:966: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " self.obj[item] = s\n", " (\u001b[1mwarnings.py\u001b[0m:110)\n", "[\u001b[1m py.warnings\u001b[0m][\u001b[1;33mWARNING\u001b[0m] - /home/shield90/miniconda3/envs/carsus/lib/python3.7/site-packages/pandas/core/frame.py:4133: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " errors=errors,\n", " (\u001b[1mwarnings.py\u001b[0m:110)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
atomic_numberion_chargewavelengthlog_gfe_lowe_upj_loj_upradstarkwaals
02514101.162586-1.1698.129311.15242.03.08.70-6.47-7.860
12614101.200426-5.99210.467313.49041.52.58.94-5.86-7.630
22224101.201266-0.44016.827319.85042.01.09.48-5.99-7.710
3214101.205217-0.72551.016854.03993.54.510.000.000.000
42624101.206318-7.28715.237518.26062.01.09.47-6.35-7.850
....................................
9902404111.108321-5.4283.84706.86282.03.08.10-6.16-7.750
991704111.108811-1.22710.690013.70581.52.50.000.00-7.419
9922004111.113052-2.6714.62447.64022.01.07.47-2.75-6.710
9932914111.127586-4.84813.936016.95185.05.08.44-5.18-7.500
9942404111.141449-3.4414.53517.55094.03.07.61-4.43-7.320
\n", "

995 rows × 11 columns

\n", "
" ], "text/plain": [ " atomic_number ion_charge wavelength log_gf e_low e_up j_lo \\\n", "0 25 1 4101.162586 -1.169 8.1293 11.1524 2.0 \n", "1 26 1 4101.200426 -5.992 10.4673 13.4904 1.5 \n", "2 22 2 4101.201266 -0.440 16.8273 19.8504 2.0 \n", "3 2 1 4101.205217 -0.725 51.0168 54.0399 3.5 \n", "4 26 2 4101.206318 -7.287 15.2375 18.2606 2.0 \n", ".. ... ... ... ... ... ... ... \n", "990 24 0 4111.108321 -5.428 3.8470 6.8628 2.0 \n", "991 7 0 4111.108811 -1.227 10.6900 13.7058 1.5 \n", "992 20 0 4111.113052 -2.671 4.6244 7.6402 2.0 \n", "993 29 1 4111.127586 -4.848 13.9360 16.9518 5.0 \n", "994 24 0 4111.141449 -3.441 4.5351 7.5509 4.0 \n", "\n", " j_up rad stark waals \n", "0 3.0 8.70 -6.47 -7.860 \n", "1 2.5 8.94 -5.86 -7.630 \n", "2 1.0 9.48 -5.99 -7.710 \n", "3 4.5 10.00 0.00 0.000 \n", "4 1.0 9.47 -6.35 -7.850 \n", ".. ... ... ... ... \n", "990 3.0 8.10 -6.16 -7.750 \n", "991 2.5 0.00 0.00 -7.419 \n", "992 1.0 7.47 -2.75 -6.710 \n", "993 5.0 8.44 -5.18 -7.500 \n", "994 3.0 7.61 -4.43 -7.320 \n", "\n", "[995 rows x 11 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vald_reader.linelist_atoms" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
moleculeion_chargewavelengthlog_gfe_lowe_upj_loj_upradstarkwaals
0TiO04101.157405-11.4720.20113.224231.032.06.9620.00.0
1TiO04101.157505-4.0370.74393.767016.015.07.2640.00.0
2TiO04101.157705-10.1880.62443.647588.087.06.9110.00.0
3TiO04101.157705-9.9150.06013.083230.031.04.8300.00.0
4TiO04101.158005-0.3141.82114.8443139.0139.07.8740.00.0
....................................
46858TiO04111.158724-2.3192.13185.1476161.0161.07.9200.00.0
46859TiO04111.158924-2.2760.37733.393144.043.07.2960.00.0
46860TiO04111.159324-2.4982.60055.6163135.0134.07.4220.00.0
46861TiO04111.159824-6.4290.61883.634675.076.07.4590.00.0
46862TiO04111.159824-5.6380.45443.470256.055.07.2890.00.0
\n", "

45868 rows × 11 columns

\n", "
" ], "text/plain": [ " molecule ion_charge wavelength log_gf e_low e_up j_lo j_up \\\n", "0 TiO 0 4101.157405 -11.472 0.2011 3.2242 31.0 32.0 \n", "1 TiO 0 4101.157505 -4.037 0.7439 3.7670 16.0 15.0 \n", "2 TiO 0 4101.157705 -10.188 0.6244 3.6475 88.0 87.0 \n", "3 TiO 0 4101.157705 -9.915 0.0601 3.0832 30.0 31.0 \n", "4 TiO 0 4101.158005 -0.314 1.8211 4.8443 139.0 139.0 \n", "... ... ... ... ... ... ... ... ... \n", "46858 TiO 0 4111.158724 -2.319 2.1318 5.1476 161.0 161.0 \n", "46859 TiO 0 4111.158924 -2.276 0.3773 3.3931 44.0 43.0 \n", "46860 TiO 0 4111.159324 -2.498 2.6005 5.6163 135.0 134.0 \n", "46861 TiO 0 4111.159824 -6.429 0.6188 3.6346 75.0 76.0 \n", "46862 TiO 0 4111.159824 -5.638 0.4544 3.4702 56.0 55.0 \n", "\n", " rad stark waals \n", "0 6.962 0.0 0.0 \n", "1 7.264 0.0 0.0 \n", "2 6.911 0.0 0.0 \n", "3 4.830 0.0 0.0 \n", "4 7.874 0.0 0.0 \n", "... ... ... ... \n", "46858 7.920 0.0 0.0 \n", "46859 7.296 0.0 0.0 \n", "46860 7.422 0.0 0.0 \n", "46861 7.459 0.0 0.0 \n", "46862 7.289 0.0 0.0 \n", "\n", "[45868 rows x 11 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "vald_reader.linelist_molecules" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "carsus", "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.7.16" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }