Faraday rotation is the rotation of a radar signal’s polarization that occurs as it passes through the ionosphere. The magnitude of the rotation depends on the local geomagnetic field and the total electron content (TEC) along the signal’s path. TEC also impacts phase, so a Faraday rotation estimate can indicate which acquisitions may be prone to ionospheric phase delay.
Faraday rotation in the ionosphere scales with the square of a SAR signal’s wavelength (). Therefore, polarization rotation is much more pronounced in NISAR’s ~25cm L-band data than in Sentinel-1’s ~5cm C-band data.
This notebook loads NISAR L-band GSLC data and performs a Faraday rotation estimation using the circular-basis method described in equation 14 of F. J. Meyer and J. B. Nicoll’s, “Prediction, detection, and correction of Faraday rotation in full-polarimetric L-band SAR data”.
Overview¶
1. Prerequisites¶
| Prerequisite | Importance | Notes |
|---|---|---|
| The software environment for this cookbook must be installed | Necessary |
Rough Notebook Time Estimate: 10 minutes
2. Search for data¶
Quad-pol data are only acquired in some areas, so it may be helpful to use Vertex to visually identify suitable AOIs prior to searching programmatically.

Quad-pol GSLC search on Vertex
Example quad-pol GSLC search on Vertex.
Select “Quad Pol” from the L-Band Polarization filter.
2a. Perform an asf_search.search()¶
Adjust the search parameters below to find a quad-pol GSLC product.
import asf_search as asf
from datetime import datetime
from getpass import getpass
import warnings
warnings.filterwarnings(
"ignore",
message="Parsing dates involving a day of month without a year specified",
)
session = asf.ASFSession()
start_date = datetime(2026, 7, 26)
end_date = datetime(2026, 12, 31)
area_of_interest = "POINT(447.0504 24.5906)" # POINT or POLYGON as WKT (well-known-text)
pattern = r'^(?=.*QP)(?!.*QA_STATS).*' # Select QP (quad-pol) data and disregard QA_STATS products
opts=asf.ASFSearchOptions(**{
"maxResults": 250,
"intersectsWith": area_of_interest,
"flightDirection": "DESCENDING",
"start": start_date,
"end": end_date,
"dataMaturity" : "PROVISIONAL",
"processingLevel": ["GSLC"],
"dataset": ["NISAR"],
"productionConfiguration": ["PR"],
"session": session,
})
response = asf.search(opts=opts)
hdf5_urls = response.find_urls(extension='.h5', pattern=pattern, directAccess=False)
print(f"Found {len(hdf5_urls)} GSLC products:")
hdf5_urlsWARNING:asf_search:WKT REPAIR/VALIDATION: The following repairs were performed on the provided AOI:
["'type': 'WRAP': 'report': 'Wrapped 1 value(s) to +/-180 longitude'"]
Found 4 GSLC products:
['https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GSLC_PROVISIONAL_V1/NISAR_L2_PR_GSLC_028_120_D_076_2005_QPDH_A_20260821T125100_20260821T125134_P05023_N_F_J_001/NISAR_L2_PR_GSLC_028_120_D_076_2005_QPDH_A_20260821T125100_20260821T125134_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GSLC_PROVISIONAL_V1/NISAR_L2_PR_GSLC_029_120_D_076_2005_QPDH_A_20260902T125059_20260902T125134_P05023_N_F_J_001/NISAR_L2_PR_GSLC_029_120_D_076_2005_QPDH_A_20260902T125059_20260902T125134_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GSLC_PROVISIONAL_V1/NISAR_L2_PR_GSLC_030_120_D_076_2005_QPDH_A_20260914T125059_20260914T125134_P05023_N_F_J_001/NISAR_L2_PR_GSLC_030_120_D_076_2005_QPDH_A_20260914T125059_20260914T125134_P05023_N_F_J_001.h5',
'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GSLC_PROVISIONAL_V1/NISAR_L2_PR_GSLC_031_120_D_076_2005_QPDH_A_20260926T125059_20260926T125134_P05023_N_F_J_001/NISAR_L2_PR_GSLC_031_120_D_076_2005_QPDH_A_20260926T125059_20260926T125134_P05023_N_F_J_001.h5']2b. Select a url from the search results¶
hdf5_url = hdf5_urls[0]
hdf5_url'https://nisar.asf.earthdatacloud.nasa.gov/NISAR/NISAR_L2_GSLC_PROVISIONAL_V1/NISAR_L2_PR_GSLC_028_120_D_076_2005_QPDH_A_20260821T125100_20260821T125134_P05023_N_F_J_001/NISAR_L2_PR_GSLC_028_120_D_076_2005_QPDH_A_20260821T125100_20260821T125134_P05023_N_F_J_001.h5'2c. Provide your Earthdata Login (EDL) Bearer Token¶
Both HTTPS and S3 access require an EDL Bearer Token

View or generate a Bearer Token in “Generate Token” tab of the Profile page in your Earthdata Login account: https://
token = getpass("Enter your EDL Bearer Token")Enter your EDL Bearer Token ········
%%time
import asf_search as asf
import fsspec
import rioxarray
import xarray as xr
group_path = "/science/LSAR/GSLC/grids/frequencyA"
fs = fsspec.filesystem(
"http",
headers = {"Authorization": f"Bearer {token}"},
block_size = 16 * 512 * 512,
)
f = fs.open(hdf5_url, "rb")
dt = xr.open_datatree(
f,
engine="h5netcdf",
decode_timedelta=False,
phony_dims="access",
chunks="auto",
group=group_path
)
display(dt)CPU times: user 651 ms, sys: 121 ms, total: 772 ms
Wall time: 7.25 s
3b. Create a spatial subset¶
import rioxarray
ds = dt.to_dataset()
projection = ds.projection.attrs['epsg_code'].item()
ds = ds.rio.write_crs(projection) # write the project to the HHHH data for easy lat/lon subsetting
# subset the data
subset_ds = ds.rio.clip_box(
minx=446.5857, miny=24.7935,
maxx=446.7342, maxy=24.9244,
crs="EPSG:4326"
)
subset_ds4. Perform a Faraday Rotation estimation and calculate a quality metric¶
4a. Define functions to perform a Faraday Rotation estimation over an optionally multilooked GSLC¶
Use the circular-basis method for Faraday rotation estimation described in equation 14 of F. J. Meyer and J. B. Nicoll’s, “Prediction, detection, and correction of Faraday rotation in full-polarimetric L-band SAR data”
import numpy as np
import xarray as xr
def multilook_mean(da, ly=1, lx=1, x_coord="xCoordinates", y_coord="yCoordinates"):
"""
Spatially multilook an `xarray.DataArray` by taking the mean over
pixel windows (ly x lx).
da : (xarray.Dataset or xarray.DataArray) 2D DataArray to multilook
ly : (int) Number of pixels to average together in the y direction
lx : (int) Number of pixels to average together in the x direction
returns: Multilooked xarray.DataArray
"""
return da.coarsen(
{y_coord: ly, x_coord: lx},
boundary="trim"
).mean()
def calculate_circular_terms(hh, hv, vh, vv):
"""
Off-diagonal circular-basis terms (Bickel & Bates; Meyer & Nicoll 2008):
Z12 = j(hh + vv) + (hv - vh)
Z21 = j(hh + vv) + (vh - hv)
"""
j = 1j
z12 = j * (hh + vv) + (hv - vh)
z21 = j * (hh + vv) + (vh - hv)
return z12, z21
def get_phase_product(z12, z21, ly=1, lx=1, x_coord="xCoordinates", y_coord="yCoordinates"):
# Find cross-product of off-diagonal terms
phase_product = z12 * np.conj(z21)
# multilook the cross-product of off-diagonal terms
return multilook_mean(
phase_product,
ly=ly, lx=lx,
x_coord=x_coord, y_coord=y_coord
)
def faraday_rotation_circular_basis(phase_product_ml, ly=1, lx=1, x_coord="xCoordinates", y_coord="yCoordinates"):
"""
Estimate Faraday rotation angle using the circular-basis method:
[Z11 Z12] [1 j] [M'hh M'vh] [1 j]
[Z21 Z22] = [j 1] [M'hv M'vv] [j 1]
from which we derive:
Ω_hat = 1/4 * arg(Z12 * conj(Z21))
M′: measured scattering matrices (linear basis)
Ω_hat: Faraday Rotation angle estimate
Z: circular basis (Z12: RL, Z21: LR)
arg: argument of complex number (phase in the complex plane)
References:
- F. J. Meyer and J. B. Nicoll, “Prediction, detection, and correction of Faraday rotation in full-polarimetric
L-band SAR data,” IEEE Trans. Geosci. Remote Sens., vol. 46, no. 10, pp. 3076–3086, Oct. 2008.
https://topex.ucsd.edu/pub/sandwell/Venus_InSAR/atmosphere/meyer_nicoll_TGRS46_10_ionosphere_Polarimetry.pdf
- S. H. Bickel and R. H. T. Bates, “Effects of magneto-ionic propagation on the
polarization scattering matrix,” Proc. IEEE, vol. 53, no. 8, pp. 1089–1091, Aug. 1965
hh, hv, vh, vv : (xarray.Dataset or xarray.DataArray) Complex-valued, linearly polarized image DataArrays
ly : (int) Number of looks in y for multilooking
lx : (int) Number of looks in x for multilooking
x_coord: (string) DataArrays' x coordinate variable name
y_coord: (sring) DataArrays' y coordinate variable name
Returns: omega (xarray.DataArray) Estimated Faraday rotation angle in radians
"""
# P = Z12 * conj(Z21)
# Ω_hat = 1/4 * arg(P)
# and
# Z=x+iy
# cosθ = x/hyp, sinθ = y/hyp
# θ = arctan(y/x)
# ∴
# arg(P)=atan2(ℑ(P),ℜ(P))
# Ω_hat = 1/4 * atan2(ℑ(P),ℜ(P))
omega_rad = 0.25 * xr.apply_ufunc(
np.arctan2, # np.arctan2 avoids quadrant ambiguity
phase_product_ml.imag, # y-coord
phase_product_ml.real, # x-coord
dask="parallelized",
output_dtypes=[np.float64],
)
omega_rad.name = "faraday_rotation_rad"
omega_rad.attrs["units"] = "radian"
return omega_rad
def coherence_based_quality(z12, z21, phase_product_ml, ly=1, lx=1, x_coord="xCoordinates", y_coord="yCoordinates"):
"""
Provides the local complex (backscatter amplitude and phase) correlation magnitude between the two circular-basis channels
Coherence-based quality metric
P = Z12 * conj(Z21)
quality = |P| / sqrt(|Z12|^2 * |Z21|^2)
quality ≈ 1: stable phase difference, reliable FR estimate
quality ≈ 0: random/noisy phase difference, unreliable FR estimate
"""
z12_pow_ml = multilook_mean(
np.abs(z12) ** 2,
ly=ly, lx=lx,
x_coord=x_coord, y_coord=y_coord
)
z21_pow_ml = multilook_mean(
np.abs(z21) ** 2,
ly=ly, lx=lx,
x_coord=x_coord, y_coord=y_coord
)
quality = np.abs(phase_product_ml) / np.sqrt(z12_pow_ml * z21_pow_ml)
quality = quality.clip(0, 1)
quality.name = "faraday_rotation_quality"
quality.attrs["units"] = "unitless"
return quality4b. Calculate the circular basis, Faraday Rotation estimate, and quality metric¶
z12, z21 = calculate_circular_terms(
subset_ds.HH,
subset_ds.HV,
subset_ds.VH,
subset_ds.VV
)
lx, ly = 10, 10 # multilooking window
phase_product_ml = get_phase_product(z12, z21, ly=ly, lx=lx)
omega_rad = faraday_rotation_circular_basis(phase_product_ml, ly=ly, lx=lx)
quality = coherence_based_quality(z12, z21, phase_product_ml, ly=ly, lx=lx)
if hasattr(subset_ds.HH, "rio") and subset_ds.HH.rio.crs is not None:
omega_rad = omega_rad.rio.write_crs(subset_ds.HH.rio.crs, inplace=False)
quality = quality.rio.write_crs(subset_ds.HH.rio.crs, inplace=False)5. Convert the Faraday Rotation Estimate from radians to degrees, mask based on a quality threshold, and project to Web-Mercator (EPSG:3857)¶
5a. Set a quality threshold for masking the Faraday Rotation estimation¶
quality_thresh = 0.655b. Convert the Faraday Rotation estimate from radians to degrees and mask it based on the quality threshold defined in Step 5a¶
import numpy as np
omega_deg = np.degrees(omega_rad)
omega_deg.name = "faraday_rotation_deg"
omega_deg.attrs["units"] = "degree"
omega_deg_masked = omega_deg.where(quality >= quality_thresh)
omega_deg_masked.name = "faraday_rotation_deg_quality_masked"
omega_deg_masked.attrs["units"] = "degree"
omega_deg_masked.attrs["quality_threshold"] = quality_thresh5c. Reproject the Faraday Rotation estimate and quality metric rasters to Web-Mercator (EPSG:3857) for plotting¶
%%time
omega_web = omega_deg_masked.rio.reproject("EPSG:3857").compute()
quality_web = quality.rio.reproject_match(omega_web).compute()
print(f"FR min/max: {float(omega_web.min())}, {float(omega_web.max())}")
abs_fr = np.abs(omega_web)
print(f"Mean abs FR: {float(abs_fr.mean(skipna=True))}")
print(f"Median abs FR: {float(abs_fr.median(skipna=True))}")
print(f"Std FR: {float(omega_web.std(skipna=True))}")
print(f"Quality min/max: {float(quality_web.min())}, {float(quality_web.max())}")
print(f"Quality valid pixels: {int(quality_web.count())}")FR min/max: -11.224892616271973, 28.431591033935547
Mean abs FR: 4.801558947807341
Median abs FR: 4.902161121368408
Std FR: 1.9307295003239537
Quality min/max: 0.1773519217967987, 0.9962980151176453
Quality valid pixels: 53357
CPU times: user 4.54 s, sys: 1.12 s, total: 5.66 s
Wall time: 1min 8s
6. Plot the Faraday rotation over a basemap¶
“Faraday rotation (FR) angles of less than are generally considered acceptable for many commonly used SAR parameter extraction methods. Higher levels of FR can introduce significant errors in SAR image interpretation and analysis, particularly for polarimetric decompositions that rely on channel ratios.”
import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd().parent))
from util.plot_faraday import fr_view
fr_view(omega_web, quality_web)7. Summary¶
You now have the tools and knowledge that you need to search GSLC data with asf_search, stream it with ffspec and xarray, and estimate Faraday rotation caused by passage of the signal through the ionosphere.