Download code/pipeline/steps/s19_finalize_selection.py from skyan1002/flash-flood-benchmark-data: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main/code/pipeline/steps/s19_finalize_selection.py
- Command line
-
hf download hf://datasets/skyan1002/flash-flood-benchmark-data/code/pipeline/steps/s19_finalize_selection.py
-
curl -L -o s19_finalize_selection.py https://huggingface.co/datasets/skyan1002/flash-flood-benchmark-data/resolve/main/code/pipeline/steps/s19_finalize_selection.py
1.29 kB
| """ | |
| 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() | |