Exemple #1
0
def parse_config_file(options):
	if options.verbose:
		print("reading %s ..." % options.config_file, file=sys.stderr)
	config = ConfigParser.SafeConfigParser()
	config.read(options.config_file)

	options.tag = config.get("pipeline", "user_tag")
	options.enable_clustering = config.getboolean("pipeline", "enable_clustering")

	seglistdict = segments.segmentlistdict()
	tiling_phase = {}
	for ifo in config.get("pipeline", "ifos").split():
		seglistdict[ifo] = segmentsUtils.fromsegwizard(file(config.get("pipeline", "seglist_%s" % ifo)), coltype = LIGOTimeGPS).coalesce()
		try:
			offset = config.getfloat("pipeline", "tiling_phase_%s" % ifo)
		except ConfigParser.NoOptionError:
			offset = 0.0
		if offset:
			tiling_phase[ifo] = offset

	options.psds_per_power = config.getint("pipeline", "psds_per_power")
	options.psds_per_injection = config.getint("pipeline", "psds_per_injection")
	options.timing_params = power.TimingParameters(config)

	return seglistdict, tiling_phase, config
Exemple #2
0
def parse_command_line():
    parser = OptionParser(
        version="%prog CVS $Id$",
        usage="%prog [options]",
        description=
        "Constructs the likelihood-ratio based coincidence stage for an excess power analysis.  The input consists of one or more LAL caches listing the sqlite database trigger files, and a list of segments giving the time intervals that should be considered to be independent.  The LAL caches list all trigger files together, that is injections, time slides, and zero-lag.  The individual trigger files are self-describing, so the analysis codes can autodetect their type.  Each segment will be analyzed using the files that intersect it:  the likelihood ratios will be constructed from the injections and time-lag triggers contained in files that intersect the segment, and that data used to assign likelihoods to the injections, time-lag, and zero-lag coincs in all files that intersect the same segment."
    )
    parser.add_option(
        "--input-cache",
        metavar="filename",
        action="append",
        default=[],
        help=
        "Add the contents of this cache file to the list of files from which to draw statistics."
    )
    parser.add_option(
        "--round-robin-cache",
        metavar="filename",
        action="append",
        default=[],
        help=
        "Add the contents of this cache file to the list of files from which to draw injection statistics in a round-robin way."
    )
    parser.add_option(
        "--condor-log-dir",
        metavar="path",
        default=".",
        help="Set the directory for Condor log files (default = \".\").")
    parser.add_option(
        "--config-file",
        metavar="filename",
        default="power.ini",
        help="Set .ini configuration file name (default = \"power.ini\").")
    parser.add_option(
        "--distribution-segments",
        metavar="filename",
        help=
        "Read boundaries for distribution data intervals from this segwizard format segments file (required)."
    )
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      help="Be verbose.")
    options, filenames = parser.parse_args()

    if options.distribution_segments is None:
        raise ValueError("missing required argument --distribution-segments")
    options.distribution_segments = segmentsUtils.fromsegwizard(
        file(options.distribution_segments), coltype=lal.LIGOTimeGPS)

    options.input_cache = set([
        CacheEntry(line) for filename in options.input_cache
        for line in file(filename)
    ])
    options.round_robin_cache = [
        set(map(CacheEntry, file(filename)))
        for filename in options.round_robin_cache
    ]

    return options, (filenames or [])
def read_seg_files(seg_files):
    """Read segments txt files"""

    if len(seg_files) != 3:
        err_msg = "The location of three segment files is necessary."
        err_msg += "[bufferSeg.txt, offSourceSeg.txt, onSourceSeg.txt]"
        raise RuntimeError(err_msg)

    times = {}
    keys = ["buffer", "off", "on"]

    for key, seg_file in zip(keys, seg_files):
        segs = fromsegwizard(open(seg_file, 'r'))
        if len(segs) > 1:
            err_msg = 'More than one segment, an error has occured.'
            raise RuntimeError(err_msg)
        times[key] = segs[0]

    return times
