From 3034de2ca1c015e649ca0544a09485b334ed472e Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Sun, 18 Sep 2022 10:45:56 -0500
Subject: [PATCH] snaphot...

---
 modules/util/viirs_l1b_l2.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py
index 314f9d97..b071fa19 100644
--- a/modules/util/viirs_l1b_l2.py
+++ b/modules/util/viirs_l1b_l2.py
@@ -57,6 +57,19 @@ label_params = l2_params
 data_params = l2_params
 
 
+def keep_tile(param_s, tile):
+    k = param_s.index('cloud_fraction')
+    grd_k = tile[k, ].flatten()
+    keep = np.invert(np.isnan(grd_k))
+    total = np.sum(keep)
+    keep = np.where(keep, np.invert(0.05 < grd_k < 0.95), False)
+
+    if keep/total > 0.5:
+        return True
+    else:
+        return False
+
+
 def run_all(directory, out_directory, day_night='ANY'):
 
     cnt = 10
@@ -215,6 +228,8 @@ def run(data_h5f, param_s, tiles, tile_width=64, kernel_size=9, day_night='ANY')
                 continue
 
             nda = data[:, j_m-border:j_stop, i_m-border:i_stop]
+            if not keep_tile(param_s, nda):
+                continue
             tiles.append(nda)
 
 
-- 
GitLab