tardis.io.config_reader module

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

Bases: tardis.io.util.HDFWriterMixin

Overrides HDFWriterMixin to obtain HDF properties from configuration keys

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

Bases: tardis.io.config_reader.ConfigurationNameSpace, tardis.io.config_reader.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'
exception tardis.io.config_reader.ConfigurationError[source]

Bases: ValueError

class tardis.io.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.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.config_reader.parse_convergence_section(convergence_section_dict)[source]

Parse the convergence section dictionary

Parameters
convergence_section_dictdict

dictionary

tardis.io.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