fix(worker): use correct band names for DE Africa STAC in hybrid inference
Build and Push Docker Images / build-and-push (push) Has been cancelled Details

This commit is contained in:
fchinembiri 2026-05-01 13:00:22 +02:00
parent 084170ddc0
commit bcba162afd
1 changed files with 15 additions and 1 deletions

View File

@ -131,15 +131,29 @@ class DEAfricaSTACWrapper:
raise ValueError("No STAC items found for this bounding box and time range.") raise ValueError("No STAC items found for this bounding box and time range.")
print(f"Found {len(items)} STAC items. Loading into xarray...") print(f"Found {len(items)} STAC items. Loading into xarray...")
# Mapping for DE Africa S2 bands
band_map = {
'B04': 'red',
'B03': 'green',
'B02': 'blue',
'B08': 'nir',
'B05': 'red_edge_1',
'SCL': 'scl'
}
ds = odc.stac.load( ds = odc.stac.load(
items, items,
measurements=['red', 'green', 'blue', 'nir', 'red_edge_1', 'scl'], measurements=list(band_map.keys()),
bbox=bbox, bbox=bbox,
crs="EPSG:6933", crs="EPSG:6933",
resolution=resolution, resolution=resolution,
groupby="solar_day" groupby="solar_day"
) )
# Rename bands to expected names
ds = ds.rename(band_map)
print("Masking clouds and shadows...") print("Masking clouds and shadows...")
valid_mask = (ds.scl == 4) | (ds.scl == 5) | (ds.scl == 6) | (ds.scl == 2) | (ds.scl == 7) valid_mask = (ds.scl == 4) | (ds.scl == 5) | (ds.scl == 6) | (ds.scl == 2) | (ds.scl == 7)
ds = ds.where(valid_mask) ds = ds.where(valid_mask)