ASFHyP3 / hyp3-autorift

A HyP3 plugin for feature tracking processing with AutoRIFT-ISCE
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

Ensure all encoding attributes are carried over when cropping #282

Closed jhkennedy closed 1 month ago

jhkennedy commented 1 month ago

For Sentinel-1 granules, the M11/M12 variables lost their scale_factor and add_offset attributes when cropping, leading to corrupted data. This ensures those attributes are preserved.

Refs:

To test you can download this uncropped S1 product:

aws s3 ls --no-sign-request s3://jhk-shenanigans/ITS_LIVE/crop/S1A_IW_SLC__1SDV_20170203T162106_20170203T162132_015121_018B9A_1380_X_S1A_IW_SLC__1SDV_20170215T162105_20170215T162133_015296_019127_6E1E_G0120V02_P099_IL_ASF_OD.nc

and then run:

from pathlib import Path

from hyp3_autorift.crop import crop_netcdf_product

netcdf_file = Path('S1A_IW_SLC__1SDV_20170203T162106_20170203T162132_015121_018B9A_1380_X_S1A_IW_SLC__1SDV_20170215T162105_20170215T162133_015296_019127_6E1E_G0120V02_P099_IL_ASF_OD.nc')

cropped_file = crop_netcdf_product(netcdf_file)

You should see a scale_factor and add_offset attribute for the M11/M12 variables (easiest to check with ncdump -h) using this branch, and not using the develop branch.