Skip to content

Commit

Permalink
Merge 3235867 into 52534dc
Browse files Browse the repository at this point in the history
  • Loading branch information
wkerzendorf committed May 24, 2014
2 parents 52534dc + 3235867 commit dc2480a
Show file tree
Hide file tree
Showing 22 changed files with 817 additions and 681 deletions.
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
## get's rid of many toctree contains errors: see https://github.com/phn/pytpm/issues/3#issuecomment-12133978
numpydoc_show_class_members = False
extensions += ['matplotlib.sphinxext.plot_directive',
'sphinxcontrib.bibtex',
'sphinxcontrib.tikz']
'sphinxcontrib.bibtex']



Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
***********************
Configuration Validator
***********************

Default Configuration Parser
============================

The default config parser takes a user configuration and a default configuration and creates a consistent and valid configuration for tardis based on the constraints given in the default configuration. Both input data are normally given as a yaml dictionary with a consistent hierarchical structure i.e. for every item in the user configuration there has to be a declaration in the default configuration at the same hierarchical level. This declaration can be either an unspecific empty level declaration like:
The default config validator takes a user configuration and a default configuration and creates a consistent and valid configuration for tardis based on the constraints given in the default configuration. Both input data are normally given as a yaml dictionary with a consistent hierarchical structure i.e. for every item in the user configuration there has to be a declaration in the default configuration at the same hierarchical level. This declaration can be either an unspecific empty level declaration like:
- Main_level:
- Second_level:
- Third_level:
Or a declaration of a configuration item like:
or a declaration of a configuration item like:
- item:
- property_type: int
- default: 1
Expand All @@ -24,10 +24,12 @@ Quantity_range: Like property type range but with quantities as start and stop.
Additionally to the four standard keywords the types integer, float, and quantity can have the keywords allowed_value and allowed_type. allowed_value specifies the allowed values in a list, whereas allowed_type specifies a range of allowed values like “x>10”.

Container
---------
^^^^^^^^^

For more complex configurations with dependencies, you can use the containers which allow branching in the configuration. A container is declared in the default configuration file by setting the property_type to container property and specifying the properties of the container with keyword type. The property_type of this section is container-declaration which allows you to specify the possible container items with the keyword container. For every specified container item, the code expects the declaration of all sub items. The keywords for this are “_“ + “name of the container item”.
If the type declaration for this container is finished you can specify all container items like normal items. Here is an example for a container configuration with two branches

..source: yaml
- container_example:
- property_type: container-property
- type:
Expand Down Expand Up @@ -62,10 +64,12 @@ If the type declaration for this container is finished you can specify all conta
- help: Like property type range but with quantities as start and stop. The consistency of the units is checked.

How to use
----------
^^^^^^^^^^

To use the default parser create a new config object form the class Config by either from a dictionaries or from yaml files.
- My_config = Config(default configuration dictionary, user configuration dictionary)
To use the default parser create a new config object form the class Config by either from a dictionaries or from yaml files::

My_config = Config(default configuration dictionary, user configuration dictionary)

or
- My_config = Config.from_yaml(default configuration file, user configuration file)
To access the configuration for tardis use the method get_config
Expand Down
6 changes: 6 additions & 0 deletions docs/configuration/configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
******************
Configuration File
******************

