Skip to content
Snippets Groups Projects
Commit 1a359c31 authored by Paolo Veglio's avatar Paolo Veglio
Browse files

the sunglint restoral seems to be fixed now, although there are still some...

the sunglint restoral seems to be fixed now, although there are still some minor differences that might need to be polished
parent 5486e3e1
No related branches found
No related tags found
No related merge requests found
...@@ -116,18 +116,18 @@ class Restoral(object): ...@@ -116,18 +116,18 @@ class Restoral(object):
# chk_sunglint # chk_sunglint
def sunglint(self, def sunglint(self,
bit: np.ndarray, bit: np.ndarray,
variability_threshold: float,
confidence: np.ndarray) -> np.ndarray: confidence: np.ndarray) -> np.ndarray:
threshold = self.thresholds['Sun_Glint'] threshold = self.thresholds['Sun_Glint']
variability_threshold = self.thresholds['Daytime_Ocean_Spatial_Variability']['var_11um']
m02 = self.data.M07.values m02 = self.data.M07.values
m09 = self.data.M02.values m09 = self.data.M02.values
m20 = self.data.M12.values m20 = self.data.M12.values
m31 = self.data.M15.values m31 = self.data.M15.values
reg_var_mean = local_nxn_mean(m02) reg_var_mean = utils.local_nxn_mean(m02)
reg_std = local_nxn_standard_deviation(m02) reg_std = utils.local_nxn_standard_deviation(m02)
bt_var = spatial_var(m31, variability_threshold) bt_var = utils.spatial_var(m31, variability_threshold)
diff37_11 = m20 - m31 diff37_11 = m20 - m31
idx = np.nonzero((bt_var == 1) & (bit == 1) & (m09 < threshold['m09']) & idx = np.nonzero((bt_var == 1) & (bit == 1) & (m09 < threshold['m09']) &
...@@ -150,8 +150,8 @@ class Restoral(object): ...@@ -150,8 +150,8 @@ class Restoral(object):
threshold = self.thresholds['Ocean_NDVI_and_Shallow_Water'] threshold = self.thresholds['Ocean_NDVI_and_Shallow_Water']
ndvi = compute_ndvi(self.data.M05.values, self.data.M07.values) ndvi = utils.compute_ndvi(self.data.M05.values, self.data.M07.values)
std_m05 = local_nxn_standard_deviation(self.data.M08.values) std_m05 = utils.local_nxn_standard_deviation(self.data.M08.values)
idx = np.nonzero((bits['ir'] == 1) & (bits['nir_1'] == 1) & (bits['nir_2'] == 1) & idx = np.nonzero((bits['ir'] == 1) & (bits['nir_1'] == 1) & (bits['nir_2'] == 1) &
(bits['sst'] == 0) & (self.scene_flag['sh_ocean'] == 0) & (bits['sst'] == 0) & (self.scene_flag['sh_ocean'] == 0) &
...@@ -220,8 +220,9 @@ class Restoral(object): ...@@ -220,8 +220,9 @@ class Restoral(object):
ndvi = utils.compute_ndvi(self.data.M05.values, self.data.M07.values) ndvi = utils.compute_ndvi(self.data.M05.values, self.data.M07.values)
threshold = self.thresholds['Coastal_NDVI_Thresholds'] threshold = self.thresholds['Coastal_NDVI_Thresholds']
idx = np.nonzero((self.scene_flag['day'] == 1) & (self.scene_flag['snow'] == 0) & idx = np.nonzero((self.scene_flag['day'] == 1) & (self.scene_flag['land'] == 1) &
(self.scene_flag['ice'] == 0) & (self.scene_flag['coast'] == 1) & (self.scene_flag['snow'] == 0) & (self.scene_flag['ice'] == 0) &
(self.scene_flag['coast'] == 1) &
(bit == 1) & ((ndvi < threshold['coast_ndvi'][0]) | (ndvi >= threshold['coast_ndvi'][1]))) (bit == 1) & ((ndvi < threshold['coast_ndvi'][0]) | (ndvi >= threshold['coast_ndvi'][1])))
confidence[idx] = 1 confidence[idx] = 1
...@@ -259,6 +260,7 @@ class Restoral(object): ...@@ -259,6 +260,7 @@ class Restoral(object):
return confidence return confidence
'''
# eventually move this function to utility_functions # eventually move this function to utility_functions
def local_nxn_mean(arr: np.ndarray, def local_nxn_mean(arr: np.ndarray,
x: int = 3, x: int = 3,
...@@ -298,8 +300,10 @@ def compute_ndvi(b01: np.ndarray, ...@@ -298,8 +300,10 @@ def compute_ndvi(b01: np.ndarray,
"""Compute Normalized Difference Vegetation Index (NDVI) """ """Compute Normalized Difference Vegetation Index (NDVI) """
ndvi = (b02-b01)/(b01+b02) ndvi = (b02-b01)/(b01+b02)
return ndvi return ndvi
'''
'''
def sunglint(viirs_data, threshold, bit, conf): def sunglint(viirs_data, threshold, bit, conf):
m09 = viirs_data.M02.values m09 = viirs_data.M02.values
...@@ -409,3 +413,4 @@ def coast(viirs_data, threshold, scene, conf): ...@@ -409,3 +413,4 @@ def coast(viirs_data, threshold, scene, conf):
conf[idx] = 1 conf[idx] = 1
return conf return conf
'''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment