@@ -260,16 +260,40 @@ def doPotentialCloudFirstPass(fmaskFilenames, fmaskConfig, missingThermal):
260
260
if fmaskConfig .sensor == config .FMASK_LANDSAT47 :
261
261
nullBandNdx = [config .BAND_BLUE , config .BAND_GREEN , config .BAND_RED , config .BAND_NIR ,
262
262
config .BAND_SWIR1 , config .BAND_SWIR2 ]
263
+ expectedNrefBands = 6
264
+ expectedNthermBands = 1
265
+
263
266
elif fmaskConfig .sensor == config .FMASK_LANDSAT8 :
264
267
nullBandNdx = [config .BAND_BLUE , config .BAND_GREEN , config .BAND_RED , config .BAND_NIR ,
265
268
config .BAND_SWIR1 , config .BAND_SWIR2 , config .BAND_CIRRUS ]
269
+ expectedNrefBands = 8
270
+ expectedNthermBands = 2
271
+
266
272
elif fmaskConfig .sensor == config .FMASK_SENTINEL2 :
267
273
# For Sentinel-2, only use the visible bands to define the null mask. This is because ESA
268
274
# are leaving a lot of spurious nulls in their imagery, most particularly in the IR bands
269
275
# and the cirrus band.
270
276
nullBandNdx = [config .BAND_BLUE , config .BAND_GREEN , config .BAND_RED ]
277
+ expectedNrefBands = 13
278
+ expectedNthermBands = 0
279
+
280
+ else :
281
+ msg = 'Unknown sensor'
282
+ raise fmaskerrors .FmaskParameterError (msg )
283
+
271
284
otherargs .bandsForRefNull = numpy .array ([fmaskConfig .bands [i ] for i in nullBandNdx ])
272
285
286
+ # do a basic check that the input data has the correct number of bands
287
+ if refImgInfo .rasterCount != expectedNrefBands :
288
+ msg = ('Expected %d bands in Reflectance file. Found %d bands' % (expectedNrefBands ,
289
+ refImgInfo .rasterCount ))
290
+ raise fmaskerrors .FmaskFileError (msg )
291
+
292
+ if not missingThermal and thermalImgInfo .rasterCount != expectedNthermBands :
293
+ msg = ('Expected %d bands in Thermal file. Found %d bands' % (expectedNthermBands ,
294
+ thermalImgInfo .rasterCount ))
295
+ raise fmaskerrors .FmaskFileError (msg )
296
+
273
297
applier .apply (potentialCloudFirstPass , infiles , outfiles , otherargs , controls = controls )
274
298
275
299
(Twater , Tlow , Thigh ) = calcBTthresholds (otherargs )
0 commit comments