Use NWM reach slope for normal depth boundary condition#3
Conversation
|
@ar-siddiqui @mdeshotel for your review |
ar-siddiqui
left a comment
There was a problem hiding this comment.
My main comment here is that the nd_slope may not always be the slope of reach, it should be the slope of the reach that intersect with the last XS, that could be the reach in consideration itself or a reach downstream of it.
… with the actual nwm reach slope from the hydrofabric
ar-siddiqui
left a comment
There was a problem hiding this comment.
Looks really good.
Minor changes requested only.
| the model with a normal depth downstream boundary condition using the NWM | ||
| reach slope for the submodel's final downstream cross section (falls back to | ||
| DEFAULT_ND_SLOPE if unavailable). The conflation step bounds the value to | ||
| [MIN_ND_SLOPE, MAX_ND_SLOPE] (currently [1e-6, 0.1]). |
There was a problem hiding this comment.
Same comment as above, also see if we really need to document this at two places. Feels redundant.
There was a problem hiding this comment.
On the redundancy: I'd lean toward keeping the note in both. create_model_run_normal_depth and run_incremental_normal_depth are two separate user-facing endpoints, and someone reading either one's docstring shouldn't have to chase a cross-reference to learn the boundary condition behavior. Happy to revisit if you feel strongly, though.
Summary
Replace the hardcoded 0.001 downstream normal depth slope with the actual NWM reach slope from the hydrofabric. Discussion in NGWPC/ripple1d-archive#220 confirmed that using the actual slope reduced water surface elevation discrepancies by several feet.
Addressing review feedback
NORMAL_DEPTH→DEFAULT_ND_SLOPE— the constant stores a slope value, not a boundary condition type.Changes
rasfim.py:_ds_xs_geometry()— resolves the ds_xs dict back to its RAS geometry_select_ds_slope_reach()— when the ds_xs intersects multiple NWM reaches, walks theto_idchain from the current reach and picks the furthest downstream candidateget_ds_boundary_slope()— orchestrates the full lookup with fallback chain: walk result → current reach slope →DEFAULT_ND_SLOPEds_slopeandds_slope_source_nwm_id(audit field showing which reach provided the slope)create_model_run_normal_depth()andrun_incremental_normal_depth()(ras_run.py) passds_slopetonormal_depth_run(), falling back toDEFAULT_ND_SLOPEdocs/source/faq.rst) and docstrings updatedIncidental cleanups
While in these files, also:
ras.py,ras_run.py,ras_conflate.pyFalsedefaults withSHOW_RASconstant fromconsts.pyforshow_rasparameterConflation file changes
tests/ras-data/*/{Baxter,MissFldwy,PatuxentRiver,winooski}.conflation.json: Regenerated againsttests/nwm-data/flows.parquetto pick up newds_slopeandds_slope_source_nwm_idvaluesTesting
pytest tests/conflation_test.py -v— 16 unit tests pass (5 new tests covering the slope selection logic and fallback chain)pytest tests/conflation_tests/conflation_test.py -v— all 14 integration tests pass