Download notebook

Download SWOT from AVISO

This notebook demonstrates how to browse and download SWOT LR data available on AVISO using the Altimetry Downloader Aviso tool.

Note

Required environment to run this notebook:

Tutorial Objectives

  • Explore products from AVISO using the altimetry_downloader_aviso

  • Download a product using the altimetry_downloader_aviso

  • Load a dataset through Opendap

Import + code

import logging
logging.basicConfig(level=logging.INFO)
from pathlib import Path
import altimetry_downloader_aviso as dl_aviso

Parameters

Define an output folder to save results

output_dir= Path.home() / "TMP_DATA"

Using the Altimetry Downloader Aviso

Discover Aviso’s products

Use the summary and details commands to discover Aviso’s catalog products.

cat = dl_aviso.summary()
INFO:altimetry_downloader_aviso.catalog_client.client:Fetching products from Aviso's catalog...
for product in cat.products:
    print(f"{product.short_name} -> {product.title}")
SWOT_L3_LR_WIND_WAVE_Extended -> Wind & Wave product SWOT Level-3 WindWave - Extended
L4_exp_with_SWOT -> Experimental Products: Multimission Gridded (with SWOT) Level-4 Sea Surface Heights and Velocities
SWOT_L3_LR_WIND_WAVE_Light -> Wind & Wave product SWOT Level-3 WindWave - Light
SWOT_L3_LR_SSH_Unsmoothed -> Altimetry product SWOT Level-3 Low Rate SSH - Unsmoothed
SWOT_L3_LR_SSH_Technical -> Altimetry product SWOT Level-3 Low Rate SSH - Technical
SWOT_L2_LR_SSH_Expert -> Altimetry product SWOT Level-2 KaRIn Low Rate SSH - Expert
SWOT_L3_LR_SSH_Expert -> Altimetry product SWOT Level-3 Low Rate SSH - Expert
SWOT_L2_LR_SSH_Basic -> Altimetry product SWOT Level-2 KaRIn Low Rate SSH - Basic
SWOT_L2_LR_SSH_WindWave -> Altimetry product SWOT Level-2 KaRIn Low Rate SSH - WindWave
SWOT_L2_LR_SSH_Unsmoothed -> Altimetry product SWOT Level-2 KaRIn Low Rate SSH - Unsmoothed
SWOT_L3_LR_SSH_Basic -> Altimetry product SWOT Level-3 Low Rate SSH - Basic
product = dl_aviso.details('SWOT_L3_LR_SSH_Basic')
INFO:altimetry_downloader_aviso.catalog_client.client:Fetching products from Aviso's catalog...
INFO:altimetry_downloader_aviso.catalog_client.client:Requesting 'SWOT_L3_LR_SSH_Basic' product from Aviso's catalog...
product.last_version
'v3.0'

Tip

In order to explore data on AVISO’s catalog (see half-orbits available…), you can explore the catalog url with the product’s tds_catalog_url attribute

product.tds_catalog_url
'https://tds-odatis.aviso.altimetry.fr/thredds/catalog/L3/SWOT_KARIN-L3_LR_SSH.html'

Download a product

Use the get command to download a product from Aviso.

The first time you download a product using the Altimetry Downloader Aviso, credentials will be asked for Aviso authentication. They will be stored in a ~/.netrc file.

Aviso authentication screenshot

dl_aviso.get?
Signature:
dl_aviso.get(
    product_short_name: str,
    output_dir: str | pathlib.Path,
    cycle_number: int | list[int] | None = None,
    pass_number: int | list[int] | None = None,
    time: tuple[numpy.datetime64, numpy.datetime64] | None = None,
    version: str | None = None,
    overwrite: bool = False,
) -> list[str]
Docstring:
Downloads a product from Aviso's Thredds Data Server.

Parameters
----------
product_short_name
    the short name of the product
output_dir
    directory to store downloaded product files
cycle_number
    the cycle number for files/folders selection
pass_number
    the pass number for files/folders selection
time
    the period for files/folders selection
version
    the version for files/folders selection
overwrite: bool
    whether to overwrite files if they already exist

Returns
-------
    The list of downloaded local file paths
File:      ~/workspace/GITHUB_robin-cls/aviso_robin-cls/altimetry_downloader_aviso/core.py
Type:      function
dl_aviso.get(
    'SWOT_L2_LR_SSH_Basic', 
    output_dir=output_dir, 
    cycle_number=37, 
    pass_number=2,
    version='PID0'
)
INFO:altimetry_downloader_aviso.catalog_client.client:Fetching products from Aviso's catalog...
INFO:altimetry_downloader_aviso.catalog_client.granule_discoverer:Filtering SWOT_L2_LR_SSH_Basic product with filters {'cycle_number': 37, 'pass_number': 2, 'version': 'PID0'}...
INFO:altimetry_downloader_aviso.core:1 files to download. 0 files already exist.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L2_LR_SSH_Basic_037_002_20250810T092805_20250810T101933_PID0_01.nc downloaded.
['/home/atonneau/TMP_DATA/SWOT_L2_LR_SSH_Basic_037_002_20250810T092805_20250810T101933_PID0_01.nc']

To download several cycles and/or half-orbits:

dl_aviso.get(
    'SWOT_L3_LR_SSH_Basic', 
    output_dir=output_dir, 
    cycle_number=[40, 41], 
    pass_number=list(range(10, 16)),
    overwrite=True
)
INFO:altimetry_downloader_aviso.catalog_client.client:Fetching products from Aviso's catalog...
INFO:altimetry_downloader_aviso.catalog_client.granule_discoverer:Filtering SWOT_L3_LR_SSH_Basic product with filters {'cycle_number': [40, 41], 'pass_number': [10, 11, 12, 13, 14, 15]}...
INFO:altimetry_downloader_aviso.core:12 files to download.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_010_20251012T063453_20251012T072620_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_011_20251012T072620_20251012T081747_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_012_20251012T081747_20251012T090913_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_013_20251012T090914_20251012T100040_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_014_20251012T100041_20251012T105207_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_015_20251012T105207_20251012T114334_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_010_20251102T031959_20251102T041126_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_011_20251102T041126_20251102T050253_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_012_20251102T050253_20251102T055419_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_013_20251102T055420_20251102T064546_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_014_20251102T064547_20251102T073713_v3.0.nc downloaded.
INFO:altimetry_downloader_aviso.tds_client:File /home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_015_20251102T073714_20251102T082840_v3.0.nc downloaded.
['/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_010_20251012T063453_20251012T072620_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_011_20251012T072620_20251012T081747_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_012_20251012T081747_20251012T090913_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_013_20251012T090914_20251012T100040_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_014_20251012T100041_20251012T105207_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_040_015_20251012T105207_20251012T114334_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_010_20251102T031959_20251102T041126_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_011_20251102T041126_20251102T050253_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_012_20251102T050253_20251102T055419_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_013_20251102T055420_20251102T064546_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_014_20251102T064547_20251102T073713_v3.0.nc',
 '/home/atonneau/TMP_DATA/SWOT_L3_LR_SSH_Basic_041_015_20251102T073714_20251102T082840_v3.0.nc']

Load a dataset via OPeNDAP

To find the data you want to load, you can explore the Swot LR L2 or Swot LR L3 catalogues.

Copy the OPeNDAP URL to load the dataset through OPeNDAP:

OPeNDAP screenshot

Note

Environment needed to run the following:

  • xarray

  • requests

  • altimetry_downloader_aviso

import warnings
warnings.filterwarnings('ignore')
import requests as rq
import xarray as xr
from xarray.backends import PydapDataStore
NETRC_PATH = Path.home() / '.netrc'

def open_dataset(dataset_url):
    """ Open the dataset at dataset_url.
    Args:
        dataset_url

    Returns:
        xr.Dataset
    """            
    session = rq.Session()
    try:
        store = PydapDataStore.open(dataset_url, session=session, timeout=300, user_charset='UTF-8')
        return xr.open_dataset(store)
    except Exception as e:
        print(f"Something wrong with opendap url {dataset_url}: {e}")
swot_lr_dataset_url = "https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc"
swot_lr_dataset = open_dataset(swot_lr_dataset_url)
swot_lr_dataset
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?time[0:1:0]
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?time[9859:1:9859]
<xarray.Dataset> Size: 27MB
Dimensions:          (num_lines: 9860, num_pixels: 69, num_nadir: 902)
Coordinates:
    latitude         (num_lines, num_pixels) float64 5MB ...
    longitude        (num_lines, num_pixels) float64 5MB ...
