Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Lab 10: Spatial Comparisons with SWOT and PACE

In the previous labs, we have explored ways to generate maps and time series for a variety of different satellite data-derived products. In each of these cases, we were just using a single data product. We often would like to intercompare different products as the same locations. However, most data products will not be co-located in space because the satellites have different orbits, the sensors have different resolutions, and/or the products were simply generated on different grids.

In this lab we will see an example analyzing two different Level 2 products at the same location - one from NASA’s Plankton, Aerosol, Cloud, ocean Ecosystem (PACE) satellite and one from NASA’s Surface Water and Ocean Topography (SWOT) satellite.

This notebook has four parts:

  1. Find and download PACE and SWOT data

  2. Plot data side-by-side

  3. Detrend SWOT data to remove a “roll” error

  4. Interpolate data onto a common spatial grid

Import the modules for this notebook

To begin, let’s import the modules used for this notebook

Motivation

A submesoscale front is a strong gradient between waters with different temperature, salinity and/or densities in the ocean. Fronts are sites of counter-balance upwelling and downwelling flows that can extend several hundred meters down into the water column. Like other upwelling mechanisms, the upwelling limb of circulation near a front can often be associated with productivity. This effect is due to the vertical fluxes of nutrients from depth into the photic zone where nutrients may limit growth. Fronts are typically visible in sea surface height data because they are associated with the edges of eddies and other rotating features.

In this lab, we’re going to compare two metrics that relate phytoplankton biomass to the presence of submesoscale fronts. For phytoplankton, we’ll examine chlorophyll-a estimates from the ocean color instrument on NASA’s PACE satellite. For fronts, we’ll examine sea surface height anomalies from NASA’s SWOT satellite.

Part 1: Finding PACE and SWOT Granules

In the past few labs, we’ve used automated Python scripts to obtain satellite data. However, sometimes we’d like to search for a given scene that fits our need. NASA’s Earthdata portal provides a convenient way to search for scenes of interest. In this lab, we’ll use this tool to search for two different scenes that encompasses the California Current region around Monterey Bay area during the spring upwelling season.

Before we begin, let’s define a data folder where we will store our data:

Download a PACE Granule

When searching on the Earthdata portal, it’s helpful to know what data product you’re looking for - there’s lots of different products available! For PACE, we will search for the level 2 data product, described on the PACE OCI Level 2 product landing page. These pages and descriptions are useful for understanding the temporal and spatial coverage of the data product, and they provide a product identifier for finding the product in Earthdata. As we can see on the PACE data page indicated above, the identifier for this data set is PACE_OCI_L2_BGC. Enter this identifier into the search tab of the Earthdata page.

Next, add in spatial and temporal queries to narrow down the dataset. For this lab, we’ll investigate the time frame 4/16/26 to 4/19/26 and a spatial extent around the California Current region. You can add the spatial query by adding a rectangle or polygon to the map on Earth data.

After implementing these queries, your search should look like the following screenshot:

Screenshot of a data request from NASA’s Earthdata portal for a PACE Level 2 granule.

Figure 1:Screenshot of a data request from NASA’s Earthdata portal for a PACE Level 2 granule.

To follow along with this lab, find and download the following granule: PACE_OCI.20260417T201750.L2.OC_BGC.V3_2.nc.

Be sure to put this into your Lab 10 data directory.

Download a SWOT Granule

Similar to the PACE data search, we’ll also use the same strategy to find a SWOT granule. The SWOT product we will use for this lab is the SWOT Level 2 Basic product. As we can see on the landing page, the identifier for this product is SWOT_L2_LR_SSH_BASIC_D.

For this lab, we will use the following SWOT granule: SWOT_L2_LR_SSH_Basic_049_011_20260418T021204_20260418T030251_PID0_01.nc.

Be sure to store this in your Lab 10 directory. Note that the measurements in this file were taken approximately 6 hours later than the measurements from PACE.

Part 2: Plotting PACE and SWOT for Comparison

Plotting PACE Data

Now that we’ve got our data in hand, let’s plot it on a map and have a look. First, read in the data from the netCDF file:

Next, let’s add the data to a map using cartopy:

<Figure size 700x500 with 2 Axes>

It looks like there’s lots of interesting submesoscale features we can see reflected in the chlorophyll-a estimates.

Plotting SWOT Data

Next, let’s plot the data from the SWOT granule. As before, let’s read this in from the netCDF file:

Let’s see what this data looks like:

<Figure size 700x500 with 2 Axes>

As we can see, there is a significant “ramp” in the SWOT data resulting from the processing of KaRIn measurements and spacecraft orientation to retrieve sea surface height anomalies. Since the process by which this ramp is removed can impact the interpretation of oceanographic properties, the science team has opted to leave this anomaly in the data released publicly, tasking scientists to address this issue in their own processing. In the next section, we’ll see one approach to remove this ramp and recover spatial variations in sea surface height anomaly.

Part 3: Detrending SWOT Data

In the previous section, we saw that there is a cross-track “ramp” in the data. To remove this ramp and to reveal spatial patterns in sea surface height anomalies, we’ll make the assumption that the errors vary consistently in both the along-track and cross-track directions. We’ll approximate these errors using a quadratic polynomial fit to the data.

Specifically, we are going to compute a polynomial of the form

