diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index f513a1163171a411c3e13ebad10c7a36412c83e2..31a1959862ac99ae4a46c96f84cd0f752d8fa1c6 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -2359,39 +2359,19 @@ def run_icing_predict_new(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_d ts = dto.timestamp() clvrx_str_time = dto.strftime('%Y-%m-%d_%H:%M') - data_dct, solzen, satzen, ll, cc = prepare_evaluate(h5f, name_list=train_params, satellite=satellite, domain=domain) + data_dct, solzen, satzen, ll, cc = prepare_evaluate(h5f, name_list=train_params, satellite=satellite, domain=domain, offset=8) num_elems = len(cc) num_lines = len(ll) - # Don't need these yet - # if fidx == 0: - # num_elems = len(cc) - # num_lines = len(ll) - # nav = get_navigation(satellite, domain) - # lons_2d, lats_2d, x_rad, y_rad = get_lon_lat_2d_mesh(nav, ll, cc, offset=int(8 / res_fac)) + if fidx == 0: + nav = get_navigation(satellite, domain) + lons_2d, lats_2d, x_rad, y_rad = get_lon_lat_2d_mesh(nav, ll, cc) - # ancil_data_dct, _, _ = make_for_full_domain_predict(h5f, name_list= - # ['solar_zenith_angle', 'sensor_zenith_angle', 'cld_height_acha', 'cld_geo_thick'], - # satellite=satellite, domain=domain, res_fac=res_fac) - # - # satzen = ancil_data_dct['sensor_zenith_angle'] - # solzen = ancil_data_dct['solar_zenith_angle'] - # day_idxs = [] - # nght_idxs = [] - # for j in range(num_lines): - # for i in range(num_elems): - # k = i + j*num_elems - # if not check_oblique(satzen[k]): - # continue - # if is_day(solzen[k]): - # day_idxs.append(k) - # else: - # nght_idxs.append(k) - # - # num_tiles = num_lines * num_elems - # num_day_tiles = len(day_idxs) - # num_nght_tiles = len(nght_idxs) - num_day_tiles = 1 + day_idxs = solzen < 80.0 + num_day_tiles = np.sum(day_idxs) + + nght_idxs = solzen > 100.0 + num_nght_tiles = np.sum(nght_idxs) # initialize output arrays probs_2d_dct = {flvl: None for flvl in flight_levels} @@ -2406,50 +2386,32 @@ def run_icing_predict_new(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_d if (day_night == 'AUTO' or day_night == 'DAY') and num_day_tiles > 0: - # day_data_dct = {name: [] for name in day_train_params} - # for name in day_train_params: - # for k in day_idxs: - # day_data_dct[name].append(data_dct[name][k]) - # day_grd_dct = {name: None for name in day_train_params} - # for ds_name in day_train_params: - # day_grd_dct[ds_name] = np.stack(day_data_dct[ds_name]) - preds_day_dct, probs_day_dct = run_evaluate_static_fcn(data_dct, day_model_path, day_night='DAY', l1b_or_l2=l1b_andor_l2, prob_thresh=prob_thresh, use_flight_altitude=use_flight_altitude, flight_levels=flight_levels) - day_idxs = np.array(day_idxs) for flvl in flight_levels: - day_preds = preds_day_dct[flvl] - day_probs = probs_day_dct[flvl] + preds = preds_day_dct[flvl] + probs = probs_day_dct[flvl] fd_preds = preds_2d_dct[flvl] fd_probs = probs_2d_dct[flvl] - fd_preds[day_idxs] = day_preds[:] - fd_probs[day_idxs] = day_probs[:] + fd_preds[day_idxs] = preds[day_idxs] + fd_probs[day_idxs] = probs[day_idxs] - # if (day_night == 'AUTO' or day_night == 'NIGHT') and num_nght_tiles > 0: - # - # nght_data_dct = {name: [] for name in nght_train_params} - # for name in nght_train_params: - # for k in nght_idxs: - # nght_data_dct[name].append(data_dct[name][k]) - # nght_grd_dct = {name: None for name in nght_train_params} - # for ds_name in nght_train_params: - # nght_grd_dct[ds_name] = np.stack(nght_data_dct[ds_name]) - # - # preds_nght_dct, probs_nght_dct = run_evaluate_static(nght_grd_dct, num_nght_tiles, night_model_path, - # day_night='NIGHT', l1b_or_l2=l1b_andor_l2, prob_thresh=prob_thresh, - # use_flight_altitude=use_flight_altitude, - # flight_levels=flight_levels) - # nght_idxs = np.array(nght_idxs) - # for flvl in flight_levels: - # nght_preds = preds_nght_dct[flvl] - # nght_probs = probs_nght_dct[flvl] - # fd_preds = preds_2d_dct[flvl] - # fd_probs = probs_2d_dct[flvl] - # fd_preds[nght_idxs] = nght_preds[:] - # fd_probs[nght_idxs] = nght_probs[:] + if (day_night == 'AUTO' or day_night == 'NIGHT') and num_nght_tiles > 0: + preds_nght_dct, probs_nght_dct = run_evaluate_static_fcn(data_dct, night_model_path, + day_night='NIGHT', l1b_or_l2=l1b_andor_l2, + prob_thresh=prob_thresh, + use_flight_altitude=use_flight_altitude, + flight_levels=flight_levels) + for flvl in flight_levels: + preds = preds_nght_dct[flvl] + probs = probs_nght_dct[flvl] + fd_preds = preds_2d_dct[flvl] + fd_probs = probs_2d_dct[flvl] + fd_preds[nght_idxs] = preds[nght_idxs] + fd_probs[nght_idxs] = probs[nght_idxs] for flvl in flight_levels: fd_preds = preds_2d_dct[flvl] @@ -2457,9 +2419,9 @@ def run_icing_predict_new(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_d preds_2d_dct[flvl] = fd_preds.reshape((num_lines, num_elems)) probs_2d_dct[flvl] = fd_probs.reshape((num_lines, num_elems)) - # write_icing_file_nc4(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, - # x_rad, y_rad, lons_2d, lats_2d, cc, ll, - # satellite=satellite, domain=domain, use_nan=use_nan, prob_thresh=prob_thresh) + write_icing_file_nc4(clvrx_str_time, output_dir, preds_2d_dct, probs_2d_dct, + x_rad, y_rad, lons_2d, lats_2d, cc, ll, + satellite=satellite, domain=domain, use_nan=use_nan, prob_thresh=prob_thresh) print('Done: ', clvrx_str_time) h5f.close()