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

Commit ba33e63

Browse files
Neil FloodNeil Flood
authored andcommitted
Merged entrypoints branch into default
2 parents 48a259e + e351f91 commit ba33e63

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fmask/fmask.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,40 @@ def doPotentialCloudFirstPass(fmaskFilenames, fmaskConfig, missingThermal):
260260
if fmaskConfig.sensor == config.FMASK_LANDSAT47:
261261
nullBandNdx = [config.BAND_BLUE, config.BAND_GREEN, config.BAND_RED, config.BAND_NIR,
262262
config.BAND_SWIR1, config.BAND_SWIR2]
263+
expectedNrefBands = 6
264+
expectedNthermBands = 1
265+
263266
elif fmaskConfig.sensor == config.FMASK_LANDSAT8:
264267
nullBandNdx = [config.BAND_BLUE, config.BAND_GREEN, config.BAND_RED, config.BAND_NIR,
265268
config.BAND_SWIR1, config.BAND_SWIR2, config.BAND_CIRRUS]
269+
expectedNrefBands = 8
270+
expectedNthermBands = 2
271+
266272
elif fmaskConfig.sensor == config.FMASK_SENTINEL2:
267273
# For Sentinel-2, only use the visible bands to define the null mask. This is because ESA
268274
# are leaving a lot of spurious nulls in their imagery, most particularly in the IR bands
269275
# and the cirrus band.
270276
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+
271284
otherargs.bandsForRefNull = numpy.array([fmaskConfig.bands[i] for i in nullBandNdx])
272285

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+
273297
applier.apply(potentialCloudFirstPass, infiles, outfiles, otherargs, controls=controls)
274298

275299
(Twater, Tlow, Thigh) = calcBTthresholds(otherargs)

0 commit comments

Comments
 (0)