From 3c9bdd369baf8eb6b5ed15e4d87f04c43e1d804e Mon Sep 17 00:00:00 2001
From: Paolo Veglio <paolo.veglio@ssec.wisc.edu>
Date: Wed, 2 Nov 2022 21:26:34 +0000
Subject: [PATCH] more tests implemented. SST Test shows reasonable results.

---
 main.py                          |  34 ++-
 preprocess_thresholds.py         |  39 ++-
 tests.py                         |  13 +-
 thresholds.mvcm.snpp.v0.0.1.yaml | 471 +++++++++++++++++++++++++++++++
 4 files changed, 543 insertions(+), 14 deletions(-)
 create mode 100644 thresholds.mvcm.snpp.v0.0.1.yaml

diff --git a/main.py b/main.py
index 307186c..1133a78 100644
--- a/main.py
+++ b/main.py
@@ -1,16 +1,16 @@
 import ruamel_yaml as yml
 import numpy as np
-import xarray as xr
+# import xarray as xr
 
 from glob import glob
 
 import read_data as rd
-import scene as scn
+# import scene as scn
 from tests import CloudTests
 
 # import tests
-import ocean_day_tests as odt
-import restoral
+# import ocean_day_tests as odt
+# import restoral
 
 # #################################################################### #
 # TEST CASE