p(x,y)=C0+C1x+C2y+C3x2+C4y2p(x,y) = C_0 + C_1x + C_2y +C_3x^2 + C_4y^2

where xx and yy correspond to the columns and rows of the data grid and the CiC_i coefficients will be derived from the data.

To understand how the polynomial will be constructed, let’s take a look at how the dataset is organized by plotting the latitude field of the data product as a function of the rows and columns of the data structure:

<Figure size 640x480 with 2 Axes>

As we can see, the granule follows the swath along the track and it stretches from the south pole to the north pole (the whole ascending track!). Since we are going to fit a polynomial to the data to remove errors, let’s subset our data to the region only around the California Current where our investigation is focused.

Subsetting to a Region of Interest

To subset our SWOT data, let’s compute the rows containing the data in our domain:

Computing a Detrended Polynomial

Next, we’ll fit a polynomial to the data subset. To compute this polynomial, we will find the coefficients CiC_i as a function of the columns xx and rows yy of the data grid.

To solve for these coefficients, we want to find the CiC_i’s such that the difference between the data and the polynomial is minimized - a classic least square errors problem.

If we write this as a system of equations for each of the NN data points

H(x1,y1)=C0+C1x+C2y+C3x2+C4y2+ε1⋮H(xN,yN)=C0+C1x+C2y+C3x2+C4y2+εN\begin{align*} H(x_1, y_1) &= C_0 + C_1x + C_2y +C_3x^2 + C_4y^2 + \varepsilon_1\\ &\vdots\\ H(x_N, y_N) &= C_0 + C_1x + C_2y +C_3x^2 + C_4y^2 + \varepsilon_N\\ \end{align*}

we aim to minimize the errors εn\varepsilon_n. This can be written in matrix form as

[H(x1,y1)⋮H(xN,yN)]=[1x1y1x12y12⋮1xNyNxN2yN2][C0C1C2C3C4]\begin{align*} \begin{bmatrix}H(x_1, y_1) \\ \vdots \\ H(x_N, y_N) \end{bmatrix} &= \begin{bmatrix}1 & x_1 & y_1 & x_1^2 & y_1^2 \\ &&\vdots \\ 1 & x_N & y_N & x_N^2 & y_N^2 \end{bmatrix} \begin{bmatrix}C_0 \\ C_1 \\ C_2 \\ C_3 \\ C_4 \end{bmatrix} \end{align*}

We can write this more concisely as $$

H=AC\begin{align*} \textbf{H} &= \textbf{A}\textbf{C} \end{align*}

$$

Clearly, this is an undetermined system because the number of data points NN is much larger than the five coefficients CiC_i. However, the solution to the system which minimizes the errors computed with the root mean square error is the “psuedo inverse”

C=(ATA)−1ATH\begin{align*} \textbf{C} &= (\textbf{A}^T\textbf{A})^{-1}\textbf{A}^T\textbf{H} \end{align*}

This can be computed manually, but its also conveniently provided in the lstsq function of scipy’s linalg module. Let’s code this up

With the coefficients in hand, we can now compute the polynomial

Let’s have a look at what this polynomial looks like:

<Figure size 640x480 with 2 Axes>

As we can see, we’ve estimated the cross-track ramp in the data although we also see some along-track variation.

Next, we remove this ramp from our data product:

Let’s see how our new detrended data looks:

<Figure size 700x500 with 2 Axes>

As we can see, the removal of the “ramp” reveals spatial variations in sea surface height that were not detectable in our previous view of the data. Namely, we can see an area of anomalously low sea surface height which could be associated with a cyclonic (counter-clockwise) eddy.

Let’s compare this new view of our sea surface height data with the chlorophyll-a estimates to see if we can find any potential connections:

<Figure size 1000x700 with 4 Axes>

On the right hand plot, we can see that the location of the cyclonic eddy is consistent with a similar feature in the chlorophyll-a estimates! This is made particularly clear by overlaying the zero-SSHA contours on the chlorophyll-a data.

Part 4: Interpolating Onto A Common Grid

In this section, we are going to consider a comparison of the sea surface height anomaly and chlorophyll-a across the cyclonic eddy identified above. However, this comparison is made a little tricky due to the fact that the data are provided on very different grids. Here, we’ll see how to interpolate one data set onto the same grid as another.

A Cross-Eddy Transect

To begin, we’ll identify a cross-eddy transect in the SWOT data. Since the orbit of the satellite is directly across the eddy, we can take this directly from the SWOT data using a column in the data grid:

Let’s see what this transect looks like:

<Figure size 1400x500 with 3 Axes>

Interpolating PACE Data Onto the Transect

Next, we’ll interpolate the PACE data onto the SSHA transect using a linear interpolation. This is made quite easy with the help of scipy’s interpolate module:

Let’s see how the data compare:

<Figure size 1000x400 with 2 Axes>

As we can see, there is a sharp gradient in chlorophyll at the edge of the cyclonic eddy! This comparison reflects how physical oceanographic processes are reflected in biological processes and can be generalized to lots of other processes and regions.

🤔 Try it for yourself!

Using this same approach, examine another system in the ocean to investigate a relationship between sea surface height and another oceanographic variable. You can investigate chlorophyll-a or you can use any of the variables explored in previous labs.