mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Add a Wind layer animating the global 10 m wind field from NOAA GFS. The /api/wind proxy selects the latest available 0.25° cycle, reads its .idx inventory, byte-range fetches only the UGRD/VGRD 10 m GRIB2 messages (~1 MB each instead of the whole ~500 MB file), decodes them with ecCodes (WASM), resamples to a compact grid (1° default), and serves a manifest plus a Float32 U/V payload cached per cycle for an hour (single-flight, last-good on failure). The client renders nullschool-style particles in a canvas overlay: bilinear field sampling with longitude wrap, per-frame advection, Cesium camera projection, and globe-occlusion culling via EllipsoidalOccluder. Validated end-to-end against the real 2026-09-14 06z cycle on Node 25 (180x91 grid at 2°, 131,040-byte payload, plausible mean |u|/|v|). The WASM decoder requires Node >=24, which the repo already requires. Registered as `wind` (token k) with attribution and docs. Verified: npm test (3412 pass, 0 fail), npm run check:boundaries.
17 lines
745 B
JavaScript
17 lines
745 B
JavaScript
export const GFS_BUCKET = 'noaa-gfs-bdp-pds';
|
|
|
|
/** Build the public GFS object key. */
|
|
export function gfsObjectKey({ date, hour, forecastHour = 0 }) {
|
|
const hh = String(hour).padStart(2, '0');
|
|
return `gfs.${date}/${hh}/atmos/gfs.t${hh}z.pgrb2.0p25.f${String(forecastHour).padStart(3, '0')}`;
|
|
}
|
|
|
|
/** Select the latest GFS cycle that should be available. */
|
|
export function selectLatestGfsCycle(nowMs, { availabilityLagMs = 5 * 3600_000 } = {}) {
|
|
const d = new Date(nowMs - availabilityLagMs);
|
|
const date = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
|
|
const hour = Math.floor(d.getUTCHours() / 6) * 6;
|
|
date.setUTCHours(hour);
|
|
return { date: date.toISOString().slice(0, 10).replaceAll('-', ''), hour };
|
|
}
|