Beispiel #1
0
def get_segments(connection,
                 xmldoc,
                 table_name,
                 live_time_program,
                 veto_segments_name=None,
                 data_segments_name="datasegments"):
    segs = segments.segmentlistdict()

    if table_name == dbtables.lsctables.CoincInspiralTable.tableName:
        if live_time_program == "gstlal_inspiral":
            segs = ligolw_segments.segmenttable_get_by_name(
                xmldoc, data_segments_name).coalesce()
            segs &= ligolw_search_summary.segmentlistdict_fromsearchsummary(
                xmldoc, live_time_program).coalesce()
        elif live_time_program == "thinca":
            segs = db_thinca_rings.get_thinca_zero_lag_segments(
                connection, program_name=live_time_program).coalesce()
        else:
            raise ValueError(
                "for burst tables livetime program must be one of gstlal_inspiral, thinca"
            )
        if veto_segments_name is not None:
            veto_segs = db_thinca_rings.get_veto_segments(
                connection, veto_segments_name)
            segs -= veto_segs
        return segs
    elif table_name == dbtables.lsctables.CoincRingdownTable.tableName:
        segs = ligolw_search_summary.segmentlistdict_fromsearchsummary(
            xmldoc, live_time_program).coalesce()
        if veto_segments_name is not None:
            veto_segs = ligolw_segments.segmenttable_get_by_name(
                xmldoc, veto_segments_name).coalesce()
            segs -= veto_segs
        return segs
    elif table_name == dbtables.lsctables.MultiBurstTable.tableName:
        if live_time_program == "omega_to_coinc":
            segs = ligolw_search_summary.segmentlistdict_fromsearchsummary(
                xmldoc, live_time_program).coalesce()
            if veto_segments_name is not None:
                veto_segs = ligolw_segments.segmenttable_get_by_name(
                    xmldoc, veto_segments_name).coalesce()
                segs -= veto_segs
        elif live_time_program == "waveburst":
            segs = db_thinca_rings.get_thinca_zero_lag_segments(
                connection, program_name=live_time_program).coalesce()
            if veto_segments_name is not None:
                veto_segs = db_thinca_rings.get_veto_segments(
                    connection, veto_segments_name)
                segs -= veto_segs
        else:
            raise ValueError(
                "for burst tables livetime program must be one of omega_to_coinc, waveburst"
            )
        return segs
    else:
        raise ValueError("table must be in " +
                         " ".join(allowed_analysis_table_names()))
Beispiel #2
0
def get_veto_segments(connection, program_name, xmldoc=None, veto_segments_name=None):
	veto_segments = segments.segmentlistdict()
	#FIXME only handles thinca case
	if not veto_segments_name: return veto_segments
	if program_name == "thinca": veto_segments = db_thinca_rings.get_veto_segments(connection, veto_segments_name)
	if program_name == "rinca": veto_segments = ligolw_segments.segmenttable_get_by_name(xmldoc, veto_segments_name).coalesce()
	return veto_segments
 def get_veto_segments(self, connection):
     if self.coinc_inspiral_table:
         if self.opts.veto_segments_name is not None:
             return db_thinca_rings.get_veto_segments(connection, opts.self.veto_segments_name)
         # FIXME BURST CASE VETOS NOT HANDLED
     else:
         return segments.segmentlistdict()
 def get_veto_segments(self, connection):
     if self.coinc_inspiral_table:
         if self.opts.veto_segments_name is not None:
             return db_thinca_rings.get_veto_segments(
                 connection, opts.self.veto_segments_name)
     # FIXME BURST CASE VETOS NOT HANDLED
     else:
         return segments.segmentlistdict()
Beispiel #5
0
def get_vetoes(fname, veto_segments_name = "vetoes", verbose=True):
  working_filename = dbtables.get_connection_filename(fname, verbose = verbose)
  connection = sqlite3.connect(working_filename)
  dbtables.DBTable_set_connection(connection)
  veto_segments = db_thinca_rings.get_veto_segments(connection, veto_segments_name)
  connection.close()
  dbtables.discard_connection_filename(fname, working_filename, verbose = verbose)
  dbtables.DBTable_set_connection(None)
  return veto_segments
