{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `xarray` Practice" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Part 1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### `xarray` Data Structures" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "import xarray as xr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. The relative filepath for the SST dataset we saw in the lesson is `../data/oisst-avhrr-v02r01.20220304.nc`. Use the `open_dataset()` function to access the file." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Display the HTML representation of the dataset (Put the Python variable name of the dataset alone in a cell, or as the last line of a cell). Read the following information from the visual display of the dataset.\n", "- What is the first and last values for latitude?\n", "- What is the \"institution\" listed in the metadata?\n", "- What date was this data taken?\n", "- How many latitude values are there? How many longitude values?" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Display just the `ice` data variable" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'ice' (time: 1, zlev: 1, lat: 720, lon: 1440)>\n", "[1036800 values with dtype=float32]\n", "Coordinates:\n", " * time (time) datetime64[ns] 2022-03-04T12:00:00\n", " * zlev (zlev) float32 0.0\n", " * lat (lat) float32 -89.88 -89.62 -89.38 -89.12 ... 89.38 89.62 89.88\n", " * lon (lon) float32 0.125 0.375 0.625 0.875 ... 359.1 359.4 359.6 359.9\n", "Attributes:\n", " long_name: Sea ice concentration\n", " units: %\n", " valid_min: 0\n", " valid_max: 100