skyan1002's picture
Add DOWNLOAD.md (detailed download guide + code)
d46f230 verified

How to download the CONUS Flash-Flood Benchmark (L1–L3)

Hugging Face dataset: skyan1002/flash-flood-benchmark-data Resolve base (every file has a stable URL of this form):

https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main/<path>

This guide shows every supported way to query (by level / US state / time range / L3 attributes) and download — from a bare terminal (curl), jq, Python (huggingface_hub, datasets, pandas), DuckDB, the hosted datasets-server API, and the ffbench helper.


0. Mental model — 3 things

  1. Manifest = discover. manifest.jsonl is one line per record (a catalog row at L1/L2/L3) or per artifact (a downloadable L3 file). Filter it locally.
  2. resolve_url = download. Every artifact row carries a precomputed direct URL. Just curl -L it.
  3. Levels: L1 = national NCEI flash-flood episodes (1996–2025, 42,466); L2 = observation-availability episodes (2021–2025, 5,424); L3 = evaluation-ready gauge testbeds (688; 152 strict; 47 NCEI-confirmed; 26 with return period ≥ 2 yr).

Filter keys present on every row: level, ff_episode_id, gage_id, year, month, begin_date (YYYY-MM-DD), primary_state_abbrev (2-letter — the state key), all_states_abbrev (pipe-joined, e.g. NJ|NY|PA). L3 adds benchmark_tier, flash_flood_class, is_strict_flash_flood, selected, lp3_return_period_yr, peak_value, …


1. Quickest path — curl + jq

BASE=https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main

# (a) fetch the index once (~40 MB, comma-safe JSONL)
curl -sL "$BASE/manifest.jsonl" -o manifest.jsonl

# (b) SCREEN by level + state + time range  (L3 strict flash floods, TX, July 2025)
jq -c 'select(.record_type=="record" and .level=="L3"
        and .primary_state_abbrev=="TX" and .is_strict_flash_flood==true
        and .begin_date>="2025-07-01" and .begin_date<="2025-07-31")
       | {testbed_id, station_name, lp3_return_period_yr, peak_value}' manifest.jsonl

# (c) DOWNLOAD every file for one testbed (resolve URLs precomputed; -L follows the LFS redirect)
jq -r 'select(.testbed_id=="FF_2025_07_TX_ep002__08167000" and .record_type=="artifact").resolve_url' \
  manifest.jsonl | xargs -n1 curl -L -O

# (d) Download ONE kind across a curated subset (e.g. just hydrographs for selected & RP>=2)
jq -r 'select(.selected==true and .lp3_return_period_yr>=2 and .artifact_kind=="streamflow").resolve_url' \
  manifest.jsonl | while read -r u; do curl -L -C - -O "$u"; done

# (e) BUDGET first: total bytes a filter would pull
jq -r 'select(.selected==true and .artifact_kind=="package_zip").bytes' manifest.jsonl \
  | awk '{s+=$1} END{printf "%.1f MB\n", s/1e6}'

artifact_kind values: streamflow, watershed, hwms_inside, summary, mrms_basin_mean (these five are loose single files), package_zip (the full per-testbed package), bundle.


2. No jq? (curl only)

BASE=https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main
# each manifest line is self-contained, so grep works; pull VT package zips:
curl -sL "$BASE/manifest.jsonl" \
  | grep '"primary_state_abbrev":"VT"' | grep '"artifact_kind":"package_zip"' \
  | grep -o '"resolve_url":"[^"]*"' | cut -d'"' -f4 \
  | while read -r u; do curl -L -C - -O "$u"; done

Do not awk -F, / cut -d, the raw CSVs in catalog/raw_csv/ — narrative/state fields contain commas and will misalign columns. Use jq on the JSONL, the Parquet, the /filter API, or a real CSV parser.


3. Hosted query API — datasets-server /filter (no manifest download)

Server-side filtering/paging over the typed Parquet (config = one per level): l1_episodes, l1_locations, l2_episodes, l3_testbeds, l3_hwms, manifest.

curl -sG https://datasets-server.huggingface.co/filter \
  --data-urlencode 'dataset=skyan1002/flash-flood-benchmark-data' \
  --data-urlencode 'config=l3_testbeds' \
  --data-urlencode 'split=train' \
  --data-urlencode "where=\"primary_state_abbrev\"='TX' AND year=2025 AND is_strict_flash_flood=true" \
  --data-urlencode 'orderby=lp3_return_period_yr DESC' \
  --data-urlencode 'length=100' \
  | jq '.rows[].row | {testbed_id, lp3_return_period_yr, package_zip_path}'

Rules: double-quote column names, single-quote string literals, URL-encode the where, length ≤ 100 (page with offset). Related endpoints: /rows (raw paging), /search (full-text), /statistics. Note: after a dataset update the server re-indexes for a few minutes, during which /filter may return an error — the manifest path (sections 1–2) always works.


4. Python — huggingface_hub (recommended for scripts)

# pip install huggingface_hub
from huggingface_hub import hf_hub_download, snapshot_download
import json, urllib.request

REPO = "skyan1002/flash-flood-benchmark-data"

# 4a. one file
p = hf_hub_download(REPO, "manifest.jsonl", repo_type="dataset")
rows = [json.loads(l) for l in open(p)]

# 4b. filter in Python, then fetch each artifact
hits = [r for r in rows
        if r["record_type"] == "record" and r["level"] == "L3"
        and r["primary_state_abbrev"] == "NM" and (r.get("lp3_return_period_yr") or 0) >= 10]
print(len(hits), "testbeds")

for r in rows:
    if r["record_type"] == "artifact" and r.get("testbed_id") == "FF_2024_07_NM_ep001__08387000":
        local = hf_hub_download(REPO, r["rel_path"], repo_type="dataset")
        print(local)

# 4c. bulk: pull only what a glob matches (e.g. all light streamflow files + the L3 catalog)
snapshot_download(REPO, repo_type="dataset",
                  allow_patterns=["catalog/l3_testbeds.parquet", "testbeds/*/*/streamflow.csv"],
                  local_dir="./ffbench_data")

# 4d. one curated bundle
hf_hub_download(REPO, "bundles/testbeds_selected26.zip", repo_type="dataset",
                local_dir="./bundles")

5. Python — datasets library (tabular catalogs)

# pip install "datasets>=2.18"
from datasets import load_dataset

l3 = load_dataset(REPO, "l3_testbeds", split="train")          # 688 rows
tx = l3.filter(lambda r: r["primary_state_abbrev"] == "TX" and r["is_strict_flash_flood"])
print(tx["testbed_id"][:5])

l1 = load_dataset(REPO, "l1_episodes", split="train")          # 42,466 rows
# configs: l1_episodes, l1_locations, l2_episodes, l3_testbeds, l3_hwms, manifest

6. SQL over the Parquet — DuckDB (power query, no download of the whole table)

# pip install duckdb
import duckdb
duckdb.sql("INSTALL httpfs; LOAD httpfs;")
BASE = "https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main"
duckdb.sql(f"""
  SELECT testbed_id, primary_state_abbrev, begin_date, lp3_return_period_yr
  FROM read_parquet('{BASE}/catalog/l3_testbeds.parquet')
  WHERE primary_state_abbrev='TX' AND is_strict_flash_flood
    AND begin_date BETWEEN '2025-07-01' AND '2025-07-31'
  ORDER BY lp3_return_period_yr DESC
""").show()

pandas works the same way: pd.read_parquet(f"{BASE}/catalog/l3_testbeds.parquet") then filter.


7. Helper CLI — ffbench

BASE=https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main
curl -sL "$BASE/ffbench" -o ffbench && chmod +x ffbench

./ffbench query    --level l3 --state TX --start 2025-07-01 --end 2025-07-31 --strict
./ffbench get      FF_2025_07_TX_ep002__08167000 --out ./tx_testbed
./ffbench download --level l3 --selected --rp-min 2 --kind streamflow --out ./hydrographs
./ffbench bundle   selected26

Needs only curl (uses jq if present, else falls back to grep). help prints all flags.


8. One-shot bundles (whole curated subsets)

BASE=https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main
curl -L -C - -O "$BASE/bundles/testbeds_selected26.zip"   # 26 selected & RP>=2  (~171 MB)
curl -L -C - -O "$BASE/bundles/testbeds_strict152.zip"    # 152 strict flash floods (~917 MB)
unzip testbeds_selected26.zip

