def make_random_document(num_procs, num_seg_defs, num_segs, num_seg_sums, start_time, end_time, max_len):
	"""Create a ligolw document with random segments and segment_summary"""
	doc = ligolw.Document()
	doc.appendChild(ligolw.LIGO_LW())

	# Add some processes
	proc_ids = []
	seg_def_ids = {}
	segment_map = {}
	segment_sum_map = {}

	for count in range(num_procs):
		proc_id = append_process(doc, "Test program %d" % count).process_id
		proc_ids.append(proc_id)
		seg_def_ids[proc_id] = []

	# Add some segment definers
	for count in range(num_seg_defs):
		proc_id	= proc_ids[int(uniform(0,num_procs))]
		seg_def_id = add_to_segment_definer(doc, proc_id, "H1", "TEST_SEG_%d" % count, 1) 
		seg_def_ids[proc_id].append(seg_def_id)

		# Add some segments
		sgmntlst = random_segments(start_time, end_time, num_segs, max_len)
		add_to_segment(doc, proc_id, seg_def_id, sgmntlst)
		sgmntlst.coalesce()
		segment_map["TEST_SEG_%d" % count] = sgmntlst

		# Add some segment summaries
		sgmntlst = random_segments(start_time, end_time, num_segs, max_len)
		add_to_segment_summary(doc, proc_id, seg_def_id, sgmntlst)
		sgmntlst.coalesce()
		segment_sum_map["TEST_SEG_%d" % count] = sgmntlst

	return doc, segment_map, segment_sum_map
Beispiel #2
0
def append_process_params(xmldoc, args, version, date):
    """Construct and append process and process_params tables to
    ligolw.Document object xmldoc, using the given sys.argv variable
    args and other parameters.
    """
    xmldoc.childNodes[-1].appendChild(lsctables.New(lsctables.ProcessTable))
    xmldoc.childNodes[-1].appendChild(
        lsctables.New(lsctables.ProcessParamsTable))

    # build and seed process params
    progName = args[0]
    process = ligolw_process.append_process(xmldoc,
                                            program=progName,
                                            version=version,
                                            cvs_repository='lscsoft',
                                            cvs_entry_time=date)
    params = []
    for i in range(len(args)):
        p = args[i]
        if not p.startswith('-'):
            continue
        v = ''
        if i < len(sys.argv) - 1:
            v = sys.argv[i + 1]
        params.append(map(unicode, (p, 'string', v)))

    ligolw_process.append_process_params(xmldoc, process, params)

    return xmldoc
Beispiel #3
0
def append_process(xmldoc,
                   comment=None,
                   force=None,
                   ds_sq_threshold=None,
                   save_small_coincs=None,
                   vetoes_name=None,
                   coinc_end_time_segment=None,
                   verbose=None):
    process = ligolw_process.append_process(xmldoc,
                                            program=process_program_name,
                                            version=__version__,
                                            cvs_repository=u"lscsoft",
                                            cvs_entry_time=__date__,
                                            comment=comment)

    params = [(u"--ds-sq-threshold", u"real_8", ds_sq_threshold)]
    if comment is not None:
        params += [(u"--comment", u"lstring", comment)]
    if force is not None:
        params += [(u"--force", None, None)]
    if save_small_coincs is not None:
        params += [(u"--save-small-coincs", None, None)]
    if vetoes_name is not None:
        params += [(u"--vetoes-name", u"lstring", vetoes_name)]
    if coinc_end_time_segment is not None:
        params += [(u"--coinc-end-time-segment", u"lstring",
                    coinc_end_time_segment)]
    if verbose is not None:
        params += [(u"--verbose", None, None)]

    ligolw_process.append_process_params(xmldoc, process, params)

    return process
def append_process_params(xmldoc, args, version, date):
    """Construct and append process and process_params tables to
    ligolw.Document object xmldoc, using the given sys.argv variable
    args and other parameters.
    """
    xmldoc.childNodes[-1].appendChild(lsctables.New(lsctables.ProcessTable))
    xmldoc.childNodes[-1].appendChild(
        lsctables.New(lsctables.ProcessParamsTable))

    # build and seed process params
    progName = args[0]
    process = ligolw_process.append_process(xmldoc, program=progName,
                                    version=version, cvs_repository='lscsoft',
                                    cvs_entry_time=date)
    params = []
    for i in range(len(args)):
        p = args[i]
        if not p.startswith('-'):
            continue
        v = ''
        if i < len(sys.argv)-1:
            v = sys.argv[i+1]
        params.append( map( unicode, (p,'string',v) ) )

    ligolw_process.append_process_params(xmldoc,process,params)

    return xmldoc
def write_to_xml(cells, intr_prms, fvals=None, fname=None, verbose=False):
    """
    Write a set of cells, with dimensions corresponding to intr_prms to an XML file as sim_inspiral rows.
    """
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    procrow = process.append_process(xmldoc, program=sys.argv[0])
    procid = procrow.process_id
    process.append_process_params(xmldoc, procrow, process.process_params_from_dict(opts.__dict__))

    rows = ["simulation_id", "process_id", "numrel_data"] + list(intr_prms)
    if fvals is not None:
        rows.append("alpha1")
    sim_insp_tbl = lsctables.New(lsctables.SimInspiralTable, rows)
    for itr, intr_prm in enumerate(cells):
        sim_insp = sim_insp_tbl.RowType()
        # FIXME: Need better IDs
        sim_insp.numrel_data = "INTR_SET_%d" % itr
        sim_insp.simulation_id = ilwd.ilwdchar("sim_inspiral:sim_inspiral_id:%d" % itr)
        sim_insp.process_id = procid
        if fvals:
            sim_insp.alpha1 = fvals[itr]
        for p, v in zip(intr_prms, intr_prm._center):
            setattr(sim_insp, p, v)
        sim_insp_tbl.append(sim_insp)

    xmldoc.childNodes[0].appendChild(sim_insp_tbl)
    if fname is None:
        channel_name = ["H=H", "L=L"]
        ifos = "".join([o.split("=")[0][0] for o in channel_name])
        #start = int(event_time)
        start = 0
        fname = "%s-MASS_POINTS-%d-1.xml.gz" % (ifos, start)
    utils.write_filename(xmldoc, fname, gz=True, verbose=verbose)
Beispiel #6
0
def tosegmentxml(file, segs):

  """
    Write the glue.segments.segmentlist object segs to file object file in xml
    format with appropriate tables.
  """

  # generate empty document
  xmldoc = ligolw.Document()
  xmldoc.appendChild(ligolw.LIGO_LW())
  xmldoc.childNodes[-1].appendChild(lsctables.New(lsctables.ProcessTable))
  xmldoc.childNodes[-1].appendChild(lsctables.New(lsctables.ProcessParamsTable))

  # append process to table
  process = ligolw_process.append_process(xmldoc,\
                                  program='pylal.dq.dqSegmentUtils',\
                                  version=__version__,\
                                  cvs_repository='lscsoft',\
                                  cvs_entry_time=__date__)

  gpssegs = segments.segmentlist()
  for seg in segs:
    gpssegs.append(segments.segment(LIGOTimeGPS(seg[0]), LIGOTimeGPS(seg[1])))

  # append segs and seg definer
  segments_tables = ligolw_segments.LigolwSegments(xmldoc)
  segments_tables.add(ligolw_segments.LigolwSegmentList(active=gpssegs))
  # finalise
  segments_tables.coalesce()
  segments_tables.optimize()
  segments_tables.finalize(process)
  ligolw_process.set_process_end_time(process)

  # write file
  utils.write_fileobj(xmldoc, file, gz=False)
def append_process(xmldoc, match_algorithm, comment):
	"""
	Convenience wrapper for adding process metadata to the document.
	"""
	process = ligolw_process.append_process(xmldoc, program = process_program_name, version = __version__, cvs_repository = u"lscsoft", cvs_entry_time = __date__, comment = comment)

	params = [(u"--match-algorithm", u"lstring", match_algorithm)]
	ligolw_process.append_process_params(xmldoc, process, params)

	return process
Beispiel #8
0
def append_process(xmldoc, comment = None, **kwargs):
	paramdict = kwargs.copy()
	if paramdict["coincidence_algorithm"] in ("stringcusp",):
		paramdict["thresholds"] = [u"%s,%s=%s" % (a, b, ",".join(map(str, value))) for (a, b), value in paramdict["thresholds"].items() if a < b]

	return ligolw_process.append_process(
		xmldoc,
		program = process_program_name,
		paramdict = paramdict,
		version = __version__,
		cvs_repository = u"lscsoft",
		cvs_entry_time = __date__,
		comment = comment
	)
Beispiel #9
0
def append_process(xmldoc, match_algorithm, time_window, loudest_by, comment):
    """Convenience wrapper for adding process metadata to the document.
    """
    process = ligolw_process.append_process(xmldoc,
                                    program=process_program_name,
                                    version=__version__,
                                    cvs_repository=u"lscsoft",
                                    cvs_entry_time=__date__, comment=comment)
    params = [(u"--match-algorithm", u"lstring", match_algorithm),
              (u"--time-window", u"lstring", time_window)]
    if loudest_by:
        params.append((u"--loudest-by", u"lstring", loudest_by))
    ligolw_process.append_process_params(xmldoc, process, params)
    return process
