Skip to content

Terrain on the line of sight: one ray, one sight angle, snapped DEM windows - #19

Merged
rharnish merged 2 commits into
mainfrom
terrain-los
Sep 26, 2026
Merged

rharnish merged 2 commits into
mainfrom
terrain-los

Conversation

@rharnish

Copy link
Copy Markdown
Owner

Follows a review of how the DEM is used (NOTES.md, "Terrain on the line of sight").

Geometry

  • geom.ray_latlon: terrain is marched along the camera's real line of sight, exact on WGS84. The old lat/lon stepping drifted up to 0.33° off the ray at 80 km on diagonal azimuths, the same kind of error PR Geolocation re-run on the precessed ledger #17 removed from bearings.
  • terrain.sight_angles / eye_height / sightline: one copy of the curvature + refraction formula instead of seven. All tracked call sites use it (horizon, ridges, terrain_range, landmarks.visible, ridge_feet.sightline, fig_sea_horizon).
  • Dem.window snaps to the tiles' pixel grid, and Dem.sample reads a pixel at its centre. Samples are now independent of the window.
  • Dem.site_problem: warns about or skips cameras whose height disagrees with the DSM (elev 0 or no agl). None of them are ledger cameras.
  • test_geolocation pins the calibrated camera model. It failed when run alone.

Measured before adopting (skyline check, 39 cameras): the line-of-sight march is real but sub-pixel on the skyline (mean |res| 6.36 → 6.32 px). Refraction k=0.13 vs 4/3 isn't decided by the data, so the terrain stays at 4/3. There is an unexplained +1.2 px per 10 km range trend, likely haze in the edge search.

Re-run: terrain-range containment is identical (60/73) and confirmed medians are unchanged. Rainbow's 30 px region is 5.0 km² (was 4.8). The skyline check is unchanged at +0.3 / 2.8 px.

Tests: new tests/test_terrain.py (numpy only). The full suite passes, and so does each module run alone.

🤖 Generated with Claude Code

rharnish and others added 2 commits September 25, 2026 20:07
…indows

- geom.ray_latlon: ground points under the camera's straight line of sight,
  exact on WGS84. Every terrain march stepped in lat/lon with fixed
  metres-per-degree, which drifts off the ray by up to 0.33 deg at 80 km on
  diagonal azimuths; bearings were made exact in PR #17, the terrain wasn't.
- terrain.sight_angles / eye_height / sightline: the curvature + refraction
  formula was copied in six places (horizon, ridges, terrain_range.profile,
  landmarks.visible, ridge_feet.sightline, fig_sea_horizon); all now share it.
  geom.enu_grid replaces the flat dn/de in terrain_range.terrain_loglik.
- Dem.window snaps to the tiles' pixel grid and Dem.sample reads a pixel's
  value at its centre. Before, every sample was shifted by up to half a pixel,
  differently per window; now samples don't depend on the window.
- Dem.site_problem: horizon/ridges warn and terrain_range skips when a
  camera's height disagrees with the DSM at its own site (elev 0, or no agl).
  No ledger camera is affected.
- terrain_range.profile: optional min_km (off), horizon_km in validate rows.
- test_geolocation pins the calibrated camera model instead of inheriting it
  from whichever module set FIGLIB_LENS at import; it failed when run alone.
- tests/test_terrain.py: ray, sight angle, pixel centre, site check and
  sightline on a synthetic raster (numpy only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- NOTES "Terrain on the line of sight": the review of every DEM use, the
  skyline-check experiment (march 6.36 -> 6.32 px mean |res|; refraction
  k=0.13 undecided; an unexplained +1.2 px per 10 km range trend, likely
  haze in the edge search), and the re-run deltas.
- terrain_range validate/solve, fig_bearing and skyline_check re-run from
  c841ee3. Containment is identical (60/73); confirmed medians unchanged.
  Rainbow's 30 px region is 5.0 km2 (was 4.8), 7.5 at 60 px (was 7.7).
- README, docs/star-calibration.md (precession only +1.8 / 3.2 px) and the
  Rainbow and skyline figures updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rharnish
rharnish merged commit 86c8058 into main Sep 26, 2026
1 check passed
@rharnish
rharnish deleted the terrain-los branch September 27, 2026 03:09
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.

1 participant