# # choose noise model # if opts.reference_psd is not None: if opts.reference_psd.endswith(".txt") or opts.reference_psd.endswith( ".txt.gz") or opts.reference_psd.endswith(".dat"): # assume psd file is a two-column ASCII formatted file data = np.loadtxt(opts.reference_psd) f_orig, psddata = data[:, 0], data[:, 1] elif opts.reference_psd.endswith(".xml") or opts.reference_psd.endswith( ".xml.gz"): # assume psd file is formatted as a LIGOLW XML psddict = read_psd(opts.reference_psd) if opts.instrument: psd = psddict[opts.instrument] elif len(psddict.keys()) == 1: psd = psddict[psddict.keys()[0]] else: raise ValueError( "More than one PSD found in file %s. Specify which you want with --instrument." % opts.reference_psd) f_orig = psd.f0 + np.arange(len(psd.data.data)) * psd.deltaF psddata = psd.data.data # cut off upper frequency content as requested by user for better # computational performance f_max_orig = max(f_orig) if opts.fhigh_max:
parser.add_option("--cache-waveforms", default = False, action="store_true", help="A given waveform in the template bank will be used many times throughout the bank simulation process. You can save a considerable amount of CPU by caching the waveform from the first time it is generated; however, do so only if you are sure that storing the waveforms in memory will not overload the system memory.") parser.add_option("--neighborhood-size", metavar="N", default = 1.0, type="float", help="Specify the window size in seconds to define \"nearby\" templates used to compute the match against each injection. The neighborhood is chosen symmetric about the injection; \"nearby\" is defined using the option --neighborhood-type. The default value of 1.0 is *not a guarantee of performance*. Choosing the neighborhood too small may lead to the reporting of lower-than-actual fitting factors.") parser.add_option("--neighborhood-param", default="tau0", choices=["tau0", "dur"], help="Choose how the neighborhood is sorted for match calculations.") opts, args = parser.parse_args() if opts.reference_psd and not opts.instrument: raise ValueError, "--instrument is a required option when specifying reference PSD" return opts, args opts, args = parse_command_line() # Choose noise model if opts.reference_psd is not None: psd = read_psd(opts.reference_psd)[opts.instrument] f_orig = psd.f0 + np.arange(len(psd.data.data)) * psd.deltaF interpolator = UnivariateSpline(f_orig, np.log(psd.data.data), s=0) noise_model = lambda g: np.exp(interpolator(g)) else: noise_model = noise_models[opts.noise_model] usertag = opts.user_tag # use to label output inj_file = opts.injection_file # pre-sorted by mchirp inj_approx = waveforms[opts.injection_approx] flow = opts.flow verbose = opts.verbose if opts.use_gpu_match: from lalinspiral.sbank.overlap_cuda import compute_match, create_workspace_cache import sbank.waveforms import sbank.bank
edge_list = igraph.Graph.Full(numTemplates) print "Writing .ncol of graph edges..." # This writes an edge list! edge_list.write("./edge_lists/edge_list_%s.ncol" % str(numTemplates), format='ncol') # This loads the edge list from the exported file # of the form: # [[0,1], [0, 2]... [2,3], [3,4]] print "Loading edge list..." edge_array = np.loadtxt("./edge_lists/edge_list_%s.ncol" % str(numTemplates)) edge_array = edge_array[generateFrom:generateTo] # Read in PSD and make it usable print "Reading PSD..." psd = read_psd('H1L1V1-REFERENCE_PSD-966386126-24805.xml.gz')['H1'] print "Preparing PSD..." f_orig = psd.f0 + np.arange(len(psd.data)) * psd.deltaF f_max_orig = max(f_orig) interpolator = UnivariateSpline(f_orig, np.log(psd.data), s=0) noise_model = lambda g: np.where(g < f_max_orig, np.exp(interpolator(g)), np.inf) PSD = get_PSD(1. / duration, f_low, f_high, noise_model) # Generate ASD print "Generating ASD" ASD = np.sqrt(PSD) print "Creating workspace..." # Create workspace for match calculation workspace_cache = CreateSBankWorkspaceCache()
fout = opts.output_filename elif opts.user_tag: fout = "%s-SBANK_%s-%d-%d.xml.gz" % (opts.instrument, opts.user_tag, opts.gps_start_time, opts.gps_end_time-opts.gps_start_time) else: fout = "%s-SBANK-%d-%d.xml.gz" % (opts.instrument, opts.gps_start_time, opts.gps_end_time-opts.gps_start_time) # # choose waveform approximant # tmplt_class = waveforms[opts.approximant] # # choose noise model # if opts.reference_psd is not None: psd = read_psd(opts.reference_psd)[opts.instrument] f_orig = psd.f0 + np.arange(len(psd.data.data)) * psd.deltaF f_max_orig = max(f_orig) if opts.fhigh_max: if opts.fhigh_max > f_max_orig: print >> sys.stderr, "Warning: requested fhigh-max (%.3f Hz) exceeds limits of PSD (%.3f Hz). Using PSD limit instead!" \ % (opts.fhigh_max, f_max_orig) opts.fhigh_max = float(f_max_orig) else: print >> sys.stderr, "Warning: fhigh-max not specified, using maximum frequency in the PSD (%.3f Hz)" \ % f_max_orig opts.fhigh_max = float(f_max_orig) interpolator = UnivariateSpline(f_orig, np.log(psd.data.data), s=0) # spline extrapolation may lead to unexpected results,
# tmplt_class = waveforms[opts.approximant] # # choose noise model # if opts.reference_psd is not None: if opts.reference_psd.endswith(".txt") or opts.reference_psd.endswith(".txt.gz") or opts.reference_psd.endswith(".dat"): # assume psd file is a two-column ASCII formatted file data = np.loadtxt(opts.reference_psd) f_orig, psddata = data[:,0], data[:,1] elif opts.reference_psd.endswith(".xml") or opts.reference_psd.endswith(".xml.gz"): # assume psd file is formatted as a LIGOLW XML psddict = read_psd(opts.reference_psd) if opts.instrument: psd = psddict[opts.instrument] elif len(psddict.keys()) == 1: psd = psddict[psddict.keys()[0]] else: raise ValueError("More than one PSD found in file %s. Specify which you want with --instrument." % opts.reference_psd) f_orig = psd.f0 + np.arange(len(psd.data.data)) * psd.deltaF psddata = psd.data.data # cut off upper frequency content as requested by user for better # computational performance f_max_orig = max(f_orig) if opts.fhigh_max: if opts.fhigh_max > f_max_orig: print >> sys.stderr, "Warning: requested fhigh-max (%.3f Hz) exceeds limits of PSD (%.3f Hz). Using PSD limit instead!" \