Skip to content

Comments

Mdeshotel ngwpc 9713 wrf geo hydro meta#101

Open
mdeshotel wants to merge 7 commits intodevelopmentfrom
mdeshotel_NGWPC-9713_WrfGeoHydroMeta
Open

Mdeshotel ngwpc 9713 wrf geo hydro meta#101
mdeshotel wants to merge 7 commits intodevelopmentfrom
mdeshotel_NGWPC-9713_WrfGeoHydroMeta

Conversation

@mdeshotel
Copy link

First PR for refactoring GeoMetaWrfHydro. This PR splits GeoMetaWrfHydro into a base class with three children classes for "gridded", "hydrofabric", and "unstructured" grid types.

Additions

Removals

Changes

-This PR splits GeoMetaWrfHydro into a base class with three children classes for "gridded", "hydrofabric", and "unstructured" grid types.
-Update imports
-Update GeoMeta initiation code in bmi_model.py.

Testing

  1. Tested RTE tests. c

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Linux

@mdeshotel mdeshotel marked this pull request as draft February 13, 2026 23:47
@mdeshotel mdeshotel marked this pull request as ready for review February 13, 2026 23:56
@mdeshotel mdeshotel requested a review from mxkpp February 13, 2026 23:57
Copy link

@mxkpp mxkpp left a comment

Choose a reason for hiding this comment

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

This is a good start to the restructuring. Please see minor requested changes.

I compared diffs of the various business logic blocks that have been moved into the new inherited classes -- they look behaviorally equivalent to before.

For the hydrofabric case only, I tested by building and running a calibration realization after clearing my existing scratch dir.

self.nx_local = None
self.ny_local = None
self.nx_local_elem = None
self.ny_local_elem = None
Copy link

Choose a reason for hiding this comment

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

Some attrs were replaced with properties (like nx_local) but others have a new property and still are an attr as well, like nx_local_elem. Is the intent for all properties to not have a corresponding attr?

Copy link
Author

Choose a reason for hiding this comment

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

The intent was to replace the attributes with properties. All 3 classes do not have a one to one match of attributes/properties. If a child class doesn't have one of the properties then is should be set as an attribute=None in the init. This was not done correctly when you reviewed but should now be corrected. Here is the original code for reference.

In summary:

  • gridded: 6 properties; 0 attributes
  • unstructured: 4 properties; 2 attributes=none
  • hydrofabric: 2 properties; 4 attributes=None

@mdeshotel mdeshotel requested a review from mxkpp February 17, 2026 16:28

# mpi_config.comm.barrier()

def calc_slope(self, esmf_nc):
Copy link

Choose a reason for hiding this comment

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

Calls to calc_slope, calc_slope_unstructured, and calc_slope_gridded are malformed

Copy link
Author

Choose a reason for hiding this comment

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

This has been fixed.

@mdeshotel mdeshotel requested a review from mxkpp February 18, 2026 16:11

def initialize_geospatial_metadata(self, config_options, mpi_config):
"""Initialize GeoMetaWrfHydro class variables.
def calc_slope_gridded(self, esmf_nc: netCDF4.Dataset) -> tuple:
Copy link

Choose a reason for hiding this comment

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

The most recent commit removed esmf_nc = netCDF4.Dataset(self.config_options.geogrid, "r") from the top of calc_slope_gridded. Regardless of the var name, the original code was passing that var into this function and then replacing the object immediately with a read from disk. I think that behavior should be preserved, namely the step of reading from disk at the top of the function. I am not sure why the original code passes a variable in just to immediately replace it, but that aspect should probably be preserved too, for now.

Copy link

Choose a reason for hiding this comment

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

Same comment for other instances where the read netCDF4.Dataset(self.config_options.geogrid, "r") was recently removed, those should be reinstated.

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