{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Making multi-panel plots using `Cartopy`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook will demonstrate how to make multi-panel contour plots with `Cartopy`, including adding a single colorbar and title for all panels." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The Subseasonal Experiment (SubX)\n", "Further information on SubX is available from Pegion et al. 2019 and the SubX project website\n", "\n", "The SubX public database is hosted on the International Research Institute for Climate and Society (IRI) data server http://iridl.ldeo.columbia.edu/SOURCES/.Models/.SubX/\n", "\n", "SubX Forecasts are hosted locally on COLA computers at the following location: \n", "```/shared/subx/forecast/weekly/```\n", "\n", "Specifically, we will use the forecast for 2m temperatures anomalies made on Apr 16, 2020, located in:\n", "```/shared/subx/forecast/weekly/20200416/data/fcst_20200416.anom.tas_2m.nc ```" ] }, { "cell_type": "code", "execution_count": 77, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import numpy as np\n", "\n", "import cartopy.feature as cfeature\n", "import cartopy.crs as ccrs\n", "import cartopy.mpl.ticker as cticker\n", "from cartopy.util import add_cyclic_point" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set the path and filename" ] }, { "cell_type": "code", "execution_count": 78, "metadata": {}, "outputs": [], "source": [ "path='/shared/subx/forecast/weekly/20200416/data/'\n", "fname='fcst_20200416.anom.tas_2m.nc'" ] }, { "cell_type": "code", "execution_count": 79, "metadata": {}, "outputs": [], "source": [ "ds=xr.open_dataset(path+fname)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This dataset contains weekly forecasts for 2m temperature anomalies from each of the SubX Models and the multi-model ensemble (MME). These are listed as the Data Variables. The forecats have 4 times, corresponding to weeks 1, 2, 3, and 4." ] }, { "cell_type": "code", "execution_count": 80, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
array([-90., -89., -88., -87., -86., -85., -84., -83., -82., -81., -80., -79.,\n", " -78., -77., -76., -75., -74., -73., -72., -71., -70., -69., -68., -67.,\n", " -66., -65., -64., -63., -62., -61., -60., -59., -58., -57., -56., -55.,\n", " -54., -53., -52., -51., -50., -49., -48., -47., -46., -45., -44., -43.,\n", " -42., -41., -40., -39., -38., -37., -36., -35., -34., -33., -32., -31.,\n", " -30., -29., -28., -27., -26., -25., -24., -23., -22., -21., -20., -19.,\n", " -18., -17., -16., -15., -14., -13., -12., -11., -10., -9., -8., -7.,\n", " -6., -5., -4., -3., -2., -1., 0., 1., 2., 3., 4., 5.,\n", " 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17.,\n", " 18., 19., 20., 21., 22., 23., 24., 25., 26., 27., 28., 29.,\n", " 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41.,\n", " 42., 43., 44., 45., 46., 47., 48., 49., 50., 51., 52., 53.,\n", " 54., 55., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65.,\n", " 66., 67., 68., 69., 70., 71., 72., 73., 74., 75., 76., 77.,\n", " 78., 79., 80., 81., 82., 83., 84., 85., 86., 87., 88., 89.,\n", " 90.], dtype=float32)
array([ 0., 1., 2., ..., 357., 358., 359.], dtype=float32)
array(['2020-04-24T00:00:00.000000000', '2020-05-01T00:00:00.000000000',\n", " '2020-05-08T00:00:00.000000000', '2020-05-15T00:00:00.000000000'],\n", " dtype='datetime64[ns]')
[260640 values with dtype=float32]
[260640 values with dtype=float32]
[260640 values with dtype=float32]
[260640 values with dtype=float32]
[260640 values with dtype=float32]
[260640 values with dtype=float32]
[260640 values with dtype=float32]