Skip to content

Add hurs and hursmin squeezing script - #113

Merged
cstephen merged 1 commit into
mainfrom
squeeze_hurs_hursmin
Jun 11, 2026
Merged

Add hurs and hursmin squeezing script#113
cstephen merged 1 commit into
mainfrom
squeeze_hurs_hursmin

Conversation

@Joshdpaul

Copy link
Copy Markdown
Contributor

This branch adds bias_adjust/squeeze_hurs.py, a post-processing script that clips bias-adjusted hurs (mean daily relative humidity) and hursmin (minimum daily relative humidity) zarr files to the physically valid [0, 100] range.

What it does

  • Scans an input directory for all hurs*_adjusted.zarr files
  • Counts and logs values below 0 and above 100 with percentages before clipping (Jeremy requested this info for the manuscript)
  • Clips out-of-range values to the [0, 100] bounds while preserving NaNs
  • Writes squeezed outputs to hurs_squeezed/ and hursmin_squeezed/ subdirectories created within the user supplied input directory
  • Saves a hurs_hursmin_squeeze_summary.csv with per-file stats (counts and percentages of clipped values)
  • Supports --skip-existing flag to resume interrupted runs

How to test:

  • Copy some of the 12km or 4km hurs and hursmin zarr outputs from the directories below into any directory of your choice:
/beegfs/CMIP6/jdpaul3/cmip6_downscaled_llm_fixes_4km_new_vars/sfcWind_hurs_hursmin/adjusted/
/beegfs/CMIP6/jdpaul3/cmip6_downscaled_llm_fixes_12km_new_vars/sfcWind_hurs_hursmin/adjusted/
  • Run the new script like so:
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/

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to scan for adjusted hurs/hursmin Zarr stores, compute out-of-range counts/percentages, clip values to bounds (NaN-preserving), and write “squeezed” outputs.
  • Writes outputs into hurs_squeezed/ and hursmin_squeezed/ subdirectories and emits hurs_hursmin_squeeze_summary.csv.
  • Adds --skip-existing to allow resuming runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bias_adjust/squeeze_hurs.py
Comment thread bias_adjust/squeeze_hurs.py
Comment thread bias_adjust/squeeze_hurs.py
Comment thread bias_adjust/squeeze_hurs.py
Comment thread bias_adjust/squeeze_hurs.py
Comment thread bias_adjust/squeeze_hurs.py
@Joshdpaul
Joshdpaul requested a review from cstephen June 10, 2026 16:20

@cstephen cstephen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@cstephen
cstephen merged commit fb69b43 into main Jun 11, 2026
1 check passed
@Joshdpaul
Joshdpaul deleted the squeeze_hurs_hursmin branch June 11, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants