Repository navigation
STOFS-2D-Global surface forcing from the public GFS flux files (source=sflux) - #73
Merged
Merged
Conversation
…bf GRIB2 files (source=sflux), add gfs_input_files
…ributes, icec bitmap rule)
…ecoder hardening, idx readiness
There was a problem hiding this comment.
🟡 Changes recommended
Sflux fallback can decode incomplete files, and consumed flux inputs bypass centralized prep input capture.
2 open findings
What changed in this PR
Adds opt-in public GFS flux-file support for STOFS-2D-Global surface forcing while retaining the existing sfcf default.
Changes:
- Adds sflux path discovery, readiness checks, decoding, caching, and dataset adaptation.
- Adds exact GFS input-file enumeration and source-aware manifests.
- Adds comprehensive sflux behavior and compatibility tests.
| File | Description |
|---|---|
nos_utils/forcing/adcirc_met.py |
Implements sflux forcing support and input discovery. |
tests/test_adcirc_met.py |
Tests decoding, structure, interpolation, readiness, caching, and errors. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+652
to
654
| cand = _SOURCE_PATH[source](comin_gfs, valid - timedelta(hours=fh), fh) | ||
| if os.access(str(cand), os.R_OK): | ||
| return cand |
| if p.exists(): | ||
| p.unlink() | ||
| _write_sfcf_manifest(out_dir / "{}_{}.sfcf_manifest.json".format(prefix, segment), cycle, segment, used) | ||
| _write_sfcf_manifest(out_dir / "{}_{}.sfcf_manifest.json".format(prefix, segment), cycle, segment, used, source) |
…the used GFS input files
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.

Description
The STOFS-2D-Global ops-mode surface forcing builder (
build_sfcf_forcing) can now read the public GFS flux files (gfs.tHHz.sfluxgrbfFFF.grib2), not only the native-gridgfs.tHHz.sfcfFFF.ncfiles. The GFS sfcf netCDF files are public only to f012, so a machine without the operational GFS COM could not build the 180 h forecast forcing. The flux files are on AWS (noaa-gfs-bdp-pds) hourly to f120, then 3-hourly to f384, back to 2021-04. They use the same native Gaussian grid and hold the four fields:PRES:surface,UGRD/VGRDat 10 m, andICEC:surface.build_sfcf_forcing(..., source="sfcf"|"sflux"). The defaultsfcfis unchanged: its output is byte-identical to 5496da0.sfluxwraps each decoded GRIB file so it looks like an sfcf dataset. The existing build loop, windows, getges search and_interp_brackettherefore run unchanged.sflux_path,SFLUX_FIELDS(the wgrib2 match strings and the sfcf names).gfs_input_files(comin_gfs, cycle, segment, start=None, source=...)lists the exact files the builder reads, for a downloader or a preflight. For a 12z ncst: 06z f000-f005 and 12z f000. For fcst: f000-f120 hourly and both brackets of the interpolated hours past f120.wgrib2call per file:-order raw -no_header, an-if/-bin/-fiblock per field, and-grid..idxexists, or when it is older than the settle time; the getges search skips flux files that are not ready, so a half-downloaded file never wins.log_input_files(GFS_SFCF/GFS_SFLUX, category atmospheric), as the other forcing processors do, for both sources.Type of change
Change characteristics
source="sfcf".source="sflux"is new and opt-in.ADCIRC_GFS_SOURCEbumps to this. Its ops-copy staging helper needsncattrs/getncattron its dataset shim, which that PR adds.How has this been tested?
pytest: 1298 passed, 9 skipped, rc 0. The new tests cover:
gfs_input_filesand checks the manifest equals it, for ncst and fcst and both sources;Real files, 20261012 12z:
_decode_sfluxwith wgrib2 2.0.8 and 3.7.0 is bitwise identical to a pygrib decode, and the field means equal wgrib2's own-stats.End to end against the operational ncst forcing for 20261012 12z (
stofs_2d_glo_ncst.{221,222,225}.ncfrom the public NCO bucket):history/NCOglobal attributes.A full 181-record forecast build: 581 s and 1.2 GB peak memory.
Not yet run on Hercules or WCOSS2.
Checklist