diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 75f5792eaaffca66a7a462d05df89062834c9f99..595c095313397527a23834c0d1e627c49ab0d482 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -624,6 +624,55 @@ def analyze2(filename, filename_l1b): plt.show() +def run_daynight(filename, filename_l1b, day_night='ANY'): + f = h5py.File(filename, 'r') + f_l1b = h5py.File(filename_l1b, 'r') + + solzen = f['solar_zenith_angle'][:, 10:30, 10:30] + num_obs = solzen.shape[0] + + idxs = [] + for i in range(num_obs): + if day_night == 'NIGHT': + if is_night(solzen[i,]): + idxs.append(i) + elif day_night == 'DAY': + if not is_night(solzen[i,]): + idxs.append(i) + + keep_idxs = np.array(idxs) + + data_dct = {} + for didx, ds_name in enumerate(ds_list): + data_dct[ds_name] = f[ds_name][keep_idxs,] + + lon_c = f['longitude'][keep_idxs] + lat_c = f['latitude'][keep_idxs] + time_s = f['time'][keep_idxs] + fl_alt_s = f['icing_altitude'][keep_idxs] + ice_int_s = f['icing_intensity'][keep_idxs] + unq_ids = f['unique_id'][keep_idxs] + + path, fname = os.path.split(filename) + fbase, fext = os.path.splitext(fname) + outfile = path + '/' + fbase + '_' + day_night + fext + + create_file(outfile, data_dct, ds_list, ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids) + + data_dct = {} + for didx, ds_name in enumerate(l1b_ds_list): + data_dct[ds_name] = f_l1b[ds_name][keep_idxs] + + path, fname = os.path.split(filename_l1b) + fbase, fext = os.path.splitext(fname) + outfile_l1b = path + '/' + fbase + '_' + 'QC' + '_' + day_night + fext + + create_file(outfile_l1b, data_dct, l1b_ds_list, l1b_ds_types, lon_c, lat_c, time_s, fl_alt_s, ice_int_s, unq_ids) + + f.close() + f_l1b.close() + + def run_qc(filename, filename_l1b, day_night='ANY'): f = h5py.File(filename, 'r') icing_alt = f['icing_altitude'][:]