SegmentListDict#
- class gwpy.segments.SegmentListDict(*args)[source]#
Bases:
segmentlistdictA
dictofSegmentLists.This class implements a standard mapping interface, with additional features added to assist with the manipulation of a collection of
SegmentListobjects. In particular, methods for taking unions and intersections of the lists in the dictionary are available, as well as the ability to record and apply numeric offsets to the boundaries of theSegmentsin each list.The numeric offsets are stored in the “offsets” attribute, which itself is a dictionary, associating a number with each key in the main dictionary. Assigning to one of the entries of the offsets attribute has the effect of shifting the corresponding
SegmentListfrom its original position (not its current position) by the given amount.Examples
>>> x = SegmentListDict() >>> x["H1"] = SegmentList([Segment(0, 10)]) >>> print(x) {'H1': [Segment(0, 10)]} >>> x.offsets["H1"] = 6 >>> print(x) {'H1': [Segment(6.0, 16.0)]} >>> x.offsets.clear() >>> print(x) {'H1': [Segment(0.0, 10.0)]} >>> x["H2"] = SegmentList([Segment(5, 15)]) >>> x.intersection(["H1", "H2"]) [Segment(5, 10.0)] >>> x.offsets["H1"] = 6 >>> x.intersection(["H1", "H2"]) [Segment(6.0, 15)] >>> c = x.extract_common(["H1", "H2"]) >>> c.offsets.clear() >>> c {'H2': [Segment(6.0, 15)], 'H1': [Segment(0.0, 9.0)]}