Skip to content

Commit

Permalink
Add option to make a Box PDF a livetime PDF, used for simulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed May 9, 2020
1 parent c6aec72 commit e0ed6e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flarestack/core/time_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,15 @@ def __init__(self, t_pdf_dict, season):
self.pre_window -= self.offset
self.post_window += self.offset

try:
if self.t_dict["livetime"] is True:
logging.debug("Using time PDF as a detector livetime PDF.")
self.mjd_to_livetime = lambda x: x - self.sig_t0([])
self.livetime_to_mjd = lambda x: x + self.sig_t0([])
# print(self.t1, self.t0, self.livetime, self.livetime_to_mjd(7.), self.pre_window, self.sig_t0([]))
except KeyError:
pass

def sig_t0(self, source):
"""Calculates the starting time for the window, equal to the
source reference time in MJD minus the length of the pre-reference-time
Expand Down Expand Up @@ -434,7 +443,6 @@ def effective_injection_time(self, source=None):
t0 = self.mjd_to_livetime(self.sig_t0(source))
t1 = self.mjd_to_livetime(self.sig_t1(source))
time = (t1 - t0) * 60 * 60 * 24

return max(time, 0.)

def raw_injection_time(self, source):
Expand Down

0 comments on commit e0ed6e8

Please sign in to comment.