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
Draft
Enable automatic data downloading, read attributes from WPS files rather than namelist, fix default ZSF values#4mkavulich wants to merge 3 commits into
mkavulich wants to merge 3 commits into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/--zsfare omitted, the source rasters are fetched for thedomain's bounding box (fire-grid perimeter + 2 km buffer):
choosing the FBFM13/FBFM40 layer to match
--fuel-tableand the newestfull-coverage LANDFIRE version (
--landfire-versionpins one). LFPSrequires an email address (
--email).(tiles are downloaded, deduplicated to the latest revision, and
merged/clipped), or from LANDFIRE 30 m elevation with
--zsf-sourcelandfire for a much smaller download.Downloads are cached in
--download-dir(default ./downloads) and reusedon 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.