Skip to content

Commit

Permalink
r.horizon: revert back to positive values only (#2955)
Browse files Browse the repository at this point in the history
Enabling negative angles in r.horizon requires more work, the current simple implementation has problems (e.g. flat areas). Also r.sun doesn't work well with negative horizon values. See #2935 for discussion. For now, reverting back to horizon values >= 0 seems best. Note was added to manual page.
  • Loading branch information
petrasovaa authored May 12, 2023
1 parent 01f2f9c commit e6dcec0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion raster/r.horizon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ double horizon_height(void)
{
double height;

tanh0 = -INFINITY;
tanh0 = 0.;
length = 0;

height = searching();
Expand Down
7 changes: 4 additions & 3 deletions raster/r.horizon/r.horizon.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ <h2>METHOD</h2>

<p>
The output with the <b>-d</b> flag is azimuth degree (-90 to 90, where
0 is parallel with the focal cell). In case of negative horizon values
obtained this indicates that the horizon height is below the cell it is
computed from.
0 is parallel with the focal cell).

<p> All horizon values are positive (or zero). While negative values are
in theory possible, <b>r.horizon</b> currently does not support them.

<h2>EXAMPLES</h2>

Expand Down
18 changes: 12 additions & 6 deletions raster/r.horizon/testsuite/test_r_horizon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
280.000000,0.039774
300.000000,0.032360
320.000000,0.014804
340.000000,-0.001438
340.000000,0.000000
360.000000,0.004724
20.000000,0.012612
40.000000,0.015207
Expand All @@ -51,7 +51,7 @@
280.000000,0.039774
300.000000,0.032360
320.000000,0.014804
340.000000,-0.001438
340.000000,0.000000
360.000000,0.004724
20.000000,0.012612
40.000000,0.015207
Expand Down Expand Up @@ -119,9 +119,9 @@ def test_raster_mode_one_direction(self):
)
self.assertModule(module)
ref = {
"min": -1.57079637050629,
"min": 0,
"max": 0.70678365230560,
"stddev": 0.0708080140468585,
"stddev": 0.0360724286360789,
}
self.assertRasterFitsUnivar(
raster="test_horizon_output_from_elevation_050",
Expand All @@ -145,7 +145,10 @@ def test_raster_mode_multiple_direction(self):
self.runModule(module_list)
stdout = module_list.outputs.stdout.strip()
self.assertMultiLineEqual(
first="test_horizon_output_from_elevation_010_000\ntest_horizon_output_from_elevation_025_512",
first=(
"test_horizon_output_from_elevation_010_000\n"
"test_horizon_output_from_elevation_025_512"
),
second=stdout,
)

Expand All @@ -166,7 +169,10 @@ def test_raster_mode_multiple_direction_offset(self):
self.runModule(module_list)
stdout = module_list.outputs.stdout.strip()
self.assertMultiLineEqual(
first="test_horizon_output_from_elevation_090_000\ntest_horizon_output_from_elevation_105_512",
first=(
"test_horizon_output_from_elevation_090_000\n"
"test_horizon_output_from_elevation_105_512"
),
second=stdout,
)

Expand Down

0 comments on commit e6dcec0

Please sign in to comment.