diff --git a/modules/deeplearning/cloud_fraction_fcn_abi.py b/modules/deeplearning/cloud_fraction_fcn_abi.py index ef6f7d126b60254f5eeb2bf2ffd80fb738890a2d..4651ecf5208cdfbaa61ac81c3e42a568200b7b95 100644 --- a/modules/deeplearning/cloud_fraction_fcn_abi.py +++ b/modules/deeplearning/cloud_fraction_fcn_abi.py @@ -776,6 +776,44 @@ 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') + refl_std = get_grid_values_all(h5f, 'refl_0_65um_nom_stddev_sub') + cp = get_grid_values_all(h5f, label_param) + lons = get_grid_values_all(h5f, 'longitude') + lats = get_grid_values_all(h5f, '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_full_disk(in_file, out_file, ckpt_dir): + gc.collect() + + h5f = h5py.File(in_file, 'r') + bt = get_grid_values_all(h5f, 'temp_11_0um_nom') y_len, x_len = bt.shape h_y_len = int(y_len/2) @@ -812,9 +850,6 @@ def run_evaluate_static(in_file, out_file, ckpt_dir): cld_frac_out[border:h_y_len, border:x_len - border] = cld_frac_nh[0, :, :] cld_frac_out[h_y_len: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)