{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Copyright CNES\n", "\n", "## Read and plot a SWOT-HR Pixel Cloud netcdf products \n", "In this notebook, we show how to read the SWOT-HR pixel cloud products with xarray and how to represent a variable on a map with cartopy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Libraries\n", "Please note that apart from the libraries listed in the cell below, you need to install the h5netcdf library (conda install -c conda-forge h5netcdf). This will be used by th xarray.open_dataset function to read the netcdf files." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import os\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Read a SWOT-HR Pixel Cloud netcdf product\n", "Note this is an extraction of the original file for demonstration purpose. It does not contain all variables and groups" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "dir_swot = \"../docs/data/swot\"\n", "file_swot_pxc = os.path.join(dir_swot, \"SWOT_L2_HR_PIXC\", \"SWOT_L2_HR_PIXC_015_033_163R_20240509T115817_20240509T115828_PIC0_01_extract.nc\")\n", "# read data with xarray, specifying a group in the netcdf structure\n", "xr_pxc = xr.open_dataset(file_swot_pxc, group=\"pixel_cloud\")\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (points: 10001)\n", "Coordinates:\n", " latitude (points) float64 4.597 4.597 4.597 ... 4.653 4.652 4.652\n", " longitude (points) float64 -53.06 -53.06 -53.06 ... -53.39 -53.39\n", "Dimensions without coordinates: points\n", "Data variables:\n", " classification (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " coherent_power (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " cross_track (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " geoid (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " height (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " sig0 (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", " wse (points) float32 nan nan nan nan nan ... nan nan nan nan nan\n", "Attributes:\n", " description: cloud of geolocated interferogram pixels\n", " interferogram_size_azimuth: 3277\n", " interferogram_size_range: 4694\n", " looks_to_efflooks: 1.55135648150391\n", " num_azimuth_looks: 7.0\n", " azimuth_offset: 7