geoprior.cli.build_external_validation_metrics#
Build external validation metrics from Stage-1 inputs and a physics payload.
This command computes borehole / pumping validation metrics by matching site coordinates from an external validation table to the nearest pixel in a Stage-1 input grid. It then joins model-derived fields from a saved physics payload and writes both a site-level table and a metrics JSON.
Functions
CLI entry point for external validation metrics build. |
|
Build the command-line parser. |
|
|
Aggregate model pixels to one row per unique site location. |
|
Compute site-level validation joins and headline metrics. |
|
Infer Stage-1 directory from explicit hints. |
|
Infer Stage-1 directory from a standard results layout. |
|
Inverse-transform BH3 coordinates to physical space. |
|
Load all arrays from a compressed NPZ file. |
|
Compute mean absolute error. |
|
CLI entry point for external validation metrics build. |
|
Compute median prediction bias. |
|
Return the nearest pixel using direct and swapped XY checks. |
|
Return the first existing path from a candidate list. |
|
Read a JSON file into a dictionary. |
|
Reduce a sequence or horizon-aligned array to one value per site. |
|
Resolve optional coordinate scaler path. |
|
Resolve the inputs NPZ used for validation matching. |
|
Resolve output directory for metrics artifacts. |
|
Resolve saved physics payload path. |
|
Resolve Stage-1 manifest path from CLI and layout hints. |
|
Resolve optional Stage-2 manifest. |
|
Resolve validation CSV path from CLI or config. |
|
Compute Spearman rank correlation with finite-value checks. |
|
Sanity-check site-to-pixel matches. |
Classes
|
Nearest matched model pixel for one validation site. |
- class geoprior.cli.build_external_validation_metrics.MatchResult(well_id, match_mode, site_x, site_y, pixel_x, pixel_y, distance_m, pixel_idx)[source]#
Bases:
objectNearest matched model pixel for one validation site.
- Parameters:
- geoprior.cli.build_external_validation_metrics.read_json(path)[source]#
Read a JSON file into a dictionary.
- geoprior.cli.build_external_validation_metrics.load_npz_dict(path)[source]#
Load all arrays from a compressed NPZ file.
- geoprior.cli.build_external_validation_metrics.pick_existing(*paths)[source]#
Return the first existing path from a candidate list.
- geoprior.cli.build_external_validation_metrics.infer_stage1_dir(*, stage1_dir, manifest_path)[source]#
Infer Stage-1 directory from explicit hints.
- geoprior.cli.build_external_validation_metrics.infer_stage1_dir_from_layout(*, results_dir, city, model)[source]#
Infer Stage-1 directory from a standard results layout.
- geoprior.cli.build_external_validation_metrics.resolve_stage1_manifest(*, manifest, stage1_dir, results_dir, city, model)[source]#
Resolve Stage-1 manifest path from CLI and layout hints.
- geoprior.cli.build_external_validation_metrics.resolve_inputs_npz(stage1_manifest, split, override)[source]#
Resolve the inputs NPZ used for validation matching.
- geoprior.cli.build_external_validation_metrics.resolve_coord_scaler_path(stage1_manifest, override)[source]#
Resolve optional coordinate scaler path.
- geoprior.cli.build_external_validation_metrics.resolve_stage2_manifest(*, override, stage1_dir)[source]#
Resolve optional Stage-2 manifest.
- geoprior.cli.build_external_validation_metrics.resolve_payload_path(override, stage2_manifest)[source]#
Resolve saved physics payload path.
- geoprior.cli.build_external_validation_metrics.resolve_validation_csv(args, cfg)[source]#
Resolve validation CSV path from CLI or config.
- geoprior.cli.build_external_validation_metrics.resolve_outdir(args, *, stage1_dir, stage2_manifest_path, split)[source]#
Resolve output directory for metrics artifacts.
- geoprior.cli.build_external_validation_metrics.inverse_txy(coords_bh3, coord_scaler)[source]#
Inverse-transform BH3 coordinates to physical space.
- geoprior.cli.build_external_validation_metrics.reduce_horizon(arr, n_seq, horizon, how)[source]#
Reduce a sequence or horizon-aligned array to one value per site.
- geoprior.cli.build_external_validation_metrics.build_pixel_table(inputs_npz, payload_npz, coord_scaler, horizon_reducer, site_reducer)[source]#
Aggregate model pixels to one row per unique site location.
- geoprior.cli.build_external_validation_metrics.nearest_match(pixels, sx, sy, well_id)[source]#
Return the nearest pixel using direct and swapped XY checks.
- Parameters:
- Return type:
- geoprior.cli.build_external_validation_metrics.spearman_rho(x, y)[source]#
Compute Spearman rank correlation with finite-value checks.
- geoprior.cli.build_external_validation_metrics.median_bias(obs, pred)[source]#
Compute median prediction bias.
- geoprior.cli.build_external_validation_metrics.validate_site_matches(site_df, *, max_distance_m=5000.0, min_unique_pixels=3)[source]#
Sanity-check site-to-pixel matches.
- geoprior.cli.build_external_validation_metrics.compute_metrics(*, validation_csv, stage1_manifest_path, outdir, split='test', inputs_npz=None, physics_payload=None, coord_scaler=None, stage2_manifest_path=None, productivity_col='step3_specific_capacity_Lps_per_m', horizon_reducer='mean', site_reducer='median', max_distance_m=5000.0, min_unique_pixels=3)[source]#
Compute site-level validation joins and headline metrics.
- geoprior.cli.build_external_validation_metrics.build_parser()[source]#
Build the command-line parser.
- Return type: