evo-flood-risk-analysis
Detects flooding events at USGS streamgages by fetching instantaneous (15-min) gage height data, computing daily maximums, and comparing against NWS flood stage thresholds from the official NWS All Ga
Файлы2
Открыть в GitHubSKILL.mdtasks-evolved/flood-risk-analysis/environment/skills/evo-flood-risk-analysis/SKILL.md
GitHubevo-flood-risk-analysis
End-to-end pipeline for identifying flood days at USGS streamgages using gage height data and NWS flood stage thresholds.
Methodology
- Gage height (parameter 00065) is used — NOT discharge (00060).
- Daily maximum of instantaneous (15-min) readings is the aggregation method. Use
nwis.get_iv()to fetch instantaneous values, then resample to daily max with.resample('D').max(). - NWS flood stage thresholds come from the NWS All Gauges Report CSV at
https://water.noaa.gov/resources/downloads/reports/nwps_all_gauges_report.csv. Match stations by USGS site ID (usgs_idorgaugelidcolumn). The flood stage column issigstages.flood.stageor similar. - Flood condition:
daily_max_gage_height >= flood_stage(greater than or equal). - Only stations with a valid numeric NWS flood stage are evaluated.
- Only stations with at least one flood day are included in output.
- Sort output by
flood_daysdescending.
Key Technical Rules
- Preserve leading zeros: USGS station IDs are 8–15 digit strings (e.g.,
04031000). Always read/store as strings. - Parameter codes:
00065= gage height (ft). Use instantaneous values (get_iv), NOT daily values (get_dv). - Missing data: Use
pd.to_numeric(errors='coerce')to handle non-numeric sensor flags. - Tuple unpacking:
nwis.get_iv()returns(DataFrame, Metadata)— always unpack. - API rate limiting: Use brief
time.sleep(0.5)between station requests. - No fallback: Do NOT use discharge-based methods. Only gage height vs NWS flood stage.
Usage
import subprocess, sys
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'dataretrieval', '-q'])
sys.path.insert(0, '/app/environment/skills/evo-flood-risk-analysis/scripts')
from utils import run_flood_analysis
run_flood_analysis(
stations_file='/root/data/michigan_stations.txt',
out_file='/root/output/flood_results.csv',
start='2025-04-01',
end='2025-04-07'
)
Output
CSV with two columns: station_id (string, leading zeros preserved) and flood_days (int). Only stations with at least one flood day are included. Sorted by flood_days descending.