diff --git a/gee/modules/landsat_init.py b/gee/modules/landsat_init.py index e607e0c..32114ca 100644 --- a/gee/modules/landsat_init.py +++ b/gee/modules/landsat_init.py @@ -1,108 +1,53 @@ import ee import mercury as mr -class LandsatInitialization: +class SentinelInitialization: def __init__(self, m, date_one, date_two, max_cloud_covering): self.m = m self.date_one = date_one self.date_two = date_two self.max_cloud_covering = max_cloud_covering - self.ls7bands = mr.MultiSelect(label="Select LandSat 7 SR bands", - value=['SR_B3', 'SR_B2', 'SR_B1'], - choices=['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7']) + def sen2msisr_init(self): + self.sen2msibands = mr.MultiSelect(label="Select Sentinel 2 MSI (TOA/SR) bands", + value=['B2', 'B3', 'B4'], + choices=['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B9', 'B11', 'B12']) - self.ls8bands = mr.MultiSelect(label="Select LandSat 8 TOA/RAW bands", - value=['B4', 'B3', 'B2'], - choices=['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11']) + sen2msi_sr = ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED').filterDate(str(self.date_one.value),str(self.date_two.value)).filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE', self.max_cloud_covering.value)) + composite_sr = sen2msi_sr.median() - self.ls8srbands = mr.MultiSelect(label="Select LandSat 8 SR bands", - value=['SR_B4', 'SR_B3', 'SR_B2'], - choices=['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7']) - - self.ls9bands = mr.MultiSelect(label="Select LandSat 9 SR bands", - value=['SR_B4', 'SR_B3', 'SR_B2'], - choices=['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7']) - - self.ls9rawbands = mr.MultiSelect(label="Select LandSat 9 RAW/TOA bands", - value=['B4', 'B3', 'B2'], - choices=['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11']) - - def ls7sr_init(self): - ls7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2").filterDate(str(self.date_one.value), str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - vis_ls7 = {'bands': self.ls7bands.value} - self.m.addLayer(ls7, vis_ls7, "LandSat 7 SR", True, 0.7) - - def ls8toa_init(self): - ls8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA").filterDate(str(self.date_one.value), str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - vis_ls8 = { - 'bands': self.ls8bands.value, - 'min': 0.0, - 'max': 0.4, + vis_sen2sr = { + 'bands': self.sen2msibands.value, + 'min': 0, + 'max': 3000, + 'gamma': 1.4, } - self.m.addLayer(ls8, vis_ls8, 'LandSat 8 TOA') - def ls8rawtc_init(self): - ls8raw = ee.ImageCollection('LANDSAT/LC09/C02/T1').filterDate(str(self.date_one.value), str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - ls8raw_tc = ls8raw.select(self.ls8bands.value) - vis_ls8raw_tc = { - min: 0.0, - max: 30000.0, - } - self.m.addLayer(ls8raw_tc, vis_ls8raw_tc, "LandSat 8 RAW") + self.m.addLayer(composite_sr, vis_sen2sr, 'Sentinel 2 MSI SR') - def ls8sr_init(self): - ls8sr = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2').filterDate(str(self.date_one.value), - str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - vis_ls8sr = { - 'bands': self.ls8srbands.value, - min: 0.0, - max: 0.3, - } - self.m.addLayer(ls8sr, vis_ls8sr, 'LandSat 8 SR') - - def ls9_init(self): - def apply_scale_factors(image): - opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2) - thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0) - return image.addBands(opticalBands, None, True).addBands(thermalBands, None, True) + def sen2msitoa_init(self): + self.sen2msibands = mr.MultiSelect(label="Select Sentinel 2 MSI (TOA/SR) bands", + value=['B2', 'B3', 'B4'], + choices=['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B8A', 'B9', 'B11', 'B12']) - collection = ee.ImageCollection('LANDSAT/LC09/C02/T1_L2').filterDate(str(self.date_one.value), - str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) + sen2msi_toa = ee.ImageCollection('COPERNICUS/S2_HARMONIZED').filterDate(str(self.date_one.value), str(self.date_two.value)).filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE', self.max_cloud_covering.value)) + composite_toa = sen2msi_toa.median() - median = collection.median() - ls9 = apply_scale_factors(median) - - vis_ls9 = { - 'bands': self.ls9bands.value, - 'min': 0.0, - 'max': 0.3, + vis_sen2toa = { + 'bands': self.sen2msibands.value, + 'min': 0, + 'max': 3000, + 'gamma': 1.4, } - self.m.addLayer(ls9, vis_ls9, 'LandSat 9 SR') + self.m.addLayer(composite_toa, vis_sen2toa, 'Sentinel 2 MSI TOA') - def ls9rawtc_init(self): - ls9raw = ee.ImageCollection("LANDSAT/LC09/C02/T2").filterDate(str(self.date_one.value), str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - ls9raw_tc = ls9raw.select(self.ls9rawbands.value) - vis_ls9raw_tc = { - 'min': 0.0, - 'max': 30000.0, + def sen5pc_init(self): + sen5pc = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_CLOUD").select('cloud_fraction').filterDate(str(self.date_one.value),str(self.date_two.value)) + vis_sen5pc = { + min: 0, + max: 0.95, + 'palette': ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red'] } - self.m.addLayer(ls9raw_tc, vis_ls9raw_tc, 'LandSat 9 RAW') - def ls9toatc_init(self): - ls9toa = ee.ImageCollection('LANDSAT/LC09/C02/T1_TOA').filterDate(str(self.date_one.value), - str(self.date_two.value)).filter( - ee.Filter.lte('CLOUD_COVER', self.max_cloud_covering.value)) - ls9toa_tc = ls9toa.select(self.ls9rawbands.value) - vis_ls9toa_tc = { - min: 0.0, - max: 0.4, - } - self.m.addLayer(ls9toa_tc, vis_ls9toa_tc, 'LandSat 9 TOA') + self.m.addLayer(sen5pc, vis_sen5pc, 'Sentinel 5P Cloud')