Class LigolwSegmentList
source code
object --+
|
LigolwSegmentList
A description of a LIGO Light-Weight XML segment list. Instances of
this class carry all the metadata associated with a LIGO Light- Weight
XML segment list including its name, version number, a comment, and so
on.
LIGO Light-Weight XML segment lists are three-state objects. A
segment list can be on, off, or undefined. Two separate sequences of
segments are used for this: the "valid" list defines the
intervals when the state of the segment list is known, and the
"active" list defines the intervals when the segment list is
on. It is not an error for the active list to be on during times when the
segment lists state is unknown, this code does not impose any policy in
that regard, but it should be expected that consumers of the segment list
will treat all times when the segment list's state is unknown the same
way.
Example:
>>> from glue.segments import *
>>> segs = segmentlist([segment(0, 10), segment(20, 30)])
>>> validity = segmentlist([segment(0, 10), segment(25, 100)])
>>> x = LigolwSegmentList(active = segs, valid = validity, instruments = set(("H1",)), name = "test")
>>>
>>> del segs[:]
>>> segs
[]
>>> x.active
[segment(0, 10), segment(20, 30)]
>>>
>>> x.active & x.valid
[segment(0, 10), segment(25, 30)]
>>> ~x.active & x.valid
[segment(30, 100)]
>>> x.active & ~x.valid
[segment(20, 25)]
>>>
>>> y = LigolwSegmentList(x)
>>> del y.active[:]
>>> y.active
[]
>>> x.active
[segment(0, 10), segment(20, 30)]
The arithmetic operators on this class implement Kleene's strong
ternary logic, taking "true" to be (active & valid),
"false" to be (~active & valid), and "unknown" to
be ~valid.
Example:
>>> from glue.segments import *
>>> segs = segmentlist([segment(0, 10), segment(20, 30)])
>>> validity = segmentlist([segment(0, 35)])
>>> x = LigolwSegmentList(active = segs, valid = validity, instruments = set(("H1",)), name = "test")
>>> segs = segmentlist([segment(40, 50), segment(60, 70)])
>>> validity = segmentlist([segment(35, 100)])
>>> y = LigolwSegmentList(active = segs, valid = validity, instruments = set(("H1",)), name = "test")
>>> (x | y).active
[segment(0, 10), segment(20, 30), segment(40, 50), segment(60, 70)]
>>> (x | y).valid
[segment(0, 10), segment(20, 30), segment(40, 50), segment(60, 70)]
>>> (x & y).active
[]
>>> (x & y).valid
[segment(10, 20), segment(30, 40), segment(50, 60), segment(70, 100)]
>>> (~x).active
[segment(10, 20), segment(30, 35)]
>>> (~x).valid
[segment(0, 35)]
With ternary logic the three basic Boolean operations AND, OR, and
NOT, do not form a complete set of operations. That is, there exist
algebraic functions that cannot be implemented using combinations of
these three operators alone. One additional operator is required to
construct a complete basis of logic operations, and we provide one:
.isfalse(). This operation inverts intervals of known state, and maps
intervals of unknown state to false.
>>> x.isfalse().active
[segment(10, 20), segment(30, 35)]
>>> x.isfalse().valid
[segment(-infinity, infinity)]
Unfortunately, one example of a function that cannot be constructed
from the three basic Boolean operators is perhaps the most common
operation we wish to perform with our tri-state segment lists. Often we
wish to construct a tri-state list from two tri-state lists such that the
final list's interval of validity is the union of the intervals of
validity of the two source lists, and the state of the final list in that
interval is the union the states of the source lists in that interval.
For example if from one source we know the state of some process spanning
some time, and from another source we know the state of the same process
spanning some other time, taken together we know the state of that
process over the union of those times. This function is given by
>>> z = ~(x.isfalse() | y.isfalse() | (x & ~x & y & ~y))
>>> z.active
[segment(0, 10), segment(20, 30), segment(40, 50), segment(60, 70)]
>>> z.valid
[segment(0, 100)]
Because this is inconvenient to type, slow, and not readable, a
special in-place arithmetic operation named .update() is provided to
implement this operation.
>>> z = LigolwSegmentList(x).update(y)
>>> z.active
[segment(0, 10), segment(20, 30), segment(40, 50), segment(60, 70)]
>>> z.valid
[segment(0, 100)]
The .update() method is not exactly equivalent to the operation above.
The .update() method demands that the two input lists' states be
identical where their intervals of validity intersect.
|
__and__(self,
other)
If either is false the result is false, if both are true the result
is true, otherwise the result is unknown. |
source code
|
|
|
__iand__(self,
other)
If either is false the result is false, if both are true the result
is true, otherwise the result is unknown. |
source code
|
|
|
__init__(self,
active=( ) ,
valid=( ) ,
instruments=( ) ,
name=None,
version=None,
comment=None)
Initialize a new LigolwSegmentList instance. |
source code
|
|
|
__invert__(self)
If unknown the result is unknown, otherwise the state is inverted. |
source code
|
|
|
__ior__(self,
other)
If either is true the result is true, if both are false the result is
false, otherwise the result is unknown. |
source code
|
|
|
__or__(self,
other)
If either is true the result is true, if both are false the result is
false, otherwise the result is unknown. |
source code
|
|
|
|
|
isfalse(self)
If unknown the result is false, otherwise the state is inverted. |
source code
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__init__(self,
active=( ) ,
valid=( ) ,
instruments=( ) ,
name=None,
version=None,
comment=None)
(Constructor)
| source code
|
Initialize a new LigolwSegmentList instance. active and valid are
sequences that will be cast to segments.segmentlist objects. They can be
generator expressions. The "active" sequence is what is
usually thought of as the segment list, the "valid" sequence
identifies the intervals of time for which the segment list's state is
defined.
- Overrides:
object.__init__
|
Coalesce the internal segment lists. Returns self.
|
Sort the internal segment lists. The optional args are passed to the
.sort() method of the segment lists. This can be used to control the
sort order by providing an alternate comparison function. The default is
to sort by start time with ties broken by end time.
|
segment_columns
- Value:
( u' process_id ' ,
u' segment_id ' ,
u' start_time ' ,
u' start_time_ns ' ,
u' end_time ' ,
u' end_time_ns ' ,
u' segment_def_id ' )
|
|
segment_def_columns
- Value:
( u' process_id ' ,
u' segment_def_id ' ,
u' ifos ' ,
u' name ' ,
u' version ' ,
u' comment ' )
|
|
segment_sum_columns
- Value:
( u' process_id ' ,
u' segment_sum_id ' ,
u' start_time ' ,
u' start_time_ns ' ,
u' end_time ' ,
u' end_time_ns ' ,
u' segment_def_id ' ,
u' comment ' )
|
|