Queue a stream of partially time ordered events: as new events are added, sort them into the queue in time order; maintain a record of the time up-to which the list of events is complete; and provide events sorted in time order to coincidence tests.
Searches must define a class subclassed from this that defines an override of the .event_time() method. See coincgen_doubles for information on what to do with the subclass.
Implementation notes:
What is actually inserted into the queue is the time of the event as defined by the .event_time() method provided by the subclass. This allows sorts and bisection searches to be performed quickly, without the need for much additional code. When we need to retrieve an event, we need some way of turning the time of the event (i.e., the thing that is actually in the queue) back into that event, and this is done by adding an attribute to the time object that points back to the original event. This means that builtin Python numeric types cannot be used for the times of the events because new attributes cannot be attached to them. Subclasses of the builtin numeric types can be used as time objects, as can be LAL's LIGOTimeGPS.
Definition at line 364 of file snglcoinc.py.
Inherits object.
Public Member Functions | |
| def | queueentry_from_event (self, event) |
| For internal use. More... | |
| def | __init__ (self, offset, max_coinc_window) |
| Initialize a new, empty, singles queue. More... | |
| def | age (self) |
| Using .event_time() to define the times of events, the time of the oldest event in the queue or self.t_complete if the queue is empty. More... | |
| def | t_coinc_complete (self) |
| The time up to which the time-shifted events in other detectors' queues can be considered complete for the purpose of forming n-tuple coincidences with the time-shifted events in this queue. More... | |
| def | push (self, events, t_complete) |
| Add new events to the queue. More... | |
| def | pull (self, t) |
| t is the time up to which the calling code is in the process of constructing all available n-tuple coincident candidates. More... | |
Static Public Member Functions | |
| def | event_time (event) |
| Override with a method to return the "time" of the given event. More... | |
Data Fields | |
| offset | |
| max_coinc_window | |
| t_complete | |
| queue | |
| index | |
| def lalburst.snglcoinc.singlesqueue.__init__ | ( | self, | |
| offset, | |||
| max_coinc_window | |||
| ) |
Initialize a new, empty, singles queue.
offset is the time that will be added to events in this queue when forming coincidences with events from other queues, and max_coinc_window is an upper bound on the maximum time that can separate events in this queue from events in other queues and they still be able to form coincidences — it is not that maximum time, necessarily, but the true maximum time cannot be larger than max_coinc_window.
Note that max_coinc_window is not defining the coincidence test, that is defined by the get_coincs machinery within the coincgen_doubles class. max_coinc_window is used by the streaming logic to determine where in the event sequences complete n-tuple candidates can be constructed. Although max_coinc_window need only bound the time interval described above, the latency of the coincidence engine is reduced and the number of events stored in the queue (and the computational overhead they cause) is reduced if the number is as small as possible.
Definition at line 413 of file snglcoinc.py.
|
static |
Override with a method to return the "time" of the given event.
The "time" object that is returned is typically a lal.LIGOTimeGPS object. If some other type is used, it must support arithmetic and comparison with python float objects and lal.LIGOTimeGPS objects, and support comparison with igwn_segments.PosInfinity and igwn_segments.NegInfinity, and it must have a .__dict__ or other mechanism allowing an additional attribute named .event to be set on the object. The builtin float type is not suitable, but a subclass of float would be.
Definition at line 378 of file snglcoinc.py.
| def lalburst.snglcoinc.singlesqueue.queueentry_from_event | ( | self, | |
| event | |||
| ) |
For internal use.
Construct the object that is to be inserted into the queue from an event.
Definition at line 385 of file snglcoinc.py.
| def lalburst.snglcoinc.singlesqueue.age | ( | self | ) |
Using .event_time() to define the times of events, the time of the oldest event in the queue or self.t_complete if the queue is empty.
The time scale for .age is that of the events themselves, not their shifted times (the offset parameter is not applied).
This is not used by the coincidence engine. This information is provided as a convenience for calling code. For example, some performance improvements might be realized if segment lists or other information are clipped to the range of times spanned by the contents of the coincidence engine queues, and this allows calling codes to see what interval that is, in physical event times not time-shifted event times.
Definition at line 454 of file snglcoinc.py.
| def lalburst.snglcoinc.singlesqueue.t_coinc_complete | ( | self | ) |
The time up to which the time-shifted events in other detectors' queues can be considered complete for the purpose of forming n-tuple coincidences with the time-shifted events in this queue.
This precedes the (time-shifted) time up to which this event list is complete by the maximum coincidence window that can separate an event in this queue from events in others and they still be considered coincident in time.
The earliest such time across all detectors is the time up to which the n-tuple candidate list can be completely constructed, assuming the "time" of an n-tuple candidate is defined to be the earliest time-shifted time of the events in the n-tuple.
Definition at line 474 of file snglcoinc.py.
| def lalburst.snglcoinc.singlesqueue.push | ( | self, | |
| events, | |||
| t_complete | |||
| ) |
Add new events to the queue.
Mark the queue complete up to t_complete, meaning you promise no further events will be added to the queue earlier than t_complete. The time scale for t_complete is that of the events themselves, not their shifted times (the offset parameter is not applied). The value of t_complete is stored for later retrieval.
NOTE: t_complete is not permitted to decrease.
NOTE: the events sequence will be iterated over multiple times. It may not be a generator.
Definition at line 490 of file snglcoinc.py.
| def lalburst.snglcoinc.singlesqueue.pull | ( | self, | |
| t | |||
| ) |
t is the time up to which the calling code is in the process of constructing all available n-tuple coincident candidates.
The return value is a tuple of all events from the queue whose time-shifted end times are up to (not including) t + max_coinc_window, which are all the events from this queue that could form a coincidence with an event up to (not including) t.
t is defined with respect to the time-shifted event times. The contents of the returned tuple is time-ordered as defined by .event_time().
Assuming that t cannot go backwards, any of the reported events that cannot be used again are removed from the internal queue.
If t is None, then the queue is completely flushed. All remaining events are pulled from the queue and reported in the tuple, .t_complete is reset to -inf and all other internal state is reset. After calling .pull() with t = None, the object's state is equivalent to its initial state and it is ready to process a new stream of events.
Definition at line 531 of file snglcoinc.py.
| lalburst.snglcoinc.singlesqueue.offset |
Definition at line 414 of file snglcoinc.py.
| lalburst.snglcoinc.singlesqueue.max_coinc_window |
Definition at line 417 of file snglcoinc.py.
| lalburst.snglcoinc.singlesqueue.t_complete |
Definition at line 425 of file snglcoinc.py.
| lalburst.snglcoinc.singlesqueue.queue |
Definition at line 427 of file snglcoinc.py.
| lalburst.snglcoinc.singlesqueue.index |
Definition at line 435 of file snglcoinc.py.