{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Google Cloud CMIP6 Public Data: Basic Python Example\n", "\n", "This notebooks shows how to query the catalog and load the data using python" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "import zarr\n", "import gcsfs\n", "\n", "xr.set_options(display_style='html')\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'retina' " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import cftime" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "plt.rcParams['figure.figsize'] = 12, 6" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Browse Catalog\n", "\n", "The data catatalog is stored as a CSV file. Here we read it with Pandas." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | activity_id | \n", "institution_id | \n", "source_id | \n", "experiment_id | \n", "member_id | \n", "table_id | \n", "variable_id | \n", "grid_label | \n", "zstore | \n", "dcpp_init_year | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "AerChemMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "histSST | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmrbc | \n", "gn | \n", "gs://cmip6/AerChemMIP/BCC/BCC-ESM1/histSST/r1i... | \n", "NaN | \n", "
1 | \n", "AerChemMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "histSST | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmrdust | \n", "gn | \n", "gs://cmip6/AerChemMIP/BCC/BCC-ESM1/histSST/r1i... | \n", "NaN | \n", "
2 | \n", "AerChemMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "histSST | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmroa | \n", "gn | \n", "gs://cmip6/AerChemMIP/BCC/BCC-ESM1/histSST/r1i... | \n", "NaN | \n", "
3 | \n", "AerChemMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "histSST | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmrso4 | \n", "gn | \n", "gs://cmip6/AerChemMIP/BCC/BCC-ESM1/histSST/r1i... | \n", "NaN | \n", "
4 | \n", "AerChemMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "histSST | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmrss | \n", "gn | \n", "gs://cmip6/AerChemMIP/BCC/BCC-ESM1/histSST/r1i... | \n", "NaN | \n", "
\n", " | activity_id | \n", "institution_id | \n", "source_id | \n", "experiment_id | \n", "member_id | \n", "table_id | \n", "variable_id | \n", "grid_label | \n", "zstore | \n", "dcpp_init_year | \n", "
---|---|---|---|---|---|---|---|---|---|---|
4896 | \n", "CMIP | \n", "AS-RCEC | \n", "TaiESM1 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/AS-RCEC/TaiESM1/historical/r1i... | \n", "NaN | \n", "
5674 | \n", "CMIP | \n", "BCC | \n", "BCC-CSM2-MR | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/BCC/BCC-CSM2-MR/historical/r1i... | \n", "NaN | \n", "
5778 | \n", "CMIP | \n", "BCC | \n", "BCC-CSM2-MR | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/BCC/BCC-CSM2-MR/historical/r2i... | \n", "NaN | \n", "
5870 | \n", "CMIP | \n", "BCC | \n", "BCC-CSM2-MR | \n", "historical | \n", "r3i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/BCC/BCC-CSM2-MR/historical/r3i... | \n", "NaN | \n", "
6180 | \n", "CMIP | \n", "BCC | \n", "BCC-ESM1 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/BCC/BCC-ESM1/historical/r1i1p1... | \n", "NaN | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
50318 | \n", "CMIP | \n", "SNU | \n", "SAM0-UNICON | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/SNU/SAM0-UNICON/historical/r1i... | \n", "NaN | \n", "
50474 | \n", "CMIP | \n", "THU | \n", "CIESM | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gr | \n", "gs://cmip6/CMIP/THU/CIESM/historical/r1i1p1f1/... | \n", "NaN | \n", "
50494 | \n", "CMIP | \n", "THU | \n", "CIESM | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gr | \n", "gs://cmip6/CMIP/THU/CIESM/historical/r2i1p1f1/... | \n", "NaN | \n", "
50579 | \n", "CMIP | \n", "UA | \n", "MCM-UA-1-0 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/UA/MCM-UA-1-0/historical/r1i1p... | \n", "NaN | \n", "
50620 | \n", "CMIP | \n", "UA | \n", "MCM-UA-1-0 | \n", "historical | \n", "r1i1p1f2 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/UA/MCM-UA-1-0/historical/r1i1p... | \n", "NaN | \n", "
311 rows × 10 columns
\n", "\n", " | activity_id | \n", "institution_id | \n", "source_id | \n", "experiment_id | \n", "member_id | \n", "table_id | \n", "variable_id | \n", "grid_label | \n", "zstore | \n", "dcpp_init_year | \n", "
---|---|---|---|---|---|---|---|---|---|---|
41761 | \n", "CMIP | \n", "NCAR | \n", "CESM2-FV2 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-FV2/historical/r1i1... | \n", "NaN | \n", "
41923 | \n", "CMIP | \n", "NCAR | \n", "CESM2-FV2 | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-FV2/historical/r2i1... | \n", "NaN | \n", "
41934 | \n", "CMIP | \n", "NCAR | \n", "CESM2-FV2 | \n", "historical | \n", "r3i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-FV2/historical/r3i1... | \n", "NaN | \n", "
42102 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM-FV2 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM-FV2/historica... | \n", "NaN | \n", "
42263 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM-FV2 | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM-FV2/historica... | \n", "NaN | \n", "
42274 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM-FV2 | \n", "historical | \n", "r3i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM-FV2/historica... | \n", "NaN | \n", "
42980 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM/historical/r1... | \n", "NaN | \n", "
43255 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM/historical/r2... | \n", "NaN | \n", "
43487 | \n", "CMIP | \n", "NCAR | \n", "CESM2-WACCM | \n", "historical | \n", "r3i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2-WACCM/historical/r3... | \n", "NaN | \n", "
44529 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r10i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r10i1p1f... | \n", "NaN | \n", "
44756 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r11i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r11i1p1f... | \n", "NaN | \n", "
45003 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r1i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r1i1p1f1... | \n", "NaN | \n", "
45280 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r2i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r2i1p1f1... | \n", "NaN | \n", "
45557 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r3i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r3i1p1f1... | \n", "NaN | \n", "
45834 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r4i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r4i1p1f1... | \n", "NaN | \n", "
46077 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r5i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r5i1p1f1... | \n", "NaN | \n", "
46320 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r6i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r6i1p1f1... | \n", "NaN | \n", "
46564 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r7i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r7i1p1f1... | \n", "NaN | \n", "
46806 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r8i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r8i1p1f1... | \n", "NaN | \n", "
47048 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r9i1p1f1 | \n", "Amon | \n", "tas | \n", "gn | \n", "gs://cmip6/CMIP/NCAR/CESM2/historical/r9i1p1f1... | \n", "NaN | \n", "
array([-90. , -89.057592, -88.115183, -87.172775, -86.230366, -85.287958,\n", " -84.34555 , -83.403141, -82.460733, -81.518325, -80.575916, -79.633508,\n", " -78.691099, -77.748691, -76.806283, -75.863874, -74.921466, -73.979058,\n", " -73.036649, -72.094241, -71.151832, -70.209424, -69.267016, -68.324607,\n", " -67.382199, -66.439791, -65.497382, -64.554974, -63.612565, -62.670157,\n", " -61.727749, -60.78534 , -59.842932, -58.900524, -57.958115, -57.015707,\n", " -56.073298, -55.13089 , -54.188482, -53.246073, -52.303665, -51.361257,\n", " -50.418848, -49.47644 , -48.534031, -47.591623, -46.649215, -45.706806,\n", " -44.764398, -43.82199 , -42.879581, -41.937173, -40.994764, -40.052356,\n", " -39.109948, -38.167539, -37.225131, -36.282723, -35.340314, -34.397906,\n", " -33.455497, -32.513089, -31.570681, -30.628272, -29.685864, -28.743455,\n", " -27.801047, -26.858639, -25.91623 , -24.973822, -24.031414, -23.089005,\n", " -22.146597, -21.204188, -20.26178 , -19.319372, -18.376963, -17.434555,\n", " -16.492147, -15.549738, -14.60733 , -13.664921, -12.722513, -11.780105,\n", " -10.837696, -9.895288, -8.95288 , -8.010471, -7.068063, -6.125654,\n", " -5.183246, -4.240838, -3.298429, -2.356021, -1.413613, -0.471204,\n", " 0.471204, 1.413613, 2.356021, 3.298429, 4.240838, 5.183246,\n", " 6.125654, 7.068063, 8.010471, 8.95288 , 9.895288, 10.837696,\n", " 11.780105, 12.722513, 13.664921, 14.60733 , 15.549738, 16.492147,\n", " 17.434555, 18.376963, 19.319372, 20.26178 , 21.204188, 22.146597,\n", " 23.089005, 24.031414, 24.973822, 25.91623 , 26.858639, 27.801047,\n", " 28.743455, 29.685864, 30.628272, 31.570681, 32.513089, 33.455497,\n", " 34.397906, 35.340314, 36.282723, 37.225131, 38.167539, 39.109948,\n", " 40.052356, 40.994764, 41.937173, 42.879581, 43.82199 , 44.764398,\n", " 45.706806, 46.649215, 47.591623, 48.534031, 49.47644 , 50.418848,\n", " 51.361257, 52.303665, 53.246073, 54.188482, 55.13089 , 56.073298,\n", " 57.015707, 57.958115, 58.900524, 59.842932, 60.78534 , 61.727749,\n", " 62.670157, 63.612565, 64.554974, 65.497382, 66.439791, 67.382199,\n", " 68.324607, 69.267016, 70.209424, 71.151832, 72.094241, 73.036649,\n", " 73.979058, 74.921466, 75.863874, 76.806283, 77.748691, 78.691099,\n", " 79.633508, 80.575916, 81.518325, 82.460733, 83.403141, 84.34555 ,\n", " 85.287958, 86.230366, 87.172775, 88.115183, 89.057592, 90. ])
\n",
"
| \n",
"\n", "\n", " | \n", "
array([ 0. , 1.25, 2.5 , ..., 356.25, 357.5 , 358.75])
\n",
"
| \n",
"\n", "\n", " | \n", "
array([cftime.DatetimeNoLeap(1850-01-15 12:00:00),\n", " cftime.DatetimeNoLeap(1850-02-14 00:00:00),\n", " cftime.DatetimeNoLeap(1850-03-15 12:00:00), ...,\n", " cftime.DatetimeNoLeap(2014-10-15 12:00:00),\n", " cftime.DatetimeNoLeap(2014-11-15 00:00:00),\n", " cftime.DatetimeNoLeap(2014-12-15 12:00:00)], dtype=object)
\n",
"
| \n",
"\n", "\n", " | \n", "
\n",
"
| \n",
"\n", "\n", " | \n", "
array([-90. , -89.057592, -88.115183, -87.172775, -86.230366, -85.287958,\n", " -84.34555 , -83.403141, -82.460733, -81.518325, -80.575916, -79.633508,\n", " -78.691099, -77.748691, -76.806283, -75.863874, -74.921466, -73.979058,\n", " -73.036649, -72.094241, -71.151832, -70.209424, -69.267016, -68.324607,\n", " -67.382199, -66.439791, -65.497382, -64.554974, -63.612565, -62.670157,\n", " -61.727749, -60.78534 , -59.842932, -58.900524, -57.958115, -57.015707,\n", " -56.073298, -55.13089 , -54.188482, -53.246073, -52.303665, -51.361257,\n", " -50.418848, -49.47644 , -48.534031, -47.591623, -46.649215, -45.706806,\n", " -44.764398, -43.82199 , -42.879581, -41.937173, -40.994764, -40.052356,\n", " -39.109948, -38.167539, -37.225131, -36.282723, -35.340314, -34.397906,\n", " -33.455497, -32.513089, -31.570681, -30.628272, -29.685864, -28.743455,\n", " -27.801047, -26.858639, -25.91623 , -24.973822, -24.031414, -23.089005,\n", " -22.146597, -21.204188, -20.26178 , -19.319372, -18.376963, -17.434555,\n", " -16.492147, -15.549738, -14.60733 , -13.664921, -12.722513, -11.780105,\n", " -10.837696, -9.895288, -8.95288 , -8.010471, -7.068063, -6.125654,\n", " -5.183246, -4.240838, -3.298429, -2.356021, -1.413613, -0.471204,\n", " 0.471204, 1.413613, 2.356021, 3.298429, 4.240838, 5.183246,\n", " 6.125654, 7.068063, 8.010471, 8.95288 , 9.895288, 10.837696,\n", " 11.780105, 12.722513, 13.664921, 14.60733 , 15.549738, 16.492147,\n", " 17.434555, 18.376963, 19.319372, 20.26178 , 21.204188, 22.146597,\n", " 23.089005, 24.031414, 24.973822, 25.91623 , 26.858639, 27.801047,\n", " 28.743455, 29.685864, 30.628272, 31.570681, 32.513089, 33.455497,\n", " 34.397906, 35.340314, 36.282723, 37.225131, 38.167539, 39.109948,\n", " 40.052356, 40.994764, 41.937173, 42.879581, 43.82199 , 44.764398,\n", " 45.706806, 46.649215, 47.591623, 48.534031, 49.47644 , 50.418848,\n", " 51.361257, 52.303665, 53.246073, 54.188482, 55.13089 , 56.073298,\n", " 57.015707, 57.958115, 58.900524, 59.842932, 60.78534 , 61.727749,\n", " 62.670157, 63.612565, 64.554974, 65.497382, 66.439791, 67.382199,\n", " 68.324607, 69.267016, 70.209424, 71.151832, 72.094241, 73.036649,\n", " 73.979058, 74.921466, 75.863874, 76.806283, 77.748691, 78.691099,\n", " 79.633508, 80.575916, 81.518325, 82.460733, 83.403141, 84.34555 ,\n", " 85.287958, 86.230366, 87.172775, 88.115183, 89.057592, 90. ])
\n",
"
| \n",
"\n", "\n", " | \n", "
array([ 0. , 1.25, 2.5 , ..., 356.25, 357.5 , 358.75])
\n",
"
| \n",
"\n", "\n", " | \n", "
\n",
"
| \n",
"\n", "\n", " | \n", "
\n",
"
| \n",
"\n", "\n", " | \n", "
array([cftime.DatetimeNoLeap(1850-01-15 12:00:00),\n", " cftime.DatetimeNoLeap(1850-02-14 00:00:00),\n", " cftime.DatetimeNoLeap(1850-03-15 12:00:00), ...,\n", " cftime.DatetimeNoLeap(2014-10-15 12:00:00),\n", " cftime.DatetimeNoLeap(2014-11-15 00:00:00),\n", " cftime.DatetimeNoLeap(2014-12-15 12:00:00)], dtype=object)
array([285.6408 , 285.57397, 286.33856, ..., 288.6992 , 287.76303,\n", " 287.0621 ], dtype=float32)
array([cftime.DatetimeNoLeap(1850-01-15 12:00:00),\n", " cftime.DatetimeNoLeap(1850-02-14 00:00:00),\n", " cftime.DatetimeNoLeap(1850-03-15 12:00:00), ...,\n", " cftime.DatetimeNoLeap(2014-10-15 12:00:00),\n", " cftime.DatetimeNoLeap(2014-11-15 00:00:00),\n", " cftime.DatetimeNoLeap(2014-12-15 12:00:00)], dtype=object)