Skip to content

Commit

Permalink
Minor changes to support Landsat-9
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Flood authored and Neil Flood committed Feb 11, 2022
1 parent 8d79866 commit 442abf1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions fmask/cmdline/usgsLandsatSaturationMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def makeSaturationMask(mtlfile, infile, outfile):
sensor = config.FMASK_LANDSAT47
elif landsat == '7':
sensor = config.FMASK_LANDSAT47
elif landsat == '8':
sensor = config.FMASK_LANDSAT8
elif landsat in ('8', '9'):
sensor = config.FMASK_LANDSATOLI
else:
raise SystemExit('Unsupported Landsat sensor')

Expand Down
6 changes: 3 additions & 3 deletions fmask/cmdline/usgsLandsatStacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def makeStacksAndAngles(cmdargs):
elif landsat == '7':
refWildcard = 'L*_B[1,2,3,4,5,7].TIF'
thermalWildcard = 'L*_B6_VCID_?.TIF'
elif landsat == '8':
elif landsat in ('8', '9'):
refWildcard = 'LC*_B[1-7,9].TIF'
thermalWildcard = 'LC*_B1[0,1].TIF'
else:
Expand Down Expand Up @@ -229,8 +229,8 @@ def mainRoutine():
sensor = config.FMASK_LANDSAT47
elif landsat == '7':
sensor = config.FMASK_LANDSAT47
elif landsat == '8':
sensor = config.FMASK_LANDSAT8
elif landsat in ('8', '9'):
sensor = config.FMASK_LANDSATOLI
else:
raise SystemExit('Unsupported Landsat sensor')

Expand Down
7 changes: 5 additions & 2 deletions fmask/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"Landsat 8"
FMASK_SENTINEL2 = 2
"Sentinel 2"
FMASK_LANDSATOLI = 3
"Landsat OLI"

"""
Some constants for the various reflective bands used in fmask.
Expand Down Expand Up @@ -121,7 +123,7 @@ def __init__(self, sensor):
if sensor == FMASK_LANDSAT47:
self.bands = {BAND_BLUE: 0, BAND_GREEN: 1, BAND_RED: 2, BAND_NIR: 3,
BAND_SWIR1: 4, BAND_SWIR2: 5}
elif sensor == FMASK_LANDSAT8:
elif sensor in (FMASK_LANDSAT8, FMASK_LANDSATOLI):
self.bands = {BAND_BLUE: 1, BAND_GREEN: 2, BAND_RED: 3, BAND_NIR: 4,
BAND_SWIR1: 5, BAND_SWIR2: 6, BAND_CIRRUS: 7}
elif sensor == FMASK_SENTINEL2:
Expand Down Expand Up @@ -535,7 +537,8 @@ def scaleThermalDNtoC(self, scaledBT):
LANDSAT_TH_BAND_NUM_DICT = {'LANDSAT_4': '6',
'LANDSAT_5': '6',
'LANDSAT_7': '6_VCID_1',
'LANDSAT_8': '10'}
'LANDSAT_8': '10',
'LANDSAT_9': '10'}


# for some reason L4, 5, and 7 don't
Expand Down
2 changes: 1 addition & 1 deletion fmask/fmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def doPotentialCloudFirstPass(fmaskFilenames, fmaskConfig, missingThermal):
nullBandNdx = [config.BAND_BLUE, config.BAND_GREEN, config.BAND_RED, config.BAND_NIR,
config.BAND_SWIR1, config.BAND_SWIR2]

elif fmaskConfig.sensor == config.FMASK_LANDSAT8:
elif fmaskConfig.sensor in (config.FMASK_LANDSAT8, config.FMASK_LANDSATOLI):
nullBandNdx = [config.BAND_BLUE, config.BAND_GREEN, config.BAND_RED, config.BAND_NIR,
config.BAND_SWIR1, config.BAND_SWIR2, config.BAND_CIRRUS]

Expand Down
8 changes: 6 additions & 2 deletions fmask/landsatTOA.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@
LANDSAT4_ESUN = [1983.0, 1795.0, 1539.0, 1028.0, 219.8, 83.49]
LANDSAT5_ESUN = [1983.0, 1796.0, 1536.0, 1031.0, 220.0, 83.44]
LANDSAT7_ESUN = [1997.0, 1812.0, 1533.0, 1039.0, 230.8, 84.90]
# Derived by RSC, using Landsat-9 RSR & Kurucz solar spectrum
LANDSAT9_ESUN = [1881.97, 1972.61, 1851.75, 1572.03, 969.37, 246.18, 82.11, 360.48]

ESUN_LOOKUP = {'LANDSAT_4': LANDSAT4_ESUN,
'LANDSAT_5': LANDSAT5_ESUN,
'LANDSAT_7': LANDSAT7_ESUN,
'LANDSAT_8': LANDSAT8_ESUN}
'LANDSAT_8': LANDSAT8_ESUN,
'LANDSAT_9': LANDSAT9_ESUN}

RADIANCE_MULT = 'RADIANCE_MULT_BAND_%d'
RADIANCE_ADD = 'RADIANCE_ADD_BAND_%d'
Expand All @@ -55,7 +58,8 @@
BAND_NUM_DICT = {'LANDSAT_4': (1, 2, 3, 4, 5, 7),
'LANDSAT_5': (1, 2, 3, 4, 5, 7),
'LANDSAT_7': (1, 2, 3, 4, 5, 7),
'LANDSAT_8': (1, 2, 3, 4, 5, 6, 7, 9)}
'LANDSAT_8': (1, 2, 3, 4, 5, 6, 7, 9),
'LANDSAT_9': (1, 2, 3, 4, 5, 6, 7, 9)}


def readGainsOffsets(mtlInfo):
Expand Down

0 comments on commit 442abf1

Please sign in to comment.