Skip to content

sky view factor for ISOFIT#735

Merged
pgbrodrick merged 17 commits into
isofit:devfrom
brentwilder:sky-view-factor
Aug 7, 2025
Merged

sky view factor for ISOFIT#735
pgbrodrick merged 17 commits into
isofit:devfrom
brentwilder:sky-view-factor

Conversation

@brentwilder

@brentwilder brentwilder commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

Changes

  • Standalone skyview.py utility that can be used prior to apply_oe. Recommended for DEM larger than image.
  • Sky view flag in apply_oe (tested for 4C, 1C, and analytical line). ENVI skyview file input must be same dimensions as radiance data (i.e., clipped to radiance data by user prior to apply_oe).
  • physical bounds [0,1] introduced for cos_i and coszen in Geometry class.

@brentwilder

brentwilder commented Jul 22, 2025

Copy link
Copy Markdown
Contributor Author

Testing on EMIT scene (Jan 29, 2025) without Analytical Line:

4C case (Red= Using skyview; Purple=set to 1). Sky view~0.86 for this example at this pixel:
Screenshot 2025-07-22 at 14 12 44

1C case (Red= Using skyview; Purple=set to 1). Sky view~0.86 for this example at this pixel:
Screenshot 2025-07-22 at 14 15 32

Tests compared to C based topo-calc code (n_angles=72, n_cores=14)

comparison on same personal laptop against topo-calc code.

  • EMIT-like (dem dimension: 3012x2640 pix, 60 m spatial resolution)
    • Times: both roughly 55-60 seconds on 14 cores..
    • Difference: RMSD: 0.0014 (n~7.95 million pixels)

Differences in skyview (topo-calc vs. skyview.py) were mostly on the edges, which is fine as this should generally be applied with a buffered DEM around the image in order for the horizons to be accurate. Measurable differences on the edges (~0.01) occurred mostly within 1km of the borders. This is mostly due I think to the greedy alg approach i applied in skyview.py. But also there is missing information bc the half of the hemisphere is missing so it is hard to tell for sure what is happening on the edge pixels. But TLDR; just use a DEM with a sufficient buffer around target image (~1km).

For reference, here is the extent of the EMIT shown in red:

Screenshot 2025-07-22 at 16 03 13

@brentwilder

Copy link
Copy Markdown
Contributor Author

Per conversation with Niklas, I am also bringing in logic to ensure cos_i respects bounds 0-1 within check_coszen_and_cos_i() . Mathematically cos ranges -1 to 1. But from a radiative transfer standpoint, it must be capped from 0-1.

@brentwilder brentwilder marked this pull request as ready for review July 22, 2025 20:35
@brentwilder

brentwilder commented Jul 23, 2025

Copy link
Copy Markdown
Contributor Author

EMIT scene (Jan 29, 2025) with Analytical Line:

1C case (Red= Using skyview; Purple=set to 1). Sky view~0.86 for this example at this pixel:
Screenshot 2025-07-23 at 11 06 31

Summary ALAlg incorporation:

  • skyview gets extracted similar to rdn.. The resulting "subs" file gets passed to initial solve.
  • Then, the atmosphere is interpolated
  • Finally, full sky view map provided directly to new Geom class in closing analytical solution.

Note: There are odd peaks in the spectra around H2O features that exist for all my runs here.. I think this is likely a user error and unrelated to any of the skyview codes contained within this PR.

@unbohn

unbohn commented Jul 28, 2025

Copy link
Copy Markdown
Collaborator

@brentwilder I ran a very quick test (single pixel inversion with the 1c model, sky view factor assumed to be 1) and couldn't observe any difference in retrieved reflectance between dev and your sky-view-factor branches. Will run a more comprehensive test soon, but it points to an issue with your LUT, rather than with the code updates. That is, your above assumption "user error" is probably right.

@brentwilder

Copy link
Copy Markdown
Contributor Author

@pgbrodrick on the conversation of computing skyview from LOC files:

I computed a test case for Copernicus DSM if we only had extent of EMIT image (A), and compared this with the larger, buffered one from above (B).

compare

If you zoom in, you can see case (A) here often has positive bias (blue) along the edges. This is due to horizon calcs not having this information on the edges. I used same logic from topo-calc on the edges, where this point is its own horizon when difference in indices are zero (https://github.com/USDA-ARS-NWRC/topocalc/blob/main/topocalc/core_c/hor1d.c#L225) . But it gets more difficult than just the pure edge case, as you can see error may leak in further into the image depending on terrain.

@brentwilder

Copy link
Copy Markdown
Contributor Author

Tested with a brand new image today and was able to find no effect on the h2o absorption features (emit20250327t212148). Still not sure what my error was before on the previous image. But the Skyview additions seem to be working as expected.

Small snippet on Lake Mary in Sierras:
Screenshot 2025-08-04 at 18 22 38

@unbohn

unbohn commented Aug 5, 2025

Copy link
Copy Markdown
Collaborator

Thanks for double-checking, @brentwilder! Great that it works on your end now too. From my perspective, we’re good to go. @pgbrodrick Feel free to merge this in.

@pgbrodrick pgbrodrick merged commit b75112c into isofit:dev Aug 7, 2025
3 checks passed
@brentwilder brentwilder deleted the sky-view-factor branch March 9, 2026 18:32
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