Exemplo n.º 1
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
Exemplo n.º 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
Exemplo n.º 3
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
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)
Exemplo n.º 5
0
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
Exemplo n.º 6
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
Exemplo n.º 7
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)
Exemplo n.º 8
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
Exemplo n.º 10
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
Exemplo n.º 11
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
Exemplo n.º 12
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
Exemplo n.º 13
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
Exemplo n.º 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
# 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:
        ifos = "".join([o.split("=")[0][0] for o in opts.channel_name])
    else:
Exemplo n.º 16
0
 from glue.ligolw.utils import process
 
 #from pylal.xlal.datatypes.ligotimegps import LIGOTimeGPS
 #formated_cvs_gps = LIGOTimeGPS(proc_cvs_entry_time)
 #from pylal.date import XLALGPSToUTC
 #cvs_time_tuple=XLALGPSToUTC(formated_cvs_gps)
 
 #proc_cvs_entry_time="%d-%d-%d %d:%d:%d +0000" %(cvs_time_tuple[0],cvs_time_tuple[1],cvs_time_tuple[2],cvs_time_tuple[3],cvs_time_tuple[4],cvs_time_tuple[5])
 
 #append_process_gpssane
 #proc_out=process.append_process(doc,program=proc_program,version=proc_version,cvs_repository=proc_cvs_repository,cvs_entry_time=proc_cvs_entry_time,comment=proc_comment,is_online=proc_is_online,jobid=proc_jobid,domain=proc_domain,ifos=proc_ifos)
 proc_out=append_process_gpssane(doc,program=proc_program,version=proc_version,cvs_repository=proc_cvs_repository,cvs_entry_time=proc_cvs_entry_time,comment=proc_comment,is_online=proc_is_online,jobid=proc_jobid,domain=proc_domain,ifos=proc_ifos)
 
 params=process.process_params_from_dict({"start_time": proc_start_time, "end_time": proc_end_time, "creator_db":proc_creator_db, "node":proc_node,"username":proc_username,"unix_procid":proc_unix_procid,"param_set":proc_param_set, "insertion_time":proc_insertion_time})
 
 process_doc_out=process.append_process_params(doc,proc_out,params)
 
 # Now add segment definer to doc 
 # Fix!!! Why didn't I just call segmentdb_utils.add_to_segment_definer?  This is that code duplicated:
 
 from glue.ligolw import lsctables
 
 seg_def_table = lsctables.New(lsctables.SegmentDefTable,columns = ['segment_def_id', 'process_id','ifos','name', 'version','comment'])
 # adds this table to the doc:
 doc.childNodes[0].appendChild(seg_def_table)
 
 # creates (local) table data container to be appended to table we just made
 segment_definer = lsctables.SegmentDef()
 
 seg_def_id = seg_def_table.get_next_id()
 segment_definer.segment_def_id = seg_def_id
Exemplo n.º 17
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
Exemplo n.º 18
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
#   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
Exemplo n.º 20
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)