diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 5e38a52932cad8e6033e3929b0951aa3e0255991..2635dd2dd445811d67a6b486d1cf7acc71633c5f 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -1490,6 +1490,29 @@ def spatial_filter(icing_dict): return grd_bins +# dt_str_0: start datetime string in format YYYY-MM-DD_HH:MM +# dt_str_1: end datetime string in format YYYY-MM-DD_HH:MM +# return a flatten list of icing reports +def time_filter(dt_str_0, dt_str_1, icing_dct): + dto_0 = datetime.datetime.strptime(dt_str_0, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) + ts_0 = dto_0.timestamp() + + dto_1 = datetime.datetime.strptime(dt_str_1, '%Y-%m-%d_%H:%M').replace(tzinfo=timezone.utc) + ts_1 = dto_1.timestamp() + + keep_reports = [] + keep_times = [] + + for ts in list(icing_dct.keys()): + if not (ts_0 <= ts < ts_1): + rpts = icing_dct[ts] + for idx, tup in enumerate(rpts): + keep_reports.append(tup) + keep_times.append(ts) + + return keep_times, keep_reports + + def analyze_moon_phase(icing_dict): ts = api.load.timescale() eph = api.load('de421.bsp')