Add VPU metadata support#95
Open
pratikshac15 wants to merge 2 commits into
Open
Conversation
pratikshac15
requested review from
JordanLaserGit,
arpita0911patel and
quinnylee
July 23, 2026 18:17
Contributor
There was a problem hiding this comment.
Pull request overview
Adds VPU-aware handling for multi-GeoPackage / multi-weight forcing runs, including standardized VPU identifiers and new VPU-delineated metadata outputs, while preserving existing global metadata behavior.
Changes:
- Add VPU ID inference/normalization to align naming across weights generation and forcing processing.
- Write new per-VPU metadata outputs (
metadata_by_vpu.csvplus catchment stats with avpu_idcolumn). - Adjust multiprocessing behavior in weights generation and harden weight-ingestion logging.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/forcingprocessor/weights_hf2ds.py | Adds VPU ID inference and uses a spawn multiprocessing context for ProcessPoolExecutor; updates naming logic used to build VPU/catchment mappings. |
| src/forcingprocessor/processor.py | Adds VPU ID normalization + config handling and writes VPU-level metadata outputs; fixes local file size accumulation and adjusts grid extraction logic. |
Comments suppressed due to low confidence (1)
src/forcingprocessor/processor.py:307
- The new condition treats any dataset with
south_north/west_eastdims like retrospective-2-1 for timestamp parsing, but many NWM files (e.g.nwm.t00z.short_range.forcing...) use those dims while the filename is notYYYYMMDDHH.... This will raise aValueErrorindatetime.strptime. Timestamp extraction should prefer themodel_output_valid_timeattribute when available, and only fall back to parsing the filename when that attribute is missing.
if "retrospective-2-1" in nwm_file or ("south_north" in nwm_data.dims and "west_east" in nwm_data.dims):
data_allvars[var_dx, :, :] = np.flip(np.squeeze(nwm_data[jvar].isel(west_east=slice(x_min, x_max+1), south_north=slice(shp[1] - (y_max+1), shp[1] - y_min)).values),axis=0)
t = datetime.strftime(datetime.strptime(nwm_file.split('/')[-1].split('.')[0],'%Y%m%d%H'),'%Y-%m-%d %H:%M:%S')
else:
data_allvars[var_dx, :, :] = np.flip(np.squeeze(nwm_data[jvar].isel(x=slice(x_min, x_max+1), y=slice(shp[1] - (y_max+1), shp[1] - y_min)).values),axis=0)
time_splt = nwm_data.attrs["model_output_valid_time"].split("_")
t = time_splt[0] + " " + time_splt[1]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+148
to
+151
| with cf.ProcessPoolExecutor( | ||
| max_workers=nprocs, | ||
| mp_context=mp.get_context("spawn"), | ||
| ) as pool: |
Comment on lines
+832
to
+834
| assert len(vpu_ids) == len(gpkg_files), ( | ||
| "Length of forcing.vpu_id must match length of forcing.gpkg_file" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR recreates the changes from #90 on a branch within the CIROH-UA repository so the authenticated GitHub Actions can run.
This includes the VPU metadata support changes and the latest review updates.
Replaces #90.