From 9b7c3f2ffc471d8e1e2a80bc57728ac023897f7f Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Tue, 30 May 2023 14:09:13 -0500 Subject: [PATCH] snapshot... --- .../deeplearning/cloud_fraction_fcn_abi.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/modules/deeplearning/cloud_fraction_fcn_abi.py b/modules/deeplearning/cloud_fraction_fcn_abi.py index 4651ecf5..69351c7f 100644 --- a/modules/deeplearning/cloud_fraction_fcn_abi.py +++ b/modules/deeplearning/cloud_fraction_fcn_abi.py @@ -865,6 +865,44 @@ def run_evaluate_static_full_disk(in_file, out_file, ckpt_dir): return [cld_frac_out, bt, refl, cp, lons, lats] +def run_evaluate_static_valid(in_file, out_file, ckpt_dir): + gc.collect() + + h5f = h5py.File(in_file, 'r') + + bt = get_grid_values_all(h5f, 'orig/temp_ch38') + y_len, x_len = bt.shape + refl = get_grid_values_all(h5f, 'orig/refl_ch01') + refl_lo = get_grid_values_all(h5f, 'orig/refl_submin_ch01') + refl_hi = get_grid_values_all(h5f, 'orig/refl_submax_ch01') + refl_std = get_grid_values_all(h5f, 'orig/refl_substddev_ch01') + cp = get_grid_values_all(h5f, 'orig/'+label_param) + lons = get_grid_values_all(h5f, 'orig/longitude') + lats = get_grid_values_all(h5f, 'orig/latitude') + + h5f.close() + + cld_frac = run_evaluate_static_(bt, refl, refl_lo, refl_hi, refl_std, cp, 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, :, :] + + 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, + 'lat': (['y', 'x'], lats), + 'lon': (['y', 'x'], lons) + }) + + if out_file is not None: + np.save(out_file, (cld_frac_out, bt, refl, cp, lons, lats)) + else: + 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) -- GitLab