Add hurs and hursmin squeezing script - #113
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new post-processing utility to the bias-adjustment workflow to “squeeze” (clip) bias-adjusted relative humidity outputs (hurs, hursmin) into the physically valid [0, 100] range, while generating per-file out-of-range statistics and a combined summary CSV.
Changes:
- Introduces
bias_adjust/squeeze_hurs.pyto scan for adjustedhurs/hursminZarr stores, compute out-of-range counts/percentages, clip values to bounds (NaN-preserving), and write “squeezed” outputs. - Writes outputs into
hurs_squeezed/andhursmin_squeezed/subdirectories and emitshurs_hursmin_squeeze_summary.csv. - Adds
--skip-existingto allow resuming runs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cstephen
left a comment
There was a problem hiding this comment.
I copied some 4km and 12km hurs and hursmin outputs (for the MIROC6 model), ran the squeeze_hurs.py against them, and verified that the squeeze counts matched the CSVs mentioned in the PR description. I also verified that the squeeze counts matched my earlier counts_outside_thresholds.py outputs from a ~month ago, and then re-used the counts_outside_thresholds.py script to confirm that no values existed below 0 or above 100 in the post-squeeze Zarr outputs. Everything looks good here!
This branch adds
bias_adjust/squeeze_hurs.py, a post-processing script that clips bias-adjustedhurs(mean daily relative humidity) andhursmin(minimum daily relative humidity) zarr files to the physically valid [0, 100] range.What it does
hurs*_adjusted.zarrfileshurs_squeezed/andhursmin_squeezed/subdirectories created within the user supplied input directoryhurs_hursmin_squeeze_summary.csvwith per-file stats (counts and percentages of clipped values)--skip-existingflag to resume interrupted runsHow to test:
hursandhursminzarr outputs from the directories below into any directory of your choice:srun --partition=analysis --mem=250GB --pty /bin/bash conda activate cmip6-utils cd /beegfs/CMIP6/jdpaul3/cmip6-utils/bias_adjust/ python squeeze_hurs.py /path/to/your/copied/outputs/hurs_hursmin_squeeze_summary_4km.csv
hurs_hursmin_squeeze_summary_12km.csv