umr-lops / xsar

Synthetic Aperture Radar (SAR) Level-1 GRD python mapper for efficient xarray/dask based processing
https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsar/
MIT License
24 stars 8 forks source link

make operations at full res #193

Open vincelhx opened 5 months ago

vincelhx commented 5 months ago

force full resolution for DN operations and then reproject on user grid with rasterio.warp.reproject

vincelhx commented 5 months ago

idea of the code to use to reproject at the end (after denoising & recalibration) inspired by code in https://github.com/umr-lops/xarray-safe-s1/blob/main/safe_s1/metadata.py

sigma0_vv = s1DatasetfullRes.dataset.sigma0.sel(pol='VV')
src_crs = sigma0_vv.rio.crs  
src_transform = sigma0_vv.rio.transform() 
dst_crs = src_crs

sample, _ = translate * scale * (s1DatasetfullRes.dataset.sample, 0)
_, line = translate * scale * (0, s1DatasetfullRes.dataset.line)
dst2 = translate * scale
destination = np.empty(shape=out_shape, dtype=sigma0_vv.dtype)

zzzz_rms = rasterio.warp.reproject(
    source=sigma0_vv,
    destination=destination,
    src_transform=src_transform,
    src_crs=src_crs,
    dst_transform=dst2,
    dst_crs=dst_crs,
    resampling=Resampling.rms  
)