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

spatial variability restoral test implemented

parent 0b9cb76a
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import xarray as xr ...@@ -4,6 +4,7 @@ import xarray as xr
from typing import Dict from typing import Dict
from attrs import define, field, validators, Factory from attrs import define, field, validators, Factory
from numpy.lib.stride_tricks import sliding_window_view from numpy.lib.stride_tricks import sliding_window_view
from copy import deepcopy
import logging import logging
...@@ -77,6 +78,38 @@ class Restoral(object): ...@@ -77,6 +78,38 @@ class Restoral(object):
""" """
data: xr.Dataset = field(validator=[validators.instance_of(xr.Dataset), ]) data: xr.Dataset = field(validator=[validators.instance_of(xr.Dataset), ])
thresholds: str = field(validator=[validators.instance_of(Dict), ]) thresholds: str = field(validator=[validators.instance_of(Dict), ])
scene_flag: Dict = field(validator=[validators.instance_of(Dict), ])
confidence: np.ndarray = field(validator=[validators.instance_of(np.ndarray), ])
# VIIRS does not have water vapor channels (6.7um and 7.2um) for this test
def night_snow_inversion(self):
pass
def spatial_variability(self):
threshold = self.thresholds['Daytime_Ocean_Spatial_Variability']
bt = self.data.M15.values
reflectance = self.data.M07.values
confidence = deepcopy(self.confidence)
var_bt = spatial_var(bt, threshold['var_11um'])
var_reflectance = spatial_var(reflectance, threshold['var_0_86um'])
idx = np.nonzero((self.confidence > 0.95) & (self.scene_flag['day'] == 1) &
(var_bt == 1) & (var_reflectance == 1))
confidence[idx] = 1
idx = np.nonzero((self.confidence > 0.66) & (
((self.scene_flag['night'] == 1) & (var_bt == 1)) |
((self.scene_flag['day'] == 1) & (var_bt == 1) & (var_reflectance == 1))))
confidence[idx] = 0.96
idx = np.nonzero((self.confidence <= 0.66) & (var_bt == 1))
confidence[idx] = 0.67
logger.info('spatial_variability restoral test performed successfully')
return confidence
def spatial_var(rad, threshold): def spatial_var(rad, threshold):
......
...@@ -39,7 +39,7 @@ Land_Night: ...@@ -39,7 +39,7 @@ Land_Night:
perform: True perform: True
7.3-11um_BTD_Mid_Level_Cloud_Test: 7.3-11um_BTD_Mid_Level_Cloud_Test:
thr: [-8.0, -10.0, -11.0, 1.0, 1.0] # nl7_11s thr: [-8.0, -10.0, -11.0, 1.0, 1.0] # nl7_11s
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
thr_low: [0.0, -0.5, -1.0, 1.0] thr_low: [0.0, -0.5, -1.0, 1.0]
thr_mid: [-0.5, 6.0, 0.5, 1.0] thr_mid: [-0.5, 6.0, 0.5, 1.0]
thr_hi: [6.5, 6.0, 5.5, 1.0] thr_hi: [6.5, 6.0, 5.5, 1.0]
...@@ -234,7 +234,7 @@ Ocean_Night: ...@@ -234,7 +234,7 @@ Ocean_Night:
thr: [3.0, 6.0, 7.0, 1.0, 1.0] thr: [3.0, 6.0, 7.0, 1.0, 1.0]
variability: 0.40 variability: 0.40
perform: True perform: True
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Ocean:
coeffs: [-0.7093, 0.1128, -0.1567] coeffs: [-0.7093, 0.1128, -0.1567]
corr: 0.0 # no_intadj corr: 0.0 # no_intadj
locut_coeff: [-4.0, 4.0] # no11_4load locut_coeff: [-4.0, 4.0] # no11_4load
...@@ -285,7 +285,7 @@ Polar_Night_Land: ...@@ -285,7 +285,7 @@ Polar_Night_Land:
# Surface_Temperature_Test_2: 12.0 # | merge these three coefficients # Surface_Temperature_Test_2: 12.0 # | merge these three coefficients
# Surface_Temperature_Test_pfm: 1.0 # __| # Surface_Temperature_Test_pfm: 1.0 # __|
# Surface_Temperature_Test: [20.0, 12.0, 1.0] # <- First attempt to merge the three values above # Surface_Temperature_Test: [20.0, 12.0, 1.0] # <- First attempt to merge the three values above
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
low: [2.00, 1.70, 1.40, 1.0] low: [2.00, 1.70, 1.40, 1.0]
mid1: [1.70, 0.70, 0.3, 1.0] mid1: [1.70, 0.70, 0.3, 1.0]
mid2: [0.00, 0.00, 0.00, 0.0] mid2: [0.00, 0.00, 0.00, 0.0]
...@@ -388,7 +388,7 @@ Polar_Day_Snow: ...@@ -388,7 +388,7 @@ Polar_Day_Snow:
1.38um_High_Cloud_Test: 1.38um_High_Cloud_Test:
thr: [0.060, 0.0525, 0.045, 1.0, 1.0] thr: [0.060, 0.0525, 0.045, 1.0, 1.0]
perform: True perform: True
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
low: [20.0, 18.0, 16.0, 1.0] low: [20.0, 18.0, 16.0, 1.0]
mid1: [18.0, 16.0, 2.0, 1.0] mid1: [18.0, 16.0, 2.0, 1.0]
mid2: [0.0, 0.0, 0.0, 0.0] mid2: [0.0, 0.0, 0.0, 0.0]
...@@ -426,7 +426,7 @@ Polar_Night_Snow: ...@@ -426,7 +426,7 @@ Polar_Night_Snow:
high_ice: [-21.0 -20.0, -19.0, 1.0] # pn_7_11hw high_ice: [-21.0 -20.0, -19.0, 1.0] # pn_7_11hw
bt11_bounds: [220.0, 245.0, 255.0, 265.0] # bt11_bnds2 bt11_bounds: [220.0, 245.0, 255.0, 265.0] # bt11_bnds2
Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0] Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
top: top:
low: [2.00, 1.70, 1.40, 1.0] low: [2.00, 1.70, 1.40, 1.0]
mid1: [1.70, 0.30, 0.300, 1.0] mid1: [1.70, 0.30, 0.300, 1.0]
...@@ -520,7 +520,7 @@ Polar_Night_Ocean: ...@@ -520,7 +520,7 @@ Polar_Night_Ocean:
thr: [3.0, 6.0, 7.0, 1.0, 1.0] thr: [3.0, 6.0, 7.0, 1.0, 1.0]
variability: 040 variability: 040
perform: True perform: True
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Ocean:
coeffs: [-0.7093, 0.1128, -0.1567] coeffs: [-0.7093, 0.1128, -0.1567]
corr: 0.0 # pno_intadj corr: 0.0 # pno_intadj
locut_coeff: [-4.0, 4.0] # pno11_4load locut_coeff: [-4.0, 4.0] # pno11_4load
...@@ -542,7 +542,7 @@ Day_Snow: ...@@ -542,7 +542,7 @@ Day_Snow:
1.38um_High_Cloud_Test: 1.38um_High_Cloud_Test:
thr: [0.060, 0.0525, 0.045, 1.0, 1.0] thr: [0.060, 0.0525, 0.045, 1.0, 1.0]
perform: True perform: True
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
low: [20.0, 18.0, 16.0, 1.0] low: [20.0, 18.0, 16.0, 1.0]
mid1: [18.0, 16.0, 2.0, 1.0] mid1: [18.0, 16.0, 2.0, 1.0]
mid2: [0.0, 0.0, 0.0, 0.0] mid2: [0.0, 0.0, 0.0, 0.0]
...@@ -565,7 +565,7 @@ Night_Snow: ...@@ -565,7 +565,7 @@ Night_Snow:
4-12um_BTD_Thin_Cirrus_Test: 4-12um_BTD_Thin_Cirrus_Test:
thr: [4.50, 4.00, 3.50, 1.0, 1.0] thr: [4.50, 4.00, 3.50, 1.0, 1.0]
perform: True perform: True
11-4um_BT_Difference_Test: 11-4um_BT_Difference_Test_Land:
thr: [0.70, 0.60, 0.50, 1.0, 1.0] thr: [0.70, 0.60, 0.50, 1.0, 1.0]
bottom: bottom:
low: [20.0, 18.0, 16.0, 1.0] low: [20.0, 18.0, 16.0, 1.0]
...@@ -606,8 +606,8 @@ Antarctic_Day: ...@@ -606,8 +606,8 @@ Antarctic_Day:
ant4_11_pfm : 1.0 ant4_11_pfm : 1.0
Daytime_Ocean_Spatial_Variability: Daytime_Ocean_Spatial_Variability:
dovar11 : 0.40 var_11um: 0.40
dovar86 : 0.0020 var_0_86um: 0.0020
Sun_Glint: Sun_Glint:
# snglntv : [1.02, 1.17] # snglntv : [1.02, 1.17]
......
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