def parse_command_line():
	parser = OptionParser(
		version = "%prog CVS $Id$",
		usage = "%prog [options]",
		description = "Constructs the likelihood-ratio based coincidence stage for an excess power analysis.  The input consists of one or more LAL caches listing the sqlite database trigger files, and a list of segments giving the time intervals that should be considered to be independent.  The LAL caches list all trigger files together, that is injections, time slides, and zero-lag.  The individual trigger files are self-describing, so the analysis codes can autodetect their type.  Each segment will be analyzed using the files that intersect it:  the likelihood ratios will be constructed from the injections and time-lag triggers contained in files that intersect the segment, and that data used to assign likelihoods to the injections, time-lag, and zero-lag coincs in all files that intersect the same segment."
	)
	parser.add_option("--input-cache", metavar = "filename", action = "append", default = [], help = "Add the contents of this cache file to the list of files from which to draw statistics.")
	parser.add_option("--round-robin-cache", metavar = "filename", action = "append", default = [], help = "Add the contents of this cache file to the list of files from which to draw injection statistics in a round-robin way.")
	parser.add_option("--condor-log-dir", metavar = "path", default = ".", help = "Set the directory for Condor log files (default = \".\").")
	parser.add_option("--config-file", metavar = "filename", default = "power.ini", help = "Set .ini configuration file name (default = \"power.ini\").")
	parser.add_option("--distribution-segments", metavar = "filename", help = "Read boundaries for distribution data intervals from this segwizard format segments file (required).")
	parser.add_option("-v", "--verbose", action = "store_true", help = "Be verbose.")
	options, filenames = parser.parse_args()

	if options.distribution_segments is None:
		raise ValueError("missing required argument --distribution-segments")
	options.distribution_segments = segmentsUtils.fromsegwizard(file(options.distribution_segments), coltype = lal.LIGOTimeGPS)

	options.input_cache = set([CacheEntry(line) for filename in options.input_cache for line in file(filename)])
	options.round_robin_cache = [set(map(CacheEntry, file(filename))) for filename in options.round_robin_cache]

	return options, (filenames or [])
Exemple #5
0
  help="make things verbose" )
parser.add_option("-H","--h1-segments",action="store",type="string",\
  default=None, metavar=" H1_SEGMENTS", help="H1 input segment to read" )
parser.add_option("-K","--h2-segments",action="store",type="string",\
  default=None, metavar=" H2_SEGMENTS", help="H2 input segment to read" )
parser.add_option("-L","--l1-segments",action="store",type="string",\
  default=None, metavar=" L1_SEGMENTS", help="L1 input segment to read" )
parser.add_option("-i","--injection-file",action="store",type="string",\
  default=None, metavar=" INJFILE", help="An injection file" )
parser.add_option("-g","--glitch-time",action="store",type="int",\
    default=None, metavar=" GLITCH_TIME",\
    help="produce plot of triggers around GLITCH_TIME")

(opts, args) = parser.parse_args()

h1seglist = segmentsUtils.fromsegwizard(file(opts.h1_segments)).coalesce()
h1seglist = cleanlist(h1seglist, 2064)
h1seglist = h1seglist.contract(72)

h2seglist = segmentsUtils.fromsegwizard(file(opts.h2_segments)).coalesce()
h2seglist = cleanlist(h2seglist, 2064)
h2seglist = h2seglist.contract(72)

l1seglist = segmentsUtils.fromsegwizard(file(opts.l1_segments))
l1seglist = cleanlist(l1seglist, 2064)
l1seglist = l1seglist.contract(72)

triplelist = h1seglist & h2seglist & l1seglist
triplelist.coalesce()

h1h2doublelist = h1seglist & h2seglist
  iend = istart + opts.interval
  if iend > opts.end_time:
    iend = opts.end_time
  search_epochs.append(segments.segment(istart,iend))
  istart += opts.interval