Beispiel #10
0
def write_to_xml(cells,
                 intr_prms,
                 pin_prms={},
                 fvals=None,
                 fname=None,
                 verbose=False):
    """
    Write a set of cells, with dimensions corresponding to intr_prms to an XML file as sim_inspiral rows.
    """
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    procrow = process.append_process(xmldoc, program=sys.argv[0])
    procid = procrow.process_id
    process.append_process_params(
        xmldoc, procrow, process.process_params_from_dict(opts.__dict__))

    rows = ["simulation_id", "process_id", "numrel_data"]
    # Override eff_lambda to with psi0, its shoehorn column
    if "eff_lambda" in intr_prms:
        intr_prms[intr_prms.index("eff_lambda")] = "psi0"
    if "deff_lambda" in intr_prms:
        intr_prms[intr_prms.index("deff_lambda")] = "psi3"
    rows += list(intr_prms)
    rows += list(pin_prms)
    if fvals is not None:
        rows.append("alpha1")
    sim_insp_tbl = lsctables.New(lsctables.SimInspiralTable, rows)
    for itr, intr_prm in enumerate(cells):
        sim_insp = sim_insp_tbl.RowType()
        # FIXME: Need better IDs
        sim_insp.numrel_data = "INTR_SET_%d" % itr
        sim_insp.simulation_id = ilwd.ilwdchar(
            "sim_inspiral:sim_inspiral_id:%d" % itr)
        sim_insp.process_id = procid
        if fvals:
            sim_insp.alpha1 = fvals[itr]
        for p, v in zip(intr_prms, intr_prm._center):
            setattr(sim_insp, p, v)
        for p, v in pin_prms.iteritems():
            setattr(sim_insp, p, v)
        sim_insp_tbl.append(sim_insp)

    xmldoc.childNodes[0].appendChild(sim_insp_tbl)
    if fname is None:
        channel_name = ["H=H", "L=L"]
        ifos = "".join([o.split("=")[0][0] for o in channel_name])
        #start = int(event_time)
        start = 0
        fname = "%s-MASS_POINTS-%d-1.xml.gz" % (ifos, start)
    utils.write_filename(xmldoc, fname, gz=True, verbose=verbose)
Beispiel #11
0
def append_process(xmldoc, comment=None, **kwargs):
    paramdict = kwargs.copy()
    if paramdict["coincidence_algorithm"] in ("stringcusp", ):
        paramdict["thresholds"] = [
            u"%s,%s=%s" % (a, b, ",".join(map(str, value)))
            for (a, b), value in paramdict["thresholds"].items() if a < b
        ]

    return ligolw_process.append_process(xmldoc,
                                         program=process_program_name,
                                         paramdict=paramdict,
                                         version=__version__,
                                         cvs_repository=u"lscsoft",
                                         cvs_entry_time=__date__,
                                         comment=comment)
Beispiel #12
0
def append_process(xmldoc, match_algorithm, time_window, loudest_by, comment):
    """Convenience wrapper for adding process metadata to the document.
    """
    process = ligolw_process.append_process(xmldoc,
                                            program=process_program_name,
                                            version=__version__,
                                            cvs_repository=u"lscsoft",
                                            cvs_entry_time=__date__,
                                            comment=comment)
    params = [(u"--match-algorithm", u"lstring", match_algorithm),
              (u"--time-window", u"lstring", time_window)]
    if loudest_by:
        params.append((u"--loudest-by", u"lstring", loudest_by))
    ligolw_process.append_process_params(xmldoc, process, params)
    return process
def append_process(xmldoc, match_algorithm, comment):
    """
	Convenience wrapper for adding process metadata to the document.
	"""
    process = ligolw_process.append_process(xmldoc,
                                            program=process_program_name,
                                            version=__version__,
                                            cvs_repository=u"lscsoft",
                                            cvs_entry_time=__date__,
                                            comment=comment)

    params = [(u"--match-algorithm", u"lstring", match_algorithm)]
    ligolw_process.append_process_params(xmldoc, process, params)

    return process
Beispiel #14
0
def append_process(doc, **kwargs):
  process = ligolw_process.append_process(
    doc, program = "ligolw_sicluster", version = git_version.verbose_msg,
    cvs_repository = "lscsoft", cvs_entry_time = git_version.date,
    comment = kwargs["comment"])

  ligolw_process.append_process_params(doc, process, 
    [("--cluster-window", "lstring", kwargs["cluster_window"])])
  if kwargs["snr_threshold"] > 0:
    ligolw_process.append_process_params(doc, process, 
      [("--snr-threshold", "lstring", kwargs["snr_threshold"])])
  if kwargs["sort_descending_snr"]:
    ligolw_process.append_process_params(doc, process, 
      [("--sort-descending-snr", "lstring", " ")])
  if kwargs["sort_ascending_snr"]:
    ligolw_process.append_process_params(doc, process, 
      [("--sort-ascending-snr", "lstring", " ")])

  return process
