Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Google Cloud CMIP6 Public Data: Basic Python Example

Authors
Affiliations
University at Albany (SUNY)
Argonne National Laboratory

Overview

This notebooks shows how to query the Google Cloud CMIP6 catalog and load the data using Python.

Prerequisites

ConceptsImportanceNotes
Intro to XarrayNecessary
Understanding of NetCDFHelpfulFamiliarity with metadata structure
  • Time to learn: 10 minutes


Imports

Browse Catalog

The data catatalog is stored as a CSV file. Here we read it with Pandas.

Loading...

The columns of the dataframe correspond to the CMI6 controlled vocabulary.

Here we filter the data to find monthly surface air temperature for historical experiments.

Loading...

Now we do further filtering to find just the models from NCAR.

Loading...

Load Data

Now we will load a single store using fsspec, zarr, and xarray.

gs://cmip6/CMIP6/CMIP/NCAR/CESM2-FV2/historical/r2i1p1f1/Amon/tas/gn/v20200226/
/home/runner/micromamba/envs/cmip6-cookbook-dev/lib/python3.14/site-packages/google/auth/transport/grpc.py:43: FutureWarning: grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). Support for non-PQC environments is deprecated. In April 2027, google-auth will raise its minimum requirements to enforce grpcio >= 1.83.0. For more details on Google Cloud's post-quantum security migration, visit: https://cloud.google.com/security/resources/post-quantum-cryptography
  warnings.warn(
Loading...

Plot the Data

Plot a map from a specific date:

<Figure size 1200x600 with 2 Axes>

The global mean of a lat-lon field needs to be weighted by the area of each grid cell, which is proportional to the cosine of its latitude.

We can pass all of the temperature data through this function:

Loading...

By default the data are loaded lazily, as Dask arrays. Here we trigger computation explicitly.

CPU times: user 251 ms, sys: 100 ms, total: 351 ms
Wall time: 1.54 s
Loading...
<Figure size 1200x600 with 1 Axes>

Summary

In this notebook, we opened a CESM2 dataset with fsspec and zarr. We calculated and plotted global average surface air temperature.

What’s next?

We will open a dataset with ESGF and OPenDAP.

Additional resources