# FIXME:  the writing out of the segments should be done at the end so
# that successfully generated dags, etc can be maintained from run to
# run
segmentsUtils.tosegwizard(file("multi_hipe_selectedsegs.txt",'w'),search_epochs)

##############################################################################
# Read in all the segment lists
ifolist = []
segdict = {}
if opts.h1_segments:
  tmplist = segmentsUtils.fromsegwizard(file(opts.h1_segments)).coalesce()
  segdict["H1"] = cleanlist(tmplist, minsciseg)
  ifolist.append("H1")

if opts.h2_segments:
  tmplist = segmentsUtils.fromsegwizard(file(opts.h2_segments)).coalesce()
  segdict["H2"] = cleanlist(tmplist, minsciseg)
  ifolist.append("H2")

if opts.l1_segments:
  tmplist = segmentsUtils.fromsegwizard(file(opts.l1_segments))
  segdict["L1"] = cleanlist(tmplist, minsciseg)
  ifolist.append("L1")

if opts.v1_segments:
  tmplist = segmentsUtils.fromsegwizard(file(opts.v1_segments))
Exemple #7
0
    if iend > opts.end_time:
        iend = opts.end_time
    search_epochs.append(segments.segment(istart, iend))
    istart += opts.interval
# FIXME:  the writing out of the segments should be done at the end so
# that successfully generated dags, etc can be maintained from run to
# run
segmentsUtils.tosegwizard(file("multi_hipe_selectedsegs.txt", 'w'),
                          search_epochs)

##############################################################################
# Read in all the segment lists
ifolist = []
segdict = {}
if opts.h1_segments:
    tmplist = segmentsUtils.fromsegwizard(file(opts.h1_segments)).coalesce()
    segdict["H1"] = cleanlist(tmplist, minsciseg)
    ifolist.append("H1")

if opts.h2_segments:
    tmplist = segmentsUtils.fromsegwizard(file(opts.h2_segments)).coalesce()
    segdict["H2"] = cleanlist(tmplist, minsciseg)
    ifolist.append("H2")

if opts.l1_segments:
    tmplist = segmentsUtils.fromsegwizard(file(opts.l1_segments))
    segdict["L1"] = cleanlist(tmplist, minsciseg)
    ifolist.append("L1")

if opts.v1_segments:
    tmplist = segmentsUtils.fromsegwizard(file(opts.v1_segments))
  help="make things verbose" )
parser.add_option("-H","--h1-segments",action="store",type="string",\
  default=None, metavar=" H1_SEGMENTS", help="H1 input segment to read" )
parser.add_option("-K","--h2-segments",action="store",type="string",\
  default=None, metavar=" H2_SEGMENTS", help="H2 input segment to read" )
parser.add_option("-L","--l1-segments",action="store",type="string",\
  default=None, metavar=" L1_SEGMENTS", help="L1 input segment to read" )
parser.add_option("-i","--injection-file",action="store",type="string",\
  default=None, metavar=" INJFILE", help="An injection file" )
parser.add_option("-g","--glitch-time",action="store",type="int",\
    default=None, metavar=" GLITCH_TIME",\
    help="produce plot of triggers around GLITCH_TIME")

( opts , args ) = parser.parse_args()

h1seglist = segmentsUtils.fromsegwizard(file(opts.h1_segments)).coalesce()
h1seglist = cleanlist(h1seglist, 2064)
h1seglist = h1seglist.contract(72)

h2seglist = segmentsUtils.fromsegwizard(file(opts.h2_segments)).coalesce()
h2seglist = cleanlist(h2seglist, 2064)
h2seglist = h2seglist.contract(72)

l1seglist = segmentsUtils.fromsegwizard(file(opts.l1_segments))
l1seglist = cleanlist(l1seglist, 2064)
l1seglist = l1seglist.contract(72)

triplelist = h1seglist & h2seglist & l1seglist
triplelist.coalesce()

h1h2doublelist = h1seglist & h2seglist