File size: 1,294 Bytes
378f073 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | """
s19_finalize_selection.py
Finalize the benchmark testbed selection.
Reads the deduplicated strict testbeds (L3/l3_testbeds_strict_dedup.csv, produced by
s16_dedup_select.py with return-period columns re-merged by s17_return_period.py;
legacy ds_260603 numbering: s28 and s27) and keeps the curated final set:
rows that are both `selected` (>=1 NCEI flash-flood point in the watershed) AND have
a fitted LP3 return period >= config.RP_MIN_FINAL years.
All columns are preserved. Writes L3/l3_final_selected.csv and reports the number of
testbeds and unique ff_episode_id.
Run: python s19_finalize_selection.py
"""
import sys, pathlib
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
import config
from lib import io, geo, nwis, nldi
import pandas as pd
DEDUP = config.B_L3 / "l3_testbeds_strict_dedup.csv"
OUT = config.B_L3 / "l3_final_selected.csv"
def main():
df = pd.read_csv(DEDUP, low_memory=False)
sel = df[(df["selected"] == True) # noqa: E712
& (df["lp3_return_period_yr"] >= config.RP_MIN_FINAL)].copy()
sel.to_csv(OUT, index=False)
print(f"Wrote {OUT}")
print(f" final testbeds : {len(sel)}")
print(f" unique ff_episode_id : {sel['ff_episode_id'].nunique()}")
if __name__ == "__main__":
main()
|