示例#1
0
    def test_resample_grid(self):
        minlon = 168
        maxlon = 170
        minlat = -46
        maxlat = -43
        mindepth = 4
        maxdepth = 10
        stations, allnodes, alllags = _read_tt(path=self.testing_path,
                                               stations=['COSA'],
                                               phase='S',
                                               phaseout='S')
        corners = [(minlon, minlat), (maxlon, minlat), (maxlon, maxlat),
                   (minlon, maxlat)]
        corners = path.Path(corners, closed=True)
        stations, nodes, lags = _resample_grid(stations,
                                               allnodes,
                                               alllags,
                                               mindepth=mindepth,
                                               maxdepth=maxdepth,
                                               corners=corners)
        for node in nodes:
            self.assertTrue(minlon < node[0] < maxlon)
            self.assertTrue(minlat < node[1] < maxlat)
            self.assertTrue(mindepth < node[2] < maxdepth)

        for node in allnodes:
            if node not in nodes:
                self.assertFalse((minlon < node[0] < maxlon)
                                 and (minlat < node[1] < maxlat)
                                 and (mindepth < node[2] < maxdepth))
示例#2
0
    def test_resample_grid(self):
        from eqcorrscan.core.bright_lights import _read_tt, _resample_grid
        from matplotlib import path
        import os

        minlon = 168
        maxlon = 170
        minlat = -46
        maxlat = -43
        mindepth = 4
        maxdepth = 10
        testing_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'test_data') + os.sep
        stations, allnodes, alllags = _read_tt(path=testing_path,
                                               stations=['COSA'],
                                               phase='S', phaseout='S')
        corners = [(minlon, minlat),
                   (maxlon, minlat),
                   (maxlon, maxlat),
                   (minlon, maxlat)]
        corners = path.Path(corners, closed=True)
        stations, nodes, lags = _resample_grid(stations, allnodes, alllags,
                                               mindepth=mindepth,
                                               maxdepth=maxdepth,
                                               corners=corners)
        for node in nodes:
            self.assertTrue(minlon < node[0] < maxlon)
            self.assertTrue(minlat < node[1] < maxlat)
            self.assertTrue(mindepth < node[2] < maxdepth)

        for node in allnodes:
            if node not in nodes:
                self.assertFalse((minlon < node[0] < maxlon) and
                                 (minlat < node[1] < maxlat) and
                                 (mindepth < node[2] < maxdepth))
示例#3
0
    def test_resample_grid(self):
        from eqcorrscan.core.bright_lights import _read_tt, _resample_grid
        from matplotlib import path
        import os

        minlon = 168
        maxlon = 170
        minlat = -46
        maxlat = -43
        mindepth = 4
        maxdepth = 10
        testing_path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'test_data') + os.sep
        stations, allnodes, alllags = _read_tt(path=testing_path,
                                               stations=['COSA'],
                                               phase='S',
                                               phaseout='S')
        corners = [(minlon, minlat), (maxlon, minlat), (maxlon, maxlat),
                   (minlon, maxlat)]
        corners = path.Path(corners, closed=True)
        stations, nodes, lags = _resample_grid(stations,
                                               allnodes,
                                               alllags,
                                               mindepth=mindepth,
                                               maxdepth=maxdepth,
                                               corners=corners)
        for node in nodes:
            self.assertTrue(minlon < node[0] < maxlon)
            self.assertTrue(minlat < node[1] < maxlat)
            self.assertTrue(mindepth < node[2] < maxdepth)

        for node in allnodes:
            if node not in nodes:
                self.assertFalse((minlon < node[0] < maxlon)
                                 and (minlat < node[1] < maxlat)
                                 and (mindepth < node[2] < maxdepth))
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!
示例#5
0
## First read in the travel times
print 'Reading in the original grids'
stations, allnodes, alltravel_times = \
           bright_lights._read_tt(brightdef.nllpath,brightdef.stations,\
                                   brightdef.phase, phaseout='S', \
                                   ps_ratio=brightdef.ps_ratio, lags_switch=False)
print 'I have read in '+str(len(allnodes))+' nodes'

# We now have a grid of travel-times which can then be used to generate synthetic\
# seismograms using the utils.synth_seis functions.

# We should trim the grid to the area we want to work in
print 'Cutting the grid'
stations, nodes, travel_times = bright_lights._resample_grid(stations, allnodes,
                                                    alltravel_times,
                                                    brightdef.mindepth,
                                                    brightdef.maxdepth,
                                                    brightdef.corners,
                                                    brightdef.resolution)
del allnodes, alltravel_times
# Check that we still have a grid!
if len(nodes) == 0:
   raise IOError("You have no nodes left")

# Call the template generation function - generate at 100 Hz then downsample
synth_templates=synth_seis.template_grid(stations, nodes, travel_times, 'S', \
       PS_ratio=brightdef.ps_ratio, samp_rate=100,\
       flength=int(100*templatedef.length), \
                                         phaseout=template_phaseout)
print 'We have '+str(len(synth_templates))+' synthetic templates'

# Write out the synthetics!