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

snapshot..

parent 8a96d286
No related branches found
No related tags found
No related merge requests found
......@@ -724,36 +724,44 @@ def run_restore_static(directory, ckpt_dir, out_file=None):
def run_evaluate_static(in_file, out_file, ckpt_dir):
N = 8
sub_y, sub_x = (N * 128) + 6, (N * 128) + 6
y_0, x_0, = 2432 - int(sub_y/2), 2432 - int(sub_x/2)
x_130 = slice(2, (N * 128) + 4)
y_130 = slice(2, (N * 128) + 4)
slc_x = slice(2, N*128 + 4)
slc_y = slice(2, N*128 + 4)
slc_x_2 = slice(1, N*128 + 6, 2)
slc_y_2 = slice(1, N*128 + 6, 2)
x_2 = np.arange(int((N*128)/2) + 3)
y_2 = np.arange(int((N*128)/2) + 3)
t = np.arange(0, int((N*128)/2) + 3, 0.5)
s = np.arange(0, int((N*128)/2) + 3, 0.5)
x_k = slice(1, N*128 + 3)
y_k = slice(1, N*128 + 3)
x_128 = slice(3, N*128 + 3)
y_128 = slice(3, N*128 + 3)
slc_y_2, slc_x_2 = slice(1, 128*N + 6, 2), slice(1, 128*N + 6, 2)
y_2, x_2 = np.arange((128*N)/2 + 3), np.arange((128*N)/2 + 3)
t, s = np.arange(1, (128*N)/2 + 2, 0.5), np.arange(1, (128*N)/2 + 2, 0.5)
sub_y, sub_x = (N * 128) + 10, (N * 128) + 10
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_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]
grd_b = grd_b[y_130, x_130]
refl = grd_b
grd_b = normalize(grd_b, 'refl_0_65um_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]
# grd_a = grd_a[y_130, x_130]
# bt = grd_a
# 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]
# grd_b = grd_b[y_130, x_130]
# refl = grd_b
# grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct)
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]
hr_grd_c = grd_c.copy()
hr_grd_c = hr_grd_c[y_128, x_128]
grd_c = grd_c[slc_y_2, slc_x_2]
if label_param != 'cloud_probability':
grd_c = normalize(grd_c, label_param, mean_std_dct)
grd_c = resample_2d_linear_one(x_2, y_2, grd_c, t, s)
print(grd_a.shape, grd_b.shape, grd_c.shape)
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)
......@@ -766,40 +774,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
if out_file is not None:
np.save(out_file, [out_sr, hr_grd_c])
else:
return out_sr, bt, refl
def run_evaluate_static_2(in_file, out_file, ckpt_dir):
nda = np.load(in_file)
grd_a = nda[:, 0, :, :]
grd_a = grd_a[:, slc_y_2, slc_x_2]
grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
grd_a = resample_2d_linear(x_2, y_2, grd_a, t, s)
grd_b = nda[:, 2, :, :]
grd_b = grd_b[:, slc_y_2, slc_x_2]
grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct)
grd_b = resample_2d_linear(x_2, y_2, grd_b, t, s)
grd_c = nda[:, 3, :, :]
grd_c = grd_c[:, slc_y_2, slc_x_2]
if label_param != 'cloud_probability':
grd_c = normalize(grd_c, label_param, mean_std_dct)
grd_c = resample_2d_linear(x_2, y_2, grd_c, t, s)
data = np.stack([grd_a, grd_b, grd_c], axis=3)
print(data.shape)
nn = SRCNN()
out_sr = nn.run_evaluate(data, ckpt_dir)
if label_param != 'cloud_probability':
out_sr = denormalize(out_sr, label_param, mean_std_dct)
pass
if out_file is not None:
np.save(out_file, out_sr)
else:
return out_sr
return out_sr, None, None
def analyze(fpath='/Users/tomrink/clavrx_snpp_viirs.A2019080.0100.001.2019080064252.uwssec_B00038315.level2.h5', param='cloud_probability'):
......
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