Skip to content

Commit ad1abef

Browse files
authored
Merge pull request #93 from VERITAS-Observatory/livetime
ONTIME is stored as sum of good time intervals and comments updated in EVENTS header
2 parents 720fa3c + 7c1b793 commit ad1abef

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

pyV2DL3/eventdisplay/fillEVENTS.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ def __fillEVENTS__(edFileIO, select={}):
134134
evt_dict["TSTART"] = tstart_from_reference
135135
evt_dict["TSTOP"] = tstop_from_reference
136136
evt_dict["MJDREFI"] = int(VTS_REFERENCE_MJD)
137-
evt_dict["ONTIME"] = tstop_from_reference - tstart_from_reference
138-
evt_dict["LIVETIME"] = (tstop_from_reference - tstart_from_reference) * (
139-
1 - deadtime
140-
)
141137
evt_dict["DEADC"] = 1 - deadtime
142138
evt_dict["OBJECT"] = runSummary["TargetName"][0]
143139
evt_dict["RA_PNT"] = avRA
@@ -168,7 +164,7 @@ def __fillEVENTS__(edFileIO, select={}):
168164
BitArray = file["run_{}".format(runNumber)]["stereo"]["timeMask"][
169165
"maskBits"
170166
].member("fAllBits")
171-
gti_tstart_from_reference, gti_tstop_from_reference = getGTI(
167+
gti_tstart_from_reference, gti_tstop_from_reference, ontime_s = getGTI(
172168
BitArray, tstart_from_reference
173169
)
174170
except (KeyError):
@@ -178,6 +174,10 @@ def __fillEVENTS__(edFileIO, select={}):
178174
)
179175
gti_tstart_from_reference = [tstart_from_reference]
180176
gti_tstop_from_reference = [tstop_from_reference]
177+
ontime_s = tstop_from_reference - tstart_from_reference
178+
179+
evt_dict["ONTIME"] = ontime_s
180+
evt_dict["LIVETIME"] = ontime_s * (1 - deadtime)
181181

182182
return (
183183
{

pyV2DL3/eventdisplay/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ def getGTI(BitArray, run_start_from_reference):
565565
------
566566
gti_start_from_reference : numpy array of start time of GTIs in second from reference time
567567
gti_end_from_reference: numpy array of stop time of GTIs in second from reference time
568+
ontime: Total of good times
568569
569570
"""
570571

@@ -574,7 +575,7 @@ def getGTI(BitArray, run_start_from_reference):
574575
TimeArray_s.append(np.binary_repr(BitArray[i]).count('1'))
575576

576577
duration_s = (n - 1) * 8 + TimeArray_s[-1]
577-
ontime_s = np.sum(TimeArray_s[0:n - 1])
578+
ontime_s = np.sum(TimeArray_s[0:n])
578579
print('Duration:', duration_s, '(sec.)', duration_s / 60., '(min.)')
579580
print('Ontime', ontime_s, '(sec.)', ontime_s / 60., '(min.)')
580581

@@ -605,7 +606,7 @@ def getGTI(BitArray, run_start_from_reference):
605606
gti_start_from_reference[i] = gti_start[i] + run_start_from_reference
606607
gti_end_from_reference[i] = gti_end[i] + run_start_from_reference
607608

608-
return gti_start_from_reference, gti_end_from_reference
609+
return gti_start_from_reference, gti_end_from_reference, ontime_s
609610

610611
def getRunQuality(logdata):
611612
"""

pyV2DL3/fillEVENTS.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ def fillEVENTS(datasource, save_multiplicity=False):
7878

7979
hdu1.header.set('ONTIME ',
8080
evt_dict['ONTIME'],
81-
'time on target (including deadtime)')
81+
'sum of good time intervals [s], does not include instrument deadtime correction')
8282

8383
# Correct live time for time cuts
8484
hdu1.header.set('LIVETIME', evt_dict['LIVETIME'],
85-
'(dead=ONTIME-LIVETIME) [s] ')
85+
'(ontime * deadtime time correction) [s] ')
8686

8787
hdu1.header.set('DEADC ', evt_dict['DEADC'],
8888
'Average dead time correction (LIVETIME/ONTIME)')

0 commit comments

Comments
 (0)