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 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>
Dimensions:               (pol: 2, line: 16778, sample: 25187)
Coordinates:
  * pol                   (pol) object 'VV' 'VH'
  * line                  (line) int64 0 1 2 3 4 ... 16774 16775 16776 16777
  * sample                (sample) int64 0 1 2 3 4 ... 25183 25184 25185 25186
    spatial_ref           int64 0
Data variables: (12/21)
    digital_number        (pol, line, sample) uint16 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    time                  (line) timedelta64[ns] 17416 days 10:30:20.93638912...
    sampleSpacing         float64 10.0
    lineSpacing           float64 10.0
    ground_heading        (line, sample) float32 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    land_mask             (line, sample) int8 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    ...                    ...
    sigma0_raw            (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    nesz                  (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0_raw            (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    negz                  (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    sigma0                (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0                (pol, line, sample) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Attributes: (12/17)
    name:              SENTINEL1_DS:/tmp/S1A_IW_GRDH_1SDV_20170907T103020_201...
    short_name:        SENTINEL1_DS:S1A_IW_GRDH_1SDV_20170907T103020_20170907...
    product:           GRDH
    safe:              S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_01826...
    swath:             IW
    multidataset:      False
    ...                ...
    footprint:         POLYGON ((-67.84221143971432 20.72564283093837, -70.22...
    coverage:          170km * 251km (line * sample )
    pixel_line_m:      <xarray.DataArray 'azimuthPixelSpacing' ()>\narray(10....
    pixel_sample_m:    <xarray.DataArray 'groundRangePixelSpacing' ()>\narray...
    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, thas 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 aditionnal 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 !

Reference

Get in touch

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


Last documentation build: Oct 17 2022 at 10:23