From dabfb8f3f5cef6c71caff85b6b2f1fff3080004e Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Mon, 12 Sep 2022 13:37:37 -0500
Subject: [PATCH] snaphot...

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

diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py
index 4cbe604d..dbfadb86 100644
--- a/modules/util/viirs_l1b_l2.py
+++ b/modules/util/viirs_l1b_l2.py
@@ -165,7 +165,7 @@ def run_all(directory, out_directory):
     print('total_num_train_samples, total_num_valid_samples: ', total_num_train_samples, total_num_valid_samples)
 
 
-def run(data_h5f, param_s, tiles, tile_width=64, kernel_size=9):
+def run(data_h5f, param_s, tiles, tile_width=64, kernel_size=9, day_night='ANY'):
 
     border = int((kernel_size - 1)/2)
 
@@ -174,6 +174,8 @@ def run(data_h5f, param_s, tiles, tile_width=64, kernel_size=9):
     num_lines = data_h5f[param_name].shape[0]
     num_pixels = data_h5f[param_name].shape[1]
 
+    solzen = get_grid_values(data_h5f, 'solar_zenith_angle', 0, 0, None, num_lines, num_pixels)
+
     grd_s = []
 
     for param in param_s:
@@ -210,6 +212,9 @@ def run(data_h5f, param_s, tiles, tile_width=64, kernel_size=9):
             if i_stop > num_pixels - 1:
                 continue
 
+            if day_night == 'DAY' and not is_day(solzen[j_m-border:j_stop, i_m-border:i_stop]):
+                continue
+
             nda = data[:, j_m-border:j_stop, i_m-border:i_stop]
             tiles.append(nda)
 
-- 
GitLab