isofit.configs.configs

class Config(configdict)[source]

Bases: BaseConfigSection

Handles the reading and formatting of configuration files. Please note - there are many ways to do this, some of which require fewer lines of code. This method was chosen to facilitate more clarity when using / adding / modifying code, particularly given the highly flexible nature of Isofit.

How to use:

To add an additional parameter to an existing class, simply go to the relevant config (e.g. for forward_model go to sections/forward_model_config.py), and in the config class (e.g. ForwardModelConfig) add the parameter. Also Add a hidden parameter with the _type suffix, which will be used to check that configs read the appropriate type. Add comments directly below, to be auto-appended to online documentation. Example:

class GenericConfigSection(BaseConfigSection):
    _attribute_type = str
    attribute = 'my attribute'
    """str: attribute does whatever it happens to do"""

To validate that attributes have appropriate relationships or characteristics, use the hidden _check_config_validity method to add more detailed validation checks. Simply return a list of string descriptions of errors from the method as demonstrated:

def _check_config_validity(self) -> List[str]:
    errors = list()
    if self.attribute_min >= self.attribute_max:
        errors.append('attribute_min must be less than attribute_max.')
    return errors
input

Input config. Holds all input file information.

Type:

InputConfig

output

Output config. Holds all output file information.

Type:

OutputConfig

forward_model

forward_model config. Holds information about surface models, radiative transfer models, and the instrument.

Type:

ForwardModelConfig

implementation

holds information regarding how isofit is to be run, including relevant sub-configs (e.g. inversion information).

Type:

ImplementationConfig

get_config_as_dict()[source]

Get configuration options as a nested dictionary with delineated sections.

Return type:

dict

Returns:

Configuration options as a nested dictionary with delineated sections.

get_config_errors()[source]

Get configuration option errors by checking the validity of each config section.

check_inter_section_validity()[source]
get_config_differences(config_a, config_b)[source]
Return type:

Dict

create_new_config(config_file)[source]

Load a config file from disk. :type config_file: str :param config_file: file to load config from. Currently accepted formats: JSON and YAML

Return type:

Config

Returns:

Config object, having completed all necessary config checks