Skip to main content

Hi,

My group used your code several times successfully.
However, when running the following command lately we run into an error:
measurements = extract_surface_water_area_per_frame(42, nominal_outline, the_dam_bbox, date, resx, resy)

**ValueError: Parameter 'all_bands' is set to False. Therefore expected band data with 10 bands, got 9 bands**

Any clues?

 

I guess this is related to V3 transition.


Hi,
we have no problem running BlueDot even after V3 transition.
Can you dig in deeper, providing with the acutal request, that fails, so that we can try to help you with?


Hi,

Thank you for your reply.

As I mentioned in my initial post, when running the following command:
measurements = extract_surface_water_area_per_frame(42, nominal_outline, the_dam_bbox, date, resx, resy)

I got this error:
ValueError Traceback (most recent call last)
in ()
4 the_dam_bbox = get_bbox(nominal_outline)
5 resx, resy = get_optimal_resolution(the_dam_bbox)
----> 6 measurements = extract_surface_water_area_per_frame(42, nominal_outline, the_dam_bbox, date, resx, resy)
7
8 measurement_with_dem = surface_water_area_with_dem_veto(measurements, nominal_outline, the_dam_bbox, resx, resy, 15)

/content/water-observatory-backend/src/s2_water_extraction.py in extract_surface_water_area_per_frame(dam_id, dam_poly, dam_bbox, date, resx, resy)
130 try:
131 all_cloud_masks = CloudMaskRequest(ogc_request=wcs_bands_request, threshold=0.4)
--> 132 cloud_mask = all_cloud_masks.get_cloud_masks()
133 except (DownloadFailedException, ImageDecodingError):
134 set_measurement_status(measurement, WaterDetectionStatus.SH_REQUEST_ERROR)

/usr/local/lib/python3.6/dist-packages/s2cloudless/S2PixelCloudDetector.py in get_cloud_masks(self, threshold, non_valid_value)
286 :rtype: numpy.ndarray
287 """
--> 288 self.get_probability_masks()
289
290 cloud_masks = self.cloud_detector.get_mask_from_prob(self.probability_masks, threshold)

/usr/local/lib/python3.6/dist-packages/s2cloudless/S2PixelCloudDetector.py in get_probability_masks(self, non_valid_value)
270 if self.probability_masks is None:
271 self.get_data()
--> 272 self.probability_masks = self.cloud_detector.get_cloud_probability_maps(self.bands)
273
274 self.probability_masks[~self.valid_data] = non_valid_value

/usr/local/lib/python3.6/dist-packages/s2cloudless/S2PixelCloudDetector.py in get_cloud_probability_maps(self, X, **kwargs)
105 if band_num != exp_bands:
106 raise ValueError("Parameter 'all_bands' is set to {}. Therefore expected band data with {} bands, "
--> 107 "got {} bands".format(self.all_bands, exp_bands, band_num))
108
109 if self.all_bands:

ValueError: Parameter 'all_bands' is set to False. Therefore expected band data with 10 bands, got 9 bands

I guess this is related to Evalscript at line 32 in the s2_water_extraction.py code:
S2_CLOUD_BANDS_SCRIPT = ‘return nB01,B02,B04,B05,B08,B8A,B09,B10,B11,B12]’

 


Sorry, I am not familiar with technical details of BlueDot, so you will have to provide more information if you think it is related to V3.

Looking at the logs, you mostly call the following script, which return 10 band value and data mask.


    //VERSION=3
function setup() {
return {
input: [{
bands: ["B01", "B02", "B04", "B05", "B08","B8A", "B09", "B10", "B11", "B12", "dataMask"],
}],
output: {
bands: 11,
sampleType: "FLOAT32"
}
};
}

function evaluatePixel(sample) {
return [sample.B01,
sample.B02,
sample.B04,
sample.B05,
sample.B08,
sample.B8A,
sample.B09,
sample.B10,
sample.B11,
sample.B12,
sample.dataMask];
}

And this script is perfectly fine.

I therefore suggest to check the code on what happens in the next step…


Hi,

Can you please send me the link of this script?

 


Hi,

The issue is related to the evalscript V3 transition as I mentioned earlier.
For this end, I created 2 pull requests:
one to the BlueDot repo and the second for the s2cloudless library.

Thanks.

 


Thank you for your contribution, most appreciated.


Reply