template = template_dummy for tr in template: for i in xrange(len(stations)): if tr.stats.station == stations[i]: if not "alllags" in locals(): alllags = [lags[i]] else: # print stations[i] alllags = np.concatenate((alllags, [lags[i]]), axis=0) # print np.shape(alllags) lags = alllags print "Lags is shaped: " + str(np.shape(lags)) print "I have " + str(len(template)) + " channels of data" # Indexing will be an issue, currently don't check that stations match between data and lags possible_locations = moveout_check( template, nodes, lags, defaults.threshold, defaults.threshtype, tempdef.lowcut, tempdef.highcut, tempdef.filter_order, ) from utils import EQcorrscan_plotting as plotting if not len(possible_locations) == 0: plotting.threeD_gridplot(possible_locations) else: raise ValueError("No possible location found")
for tr in stream) stream = Stream(stream) print stream if not Prep: #stream_copy=stream.copy() # Keep the stream safe print "Running the detection routine" # Check that the data are okay detect_templates, detect_nodes=bright_lights.brightness(stations, \ nodes, lags, stream, brightdef.threshold, brightdef.thresh_type,\ brightdef.coherance, instance, matchdef, templatedef) del detect_templates #, stream # Delete templates from memory to conserve RAM! #stream=stream_copy nodesout += detect_nodes if Split: plotting.threeD_gridplot(nodesout, save=brightdef.plotsave,\ savefile='Detected_nodes_'+str(instance)+'.png') else: plotting.threeD_gridplot(nodesout, save=brightdef.plotsave,\ savefile='Detected_nodes.png') else: for tr in stream: print "Writing data as: test_data/"+tr.stats.station+'-'+tr.stats.channel+\ '-'+str(tr.stats.starttime.year)+\ '-'+str(tr.stats.starttime.month).zfill(2)+\ '-'+str(tr.stats.starttime.day).zfill(2)+\ '-processed.ms' tr.write('test_data/'+tr.stats.station+'-'+tr.stats.channel+\ '-'+str(tr.stats.starttime.year)+\ '-'+str(tr.stats.starttime.month).zfill(2)+\ '-'+str(tr.stats.starttime.day).zfill(2)+\
sys.path.insert(0,path[0:len(path)-5]) from par import template_gen_par as templatedef from par import bright_lights_par as brightdef from core import bright_lights from utils import EQcorrscan_plotting as plotting # Use the brightness function to search for possible templates # First read in the travel times print 'Reading in the original grids' stations, allnodes, alllags = \ bright_lights._read_tt(brightdef.nllpath,brightdef.stations,\ brightdef.phase) # Resample the grid to allow us to run it quickly! print 'Cutting the grid' stations, nodes, lags = bright_lights._resample_grid(stations, allnodes, alllags, brightdef.volume, brightdef.resolution) # Remove lags that have a similar network moveout, e.g. the sum of the # differences in moveouts is small. print "Removing simlar lags" stations, nodes, lags = bright_lights._rm_similarlags(stations, nodes, lags, brightdef.nodesimthresh) print "Plotting new grid" plotting.threeD_gridplot(nodes) dailycoherence = coherence_test(stream, stations, nodes, lags, \ templatedef.length) else: raise IOError("No traces read in for this day, are they processed?") else: raise IOError("I only know --coherence at the moment")
for tr in stream) stream=Stream(stream) print stream if not Prep: #stream_copy=stream.copy() # Keep the stream safe print "Running the detection routine" # Check that the data are okay detect_templates, detect_nodes=bright_lights.brightness(stations, \ nodes, lags, stream, brightdef.threshold, brightdef.thresh_type,\ brightdef.coherance, instance, matchdef, templatedef) del detect_templates#, stream # Delete templates from memory to conserve RAM! #stream=stream_copy nodesout+=detect_nodes if Split: plotting.threeD_gridplot(nodesout, save=brightdef.plotsave,\ savefile='Detected_nodes_'+str(instance)+'.png') else: plotting.threeD_gridplot(nodesout, save=brightdef.plotsave,\ savefile='Detected_nodes.png') else: for tr in stream: print "Writing data as: test_data/"+tr.stats.station+'-'+tr.stats.channel+\ '-'+str(tr.stats.starttime.year)+\ '-'+str(tr.stats.starttime.month).zfill(2)+\ '-'+str(tr.stats.starttime.day).zfill(2)+\ '-processed.ms' tr.write('test_data/'+tr.stats.station+'-'+tr.stats.channel+\ '-'+str(tr.stats.starttime.year)+\ '-'+str(tr.stats.starttime.month).zfill(2)+\ '-'+str(tr.stats.starttime.day).zfill(2)+\
stations, nodes, lags = _resample_grid(stations, nodes, lags, brightdef.volume,\ brightdef.resolution) # print np.shape(lags) for station in stations: if not 'template_dummy' in locals(): template_dummy = template.select(station=station) else: template_dummy += template.select(station=station) template = template_dummy for tr in template: for i in xrange(len(stations)): if tr.stats.station == stations[i]: if not 'alllags' in locals(): alllags = [lags[i]] else: # print stations[i] alllags = np.concatenate((alllags, [lags[i]]), axis=0) # print np.shape(alllags) lags = alllags print 'Lags is shaped: ' + str(np.shape(lags)) print 'I have ' + str(len(template)) + ' channels of data' # Indexing will be an issue, currently don't check that stations match between data and lags possible_locations = moveout_check(template, nodes, lags, defaults.threshold,\ defaults.threshtype, tempdef.lowcut,\ tempdef.highcut, tempdef.filter_order) from utils import EQcorrscan_plotting as plotting if not len(possible_locations) == 0: plotting.threeD_gridplot(possible_locations) else: raise ValueError("No possible location found")