Skip to content
Snippets Groups Projects
Commit d96a7edf authored by tomrink's avatar tomrink
Browse files

normalize before upsampling (nans)

parent 323a9b6c
No related branches found
No related tags found
No related merge requests found
...@@ -225,22 +225,23 @@ class SRCNN: ...@@ -225,22 +225,23 @@ class SRCNN:
for param in data_params: for param in data_params:
idx = params.index(param) idx = params.index(param)
tmp = input_data[:, idx, 3:131:2, 3:131:2] tmp = input_data[:, idx, 3:131:2, 3:131:2]
tmp = resample_2d_linear(x_64, y_64, tmp, t, s)
tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale) tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale)
tmp = resample_2d_linear(x_64, y_64, tmp, t, s)
data_norm.append(tmp) data_norm.append(tmp)
# -------- # --------
idx = params.index('refl_0_65um_nom') idx = params.index('refl_0_65um_nom')
tmp = input_data[:, idx, 3:131, 3:131] tmp = input_data[:, idx, 3:131, 3:131]
tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale)
# tmp = input_data[:, idx, 3:131:2, 3:131:2] # tmp = input_data[:, idx, 3:131:2, 3:131:2]
# tmp = resample_2d_linear(x_64, y_64, tmp, t, s) # tmp = resample_2d_linear(x_64, y_64, tmp, t, s)
tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale)
data_norm.append(tmp) data_norm.append(tmp)
# -------- # --------
tmp = input_data[:, label_idx, 3:131:2, 3:131:2] tmp = input_data[:, label_idx, 3:131:2, 3:131:2]
tmp = np.where(np.isnan(tmp), 0, tmp)
tmp = resample_2d_linear(x_64, y_64, tmp, t, s)
if label_param != 'cloud_fraction': if label_param != 'cloud_fraction':
tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale) tmp = normalize(tmp, param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale)
else:
tmp = np.where(np.isnan(tmp), 0, tmp)
tmp = resample_2d_linear(x_64, y_64, tmp, t, s)
data_norm.append(tmp) data_norm.append(tmp)
# --------- # ---------
data = np.stack(data_norm, axis=3) data = np.stack(data_norm, axis=3)
...@@ -248,10 +249,11 @@ class SRCNN: ...@@ -248,10 +249,11 @@ class SRCNN:
# label = input_data[:, label_idx, 3:131:2, 3:131:2] # label = input_data[:, label_idx, 3:131:2, 3:131:2]
label = input_data[:, label_idx, 3:131, 3:131] label = input_data[:, label_idx, 3:131, 3:131]
label = np.where(np.isnan(label), 0, label)
label = np.expand_dims(label, axis=3)
if label_param != 'cloud_fraction': if label_param != 'cloud_fraction':
label = normalize(label, label_param, mean_std_dct) label = normalize(label, label_param, mean_std_dct)
else:
label = np.where(np.isnan(label), 0, label)
label = np.expand_dims(label, axis=3)
data = data.astype(np.float32) data = data.astype(np.float32)
label = label.astype(np.float32) label = label.astype(np.float32)
...@@ -692,16 +694,16 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): ...@@ -692,16 +694,16 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
x_up = np.arange(0, lenx, 0.5) x_up = np.arange(0, lenx, 0.5)
y_up = np.arange(0, leny, 0.5) y_up = np.arange(0, leny, 0.5)
grd_a = resample_2d_linear_one(x, y, grd_a, x_up, y_up)
grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct) grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
grd_a = resample_2d_linear_one(x, y, grd_a, x_up, y_up)
grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct) grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct)
grd_c = resample_2d_linear_one(x, y, grd_c, x_up, y_up)
if label_param == 'cloud_fraction': if label_param == 'cloud_fraction':
grd_c = np.where(np.isnan(grd_c), 0, grd_c) grd_c = np.where(np.isnan(grd_c), 0, grd_c)
else: else:
grd_c = normalize(grd_c, label_param, mean_std_dct) grd_c = normalize(grd_c, label_param, mean_std_dct)
grd_c = resample_2d_linear_one(x, y, grd_c, x_up, y_up)
data = np.stack([grd_a, grd_b, grd_c], axis=2) data = np.stack([grd_a, grd_b, grd_c], axis=2)
data = np.expand_dims(data, axis=0) data = np.expand_dims(data, axis=0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment