Skip to content

feat(examples): add a zarr-globe example - #794

Merged
kylebarron merged 14 commits into
mainfrom
kyle/zarr-globe-example
Nov 6, 2026
Merged

kylebarron merged 14 commits into
mainfrom
kyle/zarr-globe-example

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

The globe-view prototype (#563) added a COG globe example, but nothing showed the Zarr path on a globe. This adds examples/zarr-globe, which animates ECMWF's AIFS Single 2 m temperature forecast on MapLibre's globe projection with deck.gl interleaved. It's the dynamical-zarr-ecmwf example on a globe, but reads a different forecast so that the whole visible half of the globe loads quickly. The shared globe render path already handles ZarrLayer, so no library changes are needed.

Why AIFS Single, not the IFS ensemble

dynamical-zarr-ecmwf reads the IFS ensemble (ENS). Each of its inner chunks holds 32x32 pixels for all 85 lead times and all 51 ensemble members, and the example draws one member. On a globe, the first view is 558 such tiles: about 1.3 GB in 558 requests, of which 2% is drawn, and it took 3.5 minutes to load.

The AIFS Single store, from the same dynamical.org bucket, has no ensemble dimension, and each inner chunk holds 241x240 pixels (60°x60°) for all 61 lead times. The whole globe is 18 chunks, of 24-39 MB in total depending on the run. In Chrome, with the browser cache off, the example's first view loaded in about 7 seconds, from 22 requests and 24 MB.

Changes

  • New examples/zarr-globe (package deck.gl-zarr-globe-example), with the data pipeline and controls of dynamical-zarr-ecmwf: it opens the store with ZarrSource.open(store, { path }), checks the data type with is, and passes the source to ZarrLayer. For the globe it follows cog-globe: projection="globe", parameters: { depthCompare: "always" } on the layer so the raster does not z-fight the basemap sphere, and a black background around the globe.
  • Differences from dynamical-zarr-ecmwf, for AIFS: no ensemble member in the selection; 61 lead times at a fixed 6-hour step, so each frame shows for the same time (200 ms by default); a forecast run every 6 hours, with the run's hour next to the date picker; no maxCacheSize, so tiles stay cached as the globe turns; and a default colour range of -20 to 40 °C, which fits the temperatures in the default view better than -40 to 50 °C, while the filter keeps -40 to 50 °C.
  • Declares the grid "spatial:registration": "node": the store's coordinates put each value on its grid point, from 90° to -90° and -180° to 179.75°. fix(examples): declare the ECMWF grid node-registered #862 makes the same change in dynamical-zarr-ecmwf. The edge cells reach 0.125° past the poles, which fix(deck.gl-raster): clamp globe mesh latitudes to the poles #858 clamps on the globe.
  • Uses the hosted Dark Matter style with beforeId: "boundary_country_outline", as cog-globe does, instead of copying the flat example's custom water-less style.
  • Docs examples page: a "Globe View" card in the Zarr section, with a card image. The card shows +6 h of the 06 UTC run, midday over Africa. It was taken after fix(deck.gl-raster): clamp globe mesh latitudes to the poles #858, which fixed dots that showed where the far-side South Pole lands.
  • pnpm-lock.yaml: adds the new importer only. The docs workflow and the pnpm workspace already pick up examples/*.

Tests

  • Example-only change, no new tests. The workspace typecheck and the example build pass, and Biome is clean.
  • Checked in Chrome: the forecast drapes on the globe with country borders and labels on top, with no z-fighting. Zooming in fetches nothing new, the animation advances one 6 h step every 200 ms, and the console shows no errors.

Notes

  • Near the globe's limb the raster can stop short, leaving slivers of basemap. The cause isn't known yet. It would be in the shared globe path, so it is not addressed here.

Closes #568

🤖 Written by Claude Code

The globe-view prototype added a COG globe example, but nothing showed the
Zarr path on a globe. Add `examples/zarr-globe`: a copy of
`dynamical-zarr-ecmwf` that renders the global ECMWF 2 m temperature
forecast on MapLibre's globe projection with deck.gl interleaved.

It follows `cog-globe`: `projection="globe"`, `depthCompare: "always"` on
the layer so the raster does not z-fight the basemap sphere, a black
background around the globe, and the hosted Dark Matter style with
`beforeId: "boundary_country_outline"`. That style replaces the flat
example's custom water-less style, which the globe does not need.

Also list the example on the docs examples page with a card image. The
docs workflow and the pnpm workspace already pick up `examples/*`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feat label Oct 24, 2026
kylebarron and others added 2 commits November 4, 2026 15:57
Port zarr-globe to the ZarrLayer API from #812, as dynamical-zarr-ecmwf
was ported there: open the array with `ZarrSource.open` and the GeoZarr
attrs, pass the source as `source`, and use the
`ZarrLayer<DataT, Dtype>` type parameter order.

Drop `initTimeIdx` from the layer id, since changing `selection` now
fetches tiles again (#818).

Match dynamical-zarr-ecmwf's dependency versions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron

Copy link
Copy Markdown
Member Author

Note

This comment was written by Claude (Claude Code), not by @kylebarron.

I ported the example to the current API on main, so it typechecks again before 0.10.0. First I merged main in, then made the port in bcd5cd7. I followed dynamical-zarr-ecmwf, which #812 ported:

I also corrected the description's Notes. The tiles aren't 320x320 (15 tiles of 80°). The store is sharded, and ZarrLayer tiles it by its 32x32 inner chunks. The first view therefore selects 558 tiles of 8°, and filling it reads about 1.5 GB over about 4 minutes. The port doesn't change this; arr.chunks and zarrita 0.7.5 are the same as on this PR's original base. A thin basemap sliver still shows at the limb once every tile has loaded, so I kept that note but dropped its 80° explanation.

Verified:

  • pnpm -r --filter='!docs' typecheck passes.
  • The example's vite build passes.
  • biome check . is clean.
  • In Chrome, the forecast draws and animates on the globe, and all 558 tiles load. The console shows no errors, only WebGL "READ-usage buffer" performance warnings, which cog-globe on main also shows.

🤖 Written by Claude Code

@kylebarron

Copy link
Copy Markdown
Member Author

we should also probably merge in latest main

kylebarron and others added 3 commits November 5, 2026 15:06
The IFS ensemble store packs all 51 members into each 32x32 chunk, so the
globe's first view read about 1.3 GB in 558 requests to draw one member.
AIFS Single has no ensemble dimension, and each chunk holds 61 lead times
for 60 by 60 degrees: the whole globe is 18 chunks, about 24 MB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron

Copy link
Copy Markdown
Member Author

Note

This comment was written by Claude (Claude Code), not by @kylebarron.

we should also probably merge in latest main

Merged main in e7a50110, with no conflicts. The workspace typecheck and the example build pass.

Since then, 58c7deac switches the example from the IFS ensemble to ECMWF's AIFS Single forecast, so the first view loads in about 7 seconds instead of 3.5 minutes. The description has the details.

🤖 Written by Claude Code

kylebarron and others added 2 commits November 6, 2026 10:45
… path

#838 renamed `source.arrays` to `source.levels`, and opens a store with a
path. This follows dynamical-zarr-ecmwf.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Nov 6, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

On the globe, a raster whose grid runs past a pole drew a spray of dark
dots over the near side of the globe. It showed up in the zarr-globe
example (#794): its 0.25° ECMWF grid has rows centred on the poles, so
the raster's last row ends at -90.25°.

## Cause

- The globe path builds its mesh with `buildUniformGridMesh`, out to the
tile's edge, with no latitude limit. Web Mercator limits its mesh to
±85.05° through `initialTriangulation`.
- Past -90°, deck.gl's globe projection folds the mesh's last band over
the pole, onto the far side of the globe. The folded triangles' winding
flips, so back-face culling keeps them, and the layer's `depthCompare:
"always"` doesn't hide them.
- The folded triangles are much thinner than a pixel, so they render as
scattered dots around the point where the far-side pole lands on screen.

## Fix

`buildUniformGridMesh` clamps output latitudes to [-90, 90]. The mesh's
last band then holds the part of its texture that lies past the pole,
which isn't visible: in the example, about 1.87° of texture in a 1.62°
band.

## Screenshots

At the docs card's view of #794's example: centred on (0°, 20°) at zoom
2.6, at lead time 0.

| Before | After |
|---|---|
|<img width="1800" height="1013" alt="before-card-view"
src="https://github.com/user-attachments/assets/c040aded-8f58-4604-9592-2dde61272f87"
/> | <img width="1800" height="1013" alt="after-card-view"
src="https://github.com/user-attachments/assets/74b4e3d9-bed2-478d-8463-2e1748c67d94"
/> |

A 6x crop around where the far-side South Pole lands, before on the left
and after on the right:

<img width="960" height="320" alt="crop-before-after"
src="https://github.com/user-attachments/assets/272c62c0-ffb0-4dc7-b174-d476b28d7a09"
/>

## Tests

- A new test checks that a grid with rows at 100°, 0° and -100° gets
vertices at 90°, 0° and -90°. It fails without the clamp.
- "places texCoords on the unit grid and positions via the reprojection
chain" used a 257x257 identity grid, whose last vertex sat at y = 256,
past the pole. It now uses 81x81.
- The deck.gl-raster tests, the workspace typecheck and Biome pass.
- Checked in Chrome with #794's example, at the docs card's view: the
dots are there before and gone after. In three views, and at all 61 lead
times in one of them, a count of the dark pixels around the far-side
pole went from up to 176 to 0.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron and others added 3 commits November 6, 2026 11:55
Its coordinates put each value on its grid point, so with pixel
registration the grid drew 0.125° east and south of where it belongs.
Same change as dynamical-zarr-ecmwf's in #862.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#858 fixed the dots, which the previous card showed in the South
Atlantic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Nov 6, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

The dynamical-zarr-ecmwf example drew the ECMWF grid 0.125° east and
0.125° south of where it belongs. Its hand-written GeoZarr metadata now
declares `"spatial:registration": "node"`.

The store's coordinate arrays put each value on its grid point:
`latitude` runs from 90 to -90 and `longitude` from -180 to 179.75,
matching the transform's origin of (-180, 90) and step of 0.25°. With
the default pixel registration, that origin was read as the corner of
the top-left cell instead of its centre, so every cell sat half a cell
east and south. With node registration, ZarrLayer draws each cell
centred on its grid point. The comment's ranges now give the grid
points: [-180, 179.75] and [90, -90].

The grid's edge cells now reach 0.125° past the poles and past -180°. On
Web Mercator the mesh stops at ±85.05° anyway, and on the globe #858
clamps it to the poles. There's no seam at the antimeridian.

The zarr-globe example in #794 reads the same grid, and gets the same
change there.

## Screenshots

At lead time 0 of the latest run, with the control panel hidden.

Sardinia, zoom 7: the island's cooler cells move west and north onto the
island.

**PLACEHOLDER: drop `sardinia-before-after.png` here** (before on the
left, after on the right)

Fiji, by the antimeridian, zoom 6: the warmer cells move onto Viti Levu,
and there's no seam at 180°.

**PLACEHOLDER: drop `fiji-before-after.png` here** (before on the left,
after on the right)

## Tests

- Example-only change, no new tests. The workspace typecheck, the
example build and Biome pass.
- Checked in Chrome: the example's initial view over Europe, Sardinia at
zoom 7, and the antimeridian by Fiji at zoom 6, before and after.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this image should show better contrast; it's too washed out. I don't think the colormap is centered on warm-temperatures over africa

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note

This comment was written by Claude (Claude Code), not by @kylebarron.

Two things washed it out, and both are fixed:

  • The colour range. The default rescale of -40 to 50 °C put half of the visible area, 11 to 26 °C, into 17% of the colormap. 1325956a narrows the example's default to -20 to 40 °C. The filter keeps its own -40 to 50 °C default, so nothing new is hidden.
  • The time of day. The card showed lead time 0 of the 06 UTC run, which is early morning over Africa, when the Sahara is cooler than the ocean around it. The new card, 4c5c8a89, is at +6 h, 12 UTC.

zarr-globe card

🤖 Written by Claude Code

kylebarron and others added 2 commits November 6, 2026 12:10
The -40 to 50 °C range put half of the default view (11 to 26 °C) into
17% of the colormap, so the globe looked washed out. The filter keeps
its -40 to 50 °C default, so nothing new is hidden.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron
kylebarron merged commit 7343f71 into main Nov 6, 2026
4 checks passed
@kylebarron
kylebarron deleted the kyle/zarr-globe-example branch November 6, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add zarr-globe example

1 participant