Newer
Older
import numpy as np
def test_11um(rad, threshold):
thr = threshold['bt11']
if thr[4] == 1:
# the C code has the line below that I don't quite understand the purpose of.
# It seems to be setting the bit to 0 if the BT value is greater than the midpoint
#
# if (m31 >= dobt11[1]) (void) set_bit(13, pxout.testbits);
confidence = utils.conf_test(rad, thr)
return confidence
def test_11_4diff(rad1, rad2, threshold):
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
day = True
sunglint = False
thr = threshold['test11_4lo']
raddiff = rad1 - rad2
if day is True and sunglint is False:
confidence = utils.conf_test(raddiff, thr)
return confidence
def nir_refl_test(rad, threshold):
sunglint = False
sza = 0
refang = 0
vza = 0
dtr = 0
band_n = 2
vzcpow = 0
sunglint_thr = np.zeros((4,))
# ref2 [5]
# b2coeffs [4]
# b2mid [1]
# b2bias_adj [1]
# b2lo [1]
# vzcpow [3] (in different place)
coeffs = threshold['b2coeffs']
hicut0 = coeffs[0] + coeffs[1]*sza + coeffs[2]*np.power(sza, 2) + coeffs[3]*np.power(sza, 3)
hicut0 = (hicut0 * 0.01) + threshold['b2adj']
hicut0 = hicut0 * threshold['b2bias_adj']
midpt0 = hicut0 + (threshold['b2mid'] * threshold['b2bias_adj'])
locut0 = midpt0 + (threshold['b2lo'] * threshold['b2bias_adj'])
if sunglint is True:
# Keep in mind that band_n uses MODIS band numbers (2=0.86um and 7=2.1um)
# For VIIRS would be 2=M7 (0.865um) and 7=M11 (2.25um)
sunglint_thr = utils.get_sunglint_thresholds(refang, threshold['Sun_Glint'],
band_n, sunglint_thr)
locut1 = sunglint[0]
midpt1 = sunglint[1]
hicut1 = sunglint[2]
else:
locut1 = locut0
midpt1 = midpt0
hicut1 = hicut0
cosvza = np.cos(vza*dtr)
locut2 = locut1 * (1./np.power(cosvza, vzcpow[0]))
midpt2 = midpt1 * (1./np.power(cosvza, vzcpow[0]))
hicut2 = hicut1 * (1./np.power(cosvza, vzcpow[0]))
corr_thr = [locut2, hicut2, 1.0, midpt2]
confidence = utils.conf_test(rad, corr_thr)
return confidence
def vis_nir_ratio_test(rad1, rad2, threshold):
pass
class CloudMaskTests(object):
def __init__(self, scene, radiance, coefficients):
self.scene = scene
self.coefficients = coefficients
def select_coefficients(self):
pass
def test_G1(self):
pass
def test_G2(self):
pass
def test_G3(self):
pass
def test_G4(self):
pass
def overall_confidence(self):
pass
def test():
rad = np.random.randint(50, size=[4, 8])
# coeffs = [5, 42, 20, 28, 15, 35, 1]
# coeffs = [20, 28, 5, 42, 15, 35, 1]
coeffs = [35, 15, 20, 1, 1]
# confidence = conf_test_dble(rad, coeffs)