Download this notebook from github.


XSAR simple example

just open a dataset with xsar.open_dataset, and display denoised sigma0 in ‘VH’ polarisation

[1]:
import xarray as xr
import xsar
import os
[2]:
import holoviews as hv
hv.extension('bokeh')
from holoviews.operation.datashader import datashade,rasterize
import datashader as dh
[3]:
# get test file. You can replace with an path to other SAFE
filename = xsar.get_test_file('S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE')
filename
[3]:
'/tmp/S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE'
[4]:
# open the datatree with xarray
dt_xsar = xsar.open_datatree(filename,resolution='100m')
dt_xsar
[4]:
<xarray.DatasetView>
Dimensions:  ()
Data variables:
    *empty*
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
[5]:
# open the dataset with xarray
ds_xsar = xsar.open_dataset(filename, resolution='100m')
ds_xsar
[5]:
<xarray.Dataset>
Dimensions:               (pol: 2, line: 1677, sample: 2518)
Coordinates:
  * pol                   (pol) object 'VV' 'VH'
  * line                  (line) float64 4.5 14.5 24.5 ... 1.675e+04 1.676e+04
  * sample                (sample) float64 4.5 14.5 24.5 ... 2.516e+04 2.517e+04
    spatial_ref           int64 0
Data variables: (12/21)
    digital_number        (pol, line, sample) uint16 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    time                  (line) timedelta64[ns] 17416 days 10:30:20.94383948...
    sampleSpacing         float64 100.0
    lineSpacing           float64 100.0
    ground_heading        (line, sample) float32 dask.array<chunksize=(1677, 2518), meta=np.ndarray>
    land_mask             (line, sample) int8 dask.array<chunksize=(1677, 2518), meta=np.ndarray>
    ...                    ...
    sigma0_raw            (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    nesz                  (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    gamma0_raw            (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    negz                  (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    sigma0                (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), meta=np.ndarray>
    gamma0                (pol, line, sample) float64 dask.array<chunksize=(1, 1677, 2518), 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
[ ]:

[6]:
# we use here 'rasterize' to display the image, because the full image is really big
rasterize(hv.Image(ds_xsar.sigma0.sel(pol='VH')).opts(cmap='gray',colorbar=True,tools=['hover'],title="xsar",width=800,height=800,clim=(0,0.02)))
[6]: