Skip to content

Add VPU-delineated metadata support for multi-geopackage runs#90

Open
pratikshac15 wants to merge 2 commits into
CIROH-UA:mainfrom
pratikshac15:vpu-metadata-support
Open

Add VPU-delineated metadata support for multi-geopackage runs#90
pratikshac15 wants to merge 2 commits into
CIROH-UA:mainfrom
pratikshac15:vpu-metadata-support

Conversation

@pratikshac15

Copy link
Copy Markdown
Contributor

Summary

This PR adds VPU-delineated metadata support for multi-geopackage and multi-weight-file forcing runs.

Additions

  • Adds VPU ID handling in processor.py
  • Adds metadata_by_vpu.csv output
  • Adds per-VPU catchment count and file/stat metadata
  • Standardizes VPU naming in weights_hf2ds.py as VPU_XX

Changes

  • Keeps existing global metadata.csv
  • Adds VPU-level metadata without changing existing single-GPKG behavior
  • Improves consistency between jcatchment_dict keys and processor metadata keys

Testing

Tested locally using two small GeoPackages created from NWM_v3_hydrofabric.gdb:

  • nextgen_VPU_03W.gpkg
  • nextgen_VPU_10L.gpkg

Verified successful generation of:

  • VPU_03W_forcings.nc
  • VPU_10L_forcings.nc
  • metadata_by_vpu.csv

Notes

This addresses Issue #9 by providing VPU-delineated stats when processing multiple geopackages/weight files.

@pratikshac15

Copy link
Copy Markdown
Contributor Author

@quinnylee

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds VPU-delineated metadata outputs to better support multi-GeoPackage / multi-weight forcing runs (Issue #9), while preserving the existing global metadata outputs.

Changes:

  • Adds VPU inference and VPU-level metadata writing (metadata_by_vpu.csv plus VPU-tagged catchment stats).
  • Improves handling of local NWM file size tracking and makes the grid-orientation branch more robust via dimension checks.
  • Standardizes VPU naming derived from filenames in the weights pipeline.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/forcingprocessor/weights_hf2ds.py Adds infer_vpu_id() and uses it to standardize jcatchment_dict keys for multi-file weight extraction.
src/forcingprocessor/processor.py Adds VPU-aware metadata helpers, config-driven/inferred VPU ids, and writes new VPU-delineated metadata artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/forcingprocessor/processor.py Outdated
Comment thread src/forcingprocessor/processor.py Outdated
elif type(vpu_ids) is not list:
vpu_ids = [vpu_ids]

vpu_ids = [str(x) for x in vpu_ids]
Comment thread src/forcingprocessor/processor.py Outdated
Comment on lines +968 to +979
for i, (vpu_id, gpkg) in enumerate(zip(vpu_ids, gpkg_files)):
if str(gpkg).endswith(".parquet"):
# Prefer exact VPU key if the weights pipeline preserved it.
if vpu_id in jcatchment_dict:
vpu_catchment_map[vpu_id] = list(jcatchment_dict[vpu_id])
# Otherwise fall back to positional mapping.
elif i < len(jcatchment_values):
vpu_catchment_map[vpu_id] = list(jcatchment_values[i])
else:
vpu_catchment_map[vpu_id] = []
else:
vpu_catchment_map[vpu_id] = read_gpkg_catchments(gpkg)
Comment on lines +1357 to +1360
# Issue 9: write VPU-delineated metadata.
# This keeps the original global metadata.csv, and adds metadata_by_vpu.csv.
if data_source == "forcings":
vpu_metadata_rows = []
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pratikshac15
pratikshac15 force-pushed the vpu-metadata-support branch from e0c9663 to a42b42f Compare July 15, 2026 23:54
@pratikshac15

Copy link
Copy Markdown
Contributor Author

Fixed the Copilot-suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants