From the PO.DAAC Cookbook, to access the GitHub version of the notebook, follow this link.

SWOT Hydrology Dataset Exploration in the Cloud

Accessing and Visualizing SWOT Datasets

Requirement:

This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.

Learning Objectives:

  • Access SWOT HR data prodcuts (archived in NASA Earthdata Cloud) within the AWS cloud, without downloading to local machine
  • Visualize accessed data for a quick check

SWOT Level 2 KaRIn High Rate Version C (aka 2.0) Datasets:

  1. River Vector Shapefile - SWOT_L2_HR_RIVERSP_2.0

  2. Lake Vector Shapefile - SWOT_L2_HR_LAKESP_2.0

  3. Water Mask Pixel Cloud NetCDF - SWOT_L2_HR_PIXC_2.0

  4. Water Mask Pixel Cloud Vector Attribute NetCDF - SWOT_L2_HR_PIXCVec_2.0

  5. Raster NetCDF - SWOT_L2_HR_Raster_2.0

  6. Single Look Complex Data product - SWOT_L1B_HR_SLC_2.0

Notebook Author: Cassie Nickles, NASA PO.DAAC (Feb 2024) || Other Contributors: Zoe Walschots (PO.DAAC Summer Intern 2023), Catalina Taglialatela (NASA PO.DAAC), Luis Lopez (NASA NSIDC DAAC)

Last updated: 7 Feb 2024

Libraries Needed

import s3fs
import fiona
import xarray as xr
import pandas as pd
import geopandas as gpd
import numpy as np
import matplotlib.pyplot as plt
import hvplot.xarray
import earthaccess

pd.set_option('display.max_columns', None) #make sure all columns displayed for shapefiles

Earthdata Login

An Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. If you don’t already have one, please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up. We use earthaccess to authenticate your login credentials below.

auth = earthaccess.login()

Single File Access

1. River Vector Shapefiles

The s3 access link can be found using earthaccess data search. Since this collection consists of Reach and Node files, we need to extract only the granule for the Reach file. We do this by filtering for the ‘Reach’ title in the data link.

Alternatively, Earthdata Search (see tutorial) can be used to search in a map graphic user interface.

For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.

Search for the data of interest

#Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname, temporal bounds, and filter by wildcards
river_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RIVERSP_2.0', 
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        granule_name = '*Reach*_009_NA*') # here we filter by Reach files (not node), pass=009, continent code=NA
Granules found: 7

Set up an s3fs session for Direct Cloud Access

s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.

fs_s3 = earthaccess.get_s3fs_session(results=river_results)

Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud

The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.

fiona_session=fiona.session.AWSSession(
        aws_access_key_id=fs_s3.storage_options["key"],
        aws_secret_access_key=fs_s3.storage_options["secret"],
        aws_session_token=fs_s3.storage_options["token"]
    )
# Get the link for the first zip file
river_link = earthaccess.results.DataGranule.data_links(river_results[0], access='direct')[0]

# We use the zip+ prefix so fiona knows that we are operating on a zip file
river_shp_url = f"zip+{river_link}"

with fiona.Env(session=fiona_session):
    SWOT_HR_shp1 = gpd.read_file(river_shp_url) 

#view the attribute table
SWOT_HR_shp1 
reach_id time time_tai time_str p_lat p_lon river_name wse wse_u wse_r_u wse_c wse_c_u slope slope_u slope_r_u slope2 slope2_u slope2_r_u width width_u width_c width_c_u area_total area_tot_u area_detct area_det_u area_wse d_x_area d_x_area_u layovr_val node_dist loc_offset xtrk_dist dschg_c dschg_c_u dschg_csf dschg_c_q dschg_gc dschg_gc_u dschg_gcsf dschg_gc_q dschg_m dschg_m_u dschg_msf dschg_m_q dschg_gm dschg_gm_u dschg_gmsf dschg_gm_q dschg_b dschg_b_u dschg_bsf dschg_b_q dschg_gb dschg_gb_u dschg_gbsf dschg_gb_q dschg_h dschg_h_u dschg_hsf dschg_h_q dschg_gh dschg_gh_u dschg_ghsf dschg_gh_q dschg_o dschg_o_u dschg_osf dschg_o_q dschg_go dschg_go_u dschg_gosf dschg_go_q dschg_s dschg_s_u dschg_ssf dschg_s_q dschg_gs dschg_gs_u dschg_gssf dschg_gs_q dschg_i dschg_i_u dschg_isf dschg_i_q dschg_gi dschg_gi_u dschg_gisf dschg_gi_q dschg_q_b dschg_gq_b reach_q reach_q_b dark_frac ice_clim_f ice_dyn_f partial_f n_good_nod obs_frac_n xovr_cal_q geoid_hght geoid_slop solid_tide load_tidef load_tideg pole_tide dry_trop_c wet_trop_c iono_c xovr_cal_c n_reach_up n_reach_dn rch_id_up rch_id_dn p_wse p_wse_var p_width p_wid_var p_n_nodes p_dist_out p_length p_maf p_dam_id p_n_ch_max p_n_ch_mod p_low_slp geometry
0 71224500951 -1.000000e+12 -1.000000e+12 no_data 48.517717 -93.692086 Rainy River -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 12582912 12582912 3 469762048 -1.000000e+12 1 -999 1 -999 -1.000000e+12 2 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 1 1 71224700961, no_data, no_data, no_data 71224300941, no_data, no_data, no_data 325.899994 0.044680 208.0 1480.031 53 244919.492 10586.381484 -1.000000e+12 0 1 1 0 LINESTRING (-93.76076 48.51651, -93.76035 48.5...
1 71224700013 7.540761e+08 7.540762e+08 2023-11-23T17:35:38Z 48.777900 -93.233350 no_data 3.364954e+02 9.003000e-02 2.290000e-03 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 3.272000e-01 8.486717e+02 2.871400e-01 -4.807161e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 8389051 8389051 3 4194318 1.338000e-03 1 -999 0 18 1.000000e+00 0 -3.141705e+01 -2.674060e-05 -2.894793e-02 -5.371819e-03 -5.384998e-03 5.780308e-03 -2.241292e+00 -1.634102e-02 -8.003274e-03 5.015258e-01 1 1 71224700021, no_data, no_data, no_data 71224700276, no_data, no_data, no_data 335.600006 0.000000 1288.0 1239358.412 18 3719.676 3514.736672 -1.000000e+12 0 6 1 0 LINESTRING (-93.21387 48.78466, -93.21403 48.7...
2 71224700021 7.540761e+08 7.540762e+08 2023-11-23T17:35:38Z 48.772163 -93.266891 no_data 3.365123e+02 9.199000e-02 1.902000e-02 -1.000000e+12 -1.000000e+12 4.959662e-05 1.018542e-05 9.733590e-06 2.575548e-05 -1.000000e+12 4.654752e-05 6.202024e+01 1.118013e+00 -1.000000e+12 -1.000000e+12 9.836880e+04 1.773253e+03 9.836880e+04 1.773300e+03 9.836880e+04 -1.000000e+12 -1.000000e+12 1.377000e-01 1.509669e+02 -1.470277e+01 -5.017144e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 8389049 8389049 1 2 0.000000e+00 1 -999 0 6 7.500000e-01 0 -3.135521e+01 2.512828e-05 -2.886645e-02 -5.377388e-03 -5.390327e-03 5.783173e-03 -2.241321e+00 -1.657549e-02 -8.003758e-03 5.314556e-01 2 1 71224700233, 71224700083, no_data, no_data 71224700013, no_data, no_data, no_data 335.600006 0.000000 30.0 76609.119 8 5305.752 1586.075688 -1.000000e+12 0 6 1 0 LINESTRING (-93.25587 48.77340, -93.25628 48.7...
3 71224700033 7.540761e+08 7.540762e+08 2023-11-23T17:35:38Z 48.733727 -93.116424 no_data 3.365715e+02 9.068000e-02 1.112000e-02 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 1.505600e+00 3.730449e+02 -1.512075e+02 -3.862870e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 8389049 8389049 3 4194318 1.153940e-01 1 -999 0 18 9.000000e-01 0 -3.153422e+01 -1.678670e-05 -2.908536e-02 -5.353698e-03 -5.371641e-03 5.773116e-03 -2.241031e+00 -1.593641e-02 -8.007598e-03 3.984029e-01 1 1 71224700286, no_data, no_data, no_data 71224700041, no_data, no_data, no_data 335.600006 0.000000 645.0 297730.945 20 306795.237 3904.961218 -1.000000e+12 0 3 1 0 LINESTRING (-93.09779 48.73888, -93.09820 48.7...
4 71224700041 7.540761e+08 7.540762e+08 2023-11-23T17:35:38Z 48.720271 -93.113458 no_data 3.364742e+02 9.085000e-02 1.238000e-02 -1.000000e+12 -1.000000e+12 -2.431140e-05 1.166051e-05 1.126799e-05 -9.248820e-05 -1.000000e+12 1.647480e-05 3.930469e+01 1.013951e+00 -1.000000e+12 -1.000000e+12 4.728760e+04 1.219887e+03 4.728760e+04 1.219900e+03 4.728760e+04 -1.000000e+12 -1.000000e+12 2.925000e-01 2.328550e+02 -4.628440e+00 -3.776046e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 25166265 25166265 1 6 0.000000e+00 1 -999 0 5 8.333333e-01 0 -3.152398e+01 -3.509400e-06 -2.906824e-02 -5.351348e-03 -5.371695e-03 5.773071e-03 -2.240743e+00 -1.600031e-02 -8.009073e-03 3.901623e-01 1 1 71224700033, no_data, no_data, no_data 71224700053, no_data, no_data, no_data 335.600006 0.000000 645.0 0.000 6 302890.276 1203.102119 -1.000000e+12 0 1 1 0 LINESTRING (-93.12101 48.72305, -93.12060 48.7...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
926 77125000241 7.540756e+08 7.540756e+08 2023-11-23T17:26:38Z 17.960957 -100.025397 no_data 3.560650e+02 1.501928e+02 1.501928e+02 -1.000000e+12 -1.000000e+12 1.139809e-03 8.453720e-04 8.453667e-04 -1.968571e-04 -1.000000e+12 6.002469e+03 6.442070e+01 1.454903e+00 -1.000000e+12 -1.000000e+12 5.130950e+04 1.158794e+03 4.143390e+04 1.158800e+03 5.130950e+04 -1.000000e+12 -1.000000e+12 3.217900e+00 6.496189e+01 -6.441719e+03 6.087360e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 8389051 8389051 1 40966 1.924710e-01 0 -999 1 4 5.714286e-02 0 -8.767097e+00 2.520024e-05 1.047472e-01 -2.491515e-03 -1.416101e-03 3.766508e-03 -2.225335e+00 -2.844600e-01 -1.248337e-02 -3.609023e-01 1 1 77125000254, no_data, no_data, no_data 77125000231, no_data, no_data, no_data 358.600006 65.289837 96.0 864.151 70 464330.310 13953.442643 -1.000000e+12 0 2 1 0 LINESTRING (-100.06409 17.97308, -100.06403 17...
927 77125000254 -1.000000e+12 -1.000000e+12 no_data 17.949648 -99.995193 no_data -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 12582912 12582912 3 469762048 -1.000000e+12 0 -999 1 -999 -1.000000e+12 2 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 1 1 77125000263, no_data, no_data, no_data 77125000241, no_data, no_data, no_data 423.700012 50.631649 162.0 21491.314 2 464735.375 405.065100 -1.000000e+12 10286 1 1 0 LINESTRING (-99.99547 17.95148, -99.99564 17.9...
928 77125000261 7.540756e+08 7.540756e+08 2023-11-23T17:26:47Z 18.362207 -100.696472 no_data 2.316304e+02 9.208000e-02 1.946000e-02 -1.000000e+12 -1.000000e+12 9.017132e-04 5.351440e-06 4.431470e-06 8.374171e-04 -1.000000e+12 3.976097e-05 3.544730e+02 2.232573e+00 -1.000000e+12 -1.000000e+12 3.936467e+06 2.479300e+04 3.776529e+06 2.479300e+04 3.936467e+06 -1.000000e+12 -1.000000e+12 1.037250e+01 1.555118e+02 -1.003980e+00 -1.240390e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 8389049 8389049 1 14 4.063000e-02 0 -999 0 56 1.000000e+00 0 -1.111140e+01 1.232563e-05 1.055168e-01 -1.683211e-03 -6.265789e-04 3.857576e-03 -2.255829e+00 -3.061254e-01 -1.237202e-02 1.378732e-01 2 1 77125000021, 77125000011, no_data, no_data 77123000251, no_data, no_data, no_data 232.000000 6.028838 195.0 3624.715 56 325106.825 11105.124379 -1.000000e+12 0 4 1 0 LINESTRING (-100.68734 18.40208, -100.68723 18...
929 77125000263 -1.000000e+12 -1.000000e+12 no_data 17.956269 -99.961388 no_data -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 12582912 12582912 3 469762048 -1.000000e+12 0 -999 1 -999 -1.000000e+12 2 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 1 1 77125000273, no_data, no_data, no_data 77125000254, no_data, no_data, no_data 463.500000 5.120043 459.0 43956.311 49 474450.182 9714.807127 -1.000000e+12 0 2 1 0 LINESTRING (-99.99398 17.94824, -99.99369 17.9...
930 77125000273 -1.000000e+12 -1.000000e+12 no_data 17.952683 -99.906755 no_data -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 12582912 12582912 3 469762048 -1.000000e+12 0 -999 1 -999 -1.000000e+12 2 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 1 1 77125000283, no_data, no_data, no_data 77125000263, no_data, no_data, no_data 463.500000 0.000000 819.0 283915.163 49 484179.822 9729.640027 -1.000000e+12 0 2 1 0 LINESTRING (-99.93256 17.94746, -99.93273 17.9...

931 rows × 127 columns

Quickly plot the SWOT river data

# Simple plot
fig, ax = plt.subplots(figsize=(7,5))
SWOT_HR_shp1.plot(ax=ax, color='black')

# # Another way to plot geopandas dataframes is with `explore`, which also plots a basemap
# SWOT_HR_shp1.explore()

2. Lake Vector Shapefiles

The lake vector shapefiles can be accessed in the same way as the river shapefiles above.

For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.

Search for data of interest

lake_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_LAKESP_2.0', 
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        granule_name = '*Prior*_009_NA*') # here we filter by files with 'Prior' in the name (This collection has three options: Obs, Unassigned, and Prior), pass #8 and continent code=NA
Granules found: 3

Set up an s3fs session for Direct Cloud Access

s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.

fs_s3 = earthaccess.get_s3fs_session(results=lake_results)

Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud

The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.

fiona_session=fiona.session.AWSSession(
        aws_access_key_id=fs_s3.storage_options["key"],
        aws_secret_access_key=fs_s3.storage_options["secret"],
        aws_session_token=fs_s3.storage_options["token"]
    )
# Get the link for the first zip file
lake_link = earthaccess.results.DataGranule.data_links(lake_results[0], access='direct')[0]

# We use the zip+ prefix so fiona knows that we are operating on a zip file
lake_shp_url = f"zip+{lake_link}"

with fiona.Env(session=fiona_session):
    SWOT_HR_shp2 = gpd.read_file(lake_shp_url) 

#view the attribute table
SWOT_HR_shp2
lake_id reach_id obs_id overlap n_overlap time time_tai time_str wse wse_u wse_r_u wse_std area_total area_tot_u area_detct area_det_u layovr_val xtrk_dist ds1_l ds1_l_u ds1_q ds1_q_u ds2_l ds2_l_u ds2_q ds2_q_u quality_f dark_frac ice_clim_f ice_dyn_f partial_f xovr_cal_q geoid_hght solid_tide load_tidef load_tideg pole_tide dry_trop_c wet_trop_c iono_c xovr_cal_c lake_name p_res_id p_lon p_lat p_ref_wse p_ref_area p_date_t0 p_ds_t0 p_storage geometry
0 7120818392 no_data 712238L999960 100 1 7.558788e+08 7.558788e+08 2023-12-14T14:20:39Z 4.221900e+02 3.900000e-02 3.100000e-02 1.750000e-01 1.133420e-01 2.746000e-03 1.123950e-01 2.746000e-03 2.450000e-01 -2.700895e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 8.362160e-01 2 -999 0 0 -2.960103e+01 -1.076270e-01 -1.385000e-02 -1.446900e-02 6.530000e-03 -2.219912e+00 -4.322200e-02 -2.460000e-03 -8.323030e-01 no_data -99999999 -93.370529 47.725706 -1.000000e+12 0.067500 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-93.37004 47.72747, -93.36976 ...
1 7120818432 no_data no_data no_data no_data -1.000000e+12 -1.000000e+12 no_data -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 2 -999 -999 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 SOUTH STURGEON LAKE -99999999 -93.063382 47.636276 -1.000000e+12 0.734400 no_data -1.000000e+12 -1.000000e+12 None
2 7120818512 no_data 712239L999974 91 1 7.558788e+08 7.558788e+08 2023-12-14T14:20:39Z 4.035210e+02 3.800000e-02 2.900000e-02 3.670000e-01 4.746580e-01 6.040000e-03 3.230260e-01 6.040000e-03 1.100000e-01 -4.768885e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 0 0 -2.928009e+01 -1.069980e-01 -1.387600e-02 -1.449100e-02 6.541000e-03 -2.224427e+00 -4.345700e-02 -2.448000e-03 -1.489370e+00 CONNORS LAKE -99999999 -93.634992 47.777938 -1.000000e+12 0.419400 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-93.64085 47.77833, -93.64070 ...
3 7120818532 no_data 712238L999960 100 1 7.558788e+08 7.558788e+08 2023-12-14T14:20:39Z 4.214720e+02 9.700000e-02 5.700000e-02 3.140000e-01 5.936400e-02 2.015000e-03 5.936400e-02 2.015000e-03 1.100000e-02 -2.658368e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 0.000000e+00 2 -999 0 0 -2.961158e+01 -1.076620e-01 -1.385000e-02 -1.446900e-02 6.530000e-03 -2.220099e+00 -4.328800e-02 -2.460000e-03 -8.189060e-01 no_data -99999999 -93.367313 47.718575 -1.000000e+12 0.018900 no_data -1.000000e+12 -1.000000e+12 POLYGON ((-93.36683 47.72159, -93.36655 47.721...
4 7120818542 no_data no_data no_data no_data -1.000000e+12 -1.000000e+12 no_data -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -999 -1.000000e+12 2 -999 -999 -999 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 no_data -99999999 -93.042420 47.711142 -1.000000e+12 0.031500 no_data -1.000000e+12 -1.000000e+12 None
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
56491 7131519532 no_data 713254R999944;713255R000006 45;42 2 7.558790e+08 7.558790e+08 2023-12-14T14:23:19Z 1.283300e+01 7.500000e-02 5.700000e-02 1.700000e-01 7.491100e-02 1.923000e-03 7.437200e-02 1.923000e-03 1.000000e-03 2.384581e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 0 0 -4.790753e+01 -7.896700e-02 -4.073000e-03 -2.923000e-03 5.666000e-03 -2.268012e+00 -1.023750e-01 -2.140000e-03 7.063360e-01 no_data -99999999 -88.000840 56.331699 -1.000000e+12 0.056700 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-87.99912 56.33127, -87.99922 ...
56492 7131519632 no_data 713254R999943;713255R000008 48;20 2 7.558790e+08 7.558790e+08 2023-12-14T14:23:19Z 1.074100e+01 1.570000e-01 1.460000e-01 1.420000e-01 3.342300e-02 1.435000e-03 3.152200e-02 1.435000e-03 5.000000e-03 2.730958e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 0 0 -4.786691e+01 -7.908800e-02 -3.548000e-03 -2.638000e-03 5.728000e-03 -2.268497e+00 -1.023450e-01 -2.141000e-03 8.137400e-01 no_data -99999999 -87.948521 56.320464 -1.000000e+12 0.025200 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-87.94670 56.32014, -87.94649 ...
56493 7131519662 no_data 713255R000009;713254R999940 42;33 2 7.558790e+08 7.558790e+08 2023-12-14T14:23:19Z 9.208000e+00 1.030000e-01 1.260000e-01 1.410000e-01 2.864300e-02 1.112000e-03 2.729100e-02 1.112000e-03 3.400000e-02 2.882420e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 0 0 -4.784918e+01 -7.914000e-02 -3.278000e-03 -2.509000e-03 6.730000e-03 -2.268922e+00 -1.023670e-01 -2.142000e-03 8.608050e-01 no_data -99999999 -87.925618 56.315773 -1.000000e+12 0.021600 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-87.92352 56.31520, -87.92363 ...
56494 7131560212 no_data 713245R000001;713245R999966;713245R999958;7132... 70;0;0;0;0;0;0;0;0;0;0 11 7.558789e+08 7.558789e+08 2023-12-14T14:21:43Z 3.717920e+02 1.000000e-03 1.000000e-03 3.720000e-01 3.853027e+02 3.084073e+00 3.231617e+02 3.084073e+00 7.000000e-03 4.695466e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 1 0 -3.585787e+01 -9.732200e-02 -1.303500e-02 -1.356500e-02 6.288000e-03 -2.208235e+00 -5.674900e-02 -2.306000e-03 1.424744e+00 CAT RIVER (EAST CHANNEL);LAKE ST JOSEPH;ST JOS... -99999999 -90.745713 51.058944 -1.000000e+12 526.421232 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-91.39550 50.91117, -91.39555 ...
56495 7420501022 no_data 742233R999968;742233R000007;742233R000003 57;8;4 3 7.558788e+08 7.558788e+08 2023-12-14T14:19:39Z 3.105560e+02 9.900000e-02 7.300000e-02 6.540000e-01 3.935470e-01 2.443000e-03 1.602010e-01 2.443000e-03 1.100000e-02 5.434642e+04 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 -1.000000e+12 0 -1.000000e+12 2 -999 0 0 -2.887526e+01 -1.217310e-01 -1.435000e-02 -1.513400e-02 6.583000e-03 -2.268862e+00 -5.500000e-02 -2.866000e-03 1.664425e+00 LAKE TUSTIN -99999999 -93.665611 44.206288 -1.000000e+12 0.546300 no_data -1.000000e+12 -1.000000e+12 MULTIPOLYGON (((-93.66006 44.20938, -93.66012 ...

56496 rows × 51 columns

Quickly plot the SWOT lakes data

fig, ax = plt.subplots(figsize=(7,5))
SWOT_HR_shp2.plot(ax=ax, color='black')

Accessing the remaining files is different than the shp files above. We do not need to read the shapefiles within a zip file using something like Fiona session (or to download and unzip in the cloud) because the following SWOT HR collections are stored in netCDF files in the cloud. For the rest of the products, we will open via xarray, not geopandas.

3. Water Mask Pixel Cloud NetCDF

Search for data collection and time of interest

For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.

pixc_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_PIXC_2.0', 
                                        #granule_name = '*_009_*', # pass number 9 if we want to filter further
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
Granules found: 39

Open data using xarray

The pixel cloud netCDF files are formatted with three groups titled, “pixel cloud”, “tvp”, or “noise” (more detail here). In order to access the coordinates and variables within the file, a group must be specified when calling xarray open_dataset.

ds_PIXC = xr.open_mfdataset(earthaccess.open([pixc_results[0]]), group = 'pixel_cloud', engine='h5netcdf')
ds_PIXC
Opening 1 granules, approx size: 0.22 GB
using endpoint: https://archive.swot.podaac.earthdata.nasa.gov/s3credentials
<xarray.Dataset>
Dimensions:                                (points: 2357958, complex_depth: 2,
                                            num_pixc_lines: 3278)
Coordinates:
    latitude                               (points) float64 dask.array<chunksize=(471592,), meta=np.ndarray>
    longitude                              (points) float64 dask.array<chunksize=(471592,), meta=np.ndarray>
Dimensions without coordinates: points, complex_depth, num_pixc_lines
Data variables: (12/61)
    azimuth_index                          (points) float64 dask.array<chunksize=(785986,), meta=np.ndarray>
    range_index                            (points) float64 dask.array<chunksize=(785986,), meta=np.ndarray>
    interferogram                          (points, complex_depth) float32 dask.array<chunksize=(785986, 1), meta=np.ndarray>
    power_plus_y                           (points) float32 dask.array<chunksize=(785986,), meta=np.ndarray>
    power_minus_y                          (points) float32 dask.array<chunksize=(785986,), meta=np.ndarray>
    coherent_power                         (points) float32 dask.array<chunksize=(785986,), meta=np.ndarray>
    ...                                     ...
    pixc_line_qual                         (num_pixc_lines) float64 dask.array<chunksize=(3278,), meta=np.ndarray>
    pixc_line_to_tvp                       (num_pixc_lines) float32 dask.array<chunksize=(3278,), meta=np.ndarray>
    data_window_first_valid                (num_pixc_lines) float64 dask.array<chunksize=(3278,), meta=np.ndarray>
    data_window_last_valid                 (num_pixc_lines) float64 dask.array<chunksize=(3278,), meta=np.ndarray>
    data_window_first_cross_track          (num_pixc_lines) float32 dask.array<chunksize=(3278,), meta=np.ndarray>
    data_window_last_cross_track           (num_pixc_lines) float32 dask.array<chunksize=(3278,), meta=np.ndarray>
Attributes:
    description:                 cloud of geolocated interferogram pixels
    interferogram_size_azimuth:  3278
    interferogram_size_range:    5623
    looks_to_efflooks:           1.5509709858820855
    num_azimuth_looks:           7.0
    azimuth_offset:              7

Simple plot of the results

# This could take a few minutes to plot
plt.scatter(x=ds_PIXC.longitude, y=ds_PIXC.latitude, c=ds_PIXC.height)
plt.colorbar().set_label('Height (m)')

4. Water Mask Pixel Cloud Vector Attribute NetCDF

Search for data of interest

pixcvec_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_PIXCVEC_2.0', 
                                        #granule_name = '*_009_*', # pass number 9 if we want to filter further
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX 
Granules found: 26

Open data using xarray

ds_PIXCVEC = xr.open_mfdataset(earthaccess.open([pixcvec_results[0]]), decode_cf=False,  engine='h5netcdf')
ds_PIXCVEC
Opening 1 granules, approx size: 0.21 GB
using endpoint: https://archive.swot.podaac.earthdata.nasa.gov/s3credentials
<xarray.Dataset>
Dimensions:               (points: 2831150, nchar_reach_id: 11,
                           nchar_node_id: 14, nchar_lake_id: 10,
                           nchar_obs_id: 13)
Dimensions without coordinates: points, nchar_reach_id, nchar_node_id,
                                nchar_lake_id, nchar_obs_id
Data variables:
    azimuth_index         (points) int32 dask.array<chunksize=(2831150,), meta=np.ndarray>
    range_index           (points) int32 dask.array<chunksize=(2831150,), meta=np.ndarray>
    latitude_vectorproc   (points) float64 dask.array<chunksize=(2831150,), meta=np.ndarray>
    longitude_vectorproc  (points) float64 dask.array<chunksize=(2831150,), meta=np.ndarray>
    height_vectorproc     (points) float32 dask.array<chunksize=(2831150,), meta=np.ndarray>
    reach_id              (points, nchar_reach_id) |S1 dask.array<chunksize=(2831150, 11), meta=np.ndarray>
    node_id               (points, nchar_node_id) |S1 dask.array<chunksize=(2831150, 14), meta=np.ndarray>
    lake_id               (points, nchar_lake_id) |S1 dask.array<chunksize=(2831150, 10), meta=np.ndarray>
    obs_id                (points, nchar_obs_id) |S1 dask.array<chunksize=(2831150, 13), meta=np.ndarray>
    ice_clim_f            (points) int8 dask.array<chunksize=(2831150,), meta=np.ndarray>
    ice_dyn_f             (points) int8 dask.array<chunksize=(2831150,), meta=np.ndarray>
Attributes: (12/45)
    Conventions:                     CF-1.7
    title:                           Level 2 KaRIn high rate pixel cloud vect...
    short_name:                      L2_HR_PIXCVec
    institution:                     CNES
    source:                          Level 1B KaRIn High Rate Single Look Com...
    history:                         2023-12-03T05:59:43.712142Z: Creation
    ...                              ...
    xref_prior_river_db_file:        
    xref_prior_lake_db_file:         SWOT_LakeDatabase_Nom_106_20000101T00000...
    xref_reforbittrack_files:        SWOT_RefOrbitTrackTileBoundary_Nom_20000...
    xref_param_l2_hr_laketile_file:  SWOT_Param_L2_HR_LakeTile_20000101T00000...
    ellipsoid_semi_major_axis:       6378137.0
    ellipsoid_flattening:            0.0033528106647474805

Simple plot

pixcvec_htvals = ds_PIXCVEC.height_vectorproc.compute()
pixcvec_latvals = ds_PIXCVEC.latitude_vectorproc.compute()
pixcvec_lonvals = ds_PIXCVEC.longitude_vectorproc.compute()

#Before plotting, we set all fill values to nan so that the graph shows up better spatially
pixcvec_htvals[pixcvec_htvals > 15000] = np.nan
pixcvec_latvals[pixcvec_latvals < 1] = np.nan
pixcvec_lonvals[pixcvec_lonvals > -1] = np.nan
plt.scatter(x=pixcvec_lonvals, y=pixcvec_latvals, c=pixcvec_htvals)
plt.colorbar().set_label('Height (m)')

5. Raster NetCDF

Search for data of interest

For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.

raster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_2.0', 
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        granule_name = '*100m*', # here we filter by files with '100m' in the name (This collection has two resolution options: 100m & 250m)
                                        bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
Granules found: 44

Open data with xarray

ds_raster = xr.open_mfdataset(earthaccess.open([raster_results[0]]), engine='h5netcdf')
ds_raster
Opening 1 granules, approx size: 0.04 GB
using endpoint: https://archive.swot.podaac.earthdata.nasa.gov/s3credentials
<xarray.Dataset>
Dimensions:                  (x: 1520, y: 1519)
Coordinates:
  * x                        (x) float64 2.969e+05 2.97e+05 ... 4.488e+05
  * y                        (y) float64 4.274e+06 4.274e+06 ... 4.426e+06
Data variables: (12/39)
    crs                      object ...
    longitude                (y, x) float64 dask.array<chunksize=(507, 507), meta=np.ndarray>
    latitude                 (y, x) float64 dask.array<chunksize=(507, 507), meta=np.ndarray>
    wse                      (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    wse_qual                 (y, x) float32 dask.array<chunksize=(1519, 1520), meta=np.ndarray>
    wse_qual_bitwise         (y, x) float64 dask.array<chunksize=(760, 760), meta=np.ndarray>
    ...                       ...
    load_tide_fes            (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    load_tide_got            (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    pole_tide                (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    model_dry_tropo_cor      (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    model_wet_tropo_cor      (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
    iono_cor_gim_ka          (y, x) float32 dask.array<chunksize=(760, 760), meta=np.ndarray>
Attributes: (12/49)
    Conventions:                   CF-1.7
    title:                         Level 2 KaRIn High Rate Raster Data Product
    source:                        Ka-band radar interferometer
    history:                       2023-12-03T08:26:57Z : Creation
    platform:                      SWOT
    references:                    V1.1.1
    ...                            ...
    x_min:                         296900.0
    x_max:                         448800.0
    y_min:                         4274000.0
    y_max:                         4425800.0
    institution:                   CNES
    product_version:               04

Quick interactive plot with hvplot

ds_raster.wse.hvplot.image(y='y', x='x')

6. SLC

Search for data collection and time of interest

For additional tips on spatial searching of SWOT HR L2 data, see also PO.DAAC Cookbook - SWOT Chapter tips section.

slc_results = earthaccess.search_data(short_name = 'SWOT_L1B_HR_SLC_2.0', 
                                        #temporal = ('2024-02-01 00:00:00', '2024-02-29 23:59:59'), # can also specify by time
                                        #granule_name = '*_009_*', # here we can additionally filter by pass number 009
                                        bounding_box = (-106.62, 38.809, -106.54, 38.859)) # Lake Travis near Austin, TX
Granules found: 46

Open data using xarray

The L1B_HR_SLC product file contains five NetCDF data group called the slc, xfactor, noise, tvp, and grdem groups. More info can be found in the product description document within the dataset table for each group.

ds_SLC = xr.open_mfdataset(earthaccess.open([slc_results[0]]), group = 'slc', engine='h5netcdf')
ds_SLC
Opening 1 granules, approx size: 2.25 GB
using endpoint: https://archive.swot.podaac.earthdata.nasa.gov/s3credentials
<xarray.Dataset>
Dimensions:      (num_lines: 22956, num_pixels: 5623, complex_depth: 2)
Dimensions without coordinates: num_lines, num_pixels, complex_depth
Data variables:
    slc_plus_y   (num_lines, num_pixels, complex_depth) float32 dask.array<chunksize=(3280, 804, 1), meta=np.ndarray>
    slc_minus_y  (num_lines, num_pixels, complex_depth) float32 dask.array<chunksize=(3280, 804, 1), meta=np.ndarray>
    slc_qual     (num_lines) float32 dask.array<chunksize=(22956,), meta=np.ndarray>
Attributes:
    description:  Single look complex images for plus_y and minus_y channels