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

snapshot...

parent e2d7db05
Branches
No related tags found
No related merge requests found
......@@ -777,6 +777,7 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
h5f = h5py.File(in_file, 'r')
bt = get_grid_values_all(h5f, 'temp_11_0um_nom')
y_len, x_len = bt.shape
refl = get_grid_values_all(h5f, 'refl_0_65um_nom')
refl_lo = get_grid_values_all(h5f, 'refl_0_65um_nom_min_sub')
refl_hi = get_grid_values_all(h5f, 'refl_0_65um_nom_max_sub')
......@@ -785,43 +786,35 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
lons = get_grid_values_all(h5f, 'longitude')
lats = get_grid_values_all(h5f, 'latitude')
# bt = bt[0:2500, :]
# refl = refl[0:2500, :]
# lons = lons[0:2500, :]
# lats = lats[0:2500, :]
# refl_lo = refl_lo[0:2500, :]
# refl_hi = refl_hi[0:2500, :]
# refl_std = refl_std[0:2500, :]
# cp = cp[0:2500, :]
bt_nh = bt[0:2501, :]
refl_nh = refl[0:2501, :]
refl_lo_nh = refl_lo[0:2501, :]
refl_hi_nh = refl_hi[0:2501, :]
refl_std_nh = refl_std[0:2501, :]
cp_nh = cp[0:2501, :]
y_len, x_len = bt.shape[0], bt.shape[1]
bt = normalize(bt, 'temp_11_0um_nom', mean_std_dct)
refl = normalize(refl, 'refl_0_65um_nom', mean_std_dct)
refl_lo = normalize(refl_lo, 'refl_0_65um_nom', mean_std_dct)
refl_hi = normalize(refl_hi, 'refl_0_65um_nom', mean_std_dct)
refl_std = np.where(np.isnan(refl_std), 0, refl_std)
cp = np.where(np.isnan(cp), 0, cp)
data = np.stack([bt, refl, refl_lo, refl_hi, refl_std, cp], axis=2)
data = np.expand_dims(data, axis=0)
bt_sh = bt[2499:y_len, :]
refl_sh = refl[2499:y_len, :]
refl_lo_sh = refl_lo[2499:y_len, :]
refl_hi_sh = refl_hi[2499:y_len, :]
refl_std_sh = refl_std[2499:y_len, :]
cp_sh = cp[2499:y_len, :]
h5f.close()
nn = SRCNN()
probs = nn.run_evaluate(data, ckpt_dir)
cld_frac = probs.argmax(axis=3)
cld_frac = cld_frac.astype(np.int8)
cld_frac_nh = run_evaluate_static_(bt_nh, refl_nh, refl_lo_nh, refl_hi_nh, refl_std_nh, cp_nh, ckpt_dir)
cld_frac_sh = run_evaluate_static_(bt_sh, refl_sh, refl_lo_sh, refl_hi_sh, refl_std_sh, cp_sh, ckpt_dir)
cld_frac_out = np.zeros((y_len, x_len), dtype=np.int8)
border = int((KERNEL_SIZE - 1)/2)
cld_frac_out[border:y_len - border, border:x_len - border] = cld_frac[0, :, :]
cld_frac_out[border:2500, border:x_len - border] = cld_frac_nh[0, :, :]
cld_frac_out[2500:y_len - border, border:x_len - border] = cld_frac_sh[0, :, :]
bt = denormalize(bt, 'temp_11_0um_nom', mean_std_dct)
refl = denormalize(refl, 'refl_0_65um_nom', mean_std_dct)
var_names = ['cloud_fraction', 'temp_11_0um', 'refl_0_65um']
dims = ['num_params', 'y', 'x']
da = xr.DataArray(np.stack([cld_frac_out, bt, refl], axis=0), dims=dims)
da.assign_coords({
'num_params': var_names,
......@@ -835,6 +828,24 @@ def run_evaluate_static(in_file, out_file, ckpt_dir):
return [cld_frac_out, bt, refl, cp, lons, lats]
def run_evaluate_static_(bt, refl, refl_lo, refl_hi, refl_std, cp, ckpt_dir):
bt = normalize(bt, 'temp_11_0um_nom', mean_std_dct)
refl = normalize(refl, 'refl_0_65um_nom', mean_std_dct)
refl_lo = normalize(refl_lo, 'refl_0_65um_nom', mean_std_dct)
refl_hi = normalize(refl_hi, 'refl_0_65um_nom', mean_std_dct)
refl_std = np.where(np.isnan(refl_std), 0, refl_std)
cp = np.where(np.isnan(cp), 0, cp)
data = np.stack([bt, refl, refl_lo, refl_hi, refl_std, cp], axis=2)
data = np.expand_dims(data, axis=0)
nn = SRCNN()
probs = nn.run_evaluate(data, ckpt_dir)
cld_frac = probs.argmax(axis=3)
cld_frac = cld_frac.astype(np.int8)
return cld_frac
def analyze_3cat(file):
tup = np.load(file, allow_pickle=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment