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 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_dataset funcion return a regular xarray.Dataset object
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: 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> elevation (atrack, xtrack) float32 dask.array<chunksize=(5000, 5000), meta=np.ndarray> incidence (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
xarray.Dataset
- atrack: 16778
- pol: 2
- xtrack: 25187
- pol(pol)object'VV' 'VH'
array(['VV', 'VH'], dtype=object)
- atrack(atrack)float640.5 1.5 2.5 ... 1.678e+04 1.678e+04
- units :
- 1
array([5.00000e-01, 1.50000e+00, 2.50000e+00, ..., 1.67755e+04, 1.67765e+04, 1.67775e+04])
- xtrack(xtrack)float640.5 1.5 2.5 ... 2.519e+04 2.519e+04
- units :
- 1
array([5.00000e-01, 1.50000e+00, 2.50000e+00, ..., 2.51845e+04, 2.51855e+04, 2.51865e+04])
- digital_number(pol, atrack, xtrack)uint16dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Array Chunk Bytes 1.57 GiB 47.68 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 98 Tasks 48 Chunks Type uint16 numpy.ndarray - time(atrack)datetime64[ns]2017-09-07T10:30:20.936409088 .....
array(['2017-09-07T10:30:20.936409088', '2017-09-07T10:30:20.937899264', '2017-09-07T10:30:20.939389184', ..., '2017-09-07T10:30:45.932283904', '2017-09-07T10:30:45.933773824', '2017-09-07T10:30:45.935264000'], dtype='datetime64[ns]')
- longitude(atrack, xtrack)float32dask.array<chunksize=(5000, 5000), meta=np.ndarray>
- standard_name :
- longitude
- units :
- degrees_east
Array Chunk Bytes 1.57 GiB 95.37 MiB Shape (16778, 25187) (5000, 5000) Count 144 Tasks 24 Chunks Type float32 numpy.ndarray - latitude(atrack, xtrack)float32dask.array<chunksize=(5000, 5000), meta=np.ndarray>
- standard_name :
- latitude
- units :
- degrees_north
Array Chunk Bytes 1.57 GiB 95.37 MiB Shape (16778, 25187) (5000, 5000) Count 144 Tasks 24 Chunks Type float32 numpy.ndarray - elevation(atrack, xtrack)float32dask.array<chunksize=(5000, 5000), meta=np.ndarray>
Array Chunk Bytes 1.57 GiB 95.37 MiB Shape (16778, 25187) (5000, 5000) Count 97 Tasks 24 Chunks Type float32 numpy.ndarray - incidence(atrack, xtrack)float32dask.array<chunksize=(5000, 5000), meta=np.ndarray>
Array Chunk Bytes 1.57 GiB 95.37 MiB Shape (16778, 25187) (5000, 5000) Count 97 Tasks 24 Chunks Type float32 numpy.ndarray - sigma0_raw(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
- units :
- m2/m2
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 628 Tasks 48 Chunks Type float64 numpy.ndarray - nesz(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 798 Tasks 48 Chunks Type float64 numpy.ndarray - gamma0_raw(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
- units :
- m2/m2
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 628 Tasks 48 Chunks Type float64 numpy.ndarray - negz(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 798 Tasks 48 Chunks Type float64 numpy.ndarray - sigma0(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 1232 Tasks 48 Chunks Type float64 numpy.ndarray - gamma0(pol, atrack, xtrack)float64dask.array<chunksize=(1, 5000, 5000), meta=np.ndarray>
Array Chunk Bytes 6.30 GiB 190.73 MiB Shape (2, 16778, 25187) (1, 5000, 5000) Count 1232 Tasks 48 Chunks Type float64 numpy.ndarray
- ipf :
- 2.84
- platform :
- SENTINEL-1A
- swath :
- IW
- product :
- GRDH
- pols :
- VV VH
- name :
- SENTINEL1_DS:/tmp/S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE:IW
- 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.22162571215458 21.14758369556577, -70.51434171237564 19.64044158236074, -68.15836401927538 19.21519321274318, -67.84221143971432 20.72564283093837))
- 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"))
[5]: