TopoSplit - switch to bilinear interpolation and fix HRRR overcast zero-dropouts - #81
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical radiation-validity and moderate fallback findings block approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates HRRR solar processing to use bilinear interpolation and adjust threshold handling for interpolated components.
Changes:
- Sets the configured GDAL interpolation default to bilinear.
- Updates solar component threshold processing.
- Adds regression tests for threshold and negative-component behavior.
File summaries
| File | Reviewed changes |
|---|---|
smrf/tests/distribute/test_solar_hrrr.py |
Adds solar behavior coverage; the threshold test no longer preserves mixed per-pixel coverage. |
smrf/framework/CoreConfig.ini |
Sets bilinear interpolation as the configured default; the runtime fallback remains inconsistent. |
smrf/envphys/solar/toposplit.pyx |
Updates solar processing conditions; negative components can produce invalid radiation, and the new comment contains a duplicate is. |
Review details
Suppressed comments (1)
smrf/tests/distribute/test_solar_hrrr.py:143
- This test now sets DSWRF below threshold for every pixel and asserts every output is zero, so it no longer covers the per-pixel case where a low-DSWRF cell is adjacent to a valid cell. The previous test exercised that mixed mask; keep a mixed input and assert only the low cell is zero to catch regressions that incorrectly clear the whole grid.
data = {
SolarHRRR.DSWRF: np.full_like(SKY_VIEW_FACTOR_MOCK, 0.0),
SolarHRRR.VBDSF: np.full_like(SKY_VIEW_FACTOR_MOCK, 6.0),
SolarHRRR.VDDSF: np.full_like(SKY_VIEW_FACTOR_MOCK, 5.0),
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
All changes are reviewed; only a non-blocking documentation nit remains.
Review details
Suppressed comments (1)
smrf/tests/distribute/test_solar_hrrr.py:174
- This sentence is grammatically incorrect: the article “a” is followed by plural “conditions.” Use the singular “condition” (and drop “legitimately”) so the test documentation is clear.
k is fully diffuse (1.0) and dni/direct are 0.
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Wasn't sure how we want to handle failed gold tests @jomey. Figured it'd be best to regenerate solar hrrr affected files and push up. Feedback welcome |
|
Quick recapture from the meeting with Michelle to keep Matt and Alvaro in the loop:
|
Cubic method resulted in out-of-distribution and invalid values. Bilinear method tested for distribution fidelity.
Move up GHI calculation. Remove 3 gate conditional. Enable calculations in fully diffuse conditions.
Separate negative value test into standalone unit. Update expected test output due to valid calculation changes. See smrf/envphys/solar/toposplit.pyx for relevant changes.
Ensure bilinear interp runs for every config path. Build in explicit cubic interp caller.
Add value clamping [0, 1] for direct normal and diffuse horizontal values. This ensures valid k values (k_val). Correct minor grammatical error.
Ensure valid [0, 1] direct normal and diffuse horizontal in expected reference values.
5dca74a to
99af844
Compare
|
Made a few changes upon review
Input arrays were read-only so direct assignment did not work, stuck to the scalar approach
This was reorganized such that DSWRF condition is the prime guard, but without the ghi_vis guard, the divide-by-zero risk in k calculations was made more likely when both direct_normal and diffuse_horizontal are clamped to 0. Decided to reimplement the ghi_vis guard
Instead of a 1 Wm-2 threshold, I set it to 0.1 Wm-2 since the smaller fractional values are the ones we are concerned about in the first place. This way, k isn't too distorted from small values of VBDSF or VDDSF |
… TopoSplit changes
My vote is to use the 1 Wm-2 threshold throughout all of the checks and clamping and change/update if needed. It was introduced to account for interpolation artifacts and now that we changing the logic, there is no need to hang on to this. With the new logic, we should also prevent any combination of pixels that are not DSWRF > ghi_vis > 0. I will add some suggestions on where, how I could see this fit. Since our logic is also more complex now, I vote to update the tests to use more physical meaningful logic. I will provide those in line too. |
|
Lastly, can we also update the title and description of this PR. Right now it hides a very key change and would be hard to find in the future if we need to get back to this. |
Substitute component floor with self.min_value (1 Wm-2).
Substitute component floor for min_value. Update docstrings. Modify test data for proposed value combinations.
|
Two more notes
I think this is ready @jomey! |
jomey
left a comment
There was a problem hiding this comment.
Did you change the SolarHRRR.MIN_RADIATION value locally and forgot to commit?
Right now we would still use the old 1 Wm-2 since this is how it is initialized.
Also noting that there is the Makefile, which has exactly those targets defined. |
Nope, missed that, fixed now @jomey |















Summary of changes