Beispiel #6
0
def get_vetoes(fname, veto_segments_name="vetoes", verbose=True):
    working_filename = dbtables.get_connection_filename(fname, verbose=verbose)
    connection = sqlite3.connect(working_filename)
    dbtables.DBTable_set_connection(connection)
    veto_segments = db_thinca_rings.get_veto_segments(connection,
                                                      veto_segments_name)
    connection.close()
    dbtables.discard_connection_filename(fname,
                                         working_filename,
                                         verbose=verbose)
    dbtables.DBTable_set_connection(None)
    return veto_segments
def get_segments(connection, xmldoc, table_name, live_time_program, veto_segments_name = None, data_segments_name = "datasegments"):
	from pylal import db_thinca_rings
	segs = segments.segmentlistdict()

	if table_name == dbtables.lsctables.CoincInspiralTable.tableName:
		if live_time_program == "gstlal_inspiral":
			segs = ligolw_segments.segmenttable_get_by_name(xmldoc, data_segments_name).coalesce()
			segs &= ligolw_search_summary.segmentlistdict_fromsearchsummary(xmldoc, live_time_program).coalesce()
		elif live_time_program == "thinca":
			segs = db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name = live_time_program).coalesce()
		else:
			raise ValueError("for burst tables livetime program must be one of gstlal_inspiral, thinca")
		if veto_segments_name is not None:
			veto_segs = db_thinca_rings.get_veto_segments(connection, veto_segments_name)
			segs -= veto_segs
		return segs
	elif table_name == dbtables.lsctables.CoincRingdownTable.tableName:
		segs = ligolw_search_summary.segmentlistdict_fromsearchsummary(xmldoc, live_time_program).coalesce()
		if veto_segments_name is not None:
			veto_segs = ligolw_segments.segmenttable_get_by_name(xmldoc, veto_segments_name).coalesce()
			segs -= veto_segs
		return segs
	elif table_name == dbtables.lsctables.MultiBurstTable.tableName:
		if live_time_program == "omega_to_coinc":
			segs = ligolw_search_summary.segmentlistdict_fromsearchsummary(xmldoc, live_time_program).coalesce()
			if veto_segments_name is not None:
				veto_segs = ligolw_segments.segmenttable_get_by_name(xmldoc, veto_segments_name).coalesce()
				segs -= veto_segs
		elif live_time_program == "waveburst":
			segs = db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name = live_time_program).coalesce()
			if veto_segments_name is not None:
				veto_segs = db_thinca_rings.get_veto_segments(connection, veto_segments_name)
				segs -= veto_segs
		else:
			raise ValueError("for burst tables livetime program must be one of omega_to_coinc, waveburst")
		return segs
	else:
		raise ValueError("table must be in " + " ".join(allowed_analysis_table_names()))
