diff --git a/modules/deeplearning/icing_cnn.py b/modules/deeplearning/icing_cnn.py index 987b70cadd3472cbcd55906a0880edae2dc44dd9..9f53379d9043304648fb16d57ce570c6307bd7b9 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: