Skip to content

Tests Update - Sky view factor from TopoCalc#69

Merged
jomey merged 13 commits intomainfrom
sky_view_factor
Mar 13, 2026
Merged

Tests Update - Sky view factor from TopoCalc#69
jomey merged 13 commits intomainfrom
sky_view_factor

Conversation

@jomey
Copy link
Copy Markdown
Member

@jomey jomey commented Mar 13, 2026

Second part of the test suite update after including self-shading of slopes in TopoCalc (iSnobal/topocalc#12)

Outside of the gold file NetCDF updates, it also adds tests for the topo to compare the terrain variables and how a "fresh" calculation would potentially change things. This aim is to have a little warning system when something would change significantly.

It also adds a convenience feature where tests can be run and stop at the first failure and preserve the simulated output that did not compare within the tolerance with the gold files.

NetCDF changes

Most of the changes will show the pattern from the sky view changes, where that was an input to calculate radiation.

Lakes Topo

topo_sky_view_factor_xy topo_sky_view_factor_hist

Thermal (theoretical)

thermal_thermal_xy thermal_thermal_hist

Thermal HRRR

thermal_hrrr_thermal_xy thermal_hrrr_thermal_hist

Thermal HRRR with vegetation correction

thermal_hrrr_vegetation_thermal_xy thermal_hrrr_vegetation_thermal_hist

Net Solar (theoretical SW)

net_solar_net_solar_xy net_solar_net_solar_hist

Net Solar HRRR

net_solar_hrrr_net_solar_xy net_solar_hrrr_net_solar_hist

Net Solar HRRR with vegetation correction

net_solar_hrrr_albedo_net_solar_xy net_solar_hrrr_albedo_net_solar_hist

jomey added 10 commits March 12, 2026 10:58
Re-run the topo.nc file sky view, terrain factor, and slope using the
updated sky view method from TopoCalc. All the changed gold files had
the sky view factor as an argument. Difference plots are provided with
the PR.
The calculations used sky view factor as part of the terrain correction which updated in
the most recent TopoCalc library.
Add a class variable that prevents the deletion of output files once a comparison with
a gold file fails. This enables troubleshooting of differences.
Add a target that stops after the first test failure.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates SMRF’s test suite and related tooling to reflect TopoCalc’s updated sky view factor behavior (self-shading), adds additional topo “warning system” tests, and introduces a fast-fail test runner option while providing notebooks to help visualize NetCDF diffs.

Changes:

  • Update expected values in solar/toporad tests to match new TopoCalc sky view factor outputs.
  • Add topo tests that regenerate missing sky view factor outputs and compare against gold topo values within tolerance.
  • Add a fast-fail unittest target and preserve outputs on NetCDF comparison failures.

Reviewed changes

Copilot reviewed 7 out of 15 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
smrf/tests/smrf_test_case.py Adds “preserve output on NetCDF compare failure” behavior and refactors comparisons.
smrf/tests/envphys/solar/test_toporad.py Updates assertions for beam/diffuse min/max values after SVF changes.
smrf/tests/data/test_topo.py Adds tests for regenerating missing SVF outputs and comparing against topo gold.
smrf/tests/basins/Topo-Compare.ipynb Adds a notebook to compare topo NetCDF variables visually.
smrf/tests/basins/Gold-NetCDF-Compare.ipynb Adds a notebook to compare new outputs vs gold NetCDF files visually.
smrf/data/load_topo.py Refactors string/style and updates SVF variable creation/compression usage.
Makefile Adds tests_fast_fail target (unittest -f).

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

Some suggestions are around test logic. The most significant suggestion
is to reset the read values from a topo file before assigning it to an
instance variable. This ensure that wrong values are not set for a
variable.
@jomey jomey force-pushed the sky_view_factor branch from b0323de to 56053b6 Compare March 13, 2026 15:01
jomey and others added 2 commits March 13, 2026 09:07
Copy link
Copy Markdown
Contributor

@brentwilder brentwilder left a comment

Choose a reason for hiding this comment

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

This looks great @jomey , thanks for going through and updating all of the tests! I also appreciate the notebook for next time for convenience

@jomey jomey enabled auto-merge March 13, 2026 23:03
@jomey jomey merged commit bb8e590 into main Mar 13, 2026
7 of 8 checks passed
@jomey jomey deleted the sky_view_factor branch March 13, 2026 23:03
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.

3 participants