Skip to content

Tripolar north-fold examples (new fold-boundary API)#24

Open
hdrake wants to merge 18 commits into
xgcm:masterfrom
hdrake:tripolar-fold-examples
Open

Tripolar north-fold examples (new fold-boundary API)#24
hdrake wants to merge 18 commits into
xgcm:masterfrom
hdrake:tripolar-fold-examples

Conversation

@hdrake

@hdrake hdrake commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Example notebooks for xgcm's new single-tile north-fold boundary
(boundary={"X": "periodic", "Y": {"fold": <pivot>}}), which replaces the
experimental two-face face_connections 4-tuple. Pairs with xgcm/xgcm#711.

  • 06_tripolar_fold.ipynb — demonstrates the fold via relative vorticity
    for three models, each with real surface velocities uo/vo, on a
    North Polar Stereographic projection where the naive-minus-fold difference
    isolates the fold as a line across the Arctic:
    • MOM6 — GFDL-CM4 (CMIP6, Pangeo cloud), "corner" pivot.
    • NEMO eORCA1 — IPSL-CM6A-LR (CMIP6, Pangeo cloud), "corner" pivot.
    • Oceananigans — a realistic 1° global ClimaOcean run (ECCO-init,
      JRA55-forced), "u" pivot — an independent third convention.
  • 03_MOM6.ipynb — getting-started tutorial rewritten to use GFDL-CM4
    surface velocities (interp to centre for surface speed, velocity curl).
  • scripts/run_one_degree_simulation.jl (ClimaOcean 1° on CPU) +
    jld2_to_netcdf.jl to produce the Oceananigans dataset (to be posted to
    Zenodo); environment.yml (conda, incl. cartopy/zarr/gcsfs).

Builds on the MOM6 tripolar work in #23.

🤖 Generated with Claude Code

hdrake and others added 4 commits May 31, 2026 08:40
Adds a self-contained section demonstrating how to represent the MOM6
tripolar grid's bipolar Arctic fold with xgcm's face_connections (using
the new `fold` connection flag in xgcm). The grid is split into two
full-height faces joined periodically in X and by the fold along their
northern edge, and the section verifies the fold halo against the
geometric neighbour and shows the velocity sign convention via MOM6's
seam transport.

Also notes that the original GFDL thredds data server is offline and
points to the Zenodo archive used by the new section.

Requires the bipolar-fold feature from xgcm/xgcm#707.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the dead GFDL thredds download with the full-resolution MOM6
example output archived on Zenodo (record 15420739), and recast the
notebook around the variables that archive actually provides:

- Load the vertically-integrated mass-budget file directly from Zenodo;
  drop the now-redundant separate ocean_grid_sym download (geolon_c /
  geolat_c are already included).
- Build the grid for the symmetric-memory layout (xq/yq are the `outer`
  position).
- Recast the vorticity demo as the curl of the vertically-integrated mass
  transport (umo, vmo), which lands on the cell corners.
- Point the bipolar-fold section at the same dataset (no second download).

Requires the bipolar-fold feature from xgcm/xgcm#707.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use boundary={"X": "periodic", "Y": {"fold": "corner"}} on a single grid
tile instead of the experimental two-face face_connections 4-tuple, and
verify the scalar fold halo, the fold-halo latitudes, and the vector
(vmo) sign flip across the seam.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 06_tripolar_fold.ipynb: demonstrate the tripolar fold via relative
  vorticity for MOM6, NEMO eORCA1 (IPSL-CM6A-LR), and Oceananigans; the
  naive (X-periodic) vs fold-aware vorticity differ only at the fold seam.
- 07_oceananigans_tripolar.ipynb: Oceananigans TripolarGrid fold check
  (tracer zipper + vector sign flip), with the generating Julia script.
- scripts/generate_oceananigans_tripolar.jl: reproducible dataset generator.
- Readme: document the new examples and their data sources.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

hdrake and others added 14 commits June 2, 2026 05:06
…rticity

- Remove the tripolar fold section from 03_MOM6 (now covered by 06).
- Remove 07_oceananigans_tripolar.ipynb (redundant with 06's Oceananigans
  vorticity demo).
- 06_tripolar_fold.ipynb: plot the naive/fold-aware/difference relative
  vorticity on a North Polar Stereographic projection, so the fold shows as
  a line across the Arctic between the two grid poles.
- Add environment.yml (conda) for running the examples, including cartopy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The MOM6 sections of 03_MOM6 and 06_tripolar_fold previously used the
vertically-integrated mass transports umo/vmo, which are not the right field
for a velocity curl / relative vorticity. Replace them with surface ocean
velocities uo/vo from CMIP6 GFDL-CM4 (MOM6 on its native tripolar grid), read
anonymously from the Pangeo cloud — mirroring the IPSL-CM6A-LR (NEMO) example.

- 03_MOM6: getting-started tutorial now interpolates uo/vo to cell centres for
  surface speed and computes the velocity curl, on GFDL-CM4 cloud data.
