tardis.io.configuration.config_reader module

class tardis.io.configuration.config_reader.ConfigWriterMixin(*args, **kwargs)[source]

Bases: HDFWriterMixin

Overrides HDFWriterMixin to obtain HDF properties from configuration keys

get_properties()[source]
class tardis.io.configuration.config_reader.Configuration(config_dict)[source]

Bases: ConfigurationNameSpace, ConfigWriterMixin

Tardis configuration class

classmethod from_config_dict(config_dict, validate=True, config_dirname='')[source]

Validating and subsequently parsing a config file.

Parameters:
config_dictdict

dictionary of a raw unvalidated config file

validatebool

Turn validation on or off.

Returns:
tardis.config_reader.Configuration
classmethod from_yaml(fname, *args, **kwargs)[source]

Read a configuration from a YAML file

Parameters:
fnamestr

filename or path

hdf_name = 'simulation'
static parse_convergence_section(convergence_section_dict)[source]

Parse the convergence section dictionary

Parameters:
convergence_section_dictdict

dictionary

static validate_model_section(model_section)[source]

Parse the model section dictionary

Parameters:
model_sectiondict
static validate_montecarlo_section(montecarlo_section)[source]

Validate the montecarlo section dictionary

Parameters:
montecarlo_sectiondict
static validate_spectrum_section(spectrum_section, enable_full_relativity=False)[source]

Validate the spectrum section dictionary

Parameters:
spectrum_sectiondict
exception tardis.io.configuration.config_reader.ConfigurationError[source]

Bases: ValueError

class tardis.io.configuration.config_reader.ConfigurationNameSpace(value=None)[source]

Bases: dict

The configuration name space class allows to wrap a dictionary and adds utility functions for easy access. Accesses like a.b.c are then possible

Code from http://goo.gl/KIaq8I

Parameters:
config_dictdict

configuration dictionary

Returns:
config_nsConfigurationNameSpace
deepcopy()[source]
classmethod from_config_dict(config_dict)[source]

Validating a config file.

Parameters:
config_dictdict

dictionary of a raw unvalidated config file

Returns:
tardis.config_reader.Configuration
classmethod from_yaml(fname)[source]

Read a configuration from a YAML file

Parameters:
fnamestr

filename or path

get_config_item(config_item_string)[source]

Get configuration items using a string of type ‘a.b.param’

Parameters:
config_item_stringstr

string of shape ‘section1.sectionb.param1’

set_config_item(config_item_string, value)[source]

set configuration items using a string of type ‘a.b.param’

Parameters:
config_item_stringstr

string of shape ‘section1.sectionb.param1’

value

value to set the parameter with it

tardis.io.configuration.config_reader.cns_representer(dumper, data)[source]

Represents Configuration as dict

Parameters:
dumper

YAML dumper object

data

ConfigurationNameSpace object

Returns:
yaml dumper representation of Configuration as dict
tardis.io.configuration.config_reader.quantity_representer(dumper, data)[source]

Represents Astropy Quantity as str

Parameters:
dumper

YAML dumper object

data

ConfigurationNameSpace object

Returns:
yaml dumper representation of Quantity as string