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

snapshot...

parent f3c8ff7a
No related branches found
No related tags found
No related merge requests found
...@@ -268,7 +268,7 @@ class SRCNN: ...@@ -268,7 +268,7 @@ class SRCNN:
data_norm.append(tmp) data_norm.append(tmp)
# -------- # --------
tmp = input_data[:, label_idx, slc_y_2, slc_x_2] tmp = input_data[:, label_idx, slc_y_2, slc_x_2]
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
tmp = normalize(tmp, label_param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale) tmp = normalize(tmp, label_param, mean_std_dct, add_noise=add_noise, noise_scale=noise_scale)
else: else:
tmp = np.where(np.isnan(tmp), 0, tmp) tmp = np.where(np.isnan(tmp), 0, tmp)
...@@ -280,7 +280,7 @@ class SRCNN: ...@@ -280,7 +280,7 @@ class SRCNN:
# ----------------------------------------------------- # -----------------------------------------------------
# ----------------------------------------------------- # -----------------------------------------------------
label = input_data[:, label_idx, slc_y, slc_x] label = input_data[:, label_idx, slc_y, slc_x]
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
label = normalize(label, label_param, mean_std_dct) label = normalize(label, label_param, mean_std_dct)
else: else:
label = np.where(np.isnan(label), 0, label) label = np.where(np.isnan(label), 0, label)
...@@ -730,7 +730,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): ...@@ -730,7 +730,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
grd_c = get_grid_values_all(h5f, label_param) grd_c = get_grid_values_all(h5f, label_param)
grd_c = grd_c[y_0:y_0+sub_y, x_0:x_0+sub_x] grd_c = grd_c[y_0:y_0+sub_y, x_0:x_0+sub_x]
grd_c = grd_c[slc_y_2, slc_x_2] grd_c = grd_c[slc_y_2, slc_x_2]
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
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_2, y_2, grd_c, t, s) grd_c = resample_2d_linear_one(x_2, y_2, grd_c, t, s)
...@@ -739,7 +739,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): ...@@ -739,7 +739,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
nn = SRCNN() nn = SRCNN()
out_sr = nn.run_evaluate(data, ckpt_dir) out_sr = nn.run_evaluate(data, ckpt_dir)
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
out_sr = denormalize(out_sr, label_param, mean_std_dct) out_sr = denormalize(out_sr, label_param, mean_std_dct)
if out_file is not None: if out_file is not None:
np.save(out_file, out_sr) np.save(out_file, out_sr)
...@@ -762,7 +762,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir): ...@@ -762,7 +762,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir):
grd_c = nda[:, 3, :, :] grd_c = nda[:, 3, :, :]
grd_c = grd_c[:, slc_y_2, slc_x_2] grd_c = grd_c[:, slc_y_2, slc_x_2]
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
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(x_2, y_2, grd_c, t, s) grd_c = resample_2d_linear(x_2, y_2, grd_c, t, s)
...@@ -771,7 +771,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir): ...@@ -771,7 +771,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir):
nn = SRCNN() nn = SRCNN()
out_sr = nn.run_evaluate(data, ckpt_dir) out_sr = nn.run_evaluate(data, ckpt_dir)
if label_param != 'cloud_fraction': if label_param != 'cloud_probability':
out_sr = denormalize(out_sr, label_param, mean_std_dct) out_sr = denormalize(out_sr, label_param, mean_std_dct)
pass pass
if out_file is not None: if out_file is not None:
...@@ -780,7 +780,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir): ...@@ -780,7 +780,7 @@ def run_evaluate_static_2(in_file, out_file, ckpt_dir):
return out_sr return out_sr
def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064252.uwssec_B00038315.level2.h5', param='cloud_fraction'): def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064252.uwssec_B00038315.level2.h5', param='cloud_probability'):
h5f = h5py.File(fpath, 'r') h5f = h5py.File(fpath, 'r')
grd = get_grid_values_all(h5f, param) grd = get_grid_values_all(h5f, param)
grd = np.where(np.isnan(grd), 0, grd) grd = np.where(np.isnan(grd), 0, grd)
...@@ -796,7 +796,7 @@ def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064 ...@@ -796,7 +796,7 @@ def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064
leny, lenx = grd_lr.shape leny, lenx = grd_lr.shape
rnd = np.random.normal(loc=0, scale=0.001, size=grd_lr.size) rnd = np.random.normal(loc=0, scale=0.001, size=grd_lr.size)
grd_lr = grd_lr + rnd.reshape(grd_lr.shape) grd_lr = grd_lr + rnd.reshape(grd_lr.shape)
if param == 'cloud_fraction': if param == 'cloud_probability':
grd_lr = np.where(grd_lr < 0, 0, grd_lr) grd_lr = np.where(grd_lr < 0, 0, grd_lr)
grd_lr = np.where(grd_lr > 1, 1, grd_lr) grd_lr = np.where(grd_lr > 1, 1, grd_lr)
......
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