Configuration

NEDAS.config.config module

class NEDAS.config.config.Config(config_file: str | None = None, parse_args: bool = False, **kwargs)[source]

Bases: object

Class to manage the configuration for running the NEDAS analysis. Configuration entries are described in details in Configuration file.

Parameters:
  • config_file (str, optional) – Path to the configuration file.

  • parse_args (bool, optional) – If true, parse command line arguments to collect configuration. Default is False.

  • **kwargs – Additional key-value pairs to be passed to parse_config. Can be used to override values in the config file.

directories: dict[str, str]
python_env: str | None
io_mode: Literal['online', 'offline']
job_submit: dict | None
nproc: int
nproc_mem: int
nproc_rec: int
nproc_util: int
pid: int
pid_mem: int
pid_rec: int
pid_show: int
nens: int
run_preproc: bool
run_forecast: bool
run_analysis: bool
run_postproc: bool
run_diagnose: bool
step: str | None
call_stack: list[dict] | None
debug: bool
timer: bool
quiet: bool
interactive: bool | None
is_notebook: bool | None
call_stack_max_level: int | None
cols: int
anchor: int
tabspace: int
progress_bar_width: int
time: datetime
time_start: datetime
time_end: datetime
time_analysis_start: datetime
time_analysis_end: datetime
cycle_period: float
forecast_period: float
obs_time_steps: list[float]
obs_time_scale: float
state_time_steps: list[float]
state_time_scale: float
grid_def: dict
state_def: dict | None
model_def: dict | None
obs_def: dict | None
dataset_def: dict | None
shuffle_obs: bool
z_coords_from: Literal['mean', 'member']
interp_method: str
perturb: dict | None
scheme: str
niter: int
iter: int
resolution_level: list[int]
character_length: list[float]
localize_scale_fac: list[float]
obs_err_scale_fac: list[float]
assimilator_def: dict
updator_def: dict
covariance_def: dict
inflation_def: dict
localization_def: dict
transform_def: dict
alignment: dict | None
diag: dict | None
work_dir: str
dump_yaml(config_file: str)[source]

Dump the current configuration to a YAML file.

Parameters:

config_file (str) – Path to the output configuration file.

summary() str[source]

Return a comprehensive summary of the NEDAS configuration.

NEDAS.config.parse_config module

NEDAS.config.parse_config.convert_notation(data)[source]

Parse values in data, convert strings to appropriate types if possible.

Goes through the data recursively if it is a list or a dictionary. If the string can be interpreted as a scientific notation, inf, or boolean flag, convert it to the appropriate type.

Parameters:

data (any) – The data to be converted.

Returns:

The converted data.

Return type:

any

NEDAS.config.parse_config.str2bool(data: str) int[source]

Convert a string to a boolean value (0 or 1).

NEDAS.config.parse_config.parse_config(code_dir: str = '.', config_file: str | None = None, parse_args: bool = False, **kwargs)[source]

Load configuration from YAML files and runtime arguments.

This function loads configuration settings from a default YAML file, located in code_dir/default.yml. If config_file is provided, then values defined in that file will overwrite those in the default YAML file. If additional key=value pairs are provided, either through runtime command-line arguments or as kwargs, those will also overwrite the existing values.

The default YAML file also serves as a template for the ArgumentParser, which parses the key-value pairs, if the value is not None, parser will add the argument with type and default value in the help message.

Parameters:
  • code_dir (str, optional) – Directory containing the default.yml file. Default is the current directory.

  • config_file (str, optional) – Alternative YAML config file to overwrite default settings.

  • parse_args (bool, optional) – If True, parse runtime arguments with argparse. Default is False.

  • **kwargs – Additional configuration key-value pairs that can overwrite existing settings.

Returns:

A dictionary containing all configuration variables.

Return type:

dict