From 5441f1de6fee2b910deeb84ec24bf415f87d06b0 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Thu, 23 Feb 2023 10:43:47 -0600
Subject: [PATCH] snapshot...

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

diff --git a/modules/util/viirs_l1b_l2.py b/modules/util/viirs_l1b_l2.py
index a348fb77..d9c99a14 100644
--- a/modules/util/viirs_l1b_l2.py
+++ b/modules/util/viirs_l1b_l2.py
@@ -203,6 +203,8 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, dum, num_keep_x_tiles=8, ti
     num_y_valid = int(num_keep_y_tiles * 0.15) + 1
     num_y_train = num_keep_y_tiles - num_y_valid - 1
 
+    tiles = []
+
     for j in range(num_y_train):
         j_a = j_start + j * j_skip
         j_b = j_a + tile_width
@@ -219,26 +221,16 @@ def run(data_h5f, param_s, train_tiles, valid_tiles, dum, num_keep_x_tiles=8, ti
             nda = data[:, j_a:j_b, i_a:i_b]
             nda = keep_tile(param_s, nda, dum)
             if nda is not None:
-                train_tiles.append(nda)
-
-    j_start = num_y_train * tile_width + 2*tile_width
-    for j in range(num_y_valid):
-        j_a = j_start + j * j_skip
-        j_b = j_a + tile_width
+                tiles.append(nda)
 
-        for i in range(num_keep_x_tiles):
-            i_a = i_start + i * i_skip
-            i_b = i_a + tile_width
+    num_tiles = len(tiles)
+    num_valid = int(num_tiles * 0.10)
+    num_train = num_tiles - num_valid
 
-            if day_night == 'DAY' and not is_day(solzen[j_a:j_b, i_a:i_b]):
-                continue
-            elif day_night == 'NIGHT' and is_day(solzen[j_a:j_b, i_a:i_b]):
-                continue
-
-            nda = data[:, j_a:j_b, i_a:i_b]
-            nda = keep_tile(param_s, nda, dum)
-            if nda is not None:
-                valid_tiles.append(nda)
+    for k in range(num_train):
+        train_tiles.append(tiles[k])
+    for k in range(num_valid):
+        valid_tiles.append(tiles[num_train + k])
 
 
 def scan(directory):
-- 
GitLab