From the PO.DAAC Cookbook, to access the GitHub version of the notebook, follow this link.
Working with SWOT Level 2 Water Mask Raster Image Data Product:
In AWS Cloud Version
Authors: Nicholas Tarpinian, PO.DAAC | Catalina Taglialatela (JPL, PO.DAAC)
Summary & Learning Objectives
Notebook showcasing how to work with multiple files from the SWOT Raster Image data product version C (aka 2.0) in the cloud
Utilizing the earthaccess Python package. For more information visit: https://nsidc.github.io/earthaccess/
Option to query the new dataset based on user’s choice; choosing between two resolutions either by ‘100m’ or ‘250m’.
Visualizing multiple raster images on a single map.
Stacking multiple raster images and creating a time dimension to analyze over time.
Adjusting images based on quality flag
Requirements
1. Compute environment
This tutorial is written to run in the following environment: - AWS instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via an s3fs session; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region. - This workflow as written works on a 14.8 GB RAM, upto 3.7 CPU cloud compute instance type. Smaller instances tent to crash.
2. 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. 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.
Import libraries
import ioimport s3fsimport xarray as xrimport numpy as npfrom datetime import datetimefrom pathlib import Pathimport hvplotimport hvplot.xarray import earthaccess
Authentication with earthaccess
In this notebook, we will be calling the authentication in the below cell.
auth = earthaccess.login()
Search for SWOT Raster products using earthaccess
Each dataset has its own unique collection concept ID. For the SWOT_L2_HR_Raster_2.0 dataset, we can find the collection ID here.
For this tutorial, we are looking at the Lake Mead Reservoir in the United States.
We used bbox finder to get the exact coordinates for our area of interest.
raster_results = earthaccess.search_data( short_name ='SWOT_L2_HR_RASTER_2.0', bounding_box=(-115.112686,35.740939,-114.224167,36.937819), temporal =('2024-02-01 12:00:00', '2024-02-01 23:59:59'), granule_name ='*_100m_*', #specify we are interested in the 100m standard raster count =200)
Granules found: 2
Visualizing Multiple Tiles
Let’s now visualize multiple raster tiles that we searched and explore the data.
Geodetic longitude [-180,180) (east of the Greenwich meridian) of the pixel.
Array
Chunk
Bytes
65.29 MiB
2.87 MiB
Shape
(2784, 3074)
(734, 513)
Dask graph
30 chunks in 23 graph layers
Data type
float64 numpy.ndarray
latitude
(y, x)
float64
dask.array<chunksize=(512, 513), meta=np.ndarray>
long_name :
latitude (positive N, negative S)
standard_name :
latitude
grid_mapping :
crs
units :
degrees_north
valid_min :
-80.0
valid_max :
80.0
comment :
Geodetic latitude [-80,80] (degrees north of equator) of the pixel.
Array
Chunk
Bytes
65.29 MiB
2.87 MiB
Shape
(2784, 3074)
(734, 513)
Dask graph
30 chunks in 23 graph layers
Data type
float64 numpy.ndarray
wse
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
water surface elevation above geoid
grid_mapping :
crs
units :
m
quality_flag :
wse_qual
valid_min :
-1500.0
valid_max :
15000.0
comment :
Water surface elevation of the pixel above the geoid and after using models to subtract the effects of tides (solid_earth_tide, load_tide_fes, pole_tide).
summary quality indicator for the water surface elevation
standard_name :
status_flag
grid_mapping :
crs
flag_meanings :
good suspect degraded bad
flag_values :
[0 1 2 3]
valid_min :
0
valid_max :
3
comment :
Summary quality indicator for the water surface elevation quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
Array
Chunk
Bytes
32.65 MiB
16.33 MiB
Shape
(2784, 3074)
(2784, 1538)
Dask graph
2 chunks in 21 graph layers
Data type
float32 numpy.ndarray
wse_qual_bitwise
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
bitwise quality indicator for the water surface elevation
Bitwise quality indicator for the water surface elevation quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
wse_uncert
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
uncertainty in the water surface elevation
grid_mapping :
crs
units :
m
valid_min :
0.0
valid_max :
999999.0
comment :
1-sigma uncertainty in the water surface elevation.
summary quality indicator for the water surface area
standard_name :
status_flag
grid_mapping :
crs
flag_meanings :
good suspect degraded bad
flag_values :
[0 1 2 3]
valid_min :
0
valid_max :
3
comment :
Summary quality indicator for the water surface area and water fraction quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
Array
Chunk
Bytes
32.65 MiB
16.33 MiB
Shape
(2784, 3074)
(2784, 1538)
Dask graph
2 chunks in 21 graph layers
Data type
float32 numpy.ndarray
water_area_qual_bitwise
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
bitwise quality indicator for the water surface area
Bitwise quality indicator for the water surface area and water fraction quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
water_area_uncert
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
uncertainty in the water surface area
grid_mapping :
crs
units :
m^2
valid_min :
0.0
valid_max :
2000000000.0
comment :
1-sigma uncertainty in the water surface area.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
water_frac
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
water fraction
grid_mapping :
crs
units :
1
quality_flag :
water_area_qual
valid_min :
-1000.0
valid_max :
10000.0
comment :
Fraction of the pixel that is water.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
water_frac_uncert
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
uncertainty in the water fraction
grid_mapping :
crs
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
1-sigma uncertainty in the water fraction.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
sig0
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
sigma0
grid_mapping :
crs
units :
1
quality_flag :
sig0_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Normalized radar cross section (sigma0) in real, linear units (not decibels). The value may be negative due to noise subtraction.
Summary quality indicator for the sigma0 quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
Bitwise quality indicator for the sigma0 quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
sig0_uncert
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
uncertainty in sigma0
grid_mapping :
crs
units :
1
valid_min :
-999999.0
valid_max :
999999.0
comment :
1-sigma uncertainty in sigma0. The value is provided in linear units. This value is a one-sigma additive (not multiplicative) uncertainty term, which can be added to or subtracted from sigma0.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
inc
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
incidence angle
grid_mapping :
crs
units :
degrees
valid_min :
0.0
valid_max :
90.0
comment :
Incidence angle.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
cross_track
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
approximate cross-track location
grid_mapping :
crs
units :
m
valid_min :
-75000.0
valid_max :
75000.0
comment :
Approximate cross-track location of the pixel.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
illumination_time
(y, x)
datetime64[ns]
dask.array<chunksize=(512, 513), meta=np.ndarray>
long_name :
time of illumination of each pixel (UTC)
standard_name :
time
tai_utc_difference :
37.0
leap_second :
0000-00-00T00:00:00Z
comment :
Time of measurement in seconds in the UTC time scale since 1 Jan 2000 00:00:00 UTC. [tai_utc_difference] is the difference between TAI and UTC reference time (seconds) for the first measurement of the data set. If a leap second occurs within the data set, the attribute leap_second is set to the UTC time at which the leap second occurs.
Array
Chunk
Bytes
65.29 MiB
2.87 MiB
Shape
(2784, 3074)
(734, 513)
Dask graph
30 chunks in 23 graph layers
Data type
datetime64[ns] numpy.ndarray
illumination_time_tai
(y, x)
datetime64[ns]
dask.array<chunksize=(512, 513), meta=np.ndarray>
long_name :
time of illumination of each pixel (TAI)
standard_name :
time
comment :
Time of measurement in seconds in the TAI time scale since 1 Jan 2000 00:00:00 TAI. This time scale contains no leap seconds. The difference (in seconds) with time in UTC is given by the attribute [illumination_time:tai_utc_difference].
Array
Chunk
Bytes
65.29 MiB
2.87 MiB
Shape
(2784, 3074)
(734, 513)
Dask graph
30 chunks in 23 graph layers
Data type
datetime64[ns] numpy.ndarray
n_wse_pix
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
number of water surface elevation pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in water surface elevation aggregation.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
n_water_area_pix
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
number of water surface area pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in water surface area and water fraction aggregation.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
n_sig0_pix
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
number of sigma0 pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in sigma0 aggregation.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
n_other_pix
(y, x)
float64
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
number of other pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in aggregation of quantities not related to water surface elevation, water surface area, water fraction or sigma0.
Array
Chunk
Bytes
65.29 MiB
7.32 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float64 numpy.ndarray
dark_frac
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
fractional area of dark water
grid_mapping :
crs
units :
l
valid_min :
-1000.0
valid_max :
10000.0
comment :
Fraction of pixel water surface area covered by dark water.
Climatological ice cover flag indicating whether the pixel is ice-covered on the day of the observation based on external climatological information (not the SWOT measurement). Values of 0, 1, and 2 indicate that the pixel is likely not ice covered, may or may not be partially or fully ice covered, and likely fully ice covered, respectively.
Dynamic ice cover flag indicating whether the surface is ice-covered on the day of the observation based on analysis of external satellite optical data. Values of 0, 1, and 2 indicate that the pixel is not ice covered, partially ice covered, and fully ice covered, respectively.
Array
Chunk
Bytes
32.65 MiB
16.33 MiB
Shape
(2784, 3074)
(2784, 1538)
Dask graph
2 chunks in 21 graph layers
Data type
float32 numpy.ndarray
layover_impact
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
layover impact
grid_mapping :
crs
units :
m
valid_min :
-999999.0
valid_max :
999999.0
comment :
Estimate of the water surface elevation error caused by layover.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
sig0_cor_atmos_model
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
two-way atmospheric correction to sigma0 from model
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
1
valid_min :
1.0
valid_max :
10.0
comment :
Atmospheric correction to sigma0 from weather model data as a linear power multiplier (not decibels). sig0_cor_atmos_model is already applied in computing sig0.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
height_cor_xover
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
height correction from KaRIn crossovers
grid_mapping :
crs
units :
m
valid_min :
-10.0
valid_max :
10.0
comment :
Height correction from KaRIn crossover calibration. The correction is applied before geolocation but reported as an equivalent height correction.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
geoid
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
geoid height
standard_name :
geoid_height_above_reference_ellipsoid
source :
EGM2008 (Pavlis et al., 2012)
grid_mapping :
crs
units :
m
valid_min :
-150.0
valid_max :
150.0
comment :
Geoid height above the reference ellipsoid with a correction to refer the value to the mean tide system, i.e. includes the permanent tide (zero frequency).
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
solid_earth_tide
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
solid Earth tide height
source :
Cartwright and Taylor (1971) and Cartwright and Edden (1973)
grid_mapping :
crs
units :
m
valid_min :
-1.0
valid_max :
1.0
comment :
Solid-Earth (body) tide height. The zero-frequency permanent tide component is not included.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
load_tide_fes
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
geocentric load tide height (FES)
source :
FES2014b (Carrere et al., 2016)
institution :
LEGOS/CNES
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth’s crust.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
load_tide_got
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
geocentric load tide height (GOT)
source :
GOT4.10c (Ray, 2013)
institution :
GSFC
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth’s crust. This value is reported for reference but is not applied to the reported height.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
pole_tide
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
geocentric pole tide height
source :
Wahr (1985) and Desai et al. (2015)
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric pole tide height. The total of the contribution from the solid-Earth (body) pole tide height and the load pole tide height (i.e., the effect of the ocean pole tide loading of the Earth’s crust).
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
model_dry_tropo_cor
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
dry troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
m
valid_min :
-3.0
valid_max :
-1.5
comment :
Equivalent vertical correction due to dry troposphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
model_wet_tropo_cor
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
wet troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
m
valid_min :
-1.0
valid_max :
0.0
comment :
Equivalent vertical correction due to wet troposphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.
Array
Chunk
Bytes
32.65 MiB
3.66 MiB
Shape
(2784, 3074)
(1247, 769)
Dask graph
12 chunks in 23 graph layers
Data type
float32 numpy.ndarray
iono_cor_gim_ka
(y, x)
float32
dask.array<chunksize=(768, 769), meta=np.ndarray>
long_name :
ionosphere vertical correction
source :
Global Ionosphere Maps
institution :
JPL
grid_mapping :
crs
units :
m
valid_min :
-0.5
valid_max :
0.0
comment :
Equivalent vertical correction due to ionosphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.