API reference

open_dataset

xsar.open_dataset(dataset_id, resolution=None, resampling=<Resampling.average: 5>, sub_datasets=None, chunks={'atrack': 120, 'xtrack': 120}, pol_dim=True, luts=False, dtypes=None)
Parameters
  • dataset_id (str or SentinelMeta object) – if str, it can be a path, or a gdal dataset identifier like ‘SENTINEL1_DS:%s:WV_001’ % filename) Note:SentinelMeta object or a full gdal string is mandatory if the SAFE has multiples subdatasets.

  • resolution (dict or None) – if None: dataset is read at full resolution. if dict: {‘atrack’: 20, ‘xtrack’: 20}, where 20 is in pixels. if resolution is not None, resampling will be used by rasterio.read to reduce resolution while reading low level dataset (i.e tiff file). if resampling is rasterio.enums.Resampling.nearest, the result looks like: >> res = [ 20 , 20 ] # note that in this case, res is in pixels. >> ds.sel(atrack=slice(res[0]/2-1,None,res[0]),xtrack=slice(res[1]/2-1,None,res[1]) but it’s computed much faster. Note also that the resulting array will have only one chunk, so it will have to fit in-memory when computed.

  • resampling (rasterio.enums.Resampling or str) – Only used if resolution is not None. ‘rms’ by default. rasterio.enums.Resampling.average` or rasterio.enums.Resampling.nearest are fastest.

  • sub_datasets (str, list of str, or None) – sub datasets to load. Names are the same as those given by gdalinfo (ie ‘WV_001’)

  • pol_dim (bool) – if False, datasets will not have ‘pol’ dimension, but several variables names (ie ‘sigma0_vv’ and ‘sigma0_vh’). (True by default).

  • luts (bool) – if True return also luts as variables (ie sigma0_lut, gamma0_lut, etc…). False by default.

  • chunks (dict) – dict with keys [‘pol’,’atrack’,’xtrack’] (dask chunks). Chunks size will be adjusted so every chunks have the same size. (rechunking later is possible if not wanted)

  • dtypes (None or dict) – Optional. Specify the data type for each variable. Keys are assumed with pol_dim=True (ie no _vv). Note also that: dtypes = { ‘digital_number’ : np.complex64, ‘sigma0_lut’: ‘f4’ } will also set ‘sigma0’ dtype to ‘f4’, because ‘sigma0’ is computed from ‘digital_number’ and ‘sigma0_lut’.

Returns

Return type

xarray.Dataset

open_mfdataset

xsar.open_mfdataset(datasets_paths, *args, **kwargs)

Open multiples datasets. See xsar.open_dataset for more infos.

Parameters

datasets_paths (iterable) – iterable of datasets path

Returns

with column ‘dataset’ that is an xarray dataset as returned by open_dataset

Return type

dataframe