Dimensions without coordinates: num_lines, num_pixels, num_nadir
Data variables:
    time             (num_lines) datetime64[ns] 79kB ...
    mdt              (num_lines, num_pixels) float64 5MB ...
    ssha_filtered    (num_lines, num_pixels) float64 5MB ...
    ssha_unfiltered  (num_lines, num_pixels) float64 5MB ...
    i_num_line       (num_nadir) int16 2kB ...
    i_num_pixel      (num_nadir) int8 902B ...
Attributes: (12/43)
    Conventions:                     CF-1.9
    Metadata_Conventions:            Unidata Dataset Discovery v1.0
    cdm_data_type:                   Swath
    comment:                         Sea Surface Height measured by Altimetry
    data_used:                       SWOT KaRIn L2_LR_SSH PGC0/PIC0/PIC2/PID0...
    doi:                             https://doi.org/10.24400/527896/A01-2023...
    ...                              ...
    geospatial_lon_max:              359.999872
    date_modified:                   2025-11-24T17:18:30Z
    history:                         2025-11-24T17:18:30Z: Created by DUACS K...
    date_created:                    2025-11-24T17:18:30Z
    date_issued:                     2025-11-24T17:18:30Z
    temporality:                     forward

Select variables

variables = ['time', 'ssha_filtered']
ds = swot_lr_dataset[variables]
ds
<xarray.Dataset> Size: 16MB
Dimensions:        (num_lines: 9860, num_pixels: 69)
Coordinates:
    latitude       (num_lines, num_pixels) float64 5MB ...
    longitude      (num_lines, num_pixels) float64 5MB ...
Dimensions without coordinates: num_lines, num_pixels
Data variables:
    time           (num_lines) datetime64[ns] 79kB ...
    ssha_filtered  (num_lines, num_pixels) float64 5MB ...
Attributes: (12/43)
    Conventions:                     CF-1.9
    Metadata_Conventions:            Unidata Dataset Discovery v1.0
    cdm_data_type:                   Swath
    comment:                         Sea Surface Height measured by Altimetry
    data_used:                       SWOT KaRIn L2_LR_SSH PGC0/PIC0/PIC2/PID0...
    doi:                             https://doi.org/10.24400/527896/A01-2023...
    ...                              ...
    geospatial_lon_max:              359.999872
    date_modified:                   2025-11-24T17:18:30Z
    history:                         2025-11-24T17:18:30Z: Created by DUACS K...
    date_created:                    2025-11-24T17:18:30Z
    date_issued:                     2025-11-24T17:18:30Z
    temporality:                     forward

Select lines

Select lines to load

idx_first, idx_last = 5000, 6000
ds = xr.merge([ds[var][idx_first:idx_last] for var in variables])
ds.load()
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?time[5000:1:5999]
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?latitude[5000:1:5999][0:1:68]
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?longitude[5000:1:5999][0:1:68]
INFO:pydap.handlers.dap:Fetching URL: https://tds-odatis.aviso.altimetry.fr/thredds/dodsC/dataset-l3-swot-karin-nadir-validated/l3_lr_ssh/v3_0/Basic/forward/cycle_037/SWOT_L3_LR_SSH_Basic_037_014_20250810T194528_20250810T203655_v3.0.nc.dods?ssha_filtered[5000:1:5999][0:1:68]
<xarray.Dataset> Size: 2MB
Dimensions:        (num_lines: 1000, num_pixels: 69)
Coordinates:
    latitude       (num_lines, num_pixels) float64 552kB -1.155 -1.157 ... -19.2
    longitude      (num_lines, num_pixels) float64 552kB 12.69 12.67 ... 14.21
Dimensions without coordinates: num_lines, num_pixels
Data variables:
    time           (num_lines) datetime64[ns] 8kB 2025-08-10T20:11:33.7479399...
    ssha_filtered  (num_lines, num_pixels) float64 552kB nan nan nan ... nan nan
Attributes:
    comment:             Time of measurement in seconds in the UTC time scale...
    leap_second:         0000-00-00T00:00:00Z
    long_name:           time in UTC
    standard_name:       time
    tai_utc_difference:  37.0
    _ChunkSizes:         9860

Store the dataset to a NetCDF file

nc_file= output_dir / "my_swot_data.nc"
# Set encoding for each variable
for var in list(ds.keys()):
    ds[var].encoding = {'zlib':True, 'complevel':5}
ds.to_netcdf(nc_file, mode='w')

Download notebook