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 dataset with xarray
sar_ds = xsar.open_dataset(filename)
sar_ds
[4]:
<xarray.Dataset>
Dimensions:         (atrack: 16778, pol: 2, xtrack: 25187)
Coordinates:
  * pol             (pol) object 'VV' 'VH'
  * atrack          (atrack) float64 0.5 1.5 2.5 ... 1.678e+04 1.678e+04
  * xtrack          (xtrack) float64 0.5 1.5 2.5 ... 2.519e+04 2.519e+04
Data variables: (12/14)
    digital_number  (pol, atrack, xtrack) uint16 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    time            (atrack) datetime64[ns] 2017-09-07T10:30:20.936409088 ......
    longitude       (atrack, xtrack) float32 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    latitude        (atrack, xtrack) float32 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    land_mask       (atrack, xtrack) int8 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    ground_heading  (atrack, xtrack) float32 dask.array<chunksize=(5000, 5000), meta=np.ndarray>
    ...              ...
    sigma0_raw      (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    nesz            (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0_raw      (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    negz            (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    sigma0          (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
    gamma0          (pol, atrack, xtrack) float64 dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Attributes: (12/15)
    ipf:               2.84
    platform:          SENTINEL-1A
    swath:             IW
    product:           GRDH
    pols:              VV VH
    name:              SENTINEL1_DS:/tmp/S1A_IW_GRDH_1SDV_20170907T103020_201...
    ...                ...
    coverage:          170km * 251km (atrack * xtrack )
    pixel_atrack_m:    10.152619433217325
    pixel_xtrack_m:    9.986179379582328
    orbit_pass:        Descending
    platform_heading:  -167.7668824808032
    Conventions:       CF-1.7
[5]:
# we use here 'rasterize' to display the image, because the full image is really big
rasterize(hv.Image(sar_ds.sigma0.sel(pol='VH')).opts(cmap='gray',colorbar=True,tools=['hover'],title="xsar",width=800,height=800,clim=(0,0.02)))
[5]: