[Bug] r.horizon selectively over-predicts horizon angle for a 45 degree slope for some azimuths
Describe the bug
The test raster is a small square hillock with 45 degree slopes towards all four cardinal directions and a flat central rooftop. At azimuth angles of 45 deg, 135 deg, 225 deg and 315 deg, horizon angle should either be zero (on the flat top, and on the downward sloping sides), or tan^-1(1/sqrt(2)) = 0.6154797 radians = 35.26439 degrees (on the two sides which slope upwards along the azimuth direction).
Note: Strictly speaking, horizon angles on downward sloping sides for this raster should be negative, but r.horizon presently does not do negative horizon angles.
r.horizon correctly generates this value on part of the raster (the light green colored portion), but over-predicts a value of 0.6939801 radians = 39.76213 degrees on one of the slopes (yellow portion).
The above image shows the horizon raster generated by r.horizon for an azimuth of 135 deg (ccw from east), but similar results are obtained for azimuths of 45, 225 and 315 degrees as well.
To reproduce
This is the test (ascii) raster file, -
which I read in using -
gs.run_command("r.in.gdal", flags="o", input="ho.txt", output="horaster")
I am using a python script with -
import grass.script as gs
I run r.horizon through the following line -
gs.run_command("r.horizon", elevation="horaster", step=45, output="horangleGrass", distance="0.5")
Expected behavior
Both upward slopes should generate a horizon angle value of tan^-1(1/sqrt(2)) = 0.6154797 radians = 35.26439 degrees.
System description
I am on windows 11, and my GRASS and windows versions are -
Welcome to GRASS GIS 8.4.0 Microsoft Windows [Version 10.0.22631.3880]
- details about further software components
C:\Users\Girish>g.version -rge version=8.4.0 date=2024 revision=e49c044e62 build_date=2024-07-28 build_platform=x86_64-w64-mingw32 build_off_t_size=8 libgis_revision=e49c044e62 libgis_date=2024-07-27T11:27:22+00:00 proj=9.4.0 gdal=3.9.1 geos=3.12.2 sqlite=3.45.1
(I just installed the most recent daily build (WinGRASS-8.4.0dev-9b4bbc43b0-136-Setup.exe) from https://wingrass.fsv.cvut.cz/grass84/)