def _read_omicron_trigs(omicron_files, span): trigs1 = SnglBurstTable.read(omicron_files[0], format='ligolw') trigs = table.new_from_template(trigs1) for omicron_file in omicron_files: trigs2 = table.new_from_template(trigs1) trigs2 = SnglBurstTable.read(omicron_file, format='ligolw') trigs.extend(filter(lambda row: row.get_peak() in span, trigs2)) times = [] print('%d found' % len(trigs)) times = trigs.get_peak() s = times.size return trigs, times, s
def plot_triggers(params,channel,segment): """plot omicron triggers for given channel and segment. @param params seismon params dictionary @param channel seismon channel structure @param segment [start,end] gps """ gpsStart = segment[0] gpsEnd = segment[1] omicronDirectory = os.path.join(params["path"],"omicron") omicronPath = os.path.join(omicronDirectory,channel.station) omicronXMLs = glob.glob(os.path.join(omicronPath,"*.xml")) table = [] for ii in range(len(omicronXMLs)): tabletmp = SnglBurstTable.read(omicronXMLs[0]) for jj in range(len(tabletmp)): table.append(tabletmp[jj]) if table == []: return peak_times = gwpy.plotter.table.get_table_column(table, "peak_time") central_freqs = gwpy.plotter.table.get_table_column(table, "central_freq") snrs = gwpy.plotter.table.get_table_column(table, "snr") textLocation = params["path"] + "/" + channel.station_underscore seismon.utils.mkdir(textLocation) f = open(os.path.join(textLocation,"triggers.txt"),"w") for peak_time,central_freq,snr in zip(peak_times,central_freqs,snrs): f.write("%.1f %e %e\n"%(peak_time,central_freq,snr)) f.close() if params["doPlots"]: plotLocation = params["path"] + "/" + channel.station_underscore seismon.utils.mkdir(plotLocation) if params["doEarthquakesAnalysis"]: pngFile = os.path.join(plotLocation,"omicron-%d-%d.png"%(gpsStart,gpsEnd)) else: pngFile = os.path.join(plotLocation,"omicron.png") epoch = gwpy.time.Time(gpsStart, format='gps') #plot = gwpy.plotter.EventTablePlot(table, 'time', 'central_freq', 'snr', figsize=[14,8],epoch=gpsStart,size_by_log='snr', size_range=[6, 20],edgecolor='none') plot = table.plot('time', 'central_freq', color='snr', edgecolor='none', epoch=gpsStart) plot.add_colorbar(log=True, clim=[6, 20],label='Signal-to-noise ratio (SNR)') plot.xlim = [gpsStart, gpsEnd] plot.ylabel = 'Frequency [Hz]' plot.ylim = [params["fmin"],params["fmax"]] plot.axes[0].set_yscale("log") plot.save(pngFile) plot.close()
def plot_triggers(filename='excesspower.xml.gz'): events = SnglBurstTable.read(filename) #plot = events.plot('time', 'central_freq', "duration", "bandwidth", color='snr') plot = events.plot('time', 'central_freq', color='snr', edgecolor='none') #plot.set_xlim(time_start,time_end) #plot.set_ylim(band, sample_rate/2.) plot.set_ylabel('Frequency [Hz]') plot.set_yscale('log') #plot.set_title('GNOME '+station+' station event triggers') plot.add_colorbar(cmap='copper_r', label='Tile Energy') pyplot.savefig("triggers.png", dpi=300)
def load_omic_trigs(omicroncachefile, segs): # Read in the Omicron triggers with open(omicroncachefile, 'r') as cachefile: cache = Cache.fromfile(cachefile) omic_trigs = SnglBurstTable.read(cache, verbose=True, filt=lambda x: x.snr <\ 100 and x.peak_frequency < 100) # Check if Omicron triggers have been read in successfully if not omic_trigs: sys.exit("ERROR: No triggers for Omicron channel: %s" % cachefile.split('.')[0]) else: print "%d Omicron triggers read" % len(omic_trigs) #Get the Omicron triggers that lie within the valid segment list omic_trigs = omic_trigs.vetoed(segs) return omic_trigs
gravitational waves, but will help tune the algorithm to improve detection of future, real signals. """ from gwpy import version __author__ = "Duncan Macleod <*****@*****.**>" __version__ = version.version from urllib2 import urlopen from numpy import asarray from gwpy.table.lsctables import SnglBurstTable # read triggers events = SnglBurstTable.read('../gwpy/tests/data/' 'H1-LDAS_STRAIN-968654552-10.xml.gz') # make a plot plot2 = events.plot('time', 'central_freq', 'duration', 'bandwidth', color='snr', epoch=968654552) plot2.set_xlim(968654552, 968654552+10) plot2.set_ylabel('Frequency [Hz]') plot2.set_yscale('log') plot2.set_title('LIGO Hanford Observatory event triggers for GW100916') plot2.add_colorbar(clim=[1, 5], label='Signal-to-noise ratio') if __name__ == '__main__': try: outfile = __file__.replace('.py', '.png') except NameError: pass else:
stretch of data. The data from which these events were generated are a simulation of Gaussian noise with the Advanced LIGO design spectrum, and so don't actually contain any real gravitational waves, but will help tune the algorithm to improve detection of future, real signals. """ from gwpy import version __author__ = "Duncan Macleod <*****@*****.**>" __version__ = version.version from gwpy.table.lsctables import SnglBurstTable # read triggers events = SnglBurstTable.read('../gwpy/tests/data/' 'H1-LDAS_STRAIN-968654552-10.xml.gz') # calculate the event rate rate = events.event_rate(1, start=968654552, end=968654562) # make a plot plot = rate.plot() plot.set_xlim(968654552, 968654562) plot.set_ylabel('Event rate [Hz]') plot.set_title('LIGO Hanford Observatory event rate for GW100916') if __name__ == '__main__': try: outfile = __file__.replace('.py', '.png') except NameError: pass
def plot_triggers(params,channel,segment): """plot omicron triggers for given channel and segment. @param params seismon params dictionary @param channel seismon channel structure @param segment [start,end] gps """ gpsStart = segment[0] gpsEnd = segment[1] omicronDirectory = os.path.join(params["path"],"omicron") omicronPath = os.path.join(omicronDirectory,channel.station) omicronXMLs = glob.glob(os.path.join(omicronPath,"*.xml")) table = [] for ii in xrange(len(omicronXMLs)): tabletmp = SnglBurstTable.read(omicronXMLs[0]) #print tabletmp for jj in xrange(len(tabletmp)): table.append(tabletmp[jj]) #print table #print stop #table = laldetchar.triggers.from_files(omicronXMLs, "omicron") if table == []: return peak_times = gwpy.plotter.table.get_table_column(table, "peak_time") central_freqs = gwpy.plotter.table.get_table_column(table, "central_freq") snrs = gwpy.plotter.table.get_table_column(table, "snr") textLocation = params["path"] + "/" + channel.station_underscore seismon.utils.mkdir(textLocation) f = open(os.path.join(textLocation,"triggers.txt"),"w") for peak_time,central_freq,snr in zip(peak_times,central_freqs,snrs): f.write("%.1f %e %e\n"%(peak_time,central_freq,snr)) f.close() if params["doPlots"]: plotLocation = params["path"] + "/" + channel.station_underscore seismon.utils.mkdir(plotLocation) if params["doEarthquakesAnalysis"]: pngFile = os.path.join(plotLocation,"omicron-%d-%d.png"%(gpsStart,gpsEnd)) else: pngFile = os.path.join(plotLocation,"omicron.png") epoch = gwpy.time.Time(gpsStart, format='gps') #plot = gwpy.plotter.EventTablePlot(table, 'time', 'central_freq', 'snr', figsize=[14,8],epoch=gpsStart,size_by_log='snr', size_range=[6, 20],edgecolor='none') plot = table.plot('time', 'central_freq', color='snr', edgecolor='none', epoch=gpsStart) plot.add_colorbar(log=True, clim=[6, 20],label='Signal-to-noise ratio (SNR)') plot.xlim = [gpsStart, gpsEnd] plot.ylabel = 'Frequency [Hz]' plot.ylim = [params["fmin"],params["fmax"]] plot.axes[0].set_yscale("log") plot.save(pngFile) plot.close() print pngFile print peak_times print gpsStart, gpsEnd print stop
print('Read %d flags from veto definer' % len(vdf.keys())) categories = [1, 2, 3, 4] vdfCats = dict((c, DataQualityDict()) for c in categories) for name, flag in vdf.iteritems(): try: vdfCats[flag.category][name] = flag except KeyError: pass #generate the triggers needed to run vet if analysis == 'omicron': triggers = SnglBurstTable.fetch('%s:GDS-CALIB_STRAIN' % ifo, 'omicron', start, end) else: triggers = SnglBurstTable.read(trigPath, ifo=ifo, format='cwb-ascii') #convert the metrics to a standard notation newMetric = [] for metric in metrics: newMetric.append(get_metric(metric)) order = ['1', '1+4', '1+2+4', '1+2+3+4'] for categories in order: category = categories.split('+') activeVdf = DataQualityFlag('VDFs') for cat in category: for flag in vdfCats[int(cat)]: activeVdf.known += vdf[flag].known activeVdf.active += vdf[flag].active