def append_process(doc, **kwargs):
  process = ligolw_process.append_process(
    doc, program = "ligolw_sicluster", version = git_version.verbose_msg,
    cvs_repository = "lscsoft", cvs_entry_time = git_version.date,
    comment = kwargs["comment"])

  ligolw_process.append_process_params(doc, process, 
    [("--cluster-window", "lstring", kwargs["cluster_window"])])
  if kwargs["snr_threshold"] > 0:
    ligolw_process.append_process_params(doc, process, 
      [("--snr-threshold", "lstring", kwargs["snr_threshold"])])
  if kwargs["sort_descending_snr"]:
    ligolw_process.append_process_params(doc, process, 
      [("--sort-descending-snr", "lstring", " ")])
  if kwargs["sort_ascending_snr"]:
    ligolw_process.append_process_params(doc, process, 
      [("--sort-ascending-snr", "lstring", " ")])

  return process
Beispiel #16
0
def append_process(xmldoc, **kwargs):
    process = ligolw_process.append_process(xmldoc,
                                            program=u"ligolw_thinca",
                                            version=__version__,
                                            cvs_repository=u"lscsoft",
                                            cvs_entry_time=__date__,
                                            comment=kwargs["comment"])

    params = [(u"--e-thinca-parameter", u"real_8",
               kwargs["e_thinca_parameter"])]

    if kwargs["comment"] is not None:
        params += [(u"--comment", u"lstring", kwargs["comment"])]
    if kwargs["weighted_snr"] is not None:
        params += [(u"--weighted-snr", u"lstring", kwargs["weighted_snr"])]
    if kwargs["magic_number"] is not None:
        params += [(u"--magic-number", u"real_8", kwargs["magic_number"])]
    if kwargs["vetoes_name"] is not None:
        params += [(u"--vetoes-name", u"lstring", kwargs["vetoes_name"])]
    if kwargs["search_group"] is not None:
        params += [(u"--search-group", u"lstring", kwargs["search_group"])]
    if kwargs["trigger_program"] is not None:
        params += [(u"--trigger-program", u"lstring",
                    kwargs["trigger_program"])]
    if kwargs["exact_match"] is not None:
        params += [(u"--exact-match", None, None)]
    if kwargs["depop_sngl_inspiral"] is not None:
        params += [(u"--depop-sngl-inspiral", None, None)]
    if kwargs["drop_veto_info"] is not None:
        params += [(u"--drop-veto-info,", None, None)]
    if kwargs["make_expr_tables"] is not None:
        params += [(u"--make-expr-tables", None, None)]
    if kwargs["verbose"] is not None:
        params += [(u"--verbose", None, None)]
    if kwargs["coinc_end_time_segment"] is not None:
        params += [(u"--coinc-end-time-segment", u"lstring",
                    kwargs["coinc_end_time_segment"])]

    ligolw_process.append_process_params(xmldoc, process, params)

    return process
Beispiel #17
0
def append_process(xmldoc, **kwargs):
	process = ligolw_process.append_process(
		xmldoc,
		program = u"ligolw_thinca",
		version = __version__,
		cvs_repository = u"lscsoft",
		cvs_entry_time = __date__,
		comment = kwargs["comment"]
	)

	params = [(u"--e-thinca-parameter", u"real_8", kwargs["e_thinca_parameter"])]

	if kwargs["comment"] is not None:
		params += [(u"--comment", u"lstring", kwargs["comment"])]
	if kwargs["weighted_snr"] is not None:
		params += [(u"--weighted-snr", u"lstring", kwargs["weighted_snr"])]
	if kwargs["magic_number"] is not None:
		params += [(u"--magic-number", u"real_8", kwargs["magic_number"])]
	if kwargs["vetoes_name"] is not None:
		params += [(u"--vetoes-name", u"lstring", kwargs["vetoes_name"])]
	if kwargs["search_group"] is not None:
		params += [(u"--search-group", u"lstring", kwargs["search_group"])]
	if kwargs["trigger_program"] is not None:
		params += [(u"--trigger-program", u"lstring", kwargs["trigger_program"])]
	if kwargs["exact_match"] is not None:
		params += [(u"--exact-match", None, None)]
	if kwargs["depop_sngl_inspiral"] is not None:
		params += [(u"--depop-sngl-inspiral", None, None)]
	if kwargs["drop_veto_info"] is not None:
		params += [(u"--drop-veto-info,", None,None)]
	if kwargs["make_expr_tables"] is not None:
		params += [(u"--make-expr-tables", None, None)]
	if kwargs["verbose"] is not None:
		params += [(u"--verbose", None, None)]
	if kwargs["coinc_end_time_segment"] is not None:
		params += [(u"--coinc-end-time-segment", u"lstring", kwargs["coinc_end_time_segment"])]

	ligolw_process.append_process_params(xmldoc, process, params)

	return process