To get everything (all 688 packages, ~4 GB):

from huggingface_hub import snapshot_download
snapshot_download("skyan1002/flash-flood-benchmark-data", repo_type="dataset",
                  allow_patterns=["packages/*.zip"], local_dir="./all_packages")

or clone the whole repo (needs git-lfs):

git lfs install
git clone https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data

9. Filtering cheat-sheet (level + state + time)

Want jq predicate (on manifest.jsonl)
Level .level=="L3" (or "L1"/"L2")
Primary state .primary_state_abbrev=="TX"
Any state touched (.all_states_abbrev|test("(^|\\|)TX(\\||$)"))
Date range .begin_date>="2025-07-01" and .begin_date<="2025-07-31"
Year / month .year==2025 , .month==7
L3 tier / class .benchmark_tier=="A" , .flash_flood_class=="flash_flood"
Strict flash flood .is_strict_flash_flood==true
Curated (NCEI-confirmed) .selected==true
Return period ≥ N yr .lp3_return_period_yr>=10
Records vs files .record_type=="record" vs .record_type=="artifact"

Per-level examples:

# L1: all NM episodes in 2024
jq -c 'select(.level=="L1" and .primary_state_abbrev=="NM" and .year==2024)|.ff_episode_id' manifest.jsonl
# L2: episodes Aug 2021 with observations available, VA
jq -c 'select(.level=="L2" and .primary_state_abbrev=="VA" and .begin_date>="2021-08-01" and .begin_date<="2021-08-31")|.ff_episode_id' manifest.jsonl
# L3: download the package zips for every selected testbed
jq -r 'select(.selected==true and .artifact_kind=="package_zip").resolve_url' manifest.jsonl | xargs -n1 curl -L -O

10. Download contract & integrity

  • Always use curl -L. Large files are Git-LFS objects that 302-redirect to a CDN; without -L you get a tiny pointer, not the data. Add -C - to resume interrupted downloads.
  • Verify integrity with the manifest's sha256:
    jq -r 'select(.testbed_id=="FF_2025_07_TX_ep002__08167000" and .artifact_kind=="package_zip")
           | "\(.sha256)  \(.rel_path|split("/")|last)"' manifest.jsonl > pkg.sha256
    curl -L -O "$BASE/packages/FF_2025_07_TX_ep002__08167000.zip"
    sha256sum -c pkg.sha256
    
  • Gridded forcing (MRMS / CREST) ships inside packages/<id>.zip as zarr v3 directories. After unzip, open with zarr.open_group("…/mrms_2min_precip.zarr")not xr.open_zarr. The light mrms_2min_precip_basin_mean.csv is the curl-friendly basin-mean alternative if you don't need the grid.
  • gage_id has leading zeros (e.g. 08167000) — always treat it as a string.

11. What's in a testbed package

packages/<ff_episode_id>__<gage_id>.zip contains:

streamflow.csv                     # 15-min USGS discharge (cfs)
watershed.geojson                  # NLDI basin polygon
hwms_inside.csv                    # in-basin USGS/FEMA high-water marks
testbed_summary.json              # peak, baseline, RP, flashiness metrics, tier, ...
mrms_2min_precip_basin_mean.csv    # basin-mean MRMS precip time series
mrms_2min_precip.zarr/             # gridded MRMS PrecipRate (2-min)
crest_maxunitstreamflow.zarr/      # gridded CREST max unit streamflow (10-min)
dem.tif                            # 3DEP DEM (~30 m)
crest_maxunitstreamflow_peak.tif   # CREST temporal-max raster
figures/                           # hydrograph.png, watershed_map.png (figure5.png where present)

The first five also exist as loose files under testbeds/<ep>/<gage>/ for single-file curl.


12. Provenance

Derived from public USGS (NWIS, STN, NLDI, 3DEP) and NOAA (NCEI Storm Events, NSSL MRMS / FLASH-CREST). License CC-BY-4.0. For byte-reproducibility pin a commit: …/resolve/<commit-sha>/<path> instead of …/resolve/main/<path>. See CITATION.cff.