def get_omicron_triggers(channel, ifo, segments, cachefile): print "Reading channel: %s\n" %channel with open(cachefile, 'r') as f: mycache = Cache.fromfile(f) # Let's try and catch failed reads try: triggers = get_triggers(ifo + ':' + channel, 'sngl_burst', segments,\ cache=mycache) except: print "No Omicron triggers read for channel %s" %channel return None return triggers
# The tag is the name of the channel extracted from the path tag = cachefile.split('/')[-1] tag = tag.split('.')[0] tag = tag.replace('_Omicron','') print ('\n\nReading file: %s now ...\n' % tag) with open(cachefile, 'r') as fobj: cache = Cache.fromfile(fobj) ### read triggers # filter to select for triggers with frequency < 100 #trigs = SnglBurstTable.read(cache, verbose=True, filt=lambda t: t.peak_frequency < 100) #filter to select for triggers with frequency <100 and snr <100 trigs = get_triggers('L1:'+tag, 'sngl_burst', segments, cache=cache) ### check triggers read successfully if not trigs: print(" WARNING: No triggers for channel '%s'." % channel, file=sys.stderr) else: print(' %d triggers read' % len(trigs)) ######## plot triggers and save plot plot = trigs.plot('time', 'snr', edgecolor='none') plot.set_ylabel('Central Frequency [Hz]') plot.set_yscale('log') title = r'L1:'+tag+' triggers'