Skip to content

sgnl.bin.inspiral_wrapper

Wrapper for sgnl-inspiral in HTCondor jobs.

Takes the same arguments as sgnl-inspiral and runs it once for each SVD bin, exiting for HTCondor checkpoints between each.

build_inspiral_args(trigger_output, ht_gate_threshold, svd_banks, bulk_args, output_likelihood_file=None)

Build argument list for sgnl-inspiral.

Returns:

Type Description

List of arguments to pass to sgnl-inspiral

Source code in sgnl/bin/inspiral_wrapper.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
def build_inspiral_args(
    trigger_output, ht_gate_threshold, svd_banks, bulk_args, output_likelihood_file=None
):
    """Build argument list for sgnl-inspiral.

    Returns:
        List of arguments to pass to sgnl-inspiral
    """
    args = [
        "--ht-gate-threshold",
        ht_gate_threshold,
        "--trigger-output",
        trigger_output,
    ]

    if output_likelihood_file:
        args.extend(["--output-likelihood-file", output_likelihood_file])

    for file in svd_banks:
        args.extend(["--svd-bank", file])

    return [*args, *bulk_args]

parse_args()

Parse arguments which change during the loop, and pass the rest unchanged

Source code in sgnl/bin/inspiral_wrapper.py
16
17
18
19
20
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def parse_args():
    """Parse arguments which change during the loop, and pass the rest unchanged"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--ht-gate-threshold",
        required=True,
        metavar="sigma",
        action="append",
        default=[],
        help="The gating threshold. Data above this value will be gated out.",
    )
    parser.add_argument(
        "--trigger-output",
        required=True,
        metavar="filename",
        action="append",
        default=[],
        help="Set the name of the sqlite output file *.sqlite",
    )
    parser.add_argument(
        "--output-likelihood-file",
        metavar="filename",
        action="append",
        help="Set the name of the LIKELIHOOD_RATIO file to which to write likelihood "
        "ratio data collected from triggers (optional). Can be given more than once. "
        "If given, exactly as many must be provided as there are --svd-bank options "
        "and they will be writen to in order. Forbidden for when --injections is set.",
    )
    parser.add_argument(
        "--svd-bank",
        required=True,
        metavar="filename",
        action="append",
        default=[],
        help="Set the name of the LIGO light-weight XML file from which to load the "
        "svd bank for a given instrument. To analyze multiple instruments, --svd-bank "
        "can be called multiple times for svd banks corresponding to different "
        "instruments. If --data-source is lvshm or framexmit, then only svd banks "
        "corresponding to a single bin must be given. If given multiple times, the "
        "banks will be processed one-by-one, in order. At least one svd bank for at "
        "least 2 detectors is required, but see also --svd-bank-cache.",
    )
    parser.add_argument(
        "--checkpoint-dir",
        metavar="filepath",
        default=checkpoints.DEFAULT_CHECKPOINT_DIR,
        help="(Optional) Set the directory to use for HTCondor checkpoint files. "
        "This directory will be created, and must be included in the "
        "transfer_checkpoint_files line of the job submit description file.",
    )
    parser.add_argument(
        "--checkpoint-exit-code",
        metavar="integer",
        type=int,
        default=checkpoints.DEFAULT_CHECKPOINT_EXIT_CODE,
        help="(Optional) Set the exit code to use when checkpointing. This must match "
        "checkpoint_exit_code in the job submit description file.",
    )
    parser.add_argument(
        "--svds-per-checkpoint",
        metavar="integer",
        type=int,
        default=3,
        help="(Optional) Set the number of SVD bins to process before checkpointing.",
    )
    wrapper_args, bulk_args = parser.parse_known_args()

    num_outputs = len(wrapper_args.trigger_output)
    assert (
        len(wrapper_args.ht_gate_threshold) == num_outputs
    ), "The number of gate thresholds does not equal the number of trigger files"
    assert (
        len(wrapper_args.svd_bank) % num_outputs == 0
    ), "The number of SVD banks is not a multiple of the number of trigger files"

    if wrapper_args.output_likelihood_file:
        assert (
            len(wrapper_args.output_likelihood_file) == num_outputs
        ), "The number of likelihood files does not equal the number of trigger files"

    return num_outputs, wrapper_args, bulk_args

parse_bin_number(filename)

Extract the bin number from an SVD bank, trigger, or dist stats filename

Source code in sgnl/bin/inspiral_wrapper.py
 99
100
101
102
103
104
105
106
107
def parse_bin_number(filename):
    """Extract the bin number from an SVD bank, trigger, or dist stats filename"""
    # Example filenames:
    # H1-0123_SGNL_SVD_BANK-1234567890-12345.xml.gz
    # H1L1-0123_SGNL_TRIGGERS-1234567890-1234.sqlite.gz
    # V1-0123_SGNL_DIST_STATS-1234567890-1234.xml.gz
    bin_number_string = filename.split("-")[1].split("_")[0]
    assert bin_number_string.isdigit(), f"Failed to extract bin number from {filename}"
    return int(bin_number_string)