From ea74857df309ad1a3abdc25a30d3f25649858e50 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Tue, 21 Jun 2022 16:54:15 -0500
Subject: [PATCH] nlcomp for VIIRS

---
 modules/icing/util.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/icing/util.py b/modules/icing/util.py
index 89b3de0a..d6c42618 100644
--- a/modules/icing/util.py
+++ b/modules/icing/util.py
@@ -28,7 +28,7 @@ import datetime
 # endif
 
 
-def get_training_parameters(day_night='DAY', l1b_andor_l2='both'):
+def get_training_parameters(day_night='DAY', l1b_andor_l2='both', lunar=False):
     if day_night == 'DAY':
         train_params_l2 = ['cld_height_acha', 'cld_geo_thick', 'cld_temp_acha', 'cld_press_acha', 'supercooled_cloud_fraction',
                            'cld_emiss_acha', 'conv_cloud_fraction', 'cld_reff_dcomp', 'cld_opd_dcomp', 'iwc_dcomp', 'lwc_dcomp']
@@ -40,6 +40,10 @@ def get_training_parameters(day_night='DAY', l1b_andor_l2='both'):
         train_params_l2 = ['cld_height_acha', 'cld_geo_thick', 'cld_temp_acha', 'cld_press_acha', 'supercooled_cloud_fraction',
                            'cld_emiss_acha', 'conv_cloud_fraction', 'cld_reff_acha', 'cld_opd_acha']
 
+        if lunar is True:
+            train_params_l2 = ['cld_height_acha', 'cld_geo_thick', 'cld_temp_acha', 'cld_press_acha', 'supercooled_cloud_fraction',
+                               'cld_emiss_acha', 'conv_cloud_fraction', 'cld_reff_dcomp', 'cld_opd_dcomp', 'iwc_dcomp', 'lwc_dcomp']
+
         train_params_l1b = ['temp_10_4um_nom', 'temp_11_0um_nom', 'temp_12_0um_nom', 'temp_13_3um_nom', 'temp_3_75um_nom',
                             'temp_6_2um_nom', 'temp_6_7um_nom', 'temp_7_3um_nom', 'temp_8_5um_nom', 'temp_9_7um_nom']
 
@@ -64,7 +68,8 @@ flt_level_ranges[4] = [8000.0, 15000.0]
 def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=homedir,
                       day_model_path=model_path_day, night_model_path=model_path_night,
                       prob_thresh=0.5, satellite='GOES16', domain='CONUS', day_night='AUTO',
-                      l1b_andor_l2='l2', use_flight_altitude=True, res_fac=1, use_nan=False, has_time=False, model_type='FCN'):
+                      l1b_andor_l2='l2', use_flight_altitude=True, res_fac=1, use_nan=False, has_time=False,
+                      model_type='FCN', lunar=False):
 
     if model_type == 'CNN':
         model_module = icing_cnn
@@ -114,7 +119,8 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
                                 ['solar_zenith_angle', 'sensor_zenith_angle', 'cld_height_acha', 'cld_geo_thick', bt_fld_name],
                                 satellite=satellite, domain=domain, res_fac=res_fac)
         elif satellite == 'VIIRS':
-            data_dct, ll, cc, lats_2d, lons_2d = make_for_full_domain_predict_viirs_clavrx(h5f, name_list=train_params, res_fac=res_fac)
+            data_dct, ll, cc, lats_2d, lons_2d = make_for_full_domain_predict_viirs_clavrx(h5f, name_list=train_params,
+                                                    day_night=day_night, lres_fac=res_fac)
 
             bt_fld_name = 'temp_11_0um_nom'
             ancil_data_dct, _, _, _, _ = make_for_full_domain_predict_viirs_clavrx(h5f, name_list=
@@ -182,6 +188,9 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
                 fd_probs[day_idxs] = day_probs[:]
 
         if (day_night == 'AUTO' or day_night == 'NIGHT') and num_nght_tiles > 0:
+            model_path = night_model_path
+            if lunar:
+                model_path = day_model_path
 
             nght_data_dct = {name: [] for name in nght_train_params}
             for name in nght_train_params:
@@ -191,7 +200,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h
             for ds_name in nght_train_params:
                 nght_grd_dct[ds_name] = np.stack(nght_data_dct[ds_name])
 
-            preds_nght_dct, probs_nght_dct = model_module.run_evaluate_static(nght_grd_dct, num_nght_tiles, night_model_path,
+            preds_nght_dct, probs_nght_dct = model_module.run_evaluate_static(nght_grd_dct, num_nght_tiles, model_path,
                                                                               day_night='NIGHT', l1b_or_l2=l1b_andor_l2,
                                                                               prob_thresh=prob_thresh,
                                                                               use_flight_altitude=use_flight_altitude,
-- 
GitLab