Beispiel #8
0
  def __init__(self, flist, opts):
    self.far = {}
    self.segments = segments.segmentlistdict()
    self.non_inj_fnames = []
    self.inj_fnames = []
    #self.der_fit = None
    self.twoDMassBins = None
    #self.dBin = {}
    self.gw = None
    self.found = {}
    self.missed = {}
    self.wnfunc = None
    self.opts = opts
    if opts.bootstrap_iterations: self.bootnum = int(opts.bootstrap_iterations)
    else: self.bootnum = 100
    self.veto_segments = segments.segmentlistdict()
    self.zero_lag_segments = {}
    self.instruments = []
    self.livetime = {}
    self.minmass = None
    self.maxmass = None
    self.mintotal = None
    self.maxtotal = None

    for f in flist: 
      if opts.verbose: print >> sys.stderr, "Gathering stats from: %s...." % (f,)
      working_filename = dbtables.get_connection_filename(f, verbose = opts.verbose)
      connection = sqlite3.connect(working_filename)
      dbtables.DBTable_set_connection(connection)
      xmldoc = dbtables.get_xml(connection)

      # look for a sim table
      try:
        sim_inspiral_table = table.get_table(xmldoc, dbtables.lsctables.SimInspiralTable.tableName)
        self.inj_fnames.append(f)
        sim = True
      except ValueError:
        self.non_inj_fnames.append(f)
        sim = False

      if not sim: 
        if opts.veto_segments_name is not None: self.veto_segments = db_thinca_rings.get_veto_segments(connection, opts.veto_segments_name)
        self.get_instruments(connection)
        self.segments += db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name = opts.live_time_program)
        self.get_far_thresholds(connection)
      else: 
        self.get_mass_ranges(connection)
      

      #connection.close()
      dbtables.discard_connection_filename(f, working_filename, verbose = opts.verbose)
      dbtables.DBTable_set_connection(None)      

    # FIXME Do these have to be done by instruments?
    self.segments -= self.veto_segments

    # compute far, segments and livetime by instruments
    for i in self.instruments:
      self.far[i] = min(self.far[i])
      # FIXME this bombs if any of the FARS are zero. maybe it should continue
      # and just remove that instrument combo from the calculation
      if self.far[i] == 0: 
        print >> sys.stderr, "Encountered 0 FAR in %s, ABORTING" % (i,)
        sys.exit(1)
      self.zero_lag_segments[i] = self.segments.intersection(i) - self.segments.union(set(self.segments.keys()) - i)
      # Livetime must have playground removed
      self.livetime[i] = float(abs(self.zero_lag_segments[i] - segmentsUtils.S2playground(self.segments.extent_all())))
      if opts.verbose: print >> sys.stderr, "%s FAR %e, livetime %f" % (",".join(sorted(list(i))), self.far[i], self.livetime[i])

    # get a 2D mass binning
    self.twoDMassBins = self.get_2d_mass_bins(self.minmass, self.maxmass, opts.mass_bins)
Beispiel #9
0
max_dist = 2000
min_mass = 1
max_mass = 99
min_mtotal = 25
max_mtotal = 100
mass_bins = 11
dist_bins = 50


opts, filenames = parse_command_line()

if opts.veto_segments_name is not None:
  working_filename = dbtables.get_connection_filename(opts.full_data_file, verbose = opts.verbose)
  connection = sqlite3.connect(working_filename)
  dbtables.DBTable_set_connection(connection)
  veto_segments = db_thinca_rings.get_veto_segments(connection, opts.veto_segments_name)
  connection.close()
  dbtables.discard_connection_filename(opts.full_data_file, working_filename, verbose = opts.verbose)
  dbtables.DBTable_set_connection(None)
else:
  veto_segments = segments.segmentlistdict()

if not opts.burst_found and not opts.burst_missed:
  FAR, seglists = get_far_threshold_and_segments(opts.full_data_file, opts.live_time_program, instruments=lsctables.ifos_from_instrument_set(opts.instruments),verbose = opts.verbose)


  # times when only exactly the required instruments are on
  seglists -= veto_segments
  zero_lag_segments = seglists.intersection(opts.instruments) - seglists.union(set(seglists.keys()) - opts.instruments)

  live_time = float(abs(zero_lag_segments))
Beispiel #10
0
max_dist = 2000
min_mass = 1
max_mass = 99
min_mtotal = 25
max_mtotal = 100
mass_bins = 11
dist_bins = 50

opts, filenames = parse_command_line()

if opts.veto_segments_name is not None:
    working_filename = dbtables.get_connection_filename(opts.full_data_file,
                                                        verbose=opts.verbose)
    connection = sqlite3.connect(working_filename)
    dbtables.DBTable_set_connection(connection)
    veto_segments = db_thinca_rings.get_veto_segments(connection,
                                                      opts.veto_segments_name)
    connection.close()
    dbtables.discard_connection_filename(opts.full_data_file,
                                         working_filename,
                                         verbose=opts.verbose)
    dbtables.DBTable_set_connection(None)
else:
    veto_segments = segments.segmentlistdict()

if not opts.burst_found and not opts.burst_missed:
    FAR, seglists = get_far_threshold_and_segments(
        opts.full_data_file,
        opts.live_time_program,
        instruments=lsctables.ifos_from_instrument_set(opts.instruments),
        verbose=opts.verbose)