diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 16e7bcd5eae18d0a88afe7ba2a75c2de5b6c4f4b..3fb5088416dd6f340a4f8070e1be63b16d105db8 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -6,7 +6,7 @@ import os from util.util import get_time_tuple_utc, GenericException, add_time_range_to_filename, is_night, is_day, \ check_oblique, make_times, find_bin_index, get_timestamp, homedir, write_icing_file, make_for_full_domain_predict from util.plot import make_icing_image -from util.geos_nav import get_navigation +from util.geos_nav import get_navigation, get_lon_lat_2d_mesh from util.setup import model_path_day, model_path_night from aeolus.datasource import CLAVRx, CLAVRx_VIIRS, GOESL1B, CLAVRx_H08 import h5py @@ -1854,6 +1854,31 @@ def tiles_info(filename): print('Icing 6: ', np.sum(iint == 6)) +def get_training_parameters(day_night='DAY', l1b_andor_l2='BOTH'): + if day_night == 'DAY': + train_params_l2 = ['cld_height_acha', 'cld_geo_thick', 'cld_temp_acha', 'cld_press_acha', 'supercooled_cloud_fraction', + 'cld_emiss_acha', 'conv_cloud_fraction', 'cld_reff_dcomp', 'cld_opd_dcomp', 'iwc_dcomp', 'lwc_dcomp'] + + train_params_l1b = ['temp_10_4um_nom', 'temp_11_0um_nom', 'temp_12_0um_nom', 'temp_13_3um_nom', 'temp_3_75um_nom', + 'temp_6_2um_nom', 'temp_6_7um_nom', 'temp_7_3um_nom', 'temp_8_5um_nom', 'temp_9_7um_nom', + 'refl_0_47um_nom', 'refl_0_65um_nom', 'refl_0_86um_nom', 'refl_1_38um_nom', 'refl_1_60um_nom'] + else: + train_params_l2 = ['cld_height_acha', 'cld_geo_thick', 'cld_temp_acha', 'cld_press_acha', 'supercooled_cloud_fraction', + 'cld_emiss_acha', 'conv_cloud_fraction', 'cld_reff_acha', 'cld_opd_acha'] + + train_params_l1b = ['temp_10_4um_nom', 'temp_11_0um_nom', 'temp_12_0um_nom', 'temp_13_3um_nom', 'temp_3_75um_nom', + 'temp_6_2um_nom', 'temp_6_7um_nom', 'temp_7_3um_nom', 'temp_8_5um_nom', 'temp_9_7um_nom'] + + if l1b_andor_l2 == 'BOTH': + train_params = train_params_l1b + train_params_l2 + elif l1b_andor_l2 == 'l1b': + train_params = train_params_l1b + elif l1b_andor_l2 == 'l2': + train_params = train_params_l2 + + return train_params + + flt_level_ranges = {k: None for k in range(5)} flt_level_ranges[0] = [0.0, 2000.0] flt_level_ranges[1] = [2000.0, 4000.0] @@ -1865,7 +1890,9 @@ flt_level_ranges[4] = [8000.0, 15000.0] def run_make_images(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ckpt_dir_s_path='/Users/tomrink/tf_model/', prob_thresh=0.5, satellite='GOES16', domain='CONUS', extent=[-105, -70, 15, 50], pirep_file='/Users/tomrink/data/pirep/pireps_202109200000_202109232359.csv', - obs_lons=None, obs_lats=None, obs_times=None, flight_level=None): + obs_lons=None, obs_lats=None, obs_times=None, flight_level=None, + day_night='DAY', l1b_andor_l2='l2'): + if pirep_file is not None: ice_dict, no_ice_dict, neg_ice_dict = setup(pirep_file) @@ -1877,17 +1904,22 @@ def run_make_images(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ckpt_dir_s_pat alt_lo, alt_hi = flt_level_ranges[flight_level] - for fname in clvrx_files: + train_params = get_training_parameters(day_night=day_night, l1b_andor_l2=l1b_andor_l2) + + for fidx, fname in enumerate(clvrx_files): h5f = h5py.File(fname, 'r') dto = clvrx_ds.get_datetime(fname) ts = dto.timestamp() clvrx_str_time = dto.strftime('%Y-%m-%d_%H:%M') + data_dct, ll, cc = make_for_full_domain_predict(h5f, name_list=train_params, satellite=satellite, domain=domain) + dto, _ = get_time_tuple_utc(ts) dto_0 = dto - datetime.timedelta(minutes=30) dto_1 = dto + datetime.timedelta(minutes=30) ts_0 = dto_0.timestamp() ts_1 = dto_1.timestamp() + if pirep_file is not None: _, keep_lons, keep_lats, _ = time_filter_3(ice_dict, ts_0, ts_1, alt_lo, alt_hi) elif obs_times is not None: @@ -1898,10 +1930,10 @@ def run_make_images(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', ckpt_dir_s_pat keep_lons = None keep_lats = None - ice_lons, ice_lats, preds_2d, lons_2d, lats_2d, x_rad, y_rad = run_evaluate_static(h5f, ckpt_dir_s_path=ckpt_dir_s_path, flight_level=flight_level, prob_thresh=prob_thresh, satellite=satellite, domain=domain) + ice_lons, ice_lats, preds_2d = run_evaluate_static(data_dct, ll, cc, ckpt_dir_s_path=ckpt_dir_s_path, flight_level=flight_level, prob_thresh=prob_thresh, satellite=satellite, domain=domain) make_icing_image(h5f, ice_lons, ice_lats, clvrx_str_time, satellite, domain, ice_lons_vld=keep_lons, ice_lats_vld=keep_lats, extent=extent) - print('Done: ', clvrx_str_time) h5f.close() + print('Done: ', clvrx_str_time) def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=homedir, model_path=None, prob_thresh=0.5, satellite='GOES16', domain='CONUS', day_night='DAY'):