Skip to content

Fix forest cover fraction download for non-CONUS AOIs#79

Merged
ZachHoppinen merged 1 commit into
mainfrom
fix-download-proba-v-args
May 8, 2026
Merged

Fix forest cover fraction download for non-CONUS AOIs#79
ZachHoppinen merged 1 commit into
mainfrom
fix-download-proba-v-args

Conversation

@ZachHoppinen

Copy link
Copy Markdown
Contributor

Summary

  • generate_dataarrays.py:340: misplaced ) was calling download_proba_v() with no args; also wrapped tempfile.gettempdir() in Path(...) so .joinpath() works.
  • utils/download.py:download_proba_v: was calling asf_search.download_url(url=..., filename=out_fp) — but download_url requires a path (directory) and filename is the basename only. Also download_url returns None, so returning its result broke downstream xr.open_dataarray. Split out_fp into parent dir + filename and return out_fp ourselves.
  • processing/wet_snow.py:227: a stale ts from the inner loop was being used outside both loops, applying the snowcover mask only to the final timestep instead of the whole dataset. Replaced with a dataset-wide where.
  • processing/wet_snow.py:174-177: removed a duplicated melt_season computation.

Reproduces from a real run failure on white_mtns 2024_2025 (Fairbanks, AK — outside CONUS).

Test plan

  • Re-run the failing case (white_mtns 2024_2025) and confirm generate_forest_fraction_dataarray returns a valid FCF DataArray.
  • Confirm CONUS-AOI runs are unaffected (NLCD path is untouched).
  • Run existing test suite: pytest tests/.

🤖 Generated with Claude Code

Three related bugs surfaced when running outside CONUS (Proba-V branch):

- generate_dataarrays.py: misplaced `)` made `download_proba_v()` get called
  with no args; also `tempfile.gettempdir()` (a str) was being treated like
  a Path. Wrap in Path(...) and pass the file path into download_proba_v.

- utils/download.py: download_proba_v passed the full filepath as `filename`
  to asf_search.download_url and omitted the required `path` argument.
  download_url returns None, so propagating its return value yielded None.
  Split out_fp into parent dir + filename and return out_fp ourselves.

- processing/wet_snow.py: a stale `ts` from the inner loop was used after
  both loops exited, so the snowcover mask only applied to the final
  timestep. Apply it to the whole dataset like the surrounding lines.
  Also dropped a duplicate `melt_season` computation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ZachHoppinen ZachHoppinen merged commit d447f4b into main May 8, 2026
1 check passed
@ZachHoppinen ZachHoppinen deleted the fix-download-proba-v-args branch May 9, 2026 00:30
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