From d0cf9ea52868ddf51138880d04fc6ee8d7208095 Mon Sep 17 00:00:00 2001
From: tomrink <rink@ssec.wisc.edu>
Date: Thu, 22 Dec 2022 11:45:22 -0600
Subject: [PATCH] snapshot...

---
 modules/deeplearning/srcnn_l1b_l2.py | 39 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/modules/deeplearning/srcnn_l1b_l2.py b/modules/deeplearning/srcnn_l1b_l2.py
index deb39a13..0c162a63 100644
--- a/modules/deeplearning/srcnn_l1b_l2.py
+++ b/modules/deeplearning/srcnn_l1b_l2.py
@@ -30,7 +30,7 @@ NUM_EPOCHS = 60
 TRACK_MOVING_AVERAGE = False
 EARLY_STOP = True
 
-NOISE_TRAINING = True
+NOISE_TRAINING = False
 NOISE_STDDEV = 0.01
 DO_AUGMENT = True
 
@@ -246,15 +246,17 @@ class SRCNN:
             DO_ADD_NOISE = True
 
         data_norm = []
-        # for param in data_params:
-        #     idx = params.index(param)
-        #     # tmp = input_data[:, idx, slc_y_2, slc_x_2]
-        #     tmp = input_data[:, idx, slc_y, slc_x]
-        #     tmp = normalize(tmp, param, mean_std_dct)
-        #     if DO_ADD_NOISE:
-        #         tmp = add_noise(tmp, noise_scale=NOISE_STDDEV)
-        #     # tmp = resample_2d_linear(x_2, y_2, tmp, t, s)
-        #     data_norm.append(tmp)
+        for param in data_params:
+            idx = params.index(param)
+            # tmp = input_data[:, idx, slc_y, slc_x]
+            tmp = input_data[:, idx, :, :]
+            tmp = smooth_2d(tmp, sigma=1.0)
+            tmp = tmp[:, slc_y_2, slc_x_2]
+            tmp = normalize(tmp, param, mean_std_dct)
+            if DO_ADD_NOISE:
+                tmp = add_noise(tmp, noise_scale=NOISE_STDDEV)
+            # tmp = resample_2d_linear(x_2, y_2, tmp, t, s)
+            data_norm.append(tmp)
         # # --------------------------
         # param = 'refl_0_65um_nom'
         # idx = params.index(param)
@@ -420,7 +422,7 @@ class SRCNN:
         activation = tf.nn.relu
         momentum = 0.99
 
-        num_filters = 64
+        num_filters = 32
 
         input_2d = self.inputs[0]
         print('input: ', input_2d.shape)
@@ -437,7 +439,7 @@ class SRCNN:
 
         conv_b = build_residual_conv2d_block(conv_b, num_filters, 'Residual_Block_2', kernel_size=KERNEL_SIZE, scale=scale)
 
-        conv_b = build_residual_conv2d_block(conv_b, num_filters, 'Residual_Block_3', kernel_size=KERNEL_SIZE, scale=scale)
+        #conv_b = build_residual_conv2d_block(conv_b, num_filters, 'Residual_Block_3', kernel_size=KERNEL_SIZE, scale=scale)
 
         #conv_b = build_residual_conv2d_block(conv_b, num_filters, 'Residual_Block_4', kernel_size=KERNEL_SIZE, scale=scale)
 
@@ -749,11 +751,12 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
     y_0, x_0, = 2432 - int(sub_y/2), 2432 - int(sub_x/2)
 
     h5f = h5py.File(in_file, 'r')
-    # grd_a = get_grid_values_all(h5f, 'temp_11_0um_nom')
-    # grd_a = grd_a[y_0:y_0+sub_y, x_0:x_0+sub_x]
-    # grd_a = grd_a[y_130, x_130]
-    # bt = grd_a
-    # grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
+    grd_a = get_grid_values_all(h5f, 'temp_11_0um_nom')
+    grd_a = grd_a[y_0:y_0+sub_y, x_0:x_0+sub_x]
+    hr_grd_a = grd_a.copy()
+    hr_grd_a = hr_grd_a[y_128, x_128]
+    grd_a = grd_a[slc_y_2, slc_x_2]
+    grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
     #
     # grd_b = get_grid_values_all(h5f, 'refl_0_65um_nom')
     # grd_b = grd_b[y_0:y_0+sub_y, x_0:x_0+sub_x]
@@ -773,7 +776,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
     grd_c = grd_c[y_k, x_k]
 
     # data = np.stack([grd_a, grd_b, grd_c], axis=2)
-    data = np.stack([grd_c], axis=2)
+    data = np.stack([grd_a, grd_c], axis=2)
     data = np.expand_dims(data, axis=0)
 
     nn = SRCNN()
-- 
GitLab