@@ -22,7 +22,7 @@ _fname_img02 = glob(f'{_datapath}/VNP02IMG.A2022173.1454.001.*.uwssec_bowtie_res
 _fname_img03 = glob(f'{_datapath}/VNP03IMG.A2022173.1454.001.*.uwssec.nc')[0]
 
 # thresholds:
-_threshold_file = '/home/pveglio/mvcm_leo/thresholds/new_thresholds.mvcm.snpp.v1.0.0.yaml'
+_threshold_file = '/home/pveglio/mvcm/thresholds.mvcm.snpp.v0.0.1.yaml'
 
 # ancillary files:
 _geos_atm_1 = 'GEOS.fpit.asm.inst3_2d_asm_Nx.GEOS5124.20220622_1200.V01.nc4'
@@ -80,6 +80,10 @@ def main(*, data_path=_datapath, mod02=_fname_mod02, mod03=_fname_mod03,
 
     cmin_G1 = np.ones(viirs_data.M01.shape)
     cmin_G2 = np.ones(viirs_data.M01.shape)
+    cmin_G3 = np.ones(viirs_data.M01.shape)
+    cmin_G4 = np.ones(viirs_data.M01.shape)
+    cmin_G5 = np.ones(viirs_data.M01.shape)
+
 #    cmin_test = {'Ocean_Day': np.ones(viirs_data.M01.shape),
 #                 'Polar_Ocean_Day': np.ones(viirs_data.M01.shape),
 #                 'Polar_Ocean_Night': np.ones(viirs_data.M01.shape)
@@ -95,9 +99,9 @@ def main(*, data_path=_datapath, mod02=_fname_mod02, mod03=_fname_mod03,
                'CO2 High Clouds Test': False,
                'Water Vapor High Clouds Test': False,
                'Surface Temperature Test': False,
-               'SST Test': False,
+               'SST Test': True,
                '8.6-11um BT Difference Test': False,
-               '11-12um BTD Thin Cirrus Test': True,
+               '11-12um BTD Thin Cirrus Test': False,
                '11-4um BT Difference Test': False,
                '7.3-11um BT Difference Mid-level Clouds': False,
                'Water Vapor Cloud Test': False,
@@ -233,10 +237,17 @@ def main(*, data_path=_datapath, mod02=_fname_mod02, mod03=_fname_mod03,
     # --------------------- #
 
     if perform['1.38um High Cloud Test'] is True:
+        # for scene_name in ['Land_Day', 'Land_Day_Coast', 'Land_Day_Desert', 'Land_Day_Desert_Coast',
+        #                    'Ocean_Day', 'Polar_Day_Land', 'Polar_Day_Coast', 'Polar_Day_Desert',
+        #                    'Polar_Day_Desert_Coast', 'Polar_Ocean_Day', 'Day_Snow']:
         for scene_name in ['Land_Day', 'Land_Day_Coast', 'Land_Day_Desert', 'Land_Day_Desert_Coast',
-                           'Ocean_Day', 'Polar_Day_Land', 'Polar_Day_Coast', 'Polar_Day_Desert',
-                           'Polar_Day_Desert_Coast', 'Polar_OCean_Day', 'Day_Snow']:
-            pass
+                           'Polar_Day_Land', 'Polar_Day_Coast', 'Polar_Day_Desert',
+                           'Polar_Day_Desert_Coast', 'Day_Snow']:
+            # The current loop is missing Ocean_Day and Polar_Ocean_Day because they need some
+            # preprocessing to compute the thresholds. Once things are implemented I can use the commented
+            # loop
+            SceneType = CloudTests(viirs_data, scene_name, thresholds)
+            cmin_G4 = SceneType.single_threshold_test('1.38um_High_Cloud_Test', 'M09', cmin_G4)
 
     # --------------------- #
     # ### Group 5 tests ### #
@@ -246,7 +257,8 @@ def main(*, data_path=_datapath, mod02=_fname_mod02, mod03=_fname_mod03,
         for scene_name in ['Land_Night', 'Polar_Night_Land', 'Polar_Night_Snow', 'Night_Snow']:
             pass
 
-    return cmin_G2
+    cmin_total = cmin_G1 * cmin_G2 * cmin_G3 * cmin_G4 * cmin_G5
+    return cmin_total
 
     '''
     Land_Day = CloudTests(viirs_data, 'Land_Day', thresholds)
diff --git a/preprocess_thresholds.py b/preprocess_thresholds.py
index af2251d..9f7bc6a 100644
--- a/preprocess_thresholds.py
+++ b/preprocess_thresholds.py
@@ -40,6 +40,8 @@ def preproc(data, thresholds):
     midpt = thr_xr.coeffs[:, :, 0].where((thr < 0.1) | (np.abs(schi-99) < 0.0001), thr)
     locut = midpt + (thr_xr.cmult * midpt)
     hicut = midpt - thr_xr.adj
+    # this below is for the method 2 of computing hicut
+    # hicut = midpt - (thr_xr.adj * midpt)
 
     thr_out = xr.DataArray(data=np.dstack((locut, midpt, hicut, np.ones(locut.shape), np.ones(locut.shape))),
                            dims=('number_of_lines', 'number_of_pixels', 'z'))
@@ -47,7 +49,22 @@ def preproc(data, thresholds):
     # return locut, hicut, midpt
 
 
-# NOTE: About the 11-12um Cirrus Test
+def preproc_sst(data, thresholds):
+    m31c = data.M15 - 273.16
+    m32c = data.M16 - 273.16
+    m31c_m32c = m31c - m32c
+    sstc = data.geos_sfct - 273.16
+    cosvza = np.cos(data.sensor_zenith*_dtr)
+
+    a = thresholds['coeffs']
+
+    modsst = 273.16 + a[0] + a[1]*m31c + a[2]*m31c_m32c*sstc + a[3]*m31c_m32c*((1/cosvza) - 1)
+    sfcdif = data.geos_sfct - modsst
+
+    return sfcdif
+
+
+# NOTE: 11-12um Cirrus Test
 # hicut is computed in different ways depending on the scene
 # 1. midpt - adj
 # - Land_Day
@@ -72,3 +89,23 @@ def preproc(data, thresholds):
 # - Polar_Night_Snow
 # - Day_Snow
 # - Night_Snow
+
+# NOTE: 1.38um High Cloud Test
+# thresholds are not always computed the same way. In group 1 there's no preprocessing required,
+# in group 2 some calcuations are needed
+# 1.
+# - Land_Day
+# - Land_Day_Coast
+# - Land_Day_Desert
+# - Land_Day_Desert_Coast
+# - Polar_Day_Land
+# - Polar_Day_Coast
+# - Polar_Day_Desert
+# - Polar_Day_Desert_Coast
+# - Polar_Day_Snow
+# - Day_Snow
+#
+# 2.
+# - Ocean_Day
+# - Polar_Ocean_Day
+
diff --git a/tests.py b/tests.py
index fecbe3d..d2c1f4e 100644
--- a/tests.py
+++ b/tests.py
@@ -255,19 +255,28 @@ class CloudTests:
             return cmin
         print(f'Running test "{test_name}" for "{self.scene_name}"')
         # preproc_thresholds()
-        thr = np.array(self.thresholds[self.scene_name][test_name])
+        thr = np.array(self.thresholds[self.scene_name][test_name]['thr'])
         thr_xr = xr.Dataset()
         if test_name == '11-12um_Cirrus_Test':
             thr_xr['threshold'] = pt.preproc(self.data, self.thresholds[self.scene_name])
             thr = np.ones((5,))  # This is only temporary to force the logic of the code
                                  # I need to find a better solution at some point
+
+        elif test_name == 'SST_Test':
+            thr_xr['threshold'] = (('number_of_lines', 'number_of_pixels', 'z'),
+                                   np.ones((self.data[band].shape[0], self.data[band].shape[1], 5))*thr)
         else:
             thr_xr['threshold'] = (('number_of_lines', 'number_of_pixels', 'z'),
                                    np.ones((self.data[band].shape[0], self.data[band].shape[1], 5))*thr)
         data = xr.Dataset(self.data, coords=thr_xr)
 
+        if test_name == 'SST_Test':
+            data['sfcdif'] = (('number_of_lines', 'number_of_pixels'),
+                              pt.preproc_sst(data, self.thresholds[self.scene_name][test_name]).values)
+            band = 'sfcdif'
+
         if thr[4] == 1:
-            print('test running')
+            print('test running...')
             confidence = conf_xr.conf_test(data, band)
 
         cmin = np.fmin(cmin, confidence)
diff --git a/thresholds.mvcm.snpp.v0.0.1.yaml b/thresholds.mvcm.snpp.v0.0.1.yaml
new file mode 100644
index 0000000..9fd834a
--- /dev/null
+++ b/thresholds.mvcm.snpp.v0.0.1.yaml
@@ -0,0 +1,471 @@
+# MODIS-VIIRS Continuity Cloud Mask (MVCCM) Thresholds
+
+# Version string
+thresholds_file_ver: v3.3.1_NPP
+
+Land_Day:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  dl_ref3_tpw    : -10.00
+  test11_4lo     : [-16.0, -14.0, -12.0, 1.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  vis_refl_test  : [0.207, 0.169, 0.132, 1.0, 1.0] # used to be dlref1
+  1.38um_High_Cloud_Test: [0.0375,  0.0250, 0.0125,  1.0, 1.0]
+  dlvrat         : [1.80, 1.85, 1.90, 1.0, 1.0]
+#  dl11_12lcmult  : 0.3
+#  dl11_12hcadj   : 1.25
+  b1bias_adj     : 0.94
+
+Land_Night:
+  nl4_12hi       : [15.0, 10.0, 5.00, 1.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  nl7_11s        : [-8.0,   -10.0, -11.0, 1.0, 1.0]
+  nl_11_4l       : [0.0,   -0.5, -1.0,  1.0]
+  nl_11_4h       : [6.5,    6.0,  5.5,  1.0]
+  nl_11_4m       : [-0.5,    6.0,  0.5,  1.0]
+  nl_11_4_pfm    : 1.0
+  Surface_Temperature_Test_df1: [-0.2, 1.0]
+  Surface_Temperature_Test_df2: [-0.5, 1.0]
+  Surface_Temperature_Test_difference: [-0.2, 1.0, -0.5, 1.0]  # <- this merges the previous two arrays
+  bt_diff_bounds : [1.0, -1.0]
+  11-12um_Cirrus_Test: [3.0, 1.0]
+  Surface_Temperature_Test_1: 20.0  #   | might be worth figuring out if we can
+  Surface_Temperature_Test_2: 12.0  #   | merge these three coefficients
+  Surface_Temperature_Test_pfm: 1.0 # __|
+  Surface_Temperature_Test: [20.0, 12.0, 1.0]  # <- First attempt to merge the three values above
+  nlbt1          : 270.0
+  nl_lat         : 30.0
+  nl_ndvi        : 0.25
+  nl_ndvi_Aust   : 0.40
+  nl_intadj      : 0.0
+  nl_btd1        : -2.0
+  nl11_4coef     : [-0.3476, 0.5307, -0.1930]
+
+Land_Day_Coast:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  dl_ref3_tpw_t2 : -10.00
+  test11_4lo     : [-16.0, -14.0, -12.0, 1.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  dlref1_t2      : [0.207, 0.169, 0.132, 1.0, 1.0]
+  1.38um_High_Cloud_Test: [0.0375,  0.0250, 0.0125,  1.0, 1.0]
+# dl11_12lcmult_t2 : 0.3
+# dl11_12hcadj_t2  : 1.25
+
+Land_Day_Desert:
+#  lds11_12hi     : [3.5, 1.0]
+  11-12um_Cirrus_Test:
+    coeffs: [3.5, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  lds11_4hi      : [2.0, 0.0, -2.0, 1.00, 1.0]
+  lds11_4lo      : [-28.0, -26.0, -24.0, 1.00]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  ldsref2        : [0.326, 0.288, 0.250, 1.00, 1.0]
+  1.38um_High_Cloud_Test: [0.0375, 0.0250, 0.0125, 1.00, 1.0]
+  ldsgemi0       : [0.085, 0.095, 0.115, 1.00, 1.0]
+  ldsgemi1       : [0.145, 0.170, 0.220, 1.00]
+  ldsgemi2       : [0.310, 0.335, 0.360, 1.00]
+  lds_ref3_tpw   : -10.00
+  ldsbt1         : 320.0
+  lds_ndvi       : 0.25
+# lds11_12lcmult : 0.3
+# lds11_12hcadj  : 1.25
+
+Land_Day_Desert_Coast:
+#  lds11_12hi_c   : [3.5, 1.0]
+  11-12um_Cirrus_Test:
+    coeffs: [3.5, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  lds11_4hi_c    : [2.00,  0.00, -2.00, 1.00]
+  lds11_4lo_c    : [-23.0, -21.0, -19.0, 1.00, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  ldsref2_c      : [0.326, 0.288, 0.250, 1.00, 1.0]
+  1.38um_High_Cloud_Test: [0.0375, 0.0250, 0.0125,  1.00, 1.0]
+  lds_ref3_tpw_c : -10.00
+  ldsbt1_c       : 320.0
+  lds_ndvi_c     : 0.25
+# lds11_12lcmult_c : 0.3
+# lds11_12hcadj_c  : 1.25
+
+Ocean_Day:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  test11_4lo     : [-11.0, -9.0,  -7.0,  1.0, 1.0]
+  11um_Test: [267.0, 270.0, 273.0, 1.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  do_b7coeffs    : [1.01339303876915, -0.00277128813739, 0.00027804834484, -0.00001549681141, 0.00000016623006, 0.00000000000000]
+  do_b7adj       : 0.0125
+  do_b7mid       : 0.0070
+  do_b7lo        : 0.0100
+  do_b7pfm       : 1.0
+  ref2           : [0.062, 0.043, 0.029, 1.0, 1.0]
+  #  vnir_ratio_hi  : [1.001, 1.154, 1.205, 1.0, 1.0]
+  #  vnir_ratio_lo  : [0.934, 0.889, 0.837, 1.0]
+  vis_nir_ratio : [0.837, 0.889, 0.934, 1.001, 1.154, 1.205, 1.0, 1.0] # This replace dovrathi and dovratlo
+                                                                       # The values are sorted left to right
+                                                                       # so that they follow the scheme:
+                                                                       # Hi-Mid-Lo--Lo-Mid-Hi
+                                                                       # Last two values are power and switch
+                                                                       # to turn the test on/off
+  8.6-11um_Test: [-0.50,  -1.00,  -1.50,  1.0, 1.0]
+  SST_Test:
+    thr: [3.000, 2.500, 2.000, 1.0, 1.0]
+    coeffs: [1.886, 0.938, 0.128, 1.094]
+  b2coeffs       : [1.7291, 0.0715, -0.0026, 0.000025889]
+  b2adj          : 0.0050
+  b2mid          : 0.0200
+  b2lo           : 0.0100
+  do_b26coeffs   : [-0.2419, 0.0455, -0.0024, 0.000059029, -0.00000069964, 0.000000003204]
+  do_b26adj      : 0.0010
+  do_b26_szafac  : 4.0
+  do_b26pfm      : 1.0
+  b2bias_adj     : 0.96
+  do_b6bias_adj  : 0.98
+  do_b7bias_adj  : 0.97
+
+Ocean_Night:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.0
+  no_intadj      : 0.0
+  no11_4lo       : [1.25,   1.00, 0.25,  1.0, 1.0]
+  11um_Test: [267.0, 270.0, 273.0, 2.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  no86_73        : [14.0,  15.0,  16.0,  1.0, 1.0]
+  11um_var       : [3.0,   6.0,   7.0,   1.0, 1.0]
+  8.6-11um_Test: [-0.5, -1.0,  -1.5,   1.0, 1.0]
+  SST_Test:
+    thr: [3.000, 2.500, 2.000, 1.0, 1.0]
+    coeffs: [1.8860, 0.9380, 0.1280, 1.094]
+  no11_4coef     : [-0.7093, 0.1128, -0.1567]
+  no11_4hiad     : [-1.5, 1.5]
+  no11_4mdad     : [-2.5, 2.5]
+  no11_4load     : [-4.0, 4.0]
+  no11_4_pfm     : 1.0
+
+Polar_Day_Land:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 0.3
+  pdl_ref3_tpw   : -10.00
+  test11_4lo     : [-16.0, -14.0, -12.0, 1.0, 1.0]
+  pdlh20         : [215.0, 220.0, 225.0, 1.0, 1.0]
+  pdlref1        : [0.207, 0.169, 0.132, 1.0, 1.0]
+  1.38um_High_Cloud_Test: [0.0375,  0.0250, 0.0125,  1.0, 1.0]
+
+Polar_Night_Land:
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  pnlbt1         : 270.0
+  pnlbt2         : 270.0
+  Surface_Temperature_Test_pfm: 1.0
+  pnl_11_4_pfm   : 1.0
+  pnl_7_11_pfm   : 1.0
+  pnl_4_12_pfm   : 1.0
+  pnl_11_4l      : [2.00, 1.70, 1.40, 1.0]
+  pnl_11_4h      : [1.00,  0.70,  0.40, 1.0]
+  pnl_11_4m1     : [1.70,  0.70, 0.300, 1.0]
+  pnl_11_4m2     : [0.00,  0.00, 0.00, 0.0]
+  pnl_11_4m3     : [0.00,  0.00, 0.00, 0.0]
+  pnl_11_bounds  : [235.0, 000.0, 000.0, 265.0]
+
+Polar_Day_Coast:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  pdl_ref3_tpw_t2 : -10.00
+  test11_4lo      : [-16.0, -14.0, -12.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pdlref1_t2      : [0.207, 0.169, 0.132, 1.0, 1.0]
+  1.38um_High_Cloud_Test: [0.0375,  0.0250, 0.0125,  1.0, 1.0]
+
+Polar_Day_Desert:
+  11-12um_Cirrus_Test:
+    coeffs: [3.5, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  pds11_4hi      : [2.00,  0.00, -2.00, 1.00]
+  pds11_4lo      : [-22.0, -20.0, -18.0, 1.00]
+  pds11_4_pfm    : 1.0
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pdsref2        : [0.326, 0.288, 0.250, 1.00, 1.0]
+  1.38um_High_Cloud_Test: [0.0375, 0.0250, 0.0125,  1.00, 1.0]
+  pdsgemi0       : [0.085, 0.110, 0.135, 1.00, 1.0]
+  pdsgemi1       : [0.170, 0.220, 0.270, 1.00]
+  pdsgemi2       : [0.310, 0.335, 0.360, 1.00]
+  pds_ref3_tpw   : -10.00
+  pdsbt1         : 320.0
+
+Polar_Day_Desert_Coast:
+  11-12um_Cirrus_Test:
+    coeffs: [3.5, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  pds11_4hi_c    :  [2.00,  0.00, -2.00, 1.00]
+  pds11_4lo_c    : [-23.0, -21.0, -19.0, 1.00]
+  pds11_4_c_pfm  : 1.0
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pdsref2_c      : [0.326, 0.288, 0.250, 1.00, 1.0]
+  1.38um_High_Cloud_Test: [0.0375, 0.0250, 0.0125,  1.00, 1.0]
+  pds_ref3_tpw_c : -10.00
+  pdsbt1_c       : 320.0
+
+Polar_Day_Snow:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  dps_ref3_tpw   : 0.75
+  dpsbt1         : 230.0
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  1.38um_High_Cloud_Test: [0.060, 0.0525, 0.045, 1.0, 1.0]
+  dps11_12adj    : 0.8
+  dps4_11l       : [20.0,  18.0,  16.0,  1.0]
+  dps4_11h       : [18.0,  16.0,  14.0,  1.0]
+  dps4_11m1      : [18.0,  16.0,   2.0,  1.0]
+  dps4_11m2      : [0.0,   0.0,   0.0,  0.0]
+  dps4_11m3      : [0.0,   0.0,   0.0,  0.0]
+  dps4_11_pfm    : 1.0
+  bt_11_bnds3    : [230.0,  0.0,   0.0, 245.0]
+
+Polar_Night_Snow:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  pn_4_12l       : [4.50, 4.00, 3.50, 1.0]
+  pn_4_12h       : [2.50, 2.00, 1.50, 1.0]
+  pn_4_12m1      : [4.00,  2.00, 0.500, 1.0]
+  pn_4_12m2      : [0.00,  0.00, 0.00, 0.0]
+  pn_4_12m3      : [0.00,  0.00, 0.00, 0.0]
+  pns_4_12_pfm   : 1.0
+  pn_7_11l       : [-1.00, 0.00, 1.00, 1.0, 1.0]
+  pn_7_11h       : [-21.0, -20.0, -19.0,1.0]
+  pn_7_11m1      : [0.00,  -4.50, -1.00, 1.0]
+  pn_7_11m2      : [-4.50, -10.50, -1.00, 1.0]
+  pn_7_11m3      : [-10.50, -20.0, -1.00, 1.0]
+  pn_7_11lw      : [0.00, 1.00, 2.00, 1.0]
+  pn_7_11hw      : [-21.0 -20.0, -19.0, 1.0]
+  pn_7_11m1w     : [1.00,  -7.00, -1.00, 1.0]
+  pn_7_11m2w     : [-7.00, -16.50, -1.00, 1.0]
+  pn_7_11m3w     : [-16.50, -20.0, -1.00, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pn_11_4l       : [2.00, 1.70, 1.40, 1.0]
+  pn_11_4h       : [0.60,  0.30,  0.00, 1.0]
+  pn_11_4m1      : [1.70,  0.30, 0.300, 1.0]
+  pn_11_4m2      : [0.00,  0.00, 0.00, 0.0]
+  pn_11_4m3      : [0.00,  0.00, 0.00, 0.0]
+  pns_11_4_pfm   : 1.0
+  bt_11_bounds   : [235.0, 000.0, 000.0, 265.0]
+  bt_11_bnds2    : [220.0, 245.0, 255.0, 265.0]
+  pn_11_4bl      : [-3.00, -2.50, -2.00, 1.0]
+  pn_11_4bh      : [-3.00, -2.50, -2.00, 1.0]
+  pn_11_4bm1     : [-2.50, -2.50, -0.50, 1.0]
+  pn_11_4bm2     : [0.00,  0.00, 0.00, 0.0]
+  pn_11_4bm3     : [0.00,  0.00, 0.00, 0.0]
+  pn11_12adj     : 0.8
+  pnbt1          : 270.0
+  pnbt2          : 270.0
+  pnbt3          : 230.0
+  pntpw          : 0.2
+
+Polar_Ocean_Day:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.25
+  pdo11_4lo      : [-11.0, -9.0,  -7.0,  1.0, 1.0]
+  11um_Test: [267.0, 270.0, 273.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pdovrathi      : [1.001, 1.154, 1.205, 1.0, 1.0]
+  pdovratlo      : [0.934, 0.889, 0.837, 1.0]
+  8.6-11um_Test: [-0.50,  -1.00,  -1.50,  1.0, 1.0]
+  SST_Test:
+    thr: [3.000, 2.500, 2.000, 1.0, 1.0]
+    coeffs: [1.998, 0.938, 0.128, 1.094]
+  pdo_b7pfm      : 1.0
+  pdo_b26pfm     : 1.0
+  pdo_b2bias_adj : 0.96
+  pdo_b6bias_adj : 0.98
+  pdo_b7bias_adj : 0.97
+
+Polar_Ocean_Night:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: 0.3
+    adj: 1.0
+  pnobt1         : 280.0
+  pno_intadj     : 0.0
+  pno11_4lo      : [1.25,  1.00,  0.25,  1.0, 1.0]
+  pno_11_4_pfm   : 1.0
+  11um_Test: [267.0, 270.0, 273.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  pno86_73       : [14.0,  15.0,  16.0,  1.0, 1.0]
+  pno_11var      : [3.0,   6.0,   7.0,   1.0, 1.0]
+  8.6-11um_Test: [-0.5,  -1.0,  -1.5,   1.0, 1.0]
+  SST_Test:
+    thr: [3.000, 2.500, 2.000, 1.0, 1.0]
+    coeffs: [1.8860, 0.9380, 0.1280, 1.094]
+  pno11_4hiad    : [-1.5, 1.5]
+  pno11_4mdad    : [-2.5, 2.5]
+  pno11_4load    : [-4.0, 4.0]
+  pno11_4coef    : [-0.7093, 0.1128, -0.1567]
+
+Day_Snow:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  ds_ref3_tpw    : 0.75
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  1.38um_High_Cloud_Test: [0.060, 0.0525, 0.045, 1.0, 1.0]
+  ds11_12adj     : 0.8
+  ds11_12lcmult  : 0.3
+  ds11_12hcmult  : 0.3
+  ds4_11_pfm     : 1.0
+
+Night_Snow:
+  11-12um_Cirrus_Test:
+    coeffs: [3.0, 1.0]
+    cmult: []  # I NEED TO WORK ON THIS
+    adj: []    # I NEED TO WORK ON THIS
+  nsbt1          : 270.0
+  nsbt2          : 270.0
+  nsbt3          : 230.0
+  ns11_4lo       : [0.70,  0.60,  0.50,  1.0, 1.0]
+  ns4_12hi       : [4.50,  4.00,  3.50,  1.0, 1.0]
+  CO2_High_Clouds_Test: [222.0, 224.0, 226.0, 1.0, 1.0]
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  ns11_12adj     : 0.8
+  nstpw          : 0.2
+  ns_7_11_pfm    : 1.0
+
+Antarctic_Day:
+  Water_Vapor_High_Clouds_Test: [215.0, 220.0, 225.0, 1.0, 1.0]
+  ant4_11l       : [26.0   23.0,  20.0,  1.0]
+  ant4_11h       : [18.0,  15.0,  12.0,  1.0]
+  ant4_11m1      : [23.0,  15.0,   3.0   1.0]
+  ant4_11m2      : [0.0,   0.0,   0.0,  0.0]
+  ant4_11m3      : [0.0,   0.0,   0.0,  0.0]
+  bt_11_bnds4    : [240.0,  0.0,   0.0, 255.0]
+  antbt1         : 230.0
+  ant4_11_pfm    : 1.0
+
+Daytime_Ocean_Spatial_Variability:
+  dovar11        : 0.40
+  dovar86        : 0.0020
+
+Sun_Glint:
+  #  snglntv        : [1.02, 1.17]
+  #  snglntvch      : [0.97, 1.28]
+  #  snglntvcl      : [1.07, 1.12]
+  snglnt         : [0.97, 1.02, 1.07, 1.12, 1.17, 1.28] # This replaces snglntv, snglntvch snglntvcl
+                                                        # The values are sorted left to right such that
+                                                        # Hi-Mid-Lo--Lo-Mid-Hi
+  sg_tbdfl       : 13.0
+  sngm09         : 0.568
+  sngm02vm       : 0.001
+  band2_0deg     : [.1296, .1152, .1008, 1.0]   # snglnt0_b2
+  band2_10deg    : [.1152, .0624, .0144, 1.0]   # snglnt10_b2
+  band2_20deg    : [.0624, .0432, .0144, 1.0]   # snglnt20_b2
+  band7_0deg     : [.1176, .1078, .0980, 1.0]   # snglnt0_b7
+  band7_10deg    : [.1078, .0686,  .0098, 1.0]  # snglnt10_b7
+  band7_20deg    : [.0686, .0196,  .0098, 1.0]  # snglnt20_b7
+  bounds         : [0.0, 10.0, 25.0, 40.0]      # snglnt_bounds
+
+Land_Restoral:
+  ldsr5_4_thr    : 1.96
+  ldr5_4_thr     : 2.94
+  ld20m22        : 11.0
+  ld22m31        : 15.0
+  ldsbt11        : [295.0, 300.0, 305.0]
+  ldsbt11bd      : [290.0, 295.0, 305.0]
+  lnbt11         : [287.5, 292.5, 297.5]
+
+Night_Snow_Inversion:
+  pn65_11        : [10.0, 1.0]
+  pn13_11        : [3.0, 1.0]
+  pn7_11         : [5.0, 1.0]
+  n65_11         : [10.0, 1.0]
+
+Snow_Mask:
+  sm_bt11        : 280.0
+  sm_ndsi        : 0.31
+  Grnlnd_ndsi    : 0.66
+  sm_ref2        : 0.1056
+  sm85_11        : 0.0
+  sm85_11hel     : 1.5
+  sm37_11        : 11.0
+  sm37_11hel     : 16.0
+  sm_mnir        : 0.196
+  sm_lsfcdif     : 20.0
+  sm_wsfcdif     : 20.0
+  sm_bt1         : 273.0
+  prd_ndvi_const : -0.2015
+
+Coastal_NDVI_Thresholds:
+  coast_ndvi     : [-0.18, 0.40]
+
+# Ocean NDVI and shallow (turbid) water test thresholds.
+Ocean_NDVI_and_Shallow_Water:
+  swc_ndvi       : [-0.35, 0.40]
+  swc_124std     : 0.0023
+
+Thin_Cirrus_Tests:
+  tci_ref3_tpw   : 0.75
+  dltci          : [0.0250, 0.0125]
+  dstci          : [0.0350, 0.0300]
+
+# Power cosine(VZA) is raised to in VZA-correction codes
+VZA_correction:
+  vzcpow         : [0.75, 0.75, 0.25]
+
+# Thresholds used in calculating 0.66 and 0.413 um cloud test thresholds
+Misc:
+  des_ndvi       : 0.25
+  fill_ndvi      : [32.000, 0.00] # replaces fill_ndvi1 and fill_ndvi2
+  ndvi_bnd1      : 0.05
+  ndvi_bnd2      : 0.95
+  adj_fac_desert : 0.10
+  adj_fac_land   : 0.00
+
+# Coefficients for band 1 land thresholds
+Coeffs_Band1_land_thresh:
+  - [32.00000000, 0.00000000, 0.00000000, 0.00000000, 42.00000000, 0.00000000, 0.00000000, 0.00000000, 52.00000000, 0.00000000, 0.00000000, 0.00000000]
+  - [24.00000000, 0.00000000, 0.00000000, 0.00000000, 28.00000000, 0.00000000, 0.00000000, 0.00000000, 32.00000000, 0.00000000, 0.00000000, 0.00000000]
+  - [99.13076923, -2.00907925, 0.01492075, -0.00003531, 122.19090909, -2.32652292, 0.01659848, -0.00003681, 142.66293706, -2.57860528, 0.01773252, -0.00003685]
+  - [85.07902098, -1.59413364, 0.01123310, -0.00002556, 144.56573427, -2.81054779, 0.01967366, -0.00004324, 204.35454545, -4.03411810, 0.02816667, -0.00006103]
+  - [85.03846154, -1.50831391, 0.01006760, -0.00002199, 165.15314685, -3.24716783, 0.02255594, -0.00004965, 242.06363636, -4.90912587, 0.03445455, -0.00007587]
+  - [81.00979021, -1.37731935, 0.00881294, -0.00001859, 220.36783217, -4.44111888, 0.03087762, -0.00006888, 359.72587413, -7.50491841, 0.05294231, -0.00011917]
+  - [76.94055944, -1.35441725, 0.00896096, -0.00001952, 172.36783217, -3.33144911, 0.02242308, -0.00004810, 267.90909091, -5.31620047, 0.03597727, -0.00007698]
+  - [85.83006993, -1.55480575, 0.01025932, -0.00002216, 160.73706294, -3.07291375, 0.02041900, -0.00004330, 237.37622378, -4.63444833, 0.03091317, -0.00006525]
+  - [105.02447552, -1.98017094, 0.01319522, -0.00002877, 135.50699301, -2.59097902, 0.01749301, -0.00003811, 165.33006993, -3.18872183, 0.02171387, -0.00004734]
+  - [105.02447552, -1.98017094, 0.01319522, -0.00002877, 135.50699301, -2.59097902, 0.01749301, -0.00003811, 165.33006993, -3.18872183, 0.02171387, -0.00004734]
+
+# Coefficients for band 8 land thresholds
+Coeffs_Band8_land_thresh:
+  - [282.74916084, -5.42869658, 0.03660781, -0.00008092, 344.87048951, -6.80660839, 0.04770163, -0.00010991, 407.83734266, -8.20392385, 0.05894114, -0.00013926]
+  - [229.50727273, -4.31606061, 0.02868182, -0.00006212, 316.38517483, -6.41910256, 0.04603089, -0.00010787, 403.78188811, -8.52743395, 0.06335781, -0.00015340]
+  - [239.32391608, -4.49928127, 0.02977214, -0.00006436, 270.31741259, -5.33625680, 0.03757168, -0.00008609, 301.76013986, -6.18557498, 0.04546562, -0.00010806]
-- 
GitLab