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

normalize before upsampling (nans)

parent d96a7edf
No related branches found
No related tags found
No related merge requests found
...@@ -718,6 +718,46 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): ...@@ -718,6 +718,46 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
return out_sr return out_sr
def run_evaluate_static_2(in_file, out_file, ckpt_dir):
nda = np.load(in_file)
grd_a = nda[:, 0, :, :]
grd_a = grd_a[:, 3:131:2, 3:131:2]
grd_b = nda[:, 2, 3:131, 3:131]
grd_c = nda[:, 3, :, :]
grd_c = grd_c[:, 3:131:2, 3:131:2]
num, leny, lenx = grd_a.shape
x = np.arange(lenx)
y = np.arange(leny)
x_up = np.arange(0, lenx, 0.5)
y_up = np.arange(0, leny, 0.5)
grd_a = normalize(grd_a, 'temp_11_0um_nom', mean_std_dct)
grd_a = resample_2d_linear(x, y, grd_a, x_up, y_up)
grd_b = normalize(grd_b, 'refl_0_65um_nom', mean_std_dct)
if label_param == 'cloud_fraction':
grd_c = np.where(np.isnan(grd_c), 0, grd_c)
else:
grd_c = normalize(grd_c, label_param, mean_std_dct)
grd_c = resample_2d_linear(x, y, grd_c, x_up, y_up)
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_fraction':
out_sr = denormalize(out_sr, label_param, mean_std_dct)
if out_file is not None:
np.save(out_file, out_sr)
else:
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_fraction'):
h5f = h5py.File(fpath, 'r') h5f = h5py.File(fpath, 'r')
grd = get_grid_values_all(h5f, param) grd = get_grid_values_all(h5f, param)
......
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