diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index db5cbbeb5cfcb62a696bc10191302062f5738f4f..8d963234cd8fd1b6a98a2005c2b850cc617bf242 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -626,6 +626,7 @@ def pirep_info(pirep_dct): lon_space_hdeg = np.linspace(-180, 180, 721) lat_space_hdeg = np.linspace(-90, 90, 361) +hgt_space_3000 = np.linspace(0, 15000, 3000) def check_no_overlap(lon, lat, ts, grd_bins, t_delta=600.0): @@ -649,6 +650,31 @@ def check_no_overlap(lon, lat, ts, grd_bins, t_delta=600.0): return False +def check_no_overlap_alt(lon, lat, hgt, ts, grd_bins, t_delta=600.0): + + grd_x_hi = lon_space_hdeg.shape[0] - 1 + grd_y_hi = lat_space_hdeg.shape[0] - 1 + grd_z_hi = hgt_space_3000.shape[0] - 1 + + lon_idx = np.searchsorted(lon_space_hdeg, lon) + lat_idx = np.searchsorted(lat_space_hdeg, lat) + hgt_idx = np.searchsorted(hgt_space_3000, hgt) + + if lon_idx < 0 or lon_idx > grd_x_hi: + return False + if lat_idx < 0 or lat_idx > grd_y_hi: + return False + if hgt_idx < 0 or hgt_idx > grd_z_hi: + return False + + last_ts = grd_bins[hgt_idx, lat_idx, lon_idx] + if ts - last_ts > t_delta: + grd_bins[hgt_idx, lat_idx, lon_idx] = ts + return True + else: + return False + + # This mostly reduces some categories for a degree of class balancing and removes no intensity reports def process(ice_dct, no_ice_dct, neg_ice_dct, t_delta=600): t_delta = 600 # seconds @@ -777,6 +803,7 @@ def process(ice_dct, no_ice_dct, neg_ice_dct, t_delta=600): all_which = all_which[sidxs] grd_bins = np.full((lat_space_hdeg.shape[0], lon_space_hdeg.shape[0]), -(t_delta+1)) + #grd_bins = np.full((hgt_space_3000.shape[0], lat_space_hdeg.shape[0], lon_space_hdeg.shape[0]), -(t_delta+1)) cnt_i = 0 cnt_ni = 0 for idx, key in enumerate(all_keys): @@ -789,8 +816,9 @@ def process(ice_dct, no_ice_dct, neg_ice_dct, t_delta=600): rpts = ice_dct[key] tup = rpts[all_tidx[idx]] - lat, lon = tup[0], tup[1] + lat, lon, falt = tup[0], tup[1], tup[2] + #if not check_no_overlap_alt(lon, lat, falt, key, grd_bins, t_delta=t_delta): if not check_no_overlap(lon, lat, key, grd_bins, t_delta=t_delta): continue @@ -817,13 +845,15 @@ def process(ice_dct, no_ice_dct, neg_ice_dct, t_delta=600): neg_ice_tidx = np.array(neg_ice_tidx) print('neg ice total: ', neg_ice_keys.shape[0]) + #grd_bins = np.full((hgt_space_3000.shape[0], lat_space_hdeg.shape[0], lon_space_hdeg.shape[0]), -(t_delta+1)) grd_bins = np.full((lat_space_hdeg.shape[0], lon_space_hdeg.shape[0]), -(t_delta+1)) cnt = 0 for idx, key in enumerate(neg_ice_keys): rpts = neg_ice_dct[key] tup = rpts[neg_ice_tidx[idx]] - lat, lon = tup[0], tup[1] + lat, lon, falt = tup[0], tup[1], tup[2] + #if not check_no_overlap_alt(lon, lat, falt, key, grd_bins, t_delta=t_delta): if not check_no_overlap(lon, lat, key, grd_bins, t_delta=t_delta): continue cnt += 1