Skip to content

Commit

Permalink
small fixes (#59)
Browse files Browse the repository at this point in the history
* skip check for events if before 2020

* load rates in sections if ext fra longer than 45 days
  • Loading branch information
jessiethw authored Aug 12, 2024
1 parent 25f3609 commit 065d1c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
13 changes: 10 additions & 3 deletions fast_response/GWFollowup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions fast_response/make_ontime_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##########
Expand Down

0 comments on commit 065d1c0

Please sign in to comment.