From 4f930558fc242a5d097b1f308ea64b117dd778bb Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Wed, 13 Apr 2022 17:03:55 -0500
Subject: [PATCH] snapshot...

---
 modules/deeplearning/icing_fcn.py | 36 +++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/modules/deeplearning/icing_fcn.py b/modules/deeplearning/icing_fcn.py
index fefbeb75..c92cc46b 100644
--- a/modules/deeplearning/icing_fcn.py
+++ b/modules/deeplearning/icing_fcn.py
@@ -363,22 +363,44 @@ class IcingIntensityFCN:
     def get_in_mem_data_batch_test(self, idxs):
         return self.get_in_mem_data_batch(idxs, False)
 
+    # For full image processing, not quite there yet :(
+    # def get_in_mem_data_batch_eval(self, idxs):
+    #     data = []
+    #     for param in self.train_params:
+    #         nda = self.data_dct[param]
+    #         nda = normalize(nda, param, mean_std_dct)
+    #         data.append(nda)
+    #     data = np.stack(data)
+    #     data = data.astype(np.float32)
+    #     data = np.transpose(data, axes=(1, 2, 0))
+    #     data = np.expand_dims(data, axis=0)
+    #
+    #     nda = np.zeros([1])
+    #     nda[0] = self.flight_level
+    #     nda = tf.one_hot(nda, 5).numpy()
+    #     nda = np.expand_dims(nda, axis=0)
+    #     nda = np.expand_dims(nda, axis=0)
+    #
+    #     return data, nda
+
     def get_in_mem_data_batch_eval(self, idxs):
+        # sort these to use as numpy indexing arrays
+        nd_idxs = np.array(idxs)
+        nd_idxs = np.sort(nd_idxs)
+
         data = []
         for param in self.train_params:
-            nda = self.data_dct[param]
+            nda = self.data_dct[param][nd_idxs, ]
             nda = normalize(nda, param, mean_std_dct)
             data.append(nda)
         data = np.stack(data)
         data = data.astype(np.float32)
-        data = np.transpose(data, axes=(1, 2, 0))
-        data = np.expand_dims(data, axis=0)
+        data = np.transpose(data, axes=(1, 2, 3, 0))
 
-        nda = np.zeros([1])
-        nda[0] = self.flight_level
+        # TODO: altitude data will be specified by user at run-time
+        nda = np.zeros([nd_idxs.size])
+        nda[:] = self.flight_level
         nda = tf.one_hot(nda, 5).numpy()
-        nda = np.expand_dims(nda, axis=0)
-        nda = np.expand_dims(nda, axis=0)
 
         return data, nda
 
-- 
GitLab