{ "cells": [ { "cell_type": "markdown", "id": "a31785d6-310c-4871-9ac6-064a7874945f", "metadata": { "tags": [] }, "source": [ "# Horizontal Regridding\n", "Author: [Jason Boutte](https://github.com/jasonb5)\n", "\n", "Date: 08/24/22\n", "\n", "Related APIs:\n", "\n", "* [xarray.Dataset.regridder.horizontal](../generated/xarray.Dataset.regridder.horizontal.rst)\n", "\n", "The data used in this example can be found through the [Earth System Grid Federation (ESGF) search portal](https://aims2.llnl.gov/search).\n", "\n", "## Overview\n", "We'll cover horizontal regridding using the `xESMF` and `Regrid2` tools as well as various methods supported by `xESMF`." ] }, { "cell_type": "code", "execution_count": 1, "id": "f44514d3-c3a5-446f-bc32-a914ef5cfb6a", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import matplotlib.pyplot as plt\n", "import xarray as xr\n", "import xcdat" ] }, { "cell_type": "markdown", "id": "7d904843-4079-4ebe-a3d0-ab439e8ce052", "metadata": {}, "source": [ "## 1. Open the Dataset\n", "We are using xarray's OPeNDAP support to read a netCDF4 dataset file directly from its source. The data is not loaded over the network until we perform operations on it (e.g., temperature unit adjustment).\n", "\n", "More information on the xarray's OPeNDAP support can be found [here](https://docs.xarray.dev/en/stable/user-guide/io.html#opendap)." ] }, { "cell_type": "code", "execution_count": 2, "id": "7e51beb4-a48b-49ca-9a28-4057886b8e51", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (time: 1980, bnds: 2, lat: 64, lon: 128)\n",
"Coordinates:\n",
" * time (time) object 1850-01-16 12:00:00 ... 2014-12-16 12:00:00\n",
" * lat (lat) float64 -87.86 -85.1 -82.31 -79.53 ... 82.31 85.1 87.86\n",
" * lon (lon) float64 0.0 2.812 5.625 8.438 ... 348.8 351.6 354.4 357.2\n",
" height float64 2.0\n",
"Dimensions without coordinates: bnds\n",
"Data variables:\n",
" time_bnds (time, bnds) object 1850-01-01 00:00:00 ... 2015-01-01 00:00:00\n",
" lat_bnds (lat, bnds) float64 -90.0 -86.58 -86.58 ... 86.58 86.58 90.0\n",
" lon_bnds (lon, bnds) float64 -1.406 1.406 1.406 ... 355.8 355.8 358.6\n",
" tas (time, lat, lon) float32 -25.04 -25.28 -25.49 ... -25.93 -25.73\n",
"Attributes: (12/54)\n",
" CCCma_model_hash: 7e8e715f3f2ce47e1bab830db971c362ca329419\n",
" CCCma_parent_runid: rc3.1-pictrl\n",
" CCCma_pycmor_hash: 33c30511acc319a98240633965a04ca99c26427e\n",
" CCCma_runid: rc3.1-his13\n",
" Conventions: CF-1.7 CMIP-6.2\n",
" YMDH_branch_time_in_child: 1850:01:01:00\n",
" ... ...\n",
" variable_id: tas\n",
" variant_label: r13i1p1f1\n",
" version: v20190429\n",
" license: CMIP6 model data produced by The Governm...\n",
" cmor_version: 3.4.0\n",
" DODS_EXTRA.Unlimited_Dimension: time