xsar: efficient level 1 sar reader for xarray/dask

xsar is a distributed level 1 SAR file reader designed to write efficient distributed processing algorhitm with xarray and dask.

It currently handles Level-1 Sentinel-1 and Radarsat-2 data in SAFE format, as found on scihub or PEPS.

xsar is as simple to use as the well known xarray.open_dataset : simply give the dataset path, and xsar.open_dataset() will return an datatree.DataTree:

import xsar
filename = xsar.get_test_file('S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE')
sar_ds = xsar.open_dataset(filename)
sar_ds
<xarray.Dataset> Size: 95GB
Dimensions:               (line: 16778, sample: 25187, pol: 2)
Coordinates:
  * line                  (line) int64 134kB 0 1 2 3 ... 16774 16775 16776 16777
  * sample                (sample) int64 201kB 0 1 2 3 ... 25184 25185 25186
  * pol                   (pol) object 16B 'VV' 'VH'
    spatial_ref           int64 8B 0
Data variables: (12/27)
    digital_number        (pol, line, sample) uint16 2GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    time                  (line) datetime64[ns] 134kB 2017-09-07T10:30:20.936...
    sampleSpacing         float64 8B 10.0
    lineSpacing           float64 8B 10.0
    gamma0_lut            (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    noise_lut_azi         (pol, line, sample) float32 3GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    ...                    ...
    sigma0_raw            (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    nesz                  (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0_raw            (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    negz                  (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    sigma0                (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0                (pol, line, sample) float64 7GB dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Attributes: (12/15)
    name:              SENTINEL1_DS:/home1/scratch/agrouaze/xsardatasync/xsar...
    short_name:        SENTINEL1_DS:S1A_IW_GRDH_1SDV_20170907T103020_20170907...
    product:           GRDH
    safe:              S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_01826...
    swath:             IW
    multidataset:      False
    ...                ...
    start_date:        2017-09-07 10:30:20.936409
    stop_date:         2017-09-07 10:30:45.935264
    footprint:         POLYGON ((-67.84221143971432 20.72564283093837, -70.22...
    coverage:          170km * 251km (line * sample )
    orbit_pass:        Descending
    platform_heading:  -167.7668824808032

Documentation

Overview

xsar rely on xarray.open_rasterio, rasterio and GDAL to read digital_number from SAFE product to return an xarray.Dataset object with dask chunks.

Luts are decoded from xml files and applied to digital_number, following official ESA thermal denoising document and ESA Sentinel-1 Product Specification.

So end user can directly use for example sigma0 variable, this is the denoised sigma0 computed from digital_number and by applying relevants luts.

Because xsar rely on dask, it have a small memory footprint: variables are read from file and computed only if needed.

xsar.open_dataset() is very close to xarray.open_dataset, but in the followings examples, you will find some additional keywords and classes that allow to:

Examples

Note

With recommended installation you will be able to download and execute those examples in jupyter notebook.

Those examples will automatically download test data from https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsardata/

Those file are not official ones: they are resampled to a lower resoltion and compressed to avoid big network transfert and disk usage.

Don’t use them for real science !

UML Description

Reference

Get in touch

  • Report bugs, suggest features or view the source code on github.


Last documentation build: Jul 30 2024 at 12:19