Module: configuration#
- class kbmod.configuration.SearchConfiguration(data=None)[source]#
This class stores a collection of configuration parameter settings.
- Parameters:
- datadict
A dictionary of initial values.
Methods
copy
()Create a new deep copy of the configuration.
from_dict
(d)Sets multiple values from a dictionary.
from_hdu
(hdu)Load a configuration from a FITS extension file.
from_table
(t)Sets multiple values from an astropy Table with a single row and one column for each parameter.
from_yaml
(config)Load a configuration from a YAML file.
set
(param, value[, warn_on_unknown])Sets the value of a specific parameter.
set_multiple
(overrides)Sets multiple parameters from a dictionary.
to_file
(filename[, overwrite])Save a configuration file with the parameters.
to_hdu
()Create a fits HDU with all the configuration parameters.
to_yaml
()Save a configuration file with the parameters.
validate
()Check that the configuration has the necessary parameters.
from_file
- classmethod from_dict(d)[source]#
Sets multiple values from a dictionary.
- Parameters:
- ddict
A dictionary mapping parameter name to valie.
- classmethod from_hdu(hdu)[source]#
Load a configuration from a FITS extension file.
- Parameters:
- hduastropy.io.fits.BinTableHDU
The HDU from which to parse the configuration information.
- classmethod from_table(t)[source]#
Sets multiple values from an astropy Table with a single row and one column for each parameter.
- Parameters:
- t~astropy.table.Table
Astropy Table containing the required configuration parameters.
- strictbool
Raise an exception on unknown parameters.
- Raises:
- Raises a
KeyError
if the parameter is not part on the list of known parameters - and
strict
is False. - Raises a
ValueError
if the table is the wrong shape.
- Raises a
- classmethod from_yaml(config)[source]#
Load a configuration from a YAML file.
- Parameters:
- configstr or _io.TextIOWrapper
The serialized YAML data.
- set(param, value, warn_on_unknown=False)[source]#
Sets the value of a specific parameter.
- Parameters:
- paramstr
The parameter name.
- valueany
The parameter’s value.
- warn_on_unknownbool
Generate a warning if the parameter is not known.
- set_multiple(overrides)[source]#
Sets multiple parameters from a dictionary.
- Parameters:
- overridesdict
A dictionary of parameter->value to overwrite.
- to_file(filename, overwrite=False)[source]#
Save a configuration file with the parameters.
- Parameters:
- filenamestr
The filename, including path, of the configuration file.
- overwritebool
Indicates whether to overwrite an existing file.
- to_hdu()[source]#
Create a fits HDU with all the configuration parameters.
- Returns:
- hduastropy.io.fits.BinTableHDU
The HDU with the configuration information.