Skip to content
Snippets Groups Projects

Plot horizon distance from ranking statistics

Merged ChiWai Chan requested to merge plot_psd_horizon into master
1 unresolved thread
1 file
+ 12
4
Compare changes
  • Side-by-side
  • Inline
@@ -49,6 +49,7 @@ import multiprocessing
def parse_command_line():
parser = OptionParser(description = __doc__)
parser.add_option("--reference-psd", metavar = "filename", action = "append", default = [], help = "Set the reference psd file. Can be supplied multiple times.")
parser.add_option("--reference-psd-cache", metavar = "filename", help = "Set the reference psd cache file.")
parser.add_option("--injection-file", metavar = "filename", help = "Set the injection xml file.")
parser.add_option("--flow", metavar = "value", type = "float", help = "Set the low frequency for waveform generation and SNR integral.")
@@ -57,8 +58,10 @@ def parse_command_line():
options, filenames = parser.parse_args()
if options.reference_psd_cache is None:
raise ValueError("Must specify --reference-psd-cache")
if options.reference_psd and options.reference_psd_cache:
raise ValueError("Cannot supply both --reference-psd and --reference-psd-cache")
elif options.reference_psd is None and options.reference_psd_cache is None:
raise ValueError("one of --reference-psd or --reference-psd-cache is required")
if options.injection_file is None:
raise ValueError("Must specify --injection-file")
@@ -137,7 +140,7 @@ def calc_expected_snr(inj):
if instrument not in chosenPSD:
continue
h = lalsimulation.SimDetectorStrainREAL8TimeSeries(h_plus, h_cross, inj.longitude, inj.latitude, inj.polarization, lalsimulation.DetectorPrefixToLALDetector(instrument))
snr[instrument] = lalsimulation.MeasureSNR(h, chosenPSD[instrument], options.flow, options.fmax)
snr[instrument] = lalsimulation.MeasureSNR(h, chosenPSD[instrument], f_min, options.fmax)
return snr
@@ -153,6 +156,11 @@ class LIGOLWContentHandler(ligolw.LIGOLWContentHandler):
options, filenames = parse_command_line()
if options.reference_psd:
reference_psd_cache = [CacheEntry.from_T050017(path) for path in options.reference_psd]
elif options.reference_psd_cache:
reference_psd_cache = list(map(CacheEntry, open(options.reference_psd_cache)))
# Now we need to read in from the sim_inspiral table
xmldoc = ligolw_utils.load_filename(options.injection_file, verbose = True, contenthandler = LIGOLWContentHandler)
sim_inspiral_table = lsctables.SimInspiralTable.get_table(xmldoc)
@@ -164,7 +172,7 @@ else:
# Load all PSDs so that they don't need to be loaded for every injection.
allPSDs = dict(
(cacheentry.segment, read_psd_xmldoc(ligolw_utils.load_url(cacheentry.url, verbose = True, contenthandler = PSDContentHandler)))
for cacheentry in map(CacheEntry, open(options.reference_psd_cache)) if inj_segment is not None and cacheentry.segment.intersects(inj_segment)
for cacheentry in reference_psd_cache if inj_segment is not None and cacheentry.segment.intersects(inj_segment)
)
pool = multiprocessing.Pool(options.npool)
Loading