diff --git a/preprocess_thresholds.py b/preprocess_thresholds.py index f4b7e5963f47e0a6ffcf547f80a965b9bf432859..fc7fc7fef76a9a928c30d6d20846d555c0f2f771 100644 --- a/preprocess_thresholds.py +++ b/preprocess_thresholds.py @@ -15,16 +15,31 @@ def prepare_thresholds(data, thresholds): coeff_values[:, :, 1] = np.full(data.M01.shape, thresholds['11-12um_Cirrus_Test']['coeffs'][1]) cmult_values = np.full(data.M01.shape, thresholds['11-12um_Cirrus_Test']['cmult']) adj_values = np.full(data.M01.shape, thresholds['11-12um_Cirrus_Test']['adj']) - + if 'bt1' in list(thresholds['11-12um_Cirrus_Test']): + bt1 = np.full(data.M01.shape, thresholds['11-12um_Cirrus_Test']['bt1']) + else: + bt1 = np.full(data.M01.shape, -999) + if 'lat' in list(thresholds['11-12um_Cirrus_Test']): + lat = np.full(data.M01.shape, thresholds['11-12um_Cirrus_Test']['lat']) + else: + lat = np.full(data.M01.shape, -999) thr_dict = {'coeffs': (['number_of_lines', 'number_of_pixels', 'z'], coeff_values), 'cmult': (['number_of_lines', 'number_of_pixels'], cmult_values), - 'adj': (['number_of_lines', 'number_of_pixels'], adj_values) + 'adj': (['number_of_lines', 'number_of_pixels'], adj_values), + 'bt1': (['number_of_lines', 'number_of_pixels'], bt1), + 'lat': (['number_of_lines', 'number_of_pixels'], lat), } return xr.Dataset(data_vars=thr_dict) +# 3. Others +# - Land_Night +# - Polar_Night_Land +# - Polar_Night_Snow +# - Day_Snow +# - Night_Snow -def preproc(data, thresholds): +def preproc(data, thresholds, scene): cosvza = np.cos(data.sensor_zenith * _dtr) schi = (1/cosvza).where(cosvza > 0, 99.0) @@ -40,9 +55,27 @@ 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) + if scene in ['Land_Day', 'Land_Day_Coast', 'Land_Day_Desert', 'Land_Day_Desert_Coast', + 'Ocean_Day', 'Ocean_Night', 'Polar_Ocean_Day', 'Polar_Ocean_Night']: + hicut = midpt - thr_xr.adj + elif scene in ['Polar_Day_Land', 'Polar_Day_Coast', 'Polar_Day_Desert', + 'Polar_Day_Desert_Coast', 'Polar_Day_Snow']: + hicut = midpt - (thr_xr.adj * midpt) + elif scene in ['Land_Night', 'Polar_Night_Land', 'Polar_Night_Snow', 'Day_Snow', 'Night_Snow']: + _coeffs = {'Land_Night': 0.3, 'Polar_Night_Land': 0.3, 'Polar_Night_Snow': 0.3, + 'Day_Snow': 0.0, 'Night_Snow': 0.3} + midpt = midpt - (_coeffs[scene] * locut) + if scene in ['Polar_Night_Land', 'Polar_Night_Snow', 'Night_Snow']: + hicut = (midpt - (0.2 * locut)).where(data.M15 < thr_xr.bt1, midpt - 1.25) + elif scene in ['Land_Night']: + hicut = -0.1 - np.power(90.0 - np.abs(data.latitude)/60, 4) * 1.15 + hicut = hicut.where((data.M15 < thr_xr.bt1) & (data.latitude > thr_xr.lat), 1.25) + elif scene in ['Day_Snow']: + hicut = locut - (thr_xr.cmult * locut) + else: + print('Scene not recognized\n') + else: + print('Scene not recognized\n') 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')) diff --git a/tests.py b/tests.py index 0e72173494107cb541eca15e4ae89fe74ee01d03..8e79c3612125d50198ea085691704e5a4d0e65be 100644 --- a/tests.py +++ b/tests.py @@ -268,7 +268,7 @@ class CloudTests: thr_xr = xr.Dataset() if test_name == '11-12um_Cirrus_Test': - thr_xr['threshold'] = pt.preproc(self.data, self.thresholds[self.scene_name]) + thr_xr['threshold'] = pt.preproc(self.data, self.thresholds[self.scene_name], 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 == 'Surface_Temperature_Test': diff --git a/thresholds.mvcm.snpp.v0.0.1.yaml b/thresholds.mvcm.snpp.v0.0.1.yaml index cf791411133277e06a8ce6ff4b83b0438f7d070c..1f495c88f6ab2f20361d0148d9c4d89654c6a216 100644 --- a/thresholds.mvcm.snpp.v0.0.1.yaml +++ b/thresholds.mvcm.snpp.v0.0.1.yaml @@ -20,6 +20,12 @@ Land_Day: b1bias_adj : 0.94 Land_Night: + 11-12um_Cirrus_Test: + coeffs: [3.0, 1.0] + cmult: 0.0 + adj: 0 + bt1: 270.0 # WILL FIND A BETTER NAME AT SOME POINT, MAYBE + lat: 30.0 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] @@ -32,7 +38,6 @@ Land_Night: 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 # __| @@ -175,9 +180,9 @@ 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 + cmult: 0 + adj: 0 # I NEED TO WORK ON THIS + bt1: 270.0 pnlbt2 : 270.0 Surface_Temperature_Test_df1: [0.0, 1.0] Surface_Temperature_Test_df2: [-0.5, 1.0] @@ -199,8 +204,8 @@ Polar_Night_Land: 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 + cmult: 0 # I NEED TO WORK ON THIS + adj: 0 # I NEED TO WORK ON THIS pdl_ref3_tpw_t2 : -10.00 11-4um_Oceanic_Stratus_Test: [-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] @@ -210,8 +215,8 @@ Polar_Day_Coast: 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 + cmult: 0 # I NEED TO WORK ON THIS + adj: 0 # 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 @@ -227,8 +232,8 @@ Polar_Day_Desert: 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 + cmult: 0 # I NEED TO WORK ON THIS + adj: 0 # 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 @@ -241,8 +246,8 @@ Polar_Day_Desert_Coast: 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 + cmult: 0 # I NEED TO WORK ON THIS + adj: 0 # 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] @@ -259,8 +264,9 @@ Polar_Day_Snow: 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 + cmult: 0 + adj: 0 # I NEED TO WORK ON THIS + bt1: 270.0 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] @@ -292,7 +298,6 @@ Polar_Night_Snow: 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 @@ -349,8 +354,8 @@ Polar_Ocean_Night: 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 + cmult: 0.3 + adj: 0 # 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] @@ -363,9 +368,9 @@ Day_Snow: 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 + cmult: 0 + adj: 0 # I NEED TO WORK ON THIS + bt1: 270.0 nsbt2 : 270.0 nsbt3 : 230.0 ns11_4lo : [0.70, 0.60, 0.50, 1.0, 1.0]