.. literalinclude:: ../../tardis/data/tardis_config_definition.yml
:language: yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ parameter ``lum_density`` which sets the distance to :math:`\sqrt{\frac{1}{4 \pi
Config Reader
^^^^^^^^^^^^^

The YAML file is read by using a classmethod of the :meth:`~tardis.config_reader.TARDISConfiguration.from_yaml`.
The YAML file is read by using a classmethod of the :meth:`~tardis.config_reader.Configuration.from_yaml`.



Expand Down
16 changes: 16 additions & 0 deletions docs/configuration/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
********************
TARDIS Configuration
********************

Most of the configuration for TARDIS uses the YAML format. If a YAML file is
handed to TARDIS it is first checked using a configuration validator to
see if the required keywords of the required type exist and produces a dictionary
with that has the validated types as well as sensible defaults for missing values
built-in. This validator uses a default validation file that already explains
a lot about the required configuration items.

.. toctree::
:maxdepth: 1

configuration
config_validator
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rapid spectral modelling of supernovae. The code is described in this documentat
installation
running
uses
configuration/index
examples/examples
testing
atomic/atomic_data
Expand Down
2 changes: 1 addition & 1 deletion docs/physics/physical_quantities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and then run your calculation, which is based on your "my_config.yml" file
import logging
import warnings
tardis_config = config_reader.TARDISConfiguration.from_yaml("my_config.yml")
tardis_config = config_reader.Configuration.from_yaml("my_config.yml")
radial1d = model.Radial1DModel(tardis_config)
simulation.run_radial1d(radial1d)
Expand Down
4 changes: 0 additions & 4 deletions docs/physics/plasma.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ description of the BasePlasma (for details see :ref:`nebular_plasma`).
All plasma calculations follow the same basic procedure in calculating the plasma state.
This is always accomplished with the function ``update_radiationfield``. This block diagram shows the basic procedure

.. blockdiag::

blockdiag update_radfield{
calculate_partition_functions -> "calculate ge" -> calculate_saha -> "iterate over calculate_ionization_balance" -> calculate_level_populations;
}

Base Plasma
-----------
Expand Down
2 changes: 1 addition & 1 deletion docs/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Scripting TARDIS
from tardis import model, simulation
from tardis.io import config_reader
tardis_config = config_reader.TARDISConfiguration.from_yaml('myconfig.yml')
tardis_config = config_reader.Configuration.from_yaml('myconfig.yml')
radial1d_mdl = model.Radial1DModel(tardis_config)
simulation.run_radial1d(radial1d_mdl)
Expand Down
2 changes: 1 addition & 1 deletion scripts/tardis
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if args.packet_log_file:
console_handler.setFormatter(packet_logging_formatter)
logger.addHandler(packet_logging_handler)

tardis_config = config_reader.TARDISConfiguration.from_yaml(args.config_fname)
tardis_config = config_reader.Configuration.from_yaml(args.config_fname)

radial1d_mdl = model.Radial1DModel(tardis_config)

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ upload-dir = docs/_build/html
show-response = 1

[pytest]
doctest_plus=disabled
doctest_rst=disabled
minversion = 2.2
norecursedirs = build docs/_build
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ supernova:
default: None
help: distance to supernova


luminosity_wavelength_start:
property_type: quantity
mandatory: False
default: 0 angstrom
help: start of the integral needed for getting the luminosity right


luminosity_wavelength_end:
property_type: quantity
mandatory: False
default: inf angstrom
help: start of the integral needed for getting the luminosity right

atom_data:
property_type: string
Expand Down Expand Up @@ -116,71 +127,99 @@ plasma:

model:
structure:
property_type : container-property
type:
property_type: container-declaration
containers: ['file', 'specific']
_file: ['filename','filetype']
+file: ['v_inner_boundary','v_outer_boundary']
_specific: ['specific-property']


filename:
property_type: string
default: None
mandatory: True
help: file name (with path) to structure model
property_type : container-property
type:
property_type: container-declaration
containers: ['file', 'specific']
_file: ['filename','filetype']
+file: ['v_inner_boundary','v_outer_boundary']
_specific: ['velocity', 'density']

filetype:
property_type: string
default: None
mandatory: True
help: file type
#### there are only a handful of types available how do we validate that ####


filename:
property_type: string
default: None
mandatory: True
help: file name (with path) to structure model

filetype:
property_type: string
default: None
allowed_value: ['simple_ascii', 'artis']
mandatory: True
help: file type

v_inner_boundary:
property_type: quantity
default: 0 km/s
mandatory: False
help: location of the inner boundary chosen from the model

v_outer_boundary:
property_type: quantity
default: inf km/s
mandatory: False
help: location of the inner boundary chosen from the model


velocity:
property_type: quantity_range_sampled
default: None
mandatory: True
help: description of the boundaries of the shells

density:
property_type: container-property
type:
property_type: container-declaration
containers: ['branch85_w7','exponential','power_law']
_branch85_w7: []
+branch85_w7: ['w7_time_0', 'w7_rho_0', 'w7_v_0']
_power_law: ['time_0', 'rho_0', 'v_0', 'exponent']
_exponential: ['time_0', 'rho_0', 'v_0']

w7_time_0:
property_type: quantity
default: 0.000231481 day
mandatory: False
help: This needs no change - DO NOT TOUCH

w7_rho_0:
property_type: quantity
default: 29.37505157 g/cm^3
mandatory: False
help: This needs no change - DO NOT TOUCH

w7_v_0:
property_type: quantity
default: 1e4 km/s
mandatory: False
help: This needs no change - DO NOT TOUCH

time_0:
property_type: quantity
default: None
mandatory: True
help: Time at which the pure model densities are right

rho_0:
property_type: quantity
default: None
mandatory: True
help: density at time_0

v_0:
property_type: quantity
default: None
mandatory: True
help: at what velocity the density rho_0 applies

exponent:
property_type: float
default: None
mandatory: True
help: exponent for exponential density profile

v_inner_boundary:
property_type: quantity
default: 0 km/s
mandatory: False
help: location of the inner boundary chosen from the model

v_outer_boundary:
property_type: quantity
default: inf km/s
mandatory: False
help: location of the inner boundary chosen from the model

specific_property:
velocity:
property_type: quantity_range
default: None
mandatory: True
help: location of boundaries in the velocity field. There will be n-1 cells as this specifis both the inner and outer velocity components


density:
property_type: container-property
type:
property_type: container-declaration
containers: ['branch85_w7']

_branch85_w7: ['branch85_w7-property'] # list

branch85_w7-property:
time_0:
property_type: quantity
default: 19.9999584 s
mandatory: False
help: This needs no change - DO NOT TOUCH

density_coefficient:
property_type: float
default: 3e29
mandatory: False
help: This needs no change - DO NOT TOUCH

abundances:
property_type: container-property
type:
Expand Down Expand Up @@ -228,7 +267,7 @@ montecarlo:

black_body_sampling:
property_type: quantity_range_sampled
default: [1 angstrom, 1e6 angstrom, 1e6 angstrom]
default: [1 angstrom, 1e6 angstrom, 1000000]
mandatory: False
help: Sampling of the black-body for energy packet creation (giving maximum and minimum packet frequency)

Expand Down Expand Up @@ -262,8 +301,8 @@ montecarlo:
type:
property_type: container-declaration
containers: ['damped', 'specific']
_damped: ['damping_constant']
+damped: ['t_inner', 't_rad', 'w']
_damped: []
+damped: ['damping_constant', 't_inner', 't_rad', 'w']
_specific: ['damping_constant', 'threshold', 'fraction', 'hold-iterations']
+specific: ['t_inner', 't_rad', 'w']

Expand Down
Loading

0 comments on commit dc2480a

Please sign in to comment.