curryer.correction.results_io ============================= .. py:module:: curryer.correction.results_io .. autoapi-nested-parse:: NetCDF I/O helpers for the correction pipeline. This module owns all read/write operations on the NetCDF result file: - :func:`_build_netcdf_structure` -- initialise the in-memory data dict. - :func:`_save_netcdf_results` -- write the final NetCDF output file. - :func:`_save_netcdf_checkpoint` -- write a partial checkpoint after each GCP pair. - :func:`_load_checkpoint` -- reload a checkpoint to resume an interrupted run. - :func:`_cleanup_checkpoint` -- delete the checkpoint file after a successful run. Attributes ---------- .. autoapisummary:: curryer.correction.results_io.logger Functions --------- .. autoapisummary:: curryer.correction.results_io._build_netcdf_structure curryer.correction.results_io._save_netcdf_checkpoint curryer.correction.results_io._load_checkpoint curryer.correction.results_io._cleanup_checkpoint curryer.correction.results_io._save_netcdf_results Module Contents --------------- .. py:data:: logger .. py:function:: _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. :param setup: GeolocationSetup (performance threshold for metric naming) :param sweep: Sweep with the parameters to vary :param netcdf_config: Resolved NetCDFConfig with metadata :param n_param_sets: Number of parameter sets (iterations) :param n_gcp_pairs: Number of GCP pairs :returns: Dictionary with initialized arrays for all NetCDF variables .. py:function:: _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. :param netcdf_data: Dictionary with current NetCDF data :param output_file: Path to final output file (checkpoint uses .checkpoint.nc suffix) :param setup: GeolocationSetup (performance threshold for metric naming) :param sweep: Sweep with parameters/iterations/seed :param netcdf_config: Resolved NetCDFConfig with metadata :param pair_idx_completed: Index of the last completed GCP pair (for pair-outer loop) .. py:function:: _load_checkpoint(output_file) Load checkpoint if it exists and convert back to netcdf_data dict. :param 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 .. py:function:: _cleanup_checkpoint(output_file) Remove checkpoint file after successful completion. :param output_file: Path to final output file (will remove .checkpoint.nc) .. py:function:: _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. :param netcdf_data: Dictionary with all NetCDF variables and data :param output_file: Path to output NetCDF file :param setup: GeolocationSetup (performance threshold for metric naming) :param sweep: Sweep with parameters/iterations/seed :param netcdf_config: Resolved NetCDFConfig with metadata