{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "0ac4a6dd", "metadata": {}, "source": [ "# 3. Basic Workflow Demo: Plotting A Monthly Mean Map\n", " \n", "To demonstrate the simplicity of using xarray, we first provide a very simple example. Here we will read a netCDF data, operate a simple statistical computation, and plotting a map. \n", "\n", "**Example 1. Regional monthly OLR map (outgoing longwave radiation, OLR) in December 2017:** The workflow is as follows: \n", "1. Open and read the file. \n", "2. Select the specific spatial and temporal range. \n", "3. Mean over time. \n", "4. Plot the result.\n", "\n", "```{note}\n", "In this unit, please set the plotting extent within 0˚-180˚. To plot a map outside this range is rather complicated and we will learn in Unit 9. \n", "```\n", "\n", "## Open the File and Slicing" ] }, { "cell_type": "code", "execution_count": 10, "id": "dedb705b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'olr' (time: 31, lat: 50, lon: 82)> Size: 508kB\n", "[127100 values with dtype=float32]\n", "Coordinates:\n", " * time (time) datetime64[ns] 248B 2017-12-01 2017-12-02 ... 2017-12-31\n", " * lon (lon) float32 328B 79.5 80.5 81.5 82.5 ... 157.5 158.5 159.5 160.5\n", " * lat (lat) float32 200B -19.5 -18.5 -17.5 -16.5 ... 26.5 27.5 28.5 29.5\n", "Attributes:\n", " standard_name: toa_outgoing_longwave_flux\n", " long_name: NOAA Climate Data Record of Daily Mean Upward Longwave Fl...\n", " units: W m-2\n", " cell_methods: time: mean area: mean
<xarray.DataArray 'olr' (lat: 50, lon: 82)> Size: 16kB\n", "array([[287.4708 , 287.87192, 286.90723, ..., 271.47592, 269.68332,\n", " 266.63043],\n", " [285.6799 , 285.8262 , 286.34995, ..., 268.567 , 266.5395 ,\n", " 263.9603 ],\n", " [282.36685, 283.75674, 285.1209 , ..., 267.8831 , 264.08185,\n", " 260.59106],\n", " ...,\n", " [262.47873, 264.25 , 263.49432, ..., 269.69827, 271.77063,\n", " 273.64374],\n", " [261.1402 , 261.74628, 260.309 , ..., 260.9607 , 262.55548,\n", " 263.67596],\n", " [253.06664, 249.58241, 238.8812 , ..., 252.71883, 254.02852,\n", " 255.21298]], dtype=float32)\n", "Coordinates:\n", " * lon (lon) float32 328B 79.5 80.5 81.5 82.5 ... 157.5 158.5 159.5 160.5\n", " * lat (lat) float32 200B -19.5 -18.5 -17.5 -16.5 ... 26.5 27.5 28.5 29.5
<xarray.DataArray 'olr' (lat: 50, lon: 82)> Size: 16kB\n", "array([[287.4708 , 287.87192, 286.90723, ..., 271.47592, 269.68332,\n", " 266.63043],\n", " [285.6799 , 285.8262 , 286.34995, ..., 268.567 , 266.5395 ,\n", " 263.9603 ],\n", " [282.36685, 283.75674, 285.1209 , ..., 267.8831 , 264.08185,\n", " 260.59106],\n", " ...,\n", " [262.47873, 264.25 , 263.49432, ..., 269.69827, 271.77063,\n", " 273.64374],\n", " [261.1402 , 261.74628, 260.309 , ..., 260.9607 , 262.55548,\n", " 263.67596],\n", " [253.06664, 249.58241, 238.8812 , ..., 252.71883, 254.02852,\n", " 255.21298]], dtype=float32)\n", "Coordinates:\n", " * lon (lon) float32 328B 79.5 80.5 81.5 82.5 ... 157.5 158.5 159.5 160.5\n", " * lat (lat) float32 200B -19.5 -18.5 -17.5 -16.5 ... 26.5 27.5 28.5 29.5