Repository navigation
Fix slope azimuth of exactly east- or west-facing cells - #194
Merged
Merged
Conversation
BenjaminRodenberg
force-pushed
the
fix-slope-gamma-zero-slope-y
branch
2 times, most recently
from
October 20, 2026 16:03
0b1fc72 to
3b3f7c0
Compare
8 of 9 tasks
BenjaminRodenberg
force-pushed
the
fix-slope-gamma-zero-slope-y
branch
from
October 21, 2026 16:11
3b3f7c0 to
046e9db
Compare
For MATLAB and NetCDF meshes, slope_gamma was built from a chain of arctan cases whose generic branches equal arctan2(slope_x, slope_y), but the slope_y == 0 special cases had the wrong sign: an east-facing cell got the azimuth of a west-facing one and vice versa, so its direct insolation peaked in the afternoon. Replace the chain with slope_azimuth(), i.e. arctan2, keeping flat cells at 0 (arctan2(0, -0.0) is pi). On examples/dem_and_mask.mat, 20 of 37993 cells are affected. In a 10-day June run (shading on and off) Tsurf changes by up to 1.7 K there; all other cells agree to 1e-15 (1-ulp differences in slope_gamma). Assisted-by: Claude Code:claude-opus-5-5
BenjaminRodenberg
force-pushed
the
fix-slope-gamma-zero-slope-y
branch
from
October 26, 2026 15:39
046e9db to
adf2951
Compare
wardvp
approved these changes
Oct 26, 2026
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.
For MATLAB and NetCDF meshes, slope_gamma was built from a chain of arctan cases whose generic branches equal arctan2(slope_x, slope_y), but the slope_y == 0 special cases had the wrong sign: an east-facing cell got the azimuth of a west-facing one and vice versa, so its direct insolation peaked in the afternoon.
Replace the chain with slope_azimuth(), i.e. arctan2, keeping flat cells at 0 (arctan2(0, -0.0) is pi).
On examples/dem_and_mask.mat, 20 of 37993 cells are affected. In a 10-day June run (shading on and off) Tsurf changes by up to 1.7 K there; all other cells agree to 1e-15 (1-ulp differences in slope_gamma).
Assisted-by: Claude Code:claude-opus-5-5
Author's Todos