- 06_tripolar_fold: MOM6 vorticity-fold section uses GFDL-CM4 uo/vo.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
scripts/run_one_degree_simulation.jl adapts ClimaOcean's one_degree_simulation
to run locally on CPU (realistic TripolarGrid + ETOPO bathymetry, ECCO4 init,
JRA55 forcing), writing surface u/v/T to JLD2 frequently so an early-stopped
run is usable. scripts/jld2_to_netcdf.jl converts the latest snapshot to the
NetCDF schema consumed by 06_tripolar_fold (Oceananigans section). Env pinned
in scripts/climaocean_env. Output data is gitignored (to be posted to Zenodo).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ample

Replace the minimal synthetic TripolarGrid dataset with a surface snapshot
from a realistic 1-degree global ClimaOcean/Oceananigans simulation
(ECCO-initialized, JRA55-forced, real ETOPO bathymetry), run ~0.75 model-days
past the barotropic adjustment via scripts/run_one_degree_simulation.jl and
converted to NetCDF with scripts/jld2_to_netcdf.jl. The Oceananigans section
of 06_tripolar_fold now shows real Arctic surface vorticity; its U-point
("u") fold pivot is an independent check vs MOM6/NEMO ("corner"). Drop the
superseded synthetic generator. Output data is gitignored (to be posted to
Zenodo).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Integrate past the initial barotropic adjustment to a spun-up state; save one
surface snapshot per model-day so day 10 is the final output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Units)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Re-run the realistic 1-degree global ClimaOcean/Oceananigans simulation to a
spun-up day-10 surface state (t = 864000 s) and regenerate the Oceananigans
section of 06_tripolar_fold from it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…scaling

Add a log-scaled global surface current speed map for the Oceananigans run,
interpolating u/v to tracer points (v reaches across the fold) as a clean,
metric-free check that the fold gives smooth fields across the Arctic seam.
Note that the relative-vorticity panels use index-space finite differences
(unscaled), so near-pole magnitudes are dominated by grid convergence; the
fold changes only the seam row, isolated by the naive-minus-fold panel.

xgcm's reconstructed fold halos were verified to match Oceananigans' own
zipper exactly (tracer + both velocity components).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…olar

Reframe 06 around testing diff and interp across the north fold:
- surface current speed (u, v interpolated to tracer points) -- tests interp;
- relative vorticity zeta = diff(v,'X')/dx - diff(u,'Y')/dy, now divided by the
  cell spacings (great-circle distances), so it is the physical vorticity and
  near-pole magnitudes are no longer inflated by grid convergence -- tests diff.
Both are plotted on North Polar Stereographic projections for MOM6 (GFDL-CM4),
NEMO (IPSL-CM6A-LR), and Oceananigans, and are smooth across the fold; the naive
(no-fold) vorticity differs only on the single seam row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Ro=zeta/f

Restructure each diagnostic as a 3x3 grid (columns = models; rows = naive
no-fold / fold-aware / difference):
- surface speed from interp, shown interpolated to BOTH tracer centres (v->centre
  crosses the fold) and cell corners (u->corner crosses it), so both velocity
  components are exercised across the seam;
- Rossby number Ro = zeta/f, with zeta = diff(v,'X')/dx - diff(u,'Y')/dy divided
  by the cell spacings and the Coriolis parameter f = 2 Omega sin(phi).
Mask land (missing values, and zeros where they dominate, e.g. the Oceananigans
immersed boundary). Mask fold/dateline wrap cells and scale the difference panels
by their non-zero magnitude so the (seam-only) difference renders correctly.
For all three models both operations are smooth across the fold and differ from
the naive calculation only on the single fold row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Relative-vorticity (Rossby) panels use a fixed colour range of +/- 0.05.
- All maps zoom to latitudes 60-90.
- Land (masked with NaN) is filled grey in every panel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…oise

The low-resolution models have very small Arctic Rossby numbers, so use a
+/-0.01 colour range. Add a note explaining that the band of vorticity at the
fold in the Oceananigans panel lives in the model's velocity field (grid-scale
north-fold noise), not in xgcm's fold operators -- it is identical in the naive
and fold-aware columns.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The single fold row was hard to read and sat next to a grey "no data" line
(the old _wrap_mask dropped the seam, and shading="nearest" + cartopy's
PlateCarree wrap smeared/blanked it). Re-plot the fold so its correctness is
obvious:

- Seamless polar cap: reconstruct the cell-corner lattice *through* the fold
  (xgcm fold-pad of the centre coords, averaged in 3-D so pole/dateline are
  clean) and pcolormesh(shading="flat") in self-projected stereographic
  coords. The Arctic is now one continuous mesh with no masked seam and no
  antimeridian smear; the difference row, normalised per panel, lights up the
  exact cells the fold changes -- a thin line across the pole.
- Cross-fold transect: continue the surface-speed field across the seam into
  the halo. The fold fills it with the true partner row (a smooth physical
  continuation); the naive boundary just flatlines. Shown for all three
  pivots (MOM6/NEMO "corner", Oceananigans "u").

Builder saved as scripts/build_06.py; the previous grey-seam builder kept as
scripts/build_06_maps_v1.py for easy revert.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant