From 265f522af13d4ebdd105c3f7d91c8d8146e44335 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Fri, 15 Oct 2021 13:40:05 -0500
Subject: [PATCH] add icing altitude

---
 modules/deeplearning/icing_cnn.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/modules/deeplearning/icing_cnn.py b/modules/deeplearning/icing_cnn.py
index 987b70ca..9f53379d 100644
--- a/modules/deeplearning/icing_cnn.py
+++ b/modules/deeplearning/icing_cnn.py
@@ -303,6 +303,35 @@ class IcingIntensityNN:
         nda = h5f[param][nd_idxs,]
         return nda
 
+    def get_scalar_data(self, nd_idxs, is_training):
+        param = 'flight_altitude'
+
+        if is_training:
+            if self.h5f_l1b_trn is not None:
+                h5f = self.h5f_l1b_trn
+            else:
+                h5f = self.h5f_l2_trn
+        else:
+            if self.h5f_l1b_tst is not None:
+                h5f = self.h5f_l1b_tst
+            else:
+                h5f = self.h5f_l2_tst
+
+        nda = h5f[param][nd_idxs,]
+        b0 = np.logical_and(nda >= 0, nda < 2000)
+        b1 = np.logical_and(nda >= 2000, nda < 4000)
+        b2 = np.logical_and(nda >= 4000, nda < 6000)
+        b3 = np.logical_and(nda >= 6000, nda < 8000)
+        b4 = np.logical_and(nda >= 8000, nda < 15000)
+        nda[b0] = 0
+        nda[b1] = 1
+        nda[b2] = 2
+        nda[b3] = 3
+        nda[b4] = 4
+        nda = tf.one_hot(nda, 5).numpy()
+
+        return nda
+
     def get_label_data(self, nd_idxs, is_training):
         # Note: labels will be same for nd_idxs across both L1B and L2
         if is_training:
-- 
GitLab