From f846b4a77a0d90e5eb2c96711191e0e62e82873f Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 15 Feb 2023 13:08:18 -0600
Subject: [PATCH] snapshot...

---
 modules/util/viirs_l1b_l2.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py
index 513cbc72..da355275 100644
--- a/modules/util/viirs_l1b_l2.py
+++ b/modules/util/viirs_l1b_l2.py
@@ -132,12 +132,12 @@ def run_all(directory, out_directory, day_night='ANY', start=10):
                 data_h5f.close()
                 continue
             kept_cnt += kept
-            print(data_f, kept_cnt, int(100 * (kept/total)))
+            print(data_f, kept, kept_cnt)
             f_cnt += 1
 
             data_h5f.close()
 
-            if len(data_train_tiles) == 0:
+            if len(data_train_tiles) == 0 and len(data_valid_tiles) == 0:
                 continue
 
             if (f_cnt % 5) == 0:
@@ -147,9 +147,11 @@ def run_all(directory, out_directory, day_night='ANY', start=10):
                     np.save(out_directory + 'data_valid_' + str(cnt), data_valid)
                     num_valid_samples = data_valid.shape[0]
 
-                data_train = np.stack(data_train_tiles)
-                np.save(out_directory+'data_train_' + str(cnt), data_train)
-                num_train_samples = data_train.shape[0]
+                num_train_samples = 0
+                if len(data_train_tiles) > 0:
+                    data_train = np.stack(data_train_tiles)
+                    np.save(out_directory+'data_train_' + str(cnt), data_train)
+                    num_train_samples = data_train.shape[0]
 
                 data_valid_tiles = []
                 data_train_tiles = []
-- 
GitLab