Skip to content

Commit

Permalink
Add test module
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Aug 22, 2024
1 parent f821773 commit 0ae195b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/geospatial/test_rechunking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
import coiled
import dask
import xarray as xr
from coiled.credentials.google import CoiledShippedCredentials


@pytest.mark.client("era5_rechunking")
def test_era5_rechunking(client):
# # Create cluster
# cluster = coiled.Cluster(
# n_workers=100,
# workspace="dask-engineering-gcp",
# region="us-central1",
# )
# client = cluster.get_client()
# with benchmark_all(client):

# Load dataset
ds = xr.open_zarr(
"gs://weatherbench2/datasets/era5/1959-2023_01_10-full_37-1h-0p25deg-chunk-1.zarr",
).drop_encoding()

time_range = slice("2020-01-01", "2023-01-01") # 101.83 GiB
subset = ds.sea_surface_temperature.sel(time=time_range)

# Rechunk
with dask.config.set({"array.rechunk.method": "p2p"}): # Use new algorithm
result = subset.chunk({"time": -1, "longitude": "auto", "latitude": "auto"})

# Write result to cloud storage
result.to_zarr(
"gs://coiled-scratch-space/benchmarks/era5.zarr/",
storage_options={"token": CoiledShippedCredentials()},
)

0 comments on commit 0ae195b

Please sign in to comment.