From 4a96fda77d5f63f75feab89b54cb2754cd230dc9 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 29 Mar 2023 14:14:08 -0500
Subject: [PATCH] snapshot...

---
 modules/util/viirs_l1b_l2.py | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py
index 67ee8b8d..b4a0220d 100644
--- a/modules/util/viirs_l1b_l2.py
+++ b/modules/util/viirs_l1b_l2.py
@@ -26,11 +26,12 @@ keep_out_opd = ['/ships19/cloud/scratch/cphillips/clavrx/run_viirs_superres/site
 
 keep_out = keep_out_opd
 
-target_param = 'cloud_probability'
-# target_param = 'cld_opd_dcomp'
+# target_param = 'cloud_probability'
+target_param = 'cld_opd_dcomp'
 
 # group_name = ''
-group_name = 'super/'
+# group_name = 'super/'
+group_name = 'orig/'
 # l2_params = [group_name+'temp_11_0um_nom', group_name+'refl_0_65um_nom', group_name+target_param]
 l2_params = [group_name+'temp_11_0um', group_name+'refl_0_65um', group_name+target_param]
 
@@ -87,27 +88,14 @@ def process_cld_prob(grd_k):
     return grd_k
 
 
-# def process_cld_opd(grd_k):
-#     keep = np.invert(np.isnan(grd_k))
-#     num_keep = np.sum(keep)
-#     grd_k = np.where(np.invert(keep), 0, grd_k)
-#     keep = np.where(keep, np.logical_and(0.1 < grd_k, grd_k < 158.0), False)
-#     frac_keep = np.sum(keep)/num_keep
-#     if frac_keep < 0.60:
-#         return None
-#     return grd_k
-
-
 def process_cld_opd(grd_k):
     keep = np.invert(np.isnan(grd_k))
     num_keep = np.sum(keep)
-    keep_vthin = np.where(keep, grd_k < 0.01, False)
-    keep_vthik = np.where(keep, grd_k < 150.0, False)
-    frac_vthin = np.sum(keep_vthin) / num_keep
-    frac_vthik = np.sum(keep_vthik) / num_keep
-    if not (frac_vthin >= 0.10 and frac_vthik >= 0.10):
+    keep_cld = np.where(keep, np.logical_and(0.1 < grd_k, grd_k < 158.0), False)
+    frac_cld = np.sum(keep_cld)/num_keep
+    if not (0.20 < frac_cld < 0.85):
         return None
-    grd_k = np.where(np.invert(keep), 0, grd_k)
+    grd_k = np.where(np.invert(keep), 0, grd_k)  # Convert NaN to 0
     return grd_k
 
 
@@ -117,6 +105,7 @@ def run_all(directory, out_directory, day_night='ANY', start=10):
     total_num_valid_samples = 0
     total_num_not_missing = 0
     num_keep_x_tiles = 14
+    tile_width = 128
 
     # pattern = 'clavrx_VNP02MOD*.highres.nc.level2.nc'
     pattern = 'clavrx_*.nc'
@@ -143,7 +132,7 @@ def run_all(directory, out_directory, day_night='ANY', start=10):
                 continue
 
             try:
-                num_not_missing = run(data_h5f, data_params, data_train_tiles, data_valid_tiles, num_keep_x_tiles=num_keep_x_tiles, tile_width=128, kernel_size=11, day_night=day_night)
+                num_not_missing = run(data_h5f, data_params, data_train_tiles, data_valid_tiles, num_keep_x_tiles=num_keep_x_tiles, tile_width=tile_width, kernel_size=11, day_night=day_night)
             except Exception as e:
                 print(e)
                 data_h5f.close()
-- 
GitLab