Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 9e88a8e

Browse files
committed
🐛 fix landsat generation - confidence mask
1 parent b8a7fc6 commit 9e88a8e

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

cube_builder/utils/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def linear_raster_scale(array: ArrayType,
737737

738738

739739
def get_resample_method(name: str) -> Resampling:
740-
"""Retrieve a resampling method from name
740+
"""Retrieve a resampling method from name.
741741
742742
Note:
743743
This method uses ``rasterio.warp.Resampling``.

cube_builder/utils/processing.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,16 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
797797
saturated = radsat_extract_bits(saturated, 1, 7).astype(numpy.bool_)
798798
masked.mask[saturated] = True
799799

800+
# Get current observation file name
801+
file_path = bandlist[order].name
802+
file_date = datetime.strptime(merges_band_map[file_path], '%Y-%m-%d')
803+
day_of_year = file_date.timetuple().tm_yday
804+
805+
if build_clear_observation and is_combined_collection:
806+
datasource_block = provenance_merge_map[file_date.strftime('%Y-%m-%d')].dataset.read(1, window=window)
807+
if mask_values['bits']:
808+
confidence.oli = numpy.isin(datasource_block, index_landsat_oli)
809+
800810
if mask_values['bits']:
801811
matched = get_qa_mask(masked,
802812
clear_data=clear_values,
@@ -829,16 +839,6 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
829839

830840
stack_total_observation[window.row_off: row_offset, window.col_off: col_offset] += copy_mask.astype(numpy.uint8)
831841

832-
# Get current observation file name
833-
file_path = bandlist[order].name
834-
file_date = datetime.strptime(merges_band_map[file_path], '%Y-%m-%d')
835-
day_of_year = file_date.timetuple().tm_yday
836-
837-
if build_clear_observation and is_combined_collection:
838-
datasource_block = provenance_merge_map[file_date.strftime('%Y-%m-%d')].dataset.read(1, window=window)
839-
if mask_values['bits']:
840-
confidence.oli = datasource_block == index_landsat_oli
841-
842842
# Find all no data in destination STACK image
843843
stack_raster_where_nodata = numpy.where(
844844
stack_raster[window.row_off: row_offset, window.col_off: col_offset] == nodata
@@ -849,9 +849,6 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
849849
stack_raster[window.row_off: row_offset,
850850
window.col_off: col_offset].shape)
851851

852-
if build_clear_observation and is_combined_collection:
853-
datasource_block = provenance_merge_map[file_date.strftime('%Y-%m-%d')].dataset.read(1, window=window)
854-
855852
# Find all valid/cloud in destination STACK image
856853
raster_where_data = numpy.where(raster != nodata)
857854
raster_data_pos = numpy.ravel_multi_index(raster_where_data, raster.shape)

0 commit comments

Comments
 (0)