Last active
August 8, 2024 19:29
-
-
Save jbusecke/da29a41fd855f1a1ad0d00cbdc7086c4 to your computer and use it in GitHub Desktop.
Minimal CMIP example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
from xmip.preprocessing import combined_preprocessing | |
data_url = 'gs://cmip6/CMIP6/CMIP/IPSL/IPSL-CM6A-LR/historical/r4i1p1f1/Omon/tos/gn/v20180803/' | |
# Run the same thing with another dataset? | |
#data_url = 'gs://cmip6/CMIP6/CMIP/MPI-M/MPI-ESM1-2-LR/historical/r4i1p1f1/Omon/tos/gn/v20190710/' | |
# read into xarray dataset | |
ds = xr.open_dataset(data_url, engine='zarr', chunks={}) | |
# preprocessing to harmonize naming | |
ds = combined_preprocessing(ds) | |
spatial_mean = ds.mean(['x', 'y']) | |
# spatial mean could be saved out to disk/cloud/... separately | |
mean = spatial_mean.mean(['time']) | |
mean.to_zarr('mean_number.zarr') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am running this on the 'pangeo-notebook' image (see here). But I think for this to run you should get along with