sentinel-hub/sentinel2-cloud-detector

Parameter 'all_bands' is set to False

aghand0ur opened this issue · 1 comments

Hello,

Using this library:
https://github.com/sentinel-hub/water-observatory-backend/blob/master/src/s2_water_extraction.py

When running the following command, I run into an error:
measurements = extract_surface_water_area_per_frame(42, nominal_outline, the_dam_bbox, date, resx, resy)

------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-29-ae7355c2e783> in <module>()
      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)

3 frames
/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)
    160     try:
    161         all_cloud_masks = CloudMaskRequest(ogc_request=wcs_bands_request, threshold=0.4)
--> 162         cloud_mask = all_cloud_masks.get_cloud_masks()
    163     except (DownloadFailedException, ImageDecodingError):
    164         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

Any clues? This is most probably related to V3 Transition.

Ali

This is indeed related to evalscript V3 transition and I have created a pull request to fix this issue. Looking forward for your review.