{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Making Maps using `Cartopy` " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`Cartopy` is a Python map plotting package. Combined with `matplotlib` is works well for making contour plots of maps for Climate Data Analysis" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook will demonstrate how to make map contour plots using `Cartopy`, including:\n", "1. some stuff\n", "2. some more stuff" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We return to our CMIP5 data for surface air temperature (tas) from the RCP8.5 scenario produced by the NCAR/CCSM4 model. For this example, we will again read the first ensemble member.\n", "\n", "The data are located on the COLA severs in the following directory:\n", "```/shared/cmip5/data/rcp45/atmos/mon/Amon/tas/NCAR.CCSM4/r1i1p1/```\n", "\n", "The filename is:\n", "```tas_Amon_CCSM4_rcp45_r1i1p1_210101-229912.nc```" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import warnings\n", "\n", "import numpy as np\n", "import xarray as xr\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\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": [ "Read Data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (bnds: 2, lat: 192, lon: 288, time: 1140)\n", "Coordinates:\n", " * time (time) object 2006-01-16 12:00:00 ... 2100-12-16 12:00:00\n", " * lat (lat) float64 -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0\n", " * lon (lon) float64 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8\n", " height float64 ...\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) object ...\n", " lat_bnds (lat, bnds) float64 ...\n", " lon_bnds (lon, bnds) float64 ...\n", " tas (time, lat, lon) float32 ...\n", "Attributes:\n", " institution: NCAR (National Center for Atmospheric Resea...\n", " institute_id: NCAR\n", " experiment_id: rcp45\n", " source: CCSM4\n", " model_id: CCSM4\n", " forcing: Sl GHG Vl SS Ds SA BC MD OC Oz AA\n", " parent_experiment_id: historical\n", " parent_experiment_rip: r1i1p1\n", " branch_time: 2005.0\n", " contact: cesm_data@ucar.edu\n", " references: Gent P. R., et.al. 2011: The Community Clim...\n", " initialization_method: 1\n", " physics_version: 1\n", " tracking_id: 0bf35136-b266-44d2-9078-f3081b83b6ad\n", " acknowledgements: The CESM project is supported by the Nation...\n", " cesm_casename: b40.rcp4_5.1deg.001\n", " cesm_repotag: ccsm4_0_beta49\n", " cesm_compset: BRCP45CN\n", " resolution: f09_g16 (0.9x1.25_gx1v6)\n", " forcing_note: Additional information on the external forc...\n", " processed_by: strandwg on mirage0 at 20111021\n", " processing_code_information: Last Changed Rev: 428 Last Changed Date: 20...\n", " product: output\n", " experiment: RCP4.5\n", " frequency: mon\n", " creation_date: 2011-10-21T21:56:22Z\n", " history: 2011-10-21T21:56:22Z CMOR rewrote data to c...\n", " Conventions: CF-1.4\n", " project_id: CMIP5\n", " table_id: Table Amon (26 July 2011) 976b7fd1d9e1be31d...\n", " title: CCSM4 model output prepared for CMIP5 RCP4.5\n", " parent_experiment: historical\n", " modeling_realm: atmos\n", " realization: 1\n", " cmor_version: 2.7.1" ], "text/plain": [ "