diff --git a/modules/icing/util.py b/modules/icing/util.py index f18c0bb0b51d870d12dadd13ddd48191f14a43c8..b55622c122b87c130ce1073ad150636d90438051 100644 --- a/modules/icing/util.py +++ b/modules/icing/util.py @@ -2,6 +2,7 @@ import numpy as np import deeplearning.icing_fcn as icing_fcn import deeplearning.icing_cnn as icing_cnn from icing.pirep_goes import setup, time_filter_3 +from icing.moon_phase import moon_phase from util.util import get_time_tuple_utc, is_day, check_oblique, get_average, homedir, write_icing_file_nc4,\ write_icing_file_nc4_viirs,\ make_for_full_domain_predict, make_for_full_domain_predict_viirs_clavrx, prepare_evaluate @@ -28,7 +29,7 @@ import datetime # endif -def get_training_parameters(day_night='DAY', l1b_andor_l2='both', lunar=False): +def get_training_parameters(day_night='DAY', l1b_andor_l2='both', use_dnb=False): 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'] @@ -40,7 +41,7 @@ def get_training_parameters(day_night='DAY', l1b_andor_l2='both', lunar=False): 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'] - if lunar is True: + if use_dnb is True: 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'] @@ -69,7 +70,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h day_model_path=model_path_day, night_model_path=model_path_night, prob_thresh=0.5, satellite='GOES16', domain='CONUS', day_night='AUTO', l1b_andor_l2='l2', use_flight_altitude=True, res_fac=1, use_nan=False, has_time=False, - model_type='FCN', lunar=False): + model_type='FCN', use_dnb=False): if model_type == 'CNN': model_module = icing_cnn @@ -81,15 +82,18 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h else: flight_levels = [0] - day_train_params = get_training_parameters(day_night='DAY', l1b_andor_l2=l1b_andor_l2, lunar=lunar) - nght_train_params = get_training_parameters(day_night='NIGHT', l1b_andor_l2=l1b_andor_l2, lunar=lunar) + day_train_params = get_training_parameters(day_night='DAY', l1b_andor_l2=l1b_andor_l2) + nght_train_params = get_training_parameters(day_night='NIGHT', l1b_andor_l2=l1b_andor_l2, use_dnb=False) + nght_train_params_dnb = get_training_parameters(day_night='NIGHT', l1b_andor_l2=l1b_andor_l2, use_dnb=True) if day_night == 'AUTO': train_params = list(set(day_train_params + nght_train_params)) + train_params_dnb = list(set(day_train_params + nght_train_params_dnb)) elif day_night == 'DAY': train_params = day_train_params elif day_night == 'NIGHT': train_params = nght_train_params + train_params_dnb = nght_train_params_dnb if satellite == 'H08': clvrx_ds = CLAVRx_H08(clvrx_dir) @@ -119,8 +123,10 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h ['solar_zenith_angle', 'sensor_zenith_angle', 'cld_height_acha', 'cld_geo_thick', bt_fld_name], satellite=satellite, domain=domain, res_fac=res_fac) elif satellite == 'VIIRS': + if use_dnb and moon_phase(ts): + train_params = train_params_dnb data_dct, ll, cc, lats_2d, lons_2d = make_for_full_domain_predict_viirs_clavrx(h5f, name_list=train_params, - day_night=day_night, res_fac=res_fac, lunar=lunar) + day_night=day_night, res_fac=res_fac, use_dnb=use_dnb) bt_fld_name = 'temp_11_0um_nom' ancil_data_dct, _, _, _, _ = make_for_full_domain_predict_viirs_clavrx(h5f, name_list= @@ -189,7 +195,7 @@ def run_icing_predict(clvrx_dir='/Users/tomrink/data/clavrx/RadC/', output_dir=h if (day_night == 'AUTO' or day_night == 'NIGHT') and num_nght_tiles > 0: model_path = night_model_path - if lunar: + if use_dnb: model_path = day_model_path day = 'DAY'