Skip to content

Enable automatic data downloading, read attributes from WPS files rather than namelist, fix default ZSF values - #4

Draft
mkavulich wants to merge 3 commits into
mainfrom
feature/download_data
Draft

Enable automatic data downloading, read attributes from WPS files rather than namelist, fix default ZSF values#4
mkavulich wants to merge 3 commits into
mainfrom
feature/download_data

Conversation

@mkavulich

@mkavulich mkavulich commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Three sets of changes coming in, all with the assistance of Claude code:

1. Add automatic download of fuel and terrain data from LANDFIRE and USGS

When --fuel / --zsf are omitted, the source rasters are fetched for the
domain's bounding box (fire-grid perimeter + 2 km buffer):

  • NFUEL_CAT via the LANDFIRE Product Service (lfps.usgs.gov) REST API,
    choosing the FBFM13/FBFM40 layer to match --fuel-table and the newest
    full-coverage LANDFIRE version (--landfire-version pins one). LFPS
    requires an email address (--email).
  • ZSF from the USGS National Map 3DEP 1/3 arc-second DEM by default
    (tiles are downloaded, deduplicated to the latest revision, and
    merged/clipped), or from LANDFIRE 30 m elevation with
    --zsf-source landfire for a much smaller download.

Downloads are cached in --download-dir (default ./downloads) and reused
on re-runs. API queries retry transient 5xx errors, which the TNM
service returns routinely. Adds the requests dependency.

2. Read subgrid ratios from WPS file attributes, making namelist.wps optional

geogrid writes the per-domain subgrid_ratio_x/y to geo_em files as the
sr_x/sr_y global attributes (copied to met_em by metgrid), so a
namelist.wps is only needed to override them — e.g. when adding a fire
grid to a domain that was originally run without one. An explicit
namelist value takes precedence, with a printed note on mismatch.

Also ignore __pycache__ directories.

3. Make the ZSF missing-data fill value configurable, defaulting to 0

Previously, fire-grid pixels with no source elevation data (outside
the DEM's extent, or nodata voids within it) surfaced the DEM
source raster's own nodata sentinel (e.g. -99999) in the output ZSF
field. Add --zsf-fill (default 0) to control this.

Also works around a GDAL/rasterio quirk where dst_nodata=0.0 is
silently ignored (falsy in the underlying binding) and falls back
to the source's nodata value regardless — reprojection now always
fills missing pixels with NaN internally and substitutes the
requested fill value afterwards, so a fill of exactly 0 works
correctly. NFUEL_CAT reprojection behavior is unchanged.

mkavulich and others added 3 commits July 14, 2026 15:36
…ional

geogrid writes the per-domain subgrid_ratio_x/y to geo_em files as the
sr_x/sr_y global attributes (copied to met_em by metgrid), so a
namelist.wps is only needed to override them — e.g. when adding a fire
grid to a domain that was originally run without one. An explicit
namelist value takes precedence, with a printed note on mismatch.

Also ignore __pycache__ directories.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When --fuel / --zsf are omitted, the source rasters are fetched for the
domain's bounding box (fire-grid perimeter + 2 km buffer):

- NFUEL_CAT via the LANDFIRE Product Service (lfps.usgs.gov) REST API,
  choosing the FBFM13/FBFM40 layer to match --fuel-table and the newest
  full-coverage LANDFIRE version (--landfire-version pins one). LFPS
  requires an email address (--email).
- ZSF from the USGS National Map 3DEP 1/3 arc-second DEM by default
  (tiles are downloaded, deduplicated to the latest revision, and
  merged/clipped), or from LANDFIRE 30 m elevation with
  --zsf-source landfire for a much smaller download.

Downloads are cached in --download-dir (default ./downloads) and reused
on re-runs. API queries retry transient 5xx errors, which the TNM
service returns routinely. Adds the requests dependency.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Previously, fire-grid pixels with no source elevation data (outside
the DEM's extent, or nodata voids within it) surfaced the DEM
source raster's own nodata sentinel (e.g. -99999) in the output ZSF
field. Add --zsf-fill (default 0) to control this.

Also works around a GDAL/rasterio quirk where dst_nodata=0.0 is
silently ignored (falsy in the underlying binding) and falls back
to the source's nodata value regardless — reprojection now always
fills missing pixels with NaN internally and substitutes the
requested fill value afterwards, so a fill of exactly 0 works
correctly. NFUEL_CAT reprojection behavior is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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