Beispiel #1
0
    templatename = str(sys.argv[1])
    from par import match_filter_par as defaults
    from par import template_gen_par as tempdef
    from par import bright_lights_par as brightdef
    from obspy import read
    from core.bright_lights import _read_tt, _resample_grid

    template = read(templatename)
    stations_in = []
    for tr in template:
        stations_in += [tr.stats.station]
    stations_in = list(set(stations_in))
    stations, nodes, lags = _read_tt(
        brightdef.nllpath, stations_in, brightdef.phase, phaseout="S", ps_ratio=brightdef.ps_ratio
    )
    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)
Beispiel #2
0
print '     length: ' + str(templatedef.length) + ' s'
print '     swin: ' + templatedef.swin + '\n'

if not oldnodes:
    # 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, phaseout='S', \
                                    ps_ratio=brightdef.ps_ratio)
    print 'I have read in ' + str(len(allnodes)) + ' nodes'
    # 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.mindepth, brightdef.maxdepth,
        brightdef.corners, brightdef.resolution)
    del allnodes, alllags
    # Check that we still have a grid!
    if len(nodes) == 0:
        raise IOError("You have no nodes left")
    # 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, save=brightdef.plotsave, savefile='Nodes_in.png')
    # Call the main function!

    fnodesin = open('Nodes_in.csv', 'w')
Beispiel #3
0
                path = os.path.dirname(os.path.abspath(__file__))
                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")
print '     swin: '+templatedef.swin+'\n'

if not oldnodes:
    # 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, phaseout='S', \
                                    ps_ratio=brightdef.ps_ratio)
    print 'I have read in '+str(len(allnodes))+' nodes'
    # 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.mindepth,
                                                         brightdef.maxdepth,
                                                         brightdef.corners,
                                                         brightdef.resolution)
    del allnodes, alllags
    # Check that we still have a grid!
    if len(nodes) == 0:
        raise IOError("You have no nodes left")
    # 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, save=brightdef.plotsave, savefile='Nodes_in.png')
    # Call the main function!
     raise IOError("Needs one argument, the template to check")
 templatename = str(sys.argv[1])
 from par import match_filter_par as defaults
 from par import template_gen_par as tempdef
 from par import bright_lights_par as brightdef
 from obspy import read
 from core.bright_lights import _read_tt, _resample_grid
 template = read(templatename)
 stations_in = []
 for tr in template:
     stations_in += [tr.stats.station]
 stations_in = list(set(stations_in))
 stations, nodes, lags = _read_tt(brightdef.nllpath,stations_in,\
                                 brightdef.phase, phaseout='S', \
                                 ps_ratio=brightdef.ps_ratio)
 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)