IGWN Segments (igwn-segments) provides a robust Pythonic representation of half-open intervals and lists of such intervals. It offers tools for creating, manipulating, and performing set-like operations (union, intersection, subtraction) on time segments, crucial for gravitational-wave data analysis and other scientific applications. Currently at version 2.1.1, the library follows an irregular release cadence, driven by the needs of the IGWN collaboration.
pip install igwn-segmentsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create `Segment` and `SegmentList` objects, calculate durations, check for intersections, and perform union operations. It also shows how to create a `SegmentList` from a string representation.
Review code that assumed or explicitly set `is_right_open`. Adjust interval definitions if previous code relied on closed or open intervals in different ways. Ensure all custom interval parsing aligns with the `[start, end)` convention.
Always assign the result of `SegmentList` operations to a new variable or reassign to the original variable. For example: `my_segment_list = my_segment_list.union(new_segment)`.
Replace `segment1 + segment2` with `SegmentList([segment1, segment2]).union()` (or similar for other operations and existing `SegmentList` objects). For example, `segment_list.union(other_segment_list)`.