Skip to content

sgnl.simulation

This module contains methods for handling simulation files.

sim_inspiral_to_segment_list(fname, pad=1, verbose=False)

Given an xml file create a segment list that marks the time of an injection with padding

Parameters:

Name Type Description Default
fname

str, the xml file name

required
pad

float, duration in seconds to pad the coalescence time when producing a segment, e.g., [tc-pad, tc+pad)

1
Source code in sgnl/simulation.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def sim_inspiral_to_segment_list(fname, pad=1, verbose=False):
    """Given an xml file create a segment list that marks the time of an injection
    with padding

    Args:
        fname:
            str, the xml file name
        pad:
            float, duration in seconds to pad the coalescence time when producing a
            segment, e.g., [tc-pad, tc+pad)
    """

    # initialization

    seglist = segments.segmentlist()

    # Parse the XML file

    xmldoc = ligolw_utils.load_filename(
        fname, contenthandler=ContentHandler, verbose=verbose
    )

    # extract the padded geocentric end times into segment lists

    for row in lsctables.SimInspiralTable.get_table(xmldoc):
        t = row.time_geocent
        seglist.append(
            segments.segment(
                LIGOTimeGPS(math.floor(t - pad)), LIGOTimeGPS(math.ceil(t + pad))
            )
        )

    # help the garbage collector

    xmldoc.unlink()

    return seglist.coalesce()