credit.cli._convert#
credit init and credit convert command handlers.
Attributes#
Classes#
YAML dumper that writes lists of scalars as flow sequences [a, b, c]. |
Functions#
|
Convert old mean/std NetCDF files into two BridgeScaler JSON files. |
|
|
|
Return all dimension names from the first matching file, or None on failure. |
|
Patch trainer reload fields and write a reload config next to the checkpoint. |
|
Interactive v1 → v2 config converter. |
|
Copy a config template to the user's desired location. |
Module Contents#
- credit.cli._convert._build_bridgescaler_jsons(mean_path, std_path, var_groups, pre_out, post_out, source_name='ERA5')#
Convert old mean/std NetCDF files into two BridgeScaler JSON files.
Creates one JSON for the preblock (batch-dict key structure) and one for the postblock (reconstructed prediction-dict structure).
- Parameters:
mean_path (str) – Paths to NetCDF files with per-variable means and standard deviations. 3-D variables have a ‘level’ dimension; 2-D variables are scalars.
std_path (str) – Paths to NetCDF files with per-variable means and standard deviations. 3-D variables have a ‘level’ dimension; 2-D variables are scalars.
var_groups (dict) –
{(field_type, dim): [varname, ...]}— maps (“prognostic”, “3d”) etc. to the list of variable names that belong to that group.pre_out (str) – Output path for the preblock scaler JSON.
post_out (str) – Output path for the postblock scaler JSON.
- Returns:
pre_keys (list[str]) – Full key paths included in the preblock scaler (e.g.
"era5/prognostic/3d/temperature").post_prog_vars (list[str]) – Short variable names of prognostic vars in the postblock scaler.
- class credit.cli._convert._FlowSeqDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)#
Bases:
yaml.DumperYAML dumper that writes lists of scalars as flow sequences [a, b, c].
- represent_sequence(tag, sequence, flow_style=None)#
- credit.cli._convert._yaml_dump(conf, f)#
- credit.cli._convert._SPATIAL_TIME_DIMS#
- credit.cli._convert._zarr_dims(glob_path: str) list[str] | None#
Return all dimension names from the first matching file, or None on failure.
- credit.cli._convert._write_reload_config(config_path: str) str#
Patch trainer reload fields and write a reload config next to the checkpoint.
Reads the YAML at config_path, sets the five fields required for a clean resume, and writes the result to
<save_loc>/config_reload.yml.Returns the path to the written reload config.
- credit.cli._convert._convert(args: argparse.Namespace) None#
Interactive v1 → v2 config converter.
- credit.cli._convert._init(args: argparse.Namespace) None#
Copy a config template to the user’s desired location.