diff --git a/modules/util/util.py b/modules/util/util.py index 58352cac56ddf9e9cd7ebe77b7ec0287ae7f1fe7..b4e5b7dc5b6979f1f3b2dd42dcb5f1b2050a3310 100644 --- a/modules/util/util.py +++ b/modules/util/util.py @@ -513,6 +513,7 @@ taiwain_extent = [-3342, -502, 1470, 3510] # GEOS coordinates, not line, elem # ------------ This code will not be needed when we implement a Fully Connected CNN ----------------------------------- +# Generate and return tiles of name_list parameters def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain='FD'): w_x = 16 w_y = 16 @@ -560,6 +561,29 @@ def make_for_full_domain_predict(h5f, name_list=None, satellite='GOES16', domain grd_dct[ds_name] = np.stack(grd_dct_n[ds_name]) return grd_dct, ll, cc + + +def make_for_full_domain_predict2(h5f, satellite='GOES16', domain='FD'): + w_x = 16 + w_y = 16 + i_0 = 0 + j_0 = 0 + s_x = w_x + s_y = w_y + + geos, xlen, xmin, xmax, ylen, ymin, ymax = get_cartopy_crs(satellite, domain) + if satellite == 'H08': + xlen = taiwan_lenx + ylen = taiwan_leny + i_0 = taiwan_i0 + j_0 = taiwan_j0 + + solzen = get_grid_values(h5f, 'solar_zenith_angle', j_0, i_0, num_j=ylen, num_i=xlen) + satzen = get_grid_values(h5f, 'sensor_zenith_angle', j_0, i_0, num_j=ylen, num_i=xlen) + solzen = solzen[0:ylen:s_y, 0:xlen:s_x] + satzen = satzen[0:ylen:s_y, 0:xlen:s_x] + + return solzen, satzen # ------------------------------------------------------------------------------------------- @@ -571,7 +595,7 @@ flt_level_ranges_str[3] = '6000_8000' flt_level_ranges_str[4] = '8000_15000' -def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lons, lats, lat_range=[-63.0, 63.0]): +def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lons, lats): outfile_name = output_dir + 'icing_prediction_'+clvrx_str_time+'.h5' h5f_out = h5py.File(outfile_name, 'w') @@ -581,8 +605,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon flt_lvls = list(preds_dct.keys()) for flvl in flt_lvls: preds = preds_dct[flvl] - keep = np.logical_or(lats < lat_range[0], lats > lat_range[1]) - np.where(keep, preds, -1) icing_pred_ds = h5f_out.create_dataset('icing_prediction_level_'+flt_level_ranges_str[flvl], data=preds, dtype='i2') icing_pred_ds.attrs.create('coordinates', data='y x') icing_pred_ds.attrs.create('grid_mapping', data='Projection') @@ -592,8 +614,6 @@ def write_icing_file(clvrx_str_time, output_dir, preds_dct, probs_dct, x, y, lon for flvl in flt_lvls: probs = probs_dct[flvl] - keep = np.logical_or(lats < lat_range[0], lats > lat_range[1]) - np.where(keep, probs, -1.0) icing_prob_ds = h5f_out.create_dataset('icing_probability_level_'+flt_level_ranges_str[flvl], data=probs, dtype='f4') icing_prob_ds.attrs.create('coordinates', data='y x') icing_prob_ds.attrs.create('grid_mapping', data='Projection')