Beispiel #18
0
def append_process(xmldoc, comment = None, force = None, ds_sq_threshold = None, save_small_coincs = None, vetoes_name = None, coinc_end_time_segment = None, verbose = None):
	process = ligolw_process.append_process(xmldoc, program = process_program_name, version = __version__, cvs_repository = u"lscsoft", cvs_entry_time = __date__, comment = comment)

	params = [
		(u"--ds-sq-threshold", u"real_8", ds_sq_threshold)
	]
	if comment is not None:
		params += [(u"--comment", u"lstring", comment)]
	if force is not None:
		params += [(u"--force", None, None)]
	if save_small_coincs is not None:
		params += [(u"--save-small-coincs", None, None)]
	if vetoes_name is not None:
		params += [(u"--vetoes-name", u"lstring", vetoes_name)]
	if coinc_end_time_segment is not None:
		params += [(u"--coinc-end-time-segment", u"lstring", coinc_end_time_segment)]
	if verbose is not None:
		params += [(u"--verbose", None, None)]

	ligolw_process.append_process_params(xmldoc, process, params)

	return process
Beispiel #19
0
def make_random_document(num_procs, num_seg_defs, num_segs, num_seg_sums,
                         start_time, end_time, max_len):
    """Create a ligolw document with random segments and segment_summary"""
    doc = ligolw.Document()
    doc.appendChild(ligolw.LIGO_LW())

    # Add some processes
    proc_ids = []
    seg_def_ids = {}
    segment_map = {}
    segment_sum_map = {}

    for count in range(num_procs):
        proc_id = append_process(doc, "Test program %d" % count).process_id
        proc_ids.append(proc_id)
        seg_def_ids[proc_id] = []

    # Add some segment definers
    for count in range(num_seg_defs):
        proc_id = proc_ids[int(uniform(0, num_procs))]
        seg_def_id = add_to_segment_definer(doc, proc_id, "H1",
                                            "TEST_SEG_%d" % count, 1)
        seg_def_ids[proc_id].append(seg_def_id)

        # Add some segments
        sgmntlst = random_segments(start_time, end_time, num_segs, max_len)
        add_to_segment(doc, proc_id, seg_def_id, sgmntlst)
        sgmntlst.coalesce()
        segment_map["TEST_SEG_%d" % count] = sgmntlst

        # Add some segment summaries
        sgmntlst = random_segments(start_time, end_time, num_segs, max_len)
        add_to_segment_summary(doc, proc_id, seg_def_id, sgmntlst)
        sgmntlst.coalesce()
        segment_sum_map["TEST_SEG_%d" % count] = sgmntlst

    return doc, segment_map, segment_sum_map
def tosegmentxml(file, segs):
    """
    Write the glue.segments.segmentlist object segs to file object file in xml
    format with appropriate tables.
  """

    # generate empty document
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    xmldoc.childNodes[-1].appendChild(lsctables.New(lsctables.ProcessTable))
    xmldoc.childNodes[-1].appendChild(
        lsctables.New(lsctables.ProcessParamsTable))

    # append process to table
    process = ligolw_process.append_process(xmldoc,\
                                    program='pylal.dq.dqSegmentUtils',\
                                    version=__version__,\
                                    cvs_repository='lscsoft',\
                                    cvs_entry_time=__date__)

    gpssegs = segments.segmentlist()
    for seg in segs:
        gpssegs.append(
            segments.segment(LIGOTimeGPS(seg[0]), LIGOTimeGPS(seg[1])))

    # append segs and seg definer
    segments_tables = ligolw_segments.LigolwSegments(xmldoc)
    segments_tables.add(ligolw_segments.LigolwSegmentList(active=gpssegs))
    # finalise
    segments_tables.coalesce()
    segments_tables.optimize()
    segments_tables.finalize(process)
    ligolw_process.set_process_end_time(process)

    # write file
    with utils.SignalsTrap():
        utils.write_fileobj(xmldoc, file, gz=False)
gam = np.real(gam)
test = np.concatenate((np.array([[McSIG/lal.MSUN_SI, etaSIG]]), gam,np.array([[r1,r2]]),np.array([[area, frac_area]]), np.array([[match_cntr,match_cntr]]) ))
# If clusters get upgraded, add this header to output:
#   header='grid center; 2x2 effective Fisher matrix, 4rd row: ellipsoid axes, 5th row: total ellipse area, estimated physical area'
if opts.save_ellipsoid_data:
    np.savetxt('ellipsoid.dat', test)

# Convert to m1, m2
m1m2_grid = np.array([lsu.m1m2(cart_grid[i][0], cart_grid[i][1])
        for i in xrange(len(cart_grid))])
m1m2_grid /= lal.MSUN_SI

if opts.mass_points_xml:
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    procrow = process.append_process(xmldoc, program=sys.argv[0])
    procid = procrow.process_id
    process.append_process_params(xmldoc, procrow, process.process_params_from_dict(opts.__dict__))
    
    sim_insp_tbl = lsctables.New(lsctables.SimInspiralTable, ["simulation_id", "process_id", "numrel_data", "mass1", "mass2", "psi0", "psi3"])
    for itr, (m1, m2) in enumerate(m1m2_grid):
        for l1 in np.linspace(common_cl.param_limits["lam_tilde"][0], common_cl.param_limits["lam_tilde"][1], Nlam):
            sim_insp = sim_insp_tbl.RowType()
            sim_insp.numrel_data = "MASS_SET_%d" % itr
            sim_insp.simulation_id = ilwd.ilwdchar("sim_inspiral:sim_inspiral_id:%d" % itr)
            sim_insp.process_id = procid
            sim_insp.mass1, sim_insp.mass2 = m1, m2
            sim_insp.psi0, sim_insp.psi3 = opts.eff_lambda or l1, opts.delta_eff_lambda or 0
            sim_insp_tbl.append(sim_insp)
    xmldoc.childNodes[0].appendChild(sim_insp_tbl)
    if opts.channel_name:
def append_process(doc, options):
	process = ligolw_process.append_process(doc, program = process_program_name, version = __version__, cvs_repository = u"lscsoft", cvs_entry_time = __date__, comment = options.comment)

	params = []
	if options.coinc_only:
		params += [(u"--coinc-only", None, None)]
	if options.inj_made_only:
		params += [(u"--inj-made-only", None, None)]
	if options.min_amplitude is not None:
		params += [(u"--min-amplitude", u"real_4", options.min_amplitude)]
	if options.max_amplitude is not None:
		params += [(u"--max-amplitude", u"real_4", options.max_amplitude)]
	if options.min_bandwidth is not None:
		params += [(u"--min-bandwidth", u"real_4", options.min_bandwidth)]
	if options.max_bandwidth is not None:
		params += [(u"--max-bandwidth", u"real_4", options.max_bandwidth)]
	if options.min_central_freq is not None:
		params += [(u"--min-central-freq", u"real_4", options.min_central_freq)]
	if options.max_central_freq is not None:
		params += [(u"--max-central-freq", u"real_4", options.max_central_freq)]
	if options.min_confidence is not None:
		params += [(u"--min-confidence", u"real_4", options.min_confidence)]
	if options.max_confidence is not None:
		params += [(u"--max-confidence", u"real_4", options.max_confidence)]
	if options.min_duration is not None:
		params += [(u"--min-duration", u"real_4", options.min_duration)]
	if options.max_duration is not None:
		params += [(u"--max-duration", u"real_4", options.max_duration)]
	if options.min_fhigh is not None:
		params += [(u"--min-fhigh", u"real_4", options.min_fhigh)]
	if options.max_fhigh is not None:
		params += [(u"--max-fhigh", u"real_4", options.max_fhigh)]
	if options.min_flow is not None:
		params += [(u"--min-flow", u"real_4", options.min_flow)]
	if options.max_flow is not None:
		params += [(u"--max-flow", u"real_4", options.max_flow)]
	if options.min_hrss is not None:
		params += [(u"--min-hrss", u"real_4", options.min_hrss)]
	if options.max_hrss is not None:
		params += [(u"--max-hrss", u"real_4", options.max_hrss)]
	for instrument in options.cut_instrument:
		params += [(u"--cut-instrument", u"lstring", instrument)]
	if options.min_peak_time is not None:
		params += [(u"--min-peak-time", u"lstring", options.min_peak_time)]
	if options.max_peak_time is not None:
		params += [(u"--max-peak-time", u"lstring", options.max_peak_time)]
	if options.min_snr is not None:
		params += [(u"--min-snr", u"real_4", options.min_snr)]
	if options.max_snr is not None:
		params += [(u"--max-snr", u"real_4", options.max_snr)]
	if options.min_start_time is not None:
		params += [(u"--min-start-time", u"lstring", options.min_start_time)]
	if options.max_start_time is not None:
		params += [(u"--max-start-time", u"lstring", options.max_start_time)]
	if options.min_stop_time is not None:
		params += [(u"--min-stop-time", u"lstring", options.min_stop_time)]
	if options.max_stop_time is not None:
		params += [(u"--max-stop-time", u"lstring", options.max_stop_time)]
	if options.program:
		params += [(u"--program", u"lstring", options.program)]
	if options.veto_file:
		params += [(u"--veto-file", u"lstring", options.veto_file)]
	ligolw_process.append_process_params(doc, process, params)

	return process
