Applying Rada Shadow to Data Cube

Hey all,

There are 3 options which were tried but they did not work for applying the radar shadow mask to a data cube. Please can you advice, how to apply the radar shadow mask to a data cube correctly?

These option were tested but none of them works:
Option A:

start_date = '2021-12-07'
end_date   = '2021-12-15'
spatial_extent  = {'west': -74.06810760, 'east': -73.90597343, 'south': 4.689864510, 'north': 4.724080996, 'crs': 'epsg:4326'} #colombia

s1_cube = connection.load_collection(
    'SENTINEL1_GRD',
     spatial_extent = spatial_extent,
     temporal_extent = [start_date, end_date],
     bands = ['VH','VV'],
     properties = {"polarization": lambda p: p == "DV"}
     )
     
s1_cube_ard = s1_cube.ard_normalized_radar_backscatter(elevation_model="COPERNICUS_30")

s1_cube_mask = s1_cube_ard.band("mask")
s1_mask_RS= (s1_cube_mask == 2)

s1_cube_masked = s1_cube_ard.mask(s1_mask_RS)
s1_cube_masked.download("s1_RS_masked")

Error: ValueError : Invalid band name/index ‘mask’. Valid names: [‘VH’, ‘VV’]

Option B:

s1_cube_ard = s1_cube.ard_normalized_radar_backscatter(elevation_model="COPERNICUS_30")
s1_cube_ard.download("s1_cube_ARD_DEM.nc")

ds_s1_cube_ard = xarray.open_dataset("s1_cube_ARD_DEM.nc").load()
mask = ds_s1_cube_ard["mask"]
RS_mask = (mask == 2)
s1_cube_ard_masked = s1_cube_ard.mask(RS_mask)

s1_cube_ard.download("s1_cube_ARD_DEM_masked.nc")

Error : AttributeError: DataArray’ object has no attribute '_pg

Option C:

s1_cube_ard = s1_cube.ard_normalized_radar_backscatter(elevation_model="COPERNICUS_30")
s1_cube_ard.download("s1_cube_ARD_DEM.nc")

ds_s1_cube_ard = xarray.open_dataset("s1_cube_ARD_DEM.nc").load()
mask = ds_s1_cube_ard["mask"]
RS_mask = (mask == 2)
s1_cube_ard_masked = ds_s1_cube_ard.mask(RS_mask)

s1_cube_ard_masked.download("s1_cube_ARD_DEM_masked.nc")

Error: TypeError : ‘DataArray’ object is not callable

Hi Andrea,
option B and C won’t work because you mix XArray objects with openEO data cubes.
Option A is closest, the problem is that on the backend side, these bands will be added by ard_normalized_radar_backscatter, but the python client doesn’t know that.

Can you try inserting:

s1_cube = s1_cube.rename_labels("bands",["VH","VV","mask", "incidence_angle])

This should get you past this error about unknown band names.

It works now :wink: