curryer.correction.results_io

NetCDF I/O helpers for the correction pipeline.

This module owns all read/write operations on the NetCDF result file:

Attributes

Functions

_build_netcdf_structure(→ dict)

Build NetCDF data structure dynamically from the sweep + output config.

_save_netcdf_checkpoint(netcdf_data, output_file, ...)

Save NetCDF checkpoint with partial results after each GCP pair completes.

_load_checkpoint(output_file)

Load checkpoint if it exists and convert back to netcdf_data dict.

_cleanup_checkpoint(output_file)

Remove checkpoint file after successful completion.

_save_netcdf_results(netcdf_data, output_file, setup, ...)

Save results to NetCDF file using config-driven metadata.

Module Contents

curryer.correction.results_io.logger
curryer.correction.results_io._build_netcdf_structure(setup: curryer.correction.config.GeolocationSetup, sweep: curryer.correction.config.Sweep, netcdf_config: curryer.correction.config.NetCDFConfig, n_param_sets: int, n_gcp_pairs: int) dict

Build NetCDF data structure dynamically from the sweep + output config.

This creates the netcdf_data dictionary with proper variable names based on the parameters defined in the sweep, avoiding hardcoded mission-specific names.

Parameters:
  • setup – GeolocationSetup (performance threshold for metric naming)

  • sweep – Sweep with the parameters to vary

  • netcdf_config – Resolved NetCDFConfig with metadata

  • n_param_sets – Number of parameter sets (iterations)

  • n_gcp_pairs – Number of GCP pairs

Returns:

Dictionary with initialized arrays for all NetCDF variables

curryer.correction.results_io._save_netcdf_checkpoint(netcdf_data, output_file, setup, sweep, netcdf_config, pair_idx_completed)

Save NetCDF checkpoint with partial results after each GCP pair completes.

This enables resuming correction runs if they are interrupted. Adapted for pair-outer loop order where each pair processes all parameters.

Parameters:
  • netcdf_data – Dictionary with current NetCDF data

  • output_file – Path to final output file (checkpoint uses .checkpoint.nc suffix)

  • setup – GeolocationSetup (performance threshold for metric naming)

  • sweep – Sweep with parameters/iterations/seed

  • netcdf_config – Resolved NetCDFConfig with metadata

  • pair_idx_completed – Index of the last completed GCP pair (for pair-outer loop)

curryer.correction.results_io._load_checkpoint(output_file)

Load checkpoint if it exists and convert back to netcdf_data dict.

Parameters:

output_file – Path to final output file (will check for .checkpoint.nc)

Returns:

Tuple of (netcdf_data dict, start_idx) or (None, 0) if no checkpoint

curryer.correction.results_io._cleanup_checkpoint(output_file)

Remove checkpoint file after successful completion.

Parameters:

output_file – Path to final output file (will remove .checkpoint.nc)

curryer.correction.results_io._save_netcdf_results(netcdf_data, output_file, setup, sweep, netcdf_config)

Save results to NetCDF file using config-driven metadata.

This function dynamically builds the NetCDF file structure from the netcdf_data dictionary, using configuration for all metadata rather than hardcoding mission-specific values.

Parameters:
  • netcdf_data – Dictionary with all NetCDF variables and data

  • output_file – Path to output NetCDF file

  • setup – GeolocationSetup (performance threshold for metric naming)

  • sweep – Sweep with parameters/iterations/seed

  • netcdf_config – Resolved NetCDFConfig with metadata