Beispiel #23
0
def append_process(doc, options):
    process = ligolw_process.append_process(doc,
                                            program=process_program_name,
                                            version=__version__,
                                            cvs_repository=u"lscsoft",
                                            cvs_entry_time=__date__,
                                            comment=options.comment)

    params = []
    if options.coinc_only:
        params += [(u"--coinc-only", None, None)]
    if options.inj_made_only:
        params += [(u"--inj-made-only", None, None)]
    if options.min_amplitude is not None:
        params += [(u"--min-amplitude", u"real_4", options.min_amplitude)]
    if options.max_amplitude is not None:
        params += [(u"--max-amplitude", u"real_4", options.max_amplitude)]
    if options.min_bandwidth is not None:
        params += [(u"--min-bandwidth", u"real_4", options.min_bandwidth)]
    if options.max_bandwidth is not None:
        params += [(u"--max-bandwidth", u"real_4", options.max_bandwidth)]
    if options.min_central_freq is not None:
        params += [(u"--min-central-freq", u"real_4", options.min_central_freq)
                   ]
    if options.max_central_freq is not None:
        params += [(u"--max-central-freq", u"real_4", options.max_central_freq)
                   ]
    if options.min_confidence is not None:
        params += [(u"--min-confidence", u"real_4", options.min_confidence)]
    if options.max_confidence is not None:
        params += [(u"--max-confidence", u"real_4", options.max_confidence)]
    if options.min_duration is not None:
        params += [(u"--min-duration", u"real_4", options.min_duration)]
    if options.max_duration is not None:
        params += [(u"--max-duration", u"real_4", options.max_duration)]
    if options.min_fhigh is not None:
        params += [(u"--min-fhigh", u"real_4", options.min_fhigh)]
    if options.max_fhigh is not None:
        params += [(u"--max-fhigh", u"real_4", options.max_fhigh)]
    if options.min_flow is not None:
        params += [(u"--min-flow", u"real_4", options.min_flow)]
    if options.max_flow is not None:
        params += [(u"--max-flow", u"real_4", options.max_flow)]
    if options.min_hrss is not None:
        params += [(u"--min-hrss", u"real_4", options.min_hrss)]
    if options.max_hrss is not None:
        params += [(u"--max-hrss", u"real_4", options.max_hrss)]
    for instrument in options.cut_instrument:
        params += [(u"--cut-instrument", u"lstring", instrument)]
    if options.min_peak_time is not None:
        params += [(u"--min-peak-time", u"lstring", options.min_peak_time)]
    if options.max_peak_time is not None:
        params += [(u"--max-peak-time", u"lstring", options.max_peak_time)]
    if options.min_snr is not None:
        params += [(u"--min-snr", u"real_4", options.min_snr)]
    if options.max_snr is not None:
        params += [(u"--max-snr", u"real_4", options.max_snr)]
    if options.min_start_time is not None:
        params += [(u"--min-start-time", u"lstring", options.min_start_time)]
    if options.max_start_time is not None:
        params += [(u"--max-start-time", u"lstring", options.max_start_time)]
    if options.min_stop_time is not None:
        params += [(u"--min-stop-time", u"lstring", options.min_stop_time)]
    if options.max_stop_time is not None:
        params += [(u"--max-stop-time", u"lstring", options.max_stop_time)]
    if options.program:
        params += [(u"--program", u"lstring", options.program)]
    if options.veto_file:
        params += [(u"--veto-file", u"lstring", options.veto_file)]
    ligolw_process.append_process_params(doc, process, params)

    return process
     np.array([[area, frac_area]]), np.array([[match_cntr, match_cntr]])))
# If clusters get upgraded, add this header to output:
#   header='grid center; 2x2 effective Fisher matrix, 4rd row: ellipsoid axes, 5th row: total ellipse area, estimated physical area'
if opts.save_ellipsoid_data:
    np.savetxt('ellipsoid.dat', test)

# Convert to m1, m2
m1m2_grid = np.array([
    lsu.m1m2(cart_grid[i][0], cart_grid[i][1]) for i in xrange(len(cart_grid))
])
m1m2_grid /= lal.MSUN_SI

if opts.mass_points_xml:
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    procrow = process.append_process(xmldoc, program=sys.argv[0])
    procid = procrow.process_id
    process.append_process_params(
        xmldoc, procrow, process.process_params_from_dict(opts.__dict__))

    sim_insp_tbl = lsctables.New(lsctables.SimInspiralTable, [
        "simulation_id", "process_id", "numrel_data", "mass1", "mass2", "psi0",
        "psi3"
    ])
    for itr, (m1, m2) in enumerate(m1m2_grid):
        for l1 in np.linspace(common_cl.param_limits["lam_tilde"][0],
                              common_cl.param_limits["lam_tilde"][1], Nlam):
            sim_insp = sim_insp_tbl.RowType()
            sim_insp.numrel_data = "MASS_SET_%d" % itr
            sim_insp.simulation_id = ilwd.ilwdchar(
                "sim_inspiral:sim_inspiral_id:%d" % itr)
Beispiel #25
0
def fake_trigger_generator(instrument='H1'):
    """
    Generate fake trigger maps.

    Parameters
    ----------
    instrument : str
      Instrument name
    """
    xmldoc = ligolw.Document()
    xmldoc.appendChild(ligolw.LIGO_LW())
    # Process information
    proc = process.append_process(xmldoc, "fake_search")
    process.append_process_params(xmldoc, proc, {})
    t0 = 1e9
    ntrig = 1000
    ifo = instrument
    inseg = segment(LIGOTimeGPS(t0), LIGOTimeGPS(t0 + ntrig / 10))
    outseg = segment(LIGOTimeGPS(t0), LIGOTimeGPS(t0 + ntrig / 10))
    # Search summary
    search_summary.append_search_summary(xmldoc,
                                         proc,
                                         comment="Fake triggers",
                                         ifos=(ifo, ),
                                         inseg=inseg,
                                         outseg=outseg)
    columns = [
        'chisq_dof', 'bandwidth', 'central_freq', 'confidence', 'peak_time_ns',
        'start_time', 'process_id', 'fhigh', 'stop_time_ns', 'channel', 'ifo',
        'duration', 'event_id', 'hrss', 'stop_time', 'peak_time', 'snr',
        'search', 'start_time_ns', 'flow', 'amplitude'
    ]
    table = lsctables.New(lsctables.SnglBurstTable, columns)
    # Generate uniformly distributed trigger times with approximate rate of 10 s
    times = t0 + uniform.rvs(0, ntrig / 10., ntrig)
    for t in times:
        row = table.RowType()
        # time frequency position and extent
        row.chisq_dof = int(2 + expon.rvs(2))
        row.duration = 1. / 2**int(uniform.rvs(0, 7))
        row.bandwidth = row.chisq_dof / row.duration / 2

        row.central_freq = uniform.rvs(16, 2048)
        row.flow = max(row.central_freq - row.bandwidth, 0)
        row.fhigh = min(row.central_freq + row.bandwidth, 2048)

        ns, sec = math.modf(t)
        ns = int("%09d" % (ns * 1e9))
        row.peak_time, row.peak_time_ns = int(sec), ns

        ns, sec = math.modf(t - row.duration / 2)
        ns = int("%09d" % (ns * 1e9))
        row.start_time, row.start_time_ns = int(sec), ns

        ns, sec = math.modf(t + row.duration / 2)
        ns = int("%09d" % (ns * 1e9))
        row.stop_time, row.stop_time_ns = int(sec), ns

        # TODO: Correlate some triggers, an upward fluctuation often triggers a few
        # tiles ontop of each other

        # SNR and confidence
        row.snr = 5.
        while row.snr < 2 * row.chisq_dof:
            row.snr = chi2.rvs(row.chisq_dof)
        row.confidence = chi2.sf(row.snr, row.chisq_dof)
        row.snr = math.sqrt(row.snr / row.chisq_dof - 1)
        row.hrss = row.amplitude = 1e-21

        # metadata
        row.search = "fake_search"
        row.channel = "FAKE"
        row.ifo = ifo

        row.event_id = table.get_next_id()
        row.process_id = proc.process_id

        table.append(row)

    xmldoc.childNodes[0].appendChild(table)

    utils.write_filename(xmldoc,
                         "%s-FAKE_SEARCH-%d-%d.xml.gz" % (ifo, int(t0), 10000),
                         gz=True)