Skip to content

Enable processing of CM4 abrupt 4xCO2 ensemble - #1584

Open
spencerkclark wants to merge 13 commits into
mainfrom
scripts/process-cm4-abrupt-4xCO2-ensemble
Open

spencerkclark wants to merge 13 commits into
mainfrom
scripts/process-cm4-abrupt-4xCO2-ensemble

Conversation

@spencerkclark

@spencerkclark spencerkclark commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

This PR adds data processing configurations and slight code additions to accommodate the output from a 36-member abrupt-4xCO2 ensemble run with CM4.

Some code / ideas are borrowed from #1565, which adds similar time-coarsening functionality.

Changes:

  • Adds CM4-abrupt-4xCO2-ensemble-atmosphere-1deg-8layer.yaml and CM4-abrupt-4xCO2-ensemble-atmosphere-4deg-8layer.yaml to process the atmosphere and land data from the CM4 abrupt-4xCO2 ensemble at both 1° and 4° resolution and a Makefile rule to submit the argo jobs.
  • Adds cm4-abrupt-4xCO2-ensemble-ocean-1deg-1daily.yaml, cm4-abrupt-4xCO2-ensemble-ocean-1deg-5daily.yaml, cm4-abrupt-4xCO2-ensemble-ocean-4deg-1daily.yaml, and cm4-abrupt-4xCO2-ensemble-ocean-4deg-5daily.yaml configs to process ocean and sea-ice data to daily and 5-daily and 1° and 4° resolution.
  • Adds the ability to process an ensemble of runs instead of just a single run in the OM4 pipeline.
  • Adds the ability to specify a time_block_mean_factor for a data stream in the OM4 pipeline to support coarsening by interval averages and labeling by the interval endpoints.

@spencerkclark
spencerkclark force-pushed the scripts/process-cm4-abrupt-4xCO2-ensemble branch 4 times, most recently from 92d6a7d to bda8984 Compare October 19, 2026 19:15
@spencerkclark
spencerkclark force-pushed the scripts/process-cm4-abrupt-4xCO2-ensemble branch from bda8984 to bb4f0d9 Compare October 19, 2026 19:29
@spencerkclark
spencerkclark marked this pull request as ready for review October 19, 2026 19:32
@spencerkclark spencerkclark changed the title Add processing configs for CM4 abrupt-4xCO2 ensemble Make updates necessary for processing CM4 abrupt 4xCO2 ensemble Oct 19, 2026
@spencerkclark spencerkclark changed the title Make updates necessary for processing CM4 abrupt 4xCO2 ensemble Enable processing of CM4 abrupt 4xCO2 ensemble Oct 19, 2026
@jpdunc23

Copy link
Copy Markdown
Member

Pre-review agent: No blockers; every code path we probed at 955619b is correct. Before merge, please add unit tests for the new time-coarsening helpers and say in the PR body whether any member is held out of the normalization stats.

Full review

Findings

# sev where issue suggested fix
1 medium scripts/gfdl_om4/pipeline/om4/run.py: _coarsen, _select_whole_blocks, stream_output_time, the process_chunk re-key, the math.lcm read width, --num-timesteps scaling; config.py: StreamConfig.__post_init__, PipelineConfig.__post_init__ No automated test covers the new time-indexing logic. Changing _coarsen to mean(skipna=True), labelling blocks by their first timestamp, or dropping the size % factor raise all pass every repo test, and the skipna change would not fail at runtime either. Add unit tests on a small synthetic cftime dataset. The reviewer has probe scripts that exercise each helper and can share them as test seeds.
2 medium (question) scripts/data_process/configs/CM4-abrupt-4xCO2-ensemble-atmosphere-{1,4}deg-8layer.yaml stats Compared with the CM4-like-AM4-random-CO2-ensemble-atmosphere-* configs, the only non-path differences are the missing stats.exclude_runs and stats.start_date. The stats therefore pool all 36 members, so a member later used for validation leaks into normalization, and the 90-day and 1-year members are weighted by length. Dropping start_date is fine for an abrupt run. State the hold-out plan; add exclude_runs if there is one.
3 low scripts/gfdl_om4/om4.mk dataflow_abrupt_4xco2_*_all; README "or all 36" run.main blocks on the pipeline and run-dataflow.sh runs under set -e, so plain make launches the 36 Dataflow jobs one after another and the first failure stops the rest. Document make -k / make -j N, or launch the jobs detached.
4 low om4.mk dataflow_abrupt_4xco2_{1,4}deg_% vs dataflow_abrupt_4xco2_{1,4}deg_1daily_% The comment relies on the shortest-stem rule, which arrived in GNU Make 3.82. GNU Make 3.81 (macOS /usr/bin/make) picks the first matching rule, so dataflow_abrupt_4xco2_1deg_1daily_ic_0001 would run the 5-daily config with MEMBER=1daily_ic_0001 and fail at store open. Put the _1daily_% rules before the 5-daily ones; that order works under both versions.
5 low configs/cm4-abrupt-4xCO2-ensemble-ocean-{1,4}deg-1daily.yaml No start_time. The sibling cm4-piControl-1deg-1daily.yaml uses it to drop an initial-condition snapshot. If any member's store has that instant, _assert_time_alignment raises. Confirm every member's store starts at the end of day 1.
6 low generate_face_masks_abrupt_4xco2; face_mask_url in the ocean configs One face-mask artifact, scanned from the stride-5 days of ic_0001, serves every member at both frequencies. A missed face raises mid-job; it does not corrupt output. None needed. Optionally scan the 1-daily config too.
7 low pipeline/om4/postprocess.py hfds_total_area derivation is rebuilt from a fixed string, so the 5-daily hfds_total_area does not record that it is a 5-day block mean. The values are correct. Carry hfds's derivation forward with append_derivation.
8 low PR body The body does not mention: _rotate_pairs now appends to an existing derivation instead of overwriting it; check_member_wetmask_equivalence; the shared face mask; the new smoke and dataflow targets. Extend the description.
9 low scripts/data_process/Makefile cm4_abrupt_4xCO2_ensemble_atmosphere The config path is inline in the recipe, and the test_config.py regexes only check CONFIG_* variables. Changing it to a non-existent path still passes. Same pattern as the random-CO2 rule. Optional: move it into a CONFIG_* variable.
10 nit README config.py bullet One line is not wrapped. Wrap it.

Linearity assumption

Coarsening runs before rotation, regridding and hfds_total_area. This is correct only because each of those steps is linear in time with static weights (rotation angle, regrid weights, wetmask, ocean fraction). A later postprocess that is nonlinear, or that uses a time-varying field on a coarsened stream, would give mean(f(x)) != f(mean(x)) without any error. A docstring note on StreamConfig.time_block_mean_factor would guard this.

Checks run

  • scripts/data_process: pytest test_config.py passes.
  • New OM4 helpers probed on a synthetic 20-day cftime dataset: block means, label positions, offset re-key, partial-block and misaligned-chunk raises, NaN propagation and StreamConfig validation all behave as documented. All four ocean configs load with ic_0001 and raise without a member.

— 🤖 Drafted by Claude (Opus 5.5) via Claude Code, posted on @jpdunc23's behalf.

@jpdunc23 jpdunc23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

See #1584 (comment) for some optional updates, most are very minor. It might be good to add test coverage if you have time, but non-blocking.

This branch has not been deployed

No deployments
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.

2 participants