Skip to content
Snippets Groups Projects
Commit 7733796f authored by Yannick Lecoeuche's avatar Yannick Lecoeuche Committed by Jameson Rollins
Browse files

handle H1 fast LOCKLOSS_DRMI -> ACQUIRE_DRMI_1F -> LOCKLOSS (3->101->2) transitions

Add logic to the history plugin to check if ISC_LOCK_STATE went from the lockloss state we're interested in (generally between 103-202) to LOCKLOSS_DRMI (3), then up briefly to ACQUIRE_DRMI_1F (101) before LOCKLOSS (2). In order to create the refined time plot correctly, the history followup moved before the refine followup in execution order. Additionally, I added a setter to change transition_index to the new values (I also removed the assertions, because they would cause an error whenever this condition was met).  This is only for H1.

Closes #150
parent 64701574
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,7 @@ TAG_COLORS = {
'COMMISSIONING': ('lightseagreen', 'darkslategrey'),
'MAINTENANCE': ('lightseagreen', 'darkslategrey'),
'CALIBRATION': ('lightseagreen', 'darkslategrey'),
'FAST_DRMI': ('blue', 'pink'),
}
##################################################
......
......@@ -16,7 +16,7 @@ def _trans_int(trans):
class LocklossEvent(object):
__slots__ = [
'__id', '__epath',
'__transition_index', '__transition_gps',
'_transition_index', '__transition_gps',
'__refined_gps', '__previous_state',
]
......@@ -34,7 +34,7 @@ class LocklossEvent(object):
self.__epath = self._gen_epath(self.__id)
if not os.path.exists(self.path()):
raise OSError("Unknown event: {}".format(self.path()))
self.__transition_index = None
self._transition_index = None
self.__transition_gps = None
self.__refined_gps = None
self.__previous_state = None
......@@ -90,11 +90,11 @@ class LocklossEvent(object):
@property
def transition_index(self):
"""tuple of indices of Guardian state transition"""
if not self.__transition_index:
if not self._transition_index:
with open(self.path('transition_index')) as f:
tis = f.read().split()
self.__transition_index = _trans_int(tis)
return self.__transition_index
self._transition_index = _trans_int(tis)
return self._transition_index
@property
def transition_gps(self):
......
......@@ -25,12 +25,12 @@ def register_plugin(func):
from .discover import discover_data
register_plugin(discover_data)
from .refine import refine_time
register_plugin(refine_time)
from .history import find_previous_state
register_plugin(find_previous_state)
from .refine import refine_time
register_plugin(refine_time)
from .ifo_mode import check_ifo_mode
register_plugin(check_ifo_mode)
......
......@@ -21,13 +21,10 @@ def find_previous_state(event):
"""
channels = [config.GRD_STATE_N_CHANNEL]
# get the lock loss transition itself
previous_index, lockloss_index = event.transition_index
# find the transition time
segment = Segment(0, 1).shift(event.id)
gbuf = data.fetch(channels, segment)[0]
lli = np.where(gbuf.data == lockloss_index)[0]
lli = np.where(gbuf.data == event.transition_index[1])[0]
assert len(lli) > 0, "Lock loss not found at this time!"
state_end_gps = gbuf.tarray[lli[0]]
# note the transition time for old events
......@@ -35,10 +32,10 @@ def find_previous_state(event):
if not os.path.exists(state_end_file):
with open(state_end_file, 'w') as f:
f.write('{:f}\n'.format(state_end_gps))
assert state_end_gps == event.transition_gps, "State end time does not match transition_gps ({} != {}).".format(state_end_gps, event.transition_gps)
# find start of previous state
lockloss_found = False
candidate = 0
state_start_gps = None
power = 1
window = [INITIAL_WINDOW[0], 1]
......@@ -51,19 +48,60 @@ def find_previous_state(event):
# check the transitions
for transition in reversed(transitions):
transt = transition[0]
transi = tuple(map(int, transition[1:]))
if lockloss_found:
assert int(transition[2]) == previous_index, "Transition history does not match lock loss transtion ({} != {}).".format(transition[2], previous_index)
state_start_gps = transition[0]
previous_index = event.transition_index[0]
assert transi[1] == previous_index, \
"Transition history does not match lock loss transtion ({} != {}).".format(transi[1], previous_index)
state_start_gps = transt
break
elif tuple(transition[1:]) == event.transition_index:
logging.info("lockloss found: {}".format(transition[0]))
# For H1, a X->3->101->2 transition is a common pattern
# that shows up as 101->2 but we actually want to record
# them as X->3. The following logic checks to see if
# we're in one of these situations and updates the
# transition_index information accordingly.
if config.IFO == 'H1': # and event.transition_index == (101, 2):
if transi == (101, 2):
# could be this case, so mark as candidate and
# continue
candidate = 1
continue
elif candidate == 1:
if transi == (3, 101):
# yup, this is it, note and continue
candidate = 2
continue
else:
# nope, this is a regular 101->2 transtion, so
# note state 101 start time and break
lockloss_found = True
state_start_gps = transt
break
elif candidate == 2:
logging.info("updating H1 lockloss for X->3->101->2 transition: {}".format(transi))
event.add_tag("FAST_DRMI")
# update the transition_index information on disk
# and clear cache so it's reloaded next access
with open(event.path('transition_index'), 'w') as f:
f.write('{} {}\n'.format(*transi))
event._transition_index = None
# don't continue so that we hit the lockloss_found
# check below.
if transi == event.transition_index:
logging.info("lockloss found: {}".format(transi))
lockloss_found = True
assert lockloss_found, "lock loss not found in first segment"
window = [edge * (2 ** power) + window[0] for edge in INITIAL_WINDOW]
power += 1
# write start of lock stretch to disk
previous_index, lockloss_index = event.transition_index
previous_state = (previous_index, state_start_gps, state_end_gps, lockloss_index)
logging.info("previous guardian state: {}".format(previous_state))
with open(event.path('previous_state'), 'w') as f:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment