-
-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Model Reader for CMFGen example (Also refactored Stella R…
…eader) (#2349) * CMFGenReader. Also refactored Stella Reader * Modify DATA_START_ROW * reformat using black * add comment about the +1 hardcoded * Test cmfgen reader * Reformat using black --------- Co-authored-by: Atharva Arya <[email protected]>
- Loading branch information
1 parent
9a13622
commit 1718002
Showing
9 changed files
with
909 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../tardis/io/tests/data/cmfgen_model.csv |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,337 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Reading CMFGEN models with TARDIS" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"Iterations: 0/? [00:00<?, ?it/s]" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"Packets: 0/? [00:00<?, ?it/s]" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"from tardis.io.model import read_cmfgen_model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cmfgen_model = read_cmfgen_model('cmfgen_model.csv')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"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>velocity</th>\n", | ||
" <th>temperature</th>\n", | ||
" <th>densities</th>\n", | ||
" <th>electron_densities</th>\n", | ||
" <th>c</th>\n", | ||
" <th>o</th>\n", | ||
" <th>mg</th>\n", | ||
" <th>si</th>\n", | ||
" <th>ni56</th>\n", | ||
" <th>ni58</th>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>0</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", | ||
" <th></th>\n", | ||
" <th></th>\n", | ||
" </tr>\n", | ||
" </thead>\n", | ||
" <tbody>\n", | ||
" <tr>\n", | ||
" <th>0</th>\n", | ||
" <td>871.66905</td>\n", | ||
" <td>76395.577</td>\n", | ||
" <td>4.253719e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.6</td>\n", | ||
" <td>0.4</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>1</th>\n", | ||
" <td>877.44269</td>\n", | ||
" <td>76395.577</td>\n", | ||
" <td>4.253719e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.1</td>\n", | ||
" <td>0.5</td>\n", | ||
" <td>0.4</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>2</th>\n", | ||
" <td>894.99407</td>\n", | ||
" <td>76395.631</td>\n", | ||
" <td>4.253719e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.3</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.7</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>3</th>\n", | ||
" <td>931.15710</td>\n", | ||
" <td>76396.057</td>\n", | ||
" <td>4.253719e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.2</td>\n", | ||
" <td>0.8</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>4</th>\n", | ||
" <td>990.30752</td>\n", | ||
" <td>76399.042</td>\n", | ||
" <td>4.253727e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.3</td>\n", | ||
" <td>0.7</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>5</th>\n", | ||
" <td>1050.86760</td>\n", | ||
" <td>76411.983</td>\n", | ||
" <td>4.253954e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.2</td>\n", | ||
" <td>0.8</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>6</th>\n", | ||
" <td>1115.15450</td>\n", | ||
" <td>76459.592</td>\n", | ||
" <td>4.256360e-09</td>\n", | ||
" <td>2.600000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.2</td>\n", | ||
" <td>0.8</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>7</th>\n", | ||
" <td>1183.37410</td>\n", | ||
" <td>76633.367</td>\n", | ||
" <td>4.268308e-09</td>\n", | ||
" <td>2.610000e+14</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.2</td>\n", | ||
" <td>0.8</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>8</th>\n", | ||
" <td>1255.76700</td>\n", | ||
" <td>77312.120</td>\n", | ||
" <td>4.290997e-09</td>\n", | ||
" <td>2.640000e+14</td>\n", | ||
" <td>0.5</td>\n", | ||
" <td>0.5</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" <tr>\n", | ||
" <th>9</th>\n", | ||
" <td>1332.58860</td>\n", | ||
" <td>79602.375</td>\n", | ||
" <td>4.339684e-09</td>\n", | ||
" <td>2.720000e+14</td>\n", | ||
" <td>0.5</td>\n", | ||
" <td>0.5</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" <td>0.0</td>\n", | ||
" </tr>\n", | ||
" </tbody>\n", | ||
"</table>\n", | ||
"</div>" | ||
], | ||
"text/plain": [ | ||
" velocity temperature densities electron_densities c o mg \\\n", | ||
"0 \n", | ||
"0 871.66905 76395.577 4.253719e-09 2.600000e+14 0.0 0.0 0.0 \n", | ||
"1 877.44269 76395.577 4.253719e-09 2.600000e+14 0.0 0.0 0.0 \n", | ||
"2 894.99407 76395.631 4.253719e-09 2.600000e+14 0.0 0.0 0.0 \n", | ||
"3 931.15710 76396.057 4.253719e-09 2.600000e+14 0.0 0.2 0.8 \n", | ||
"4 990.30752 76399.042 4.253727e-09 2.600000e+14 0.0 0.3 0.7 \n", | ||
"5 1050.86760 76411.983 4.253954e-09 2.600000e+14 0.0 0.2 0.8 \n", | ||
"6 1115.15450 76459.592 4.256360e-09 2.600000e+14 0.0 0.2 0.8 \n", | ||
"7 1183.37410 76633.367 4.268308e-09 2.610000e+14 0.0 0.2 0.8 \n", | ||
"8 1255.76700 77312.120 4.290997e-09 2.640000e+14 0.5 0.5 0.0 \n", | ||
"9 1332.58860 79602.375 4.339684e-09 2.720000e+14 0.5 0.5 0.0 \n", | ||
"\n", | ||
" si ni56 ni58 \n", | ||
"0 \n", | ||
"0 0.6 0.4 0.0 \n", | ||
"1 0.1 0.5 0.4 \n", | ||
"2 0.3 0.0 0.7 \n", | ||
"3 0.0 0.0 0.0 \n", | ||
"4 0.0 0.0 0.0 \n", | ||
"5 0.0 0.0 0.0 \n", | ||
"6 0.0 0.0 0.0 \n", | ||
"7 0.0 0.0 0.0 \n", | ||
"8 0.0 0.0 0.0 \n", | ||
"9 0.0 0.0 0.0 " | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"cmfgen_model.data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'t0': <Quantity 0.976 d>,\n", | ||
" 'velocity_unit': Unit(\"km / s\"),\n", | ||
" 'temperature_unit': Unit(\"K\"),\n", | ||
" 'densities_unit': Unit(\"g / cm3\"),\n", | ||
" 'electron_densities_unit': Unit(\"1 / cm3\")}" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"cmfgen_model.metadata" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.8.16" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.