Skip to content

Commit

Permalink
Making Changes to Several Tutorials (#1763)
Browse files Browse the repository at this point in the history
* changing hdf notebooks

* formatting physical_quantities.ipynb

* updating atom data error message

* formatting read_configuration notebook

* deleting duplicate notebook

* actually deleting duplicate notebook

* fixing visualization notebooks that require hdf

* shrinking hdf

* clearning notebook outputs

* removing some sdec examples

* small changes in many tutorials

* redoing callback example and adding note to quickstart

* a few changes to stella_to_tardis

* adding atomic data to grid tutorial

* clearing output in stella_to_tardis

* adding missing import statement

* fixing typos

* changing hdf so that Ar shows in real SDEC plot
  • Loading branch information
isaacgsmith authored Sep 17, 2021
1 parent 6a0b8db commit b579fc1
Show file tree
Hide file tree
Showing 19 changed files with 748 additions and 1,109,475 deletions.
1,869 changes: 55 additions & 1,814 deletions docs/io/configuration/components/models/converters/stella_to_tardis.ipynb

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Inner Boundary

The first velocity-density pair in a custom density file (given by index 0) specifies the velocity of the inner boundary approximation. The density associated with this velocity is the density within the inner boundary, which does not affect TARDIS spectra. Therefore, the first density (5.4869692e-10 in the example above) can be replaced by a placeholder value. The user can choose to both specify a custom density file AND specify v_inner_boundary or v_outer_boundary in the configuration YAML file for a TARDIS run. However, the YAML-specified values must be within the velocity range specified in the custom density file, otherwise TARDIS will raise an error. When one of the YAML-specified boundary velocities falls within the velocity range specified in the custom density file, then the boundary velocity is set equal to the number in the configuration YAML file. This has the effect of splitting a cell in the custom density file into two parts, a region within the boundary and a region outside the boundary.

.. toctree::

Custom_Density_And_Boundary_Velocities.ipynb

It is always a good idea to check the model velocities and abundances used in a TARDIS simulation after it has been successfully run.

.. warning::
Expand Down
181 changes: 127 additions & 54 deletions docs/io/configuration/read_configuration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,188 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Reading the Configuration Files ###"
]
"# Reading a Configuration\n",
"\n",
"This notebook demonstrates how TARDIS reads a configuration file or a configuration dictionary and creates an instance of the `Configuration` class."
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"source": [
"from tardis.io.config_reader import Configuration"
],
"outputs": [],
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-18T16:56:52.848130Z",
"start_time": "2018-07-18T16:56:52.844292Z"
}
},
"outputs": [],
"source": [
"from tardis.io.config_reader import Configuration"
]
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The configuration can be read this way. It will be validated by the json-schema schemas (including filling out default configuration options that had not been specified)."
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"source": [
"conf = Configuration.from_yaml('tardis_example.yml')"
],
"outputs": [],
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-18T16:59:08.589550Z",
"start_time": "2018-07-18T16:59:08.305384Z"
}
},
"outputs": [],
"source": [
"conf = Configuration.from_yaml('tardis_example.yml')"
]
}
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Despite the very simple nature of tardis_example.yml, the output does contain all the default values"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"source": [
"conf"
],
"outputs": [],
"metadata": {
"ExecuteTime": {
"end_time": "2018-07-18T17:02:54.736144Z",
"start_time": "2018-07-18T17:02:54.729478Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'disable_electron_scattering': False,\n",
" 'excitation': 'lte',\n",
" 'heating_rate_data_file': 'none',\n",
" 'helium_treatment': 'none',\n",
" 'initial_t_inner': <Quantity -1.0 K>,\n",
" 'initial_t_rad': <Quantity -1.0 K>,\n",
" 'ionization': 'lte',\n",
" 'line_interaction_type': 'macroatom',\n",
" 'nlte': {'classical_nebular': False,\n",
" 'coronal_approximation': False,\n",
" 'species': []},\n",
" 'radiative_rates_type': 'dilute-blackbody',\n",
" 'w_epsilon': 1e-10}"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
}
},
{
"cell_type": "markdown",
"source": [
"Values can either be accessed using `.`:"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"conf.model.structure.velocity.start"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"or by treating the configuration as a dictionary:"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"conf['montecarlo']['convergence_strategy']['damping_constant']"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"You can also read a configuration from a dictionary. For example:"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"conf.plasma"
]
"from astropy import units as u\n",
"\n",
"conf_dict = {'tardis_config_version': 'v1.0',\n",
" 'supernova': {'luminosity_requested': 1.05e+43 * u.erg / u.s,\n",
" 'time_explosion': 13 * u.day},\n",
" 'atom_data': 'kurucz_cd23_chianti_H_He.h5',\n",
" 'model': {'structure': {'type': 'specific',\n",
" 'velocity': {'start': 11000. * u.km / u.s,\n",
" 'stop': 20000. * u.km / u.s,\n",
" 'num': 20},\n",
" 'density': {'type': 'branch85_w7'}},\n",
" 'abundances': {'type': 'uniform',\n",
" 'O': 0.19,\n",
" 'Mg': 0.03,\n",
" 'Si': 0.52,\n",
" 'S': 0.19,\n",
" 'Ar': 0.04,\n",
" 'Ca': 0.03}},\n",
" 'plasma': {'ionization': 'lte',\n",
" 'excitation': 'lte',\n",
" 'radiative_rates_type': 'dilute-blackbody',\n",
" 'line_interaction_type': 'macroatom',},\n",
" 'montecarlo': {'seed': 23111963,\n",
" 'no_of_packets': 40000.0,\n",
" 'iterations': 20,\n",
" 'last_no_of_packets': 100000.0,\n",
" 'no_of_virtual_packets': 10,},\n",
" 'spectrum': {'start': 500. * u.Angstrom,\n",
" 'stop': 20000. * u.Angstrom,\n",
" 'num': 10000,}}"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"source": [
"conf2 = Configuration.from_config_dict(conf_dict)\n",
"conf2"
],
"outputs": [],
"source": []
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"Notice that the `Configuration` object once again has all the default values filled in.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"\n",
"Note\n",
"\n",
"In most cases, we strongly recommend using a configuration file as opposed to a configuration dictionary.\n",
"</div>"
],
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
"pygments_lexer": "ipython3",
"version": "3.7.10"
},
"toc": {
"nav_menu": {},
Expand All @@ -125,4 +198,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
Loading

0 comments on commit b579fc1

Please sign in to comment.