diff --git a/fast_response/GWFollowup.py b/fast_response/GWFollowup.py index 3dbd6f0..607cbbc 100644 --- a/fast_response/GWFollowup.py +++ b/fast_response/GWFollowup.py @@ -163,7 +163,7 @@ def check_events_after(self): t1 = Time(datetime.datetime.utcnow()).mjd if ((t1-self.stop)*86400.)>5000.: - #if it's been long enough, only load 1000s + #if it's been long enough, only load 2000s print('Loading 2000s of data after the time window') t1 = self.stop + 2000./86400. exp_long, livetime_long, grl_long = self.dset.livestream( @@ -179,6 +179,9 @@ def check_events_after(self): if exp_long[mask].size > 0: check_passed = True print('Found {} events after end of time window'.format(exp_long[mask].size)) + # elif Time(datetime.datetime.utcnow()).mjd > (self.stop + 5000./86400.): + # raise Exception('No events found 2000 seconds after GW event.') + return check_passed def initialize_llh(self, skipped=None, scramble=False): @@ -209,10 +212,14 @@ def initialize_llh(self, skipped=None, scramble=False): dset = Datasets[self.dataset] self.dset = dset check_passed = False - print('Checking for events after time window') + if self.stop < 59215: + print('Old times: Skipping check for events after time window') + check_passed = True + else: + print('Checking for events after time window') + while not check_passed: check_passed = self.check_events_after() - self.get_data() if self._verbose: diff --git a/fast_response/make_ontime_plots.py b/fast_response/make_ontime_plots.py index 0239e4c..119a1b6 100644 --- a/fast_response/make_ontime_plots.py +++ b/fast_response/make_ontime_plots.py @@ -165,14 +165,24 @@ def make_rate_plots(time_window, run_table, query_events, dirname, season='neutr plt.locator_params(axis='x', nbins = 8) plt.grid(b = True, axis = 'y', alpha = 0.3) plt.savefig('{}/badness_plot.png'.format(dirname)) - + try: - rates = icecube.realtime_tools.live.get_rates(run_table[0]['start'], run_table[-1]['stop']) + if (Time(run_table[-1]['stop'],format='iso',scale='utc').mjd \ + - Time(run_table[0]['start'],format='iso',scale='utc').mjd) > 45.: + #load as two sections, otherwise this may time out + midpt = Time(Time(run_table[0]['start'],format='iso',scale='utc').mjd + 35., + format='mjd').iso #first 35 days + rates1 = icecube.realtime_tools.live.get_rates(run_table[0]['start'], midpt) + rates2 = icecube.realtime_tools.live.get_rates(midpt, run_table[-1]['stop']) + #avoid double counting last entry + rates = np.concatenate([rates1, rates2]) + else: + rates = icecube.realtime_tools.live.get_rates(run_table[0]['start'], run_table[-1]['stop']) except Exception as e: #rates=np.load('/data/user/jthwaites/FastResponseAnalysis/output/2022_2mo_followup_rates.npy') print(e) print("Failed to load rates. In case of timeout: save rate information and reload manually") - print("Check lines 115-119 of make_ontime_plots.py") + print("Check lines 169-179 of make_ontime_plots.py") return ########## MAKE RATES PLOTS ##########