Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALApps 10.1.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lalapps_cafe.py
Go to the documentation of this file.
1##python
2#
3# Copyright (C) 2006 Kipp Cannon
4#
5# This program is free software; you can redistribute it and/or modify it
6# under the terms of the GNU General Public License as published by the
7# Free Software Foundation; either version 2 of the License, or (at your
8# option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13# Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19
20#
21# =============================================================================
22#
23# Preamble
24#
25# =============================================================================
26#
27
28
29"""
30LIGO Light-Weight XML Coincidence Analysis Front End.
31"""
32
33
34from optparse import OptionParser
35
36
37from igwn_ligolw import lsctables
38from igwn_ligolw import utils as ligolw_utils
39from lalburst import git_version
40from lalburst import cafe
41
42
43__author__ = "Kipp Cannon <kipp.cannon@ligo.org>"
44__version__ = "git id %s" % git_version.id
45__date__ = git_version.date
46
47
48#
49# =============================================================================
50#
51# Command Line
52#
53# =============================================================================
54#
55
56
58 parser = OptionParser(
59 version = "Name: %%prog\n%s" % git_version.verbose_msg,
60 usage = "%prog --time-slides time_slides_filename [options] [filename ...]",
61 description = "%prog is a generic coincidence analysis front-end for trigger-based searches for gravitational wave events. This program answers the question \"given that I have a collection of files containing event lists, and given that I wish to perform a coincidence analysis by time-shifting the events to simulate a background, what are the smallest groups of trigger files such that if each group is analyzed separately no coincidences will be missed?\" The inputs consist of one or more LAL cache files describing the collection of trigger files to be analyzed, and a LIGO Light Weight XML file containing a time_slide table describing the time shifts to be applied to the triggers. If no cache files are named on the command line, then the cache is read from stdin. The output is a collection of LAL cache files, one each for the file groups identified from the input. See also lalapps_ll2cache (a program that constructs a LAL cache file from a list of LIGO Light Weight XML trigger files by parsing each file's search_summary table), and ligolw_add (a program that combines LIGO Light Weight XML trigger files, and is capable of reading its input file list from a LAL cache)."
62 )
63 parser.add_option("-s", "--single-instrument", action = "store_true", help = "Select single instrument mode. In this mode, after grouping the files as usual, for each group a separate LAL cache file is written for each instrument, rather than a single cache listing all input files.")
64 parser.add_option("-t", "--time-slides", metavar = "filename", help = "Read the time slide table from this file.")
65 parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose.")
66 parser.add_option("-b", "--base", metavar = "base", default = "cafe_", help = "Set base for output caches (default = \"cafe_\").")
67 options, cachenames = parser.parse_args()
68
69 if not options.time_slides:
70 raise ValueError("--time-slides required")
71
72 return options, (cachenames or [None])
73
74
75#
76# =============================================================================
77#
78# Main
79#
80# =============================================================================
81#
82
83
84options, cachenames = parse_command_line()
85
86
87cache = []
88for filename in cachenames:
89 cache.extend(cafe.load_cache(filename, options.verbose))
90
91
92seglists, outputcaches = cafe.ligolw_cafe(cache, lsctables.TimeSlideTable.get_table(ligolw_utils.load_filename(options.time_slides, verbose = options.verbose)).as_dict().values(), options.verbose)
93instruments = set(seglists.keys())
94
95
96if options.single_instrument:
97 cafe.write_single_instrument_caches(options.base, outputcaches, instruments, options.verbose)
98else:
99 cafe.write_caches(options.base, outputcaches, instruments, options.verbose)
def parse_command_line()
Definition: lalapps_cafe.py:57