예제 #1
0
def rtwlStart():
    """
    Starts rtwl. Configuration is read from 'rtwl.config' file.
    """

    config_file = 'rtwl.config'

    # read options into waveloc options objet
    wo = RtWavelocOptions()
    wo.opdict = readConfig(config_file)

    if wo.run_offline:
        # Run in offline mode
        print "Starting rtwl in offline mode"
        import glob, os
        from obspy.core import read

        # read data
        fnames = glob.glob(os.path.join(wo.data_dir, wo.opdict['data_glob']))
        obs_list = []
        for name in fnames:
            st = read(name)
            obs_list.append(st[0])

    else:
        # Run in true real-time mode
        raise NotImplementedError()
예제 #2
0
    def setUp(self):
        import obspy.realtime
        rt_dict = obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
        rt_dict['neg_to_zero'] = (am_rt_signal.neg_to_zero, 0)
        rt_dict['convolve'] = (am_rt_signal.convolve, 1)

        self.wo = RtWavelocOptions()
        self.wo.opdict['base_path'] = 'test_data'
        self.wo.opdict['outdir'] = 'Test'
        self.wo.opdict['time_grid'] = 'Slow_len.100m.P'
        self.wo.opdict['max_length'] = 120
        self.wo.opdict['safety_margin'] = 20
        self.wo.opdict['dt'] = 0.01
        self.wo.opdict['syn'] = True

        self.wo.verifyDirectories()

        # make synthetic data
        self.obs_list, self.ot, (x0, y0, z0) = make_synthetic_data(self.wo)

        self.starttime = self.obs_list[0].stats.starttime
        self.dt = self.obs_list[0].stats.delta

        # split data files to simulate packets of real-time data
        self.obs_split = []
        for obs in self.obs_list:
            obs_split = obs / 3
            self.obs_split.append(obs_split)

        # generate ttimes_files for test
        n_test = 150
        generate_random_test_points(self.wo, n_test, (x0, y0, z0))
예제 #3
0
def rtwlStart():
    """
    Starts rtwl. Configuration is read from 'rtwl.config' file.
    """
   
    
    config_file='rtwl.config'
    
    # read options into waveloc options objet
    wo=RtWavelocOptions()
    wo.opdict=readConfig(config_file)
    
    if wo.run_offline:
        # Run in offline mode
        print "Starting rtwl in offline mode"
        import glob,os
        from obspy.core import read
        
        # read data
        fnames=glob.glob(os.path.join(wo.data_dir, wo.opdict['data_glob']))
        obs_list=[]
        for name in fnames:
            st=read(name)
            obs_list.append(st[0])
    
    
    
    else :
        # Run in true real-time mode
        raise NotImplementedError()
예제 #4
0
    def setUp(self):
        import obspy.realtime
        rt_dict= obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
        rt_dict['neg_to_zero']=(am_rt_signal.neg_to_zero,0)
        rt_dict['convolve']=(am_rt_signal.convolve,1)
        
        self.wo = RtWavelocOptions()
        self.wo.opdict['base_path'] = 'test_data'
        self.wo.opdict['outdir'] = 'Test'
        self.wo.opdict['time_grid'] = 'Slow_len.100m.P'
        self.wo.opdict['max_length'] = 120
        self.wo.opdict['safety_margin'] = 20
        self.wo.opdict['dt'] = 0.01
        self.wo.opdict['syn'] = True

        self.wo.verifyDirectories()

        # make synthetic data
        self.obs_list, self.ot, (x0,y0,z0) = make_synthetic_data(self.wo)

        self.starttime=self.obs_list[0].stats.starttime
        self.dt=self.obs_list[0].stats.delta

        # split data files to simulate packets of real-time data
        self.obs_split=[]
        for obs in self.obs_list:
            obs_split = obs / 3
            self.obs_split.append(obs_split)

        # generate ttimes_files for test
        n_test=150
        generate_random_test_points(self.wo, n_test, (x0, y0, z0))
예제 #5
0
    def setUp(self):
        # set up expected waveloc options
        self.wo = RtWavelocOptions()
        self.wo.opdict['base_path'] = 'test_data'
        self.wo.opdict['outdir'] = 'RealDataTest'
        self.wo.opdict['datadir'] = 'RealDataTest'
        self.wo.opdict['data_glob'] = 'YA*MSEED'
        self.wo.opdict['time_grid'] = 'Slow_len.100m.P'
        self.wo.opdict['max_length'] = 120
        self.wo.opdict['safety_margin'] = 20
        self.wo.opdict['syn'] = False
        self.wo.opdict['filt_f0'] = 27.0
        self.wo.opdict['filt_sigma'] = 7.0
        self.wo.opdict['kwin'] = 3.0

        # filename for test waveloc options
        self.config_file = 'test_data/test_rtwl.config'
예제 #6
0
###############
# stuff that needs doing while I still have
# realtime functions that are not part of obspy
import obspy.realtime
rt_dict = obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
rt_dict['neg_to_zero'] = (am_rt_signal.neg_to_zero, 0)
rt_dict['convolve'] = (am_rt_signal.convolve, 1)
rt_dict['sw_kurtosis'] = (am_rt_signal.sw_kurtosis, 1)
rt_dict['dx2'] = (am_rt_signal.dx2, 2)

###############

n_test = 500

# set up options
wo = RtWavelocOptions()
wo.opdict['base_path'] = 'test_data'
wo.opdict['outdir'] = 'RealDataTest'
wo.opdict['datadir'] = 'RealDataTest'
wo.opdict['data_glob'] = 'YA*MSEED'
wo.opdict['time_grid'] = 'Slow_len.100m.P'
wo.opdict['max_length'] = 120
wo.opdict['safety_margin'] = 20
wo.opdict['syn'] = False
wo.opdict['filt_f0'] = 27.0
wo.opdict['filt_sigma'] = 7.0
wo.opdict['kwin'] = 3.0

# read data

fnames = glob.glob(os.path.join(wo.data_dir, wo.opdict['data_glob']))
예제 #7
0
###############
# stuff that needs doing while I still have 
# realtime functions that are not part of obspy
import obspy.realtime
rt_dict= obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
rt_dict['neg_to_zero']=(am_rt_signal.neg_to_zero,0)
rt_dict['convolve']=(am_rt_signal.convolve,1)
rt_dict['sw_kurtosis']=(am_rt_signal.sw_kurtosis,1)
rt_dict['dx2']=(am_rt_signal.dx2,2)

###############

n_test=500

# set up options
wo = RtWavelocOptions()
wo.opdict['base_path'] = 'test_data'
wo.opdict['outdir'] = 'RealDataTest'
wo.opdict['datadir'] = 'RealDataTest'
wo.opdict['data_glob'] = 'YA*MSEED'
wo.opdict['time_grid'] = 'Slow_len.100m.P'
wo.opdict['max_length'] = 120
wo.opdict['safety_margin'] = 20
wo.opdict['syn'] = False
wo.opdict['filt_f0'] = 27.0
wo.opdict['filt_sigma'] = 7.0
wo.opdict['kwin'] = 3.0


# read data
예제 #8
0
class SyntheticMigrationTests(unittest.TestCase):

    def setUp(self):
        import obspy.realtime
        rt_dict= obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
        rt_dict['neg_to_zero']=(am_rt_signal.neg_to_zero,0)
        rt_dict['convolve']=(am_rt_signal.convolve,1)
        
        self.wo = RtWavelocOptions()
        self.wo.opdict['base_path'] = 'test_data'
        self.wo.opdict['outdir'] = 'Test'
        self.wo.opdict['time_grid'] = 'Slow_len.100m.P'
        self.wo.opdict['max_length'] = 120
        self.wo.opdict['safety_margin'] = 20
        self.wo.opdict['dt'] = 0.01
        self.wo.opdict['syn'] = True

        self.wo.verifyDirectories()

        # make synthetic data
        self.obs_list, self.ot, (x0,y0,z0) = make_synthetic_data(self.wo)

        self.starttime=self.obs_list[0].stats.starttime
        self.dt=self.obs_list[0].stats.delta

        # split data files to simulate packets of real-time data
        self.obs_split=[]
        for obs in self.obs_list:
            obs_split = obs / 3
            self.obs_split.append(obs_split)

        # generate ttimes_files for test
        n_test=150
        generate_random_test_points(self.wo, n_test, (x0, y0, z0))

    def test_rt_migration_true(self):

        migrator = RtMigrator(self.wo)
        nsta = migrator.nsta


        ntr=len(self.obs_split[0])
        #########################
        # start loops
        #########################
        # loop over segments (simulate real-time data)
        for itr in xrange(ntr):
            # update all input streams
            # loop over stations
            data_list=[]
            for ista in xrange(nsta):
                tr = self.obs_split[ista][itr]
                data_list.append(tr)

            # update data
            migrator.updateData(data_list)

            # update stacks
            migrator.updateStacks()
            
            # update max
            migrator.updateMax()

        #########################
        # end loops
        #########################

        # check we find the same absolute origin time
        #migrator.max_out.plot()
        st=migrator.max_out.stats.starttime+45
        ed=migrator.max_out.stats.starttime+55
        #max_out=migrator.max_out.slice(st,ed)
        #x_out=migrator.x_out.slice(st,ed)
        #y_out=migrator.y_out.slice(st,ed)
        #z_out=migrator.z_out.slice(st,ed)
        #plotMaxXYZ(max_out, x_out, y_out, z_out, 'test_out.png')
        max_trace=migrator.max_out.data
        tmax=np.argmax(max_trace)*self.dt
        tdiff=(migrator.max_out.stats.starttime + tmax)-(self.starttime + self.ot)
        self.assertEquals(tdiff,0)
예제 #9
0
class SyntheticMigrationTests(unittest.TestCase):
    def setUp(self):
        import obspy.realtime
        rt_dict = obspy.realtime.rttrace.REALTIME_PROCESS_FUNCTIONS
        rt_dict['neg_to_zero'] = (am_rt_signal.neg_to_zero, 0)
        rt_dict['convolve'] = (am_rt_signal.convolve, 1)

        self.wo = RtWavelocOptions()
        self.wo.opdict['base_path'] = 'test_data'
        self.wo.opdict['outdir'] = 'Test'
        self.wo.opdict['time_grid'] = 'Slow_len.100m.P'
        self.wo.opdict['max_length'] = 120
        self.wo.opdict['safety_margin'] = 20
        self.wo.opdict['dt'] = 0.01
        self.wo.opdict['syn'] = True

        self.wo.verifyDirectories()

        # make synthetic data
        self.obs_list, self.ot, (x0, y0, z0) = make_synthetic_data(self.wo)

        self.starttime = self.obs_list[0].stats.starttime
        self.dt = self.obs_list[0].stats.delta

        # split data files to simulate packets of real-time data
        self.obs_split = []
        for obs in self.obs_list:
            obs_split = obs / 3
            self.obs_split.append(obs_split)

        # generate ttimes_files for test
        n_test = 150
        generate_random_test_points(self.wo, n_test, (x0, y0, z0))

    def test_rt_migration_true(self):

        migrator = RtMigrator(self.wo)
        nsta = migrator.nsta

        ntr = len(self.obs_split[0])
        #########################
        # start loops
        #########################
        # loop over segments (simulate real-time data)
        for itr in xrange(ntr):
            # update all input streams
            # loop over stations
            data_list = []
            for ista in xrange(nsta):
                tr = self.obs_split[ista][itr]
                data_list.append(tr)

            # update data
            migrator.updateData(data_list)

            # update stacks
            migrator.updateStacks()

            # update max
            migrator.updateMax()

        #########################
        # end loops
        #########################

        # check we find the same absolute origin time
        #migrator.max_out.plot()
        st = migrator.max_out.stats.starttime + 45
        ed = migrator.max_out.stats.starttime + 55
        #max_out=migrator.max_out.slice(st,ed)
        #x_out=migrator.x_out.slice(st,ed)
        #y_out=migrator.y_out.slice(st,ed)
        #z_out=migrator.z_out.slice(st,ed)
        #plotMaxXYZ(max_out, x_out, y_out, z_out, 'test_out.png')
        max_trace = migrator.max_out.data
        tmax = np.argmax(max_trace) * self.dt
        tdiff = (migrator.max_out.stats.starttime + tmax) - (self.starttime +
                                                             self.ot)
        self.assertEquals(tdiff, 0)
예제 #10
0
import os, time
from options import RtWavelocOptions
from synthetics import make_synthetic_data, generate_random_test_points
from migration import RtMigrator
from plotting import plotMaxXYZ


n_test=500

# set up options
wo = RtWavelocOptions()
wo.opdict['base_path'] = 'test_data'
wo.opdict['outdir'] = 'SynTest'
wo.opdict['time_grid'] = 'Slow_len.100m.P'
wo.opdict['max_length'] = 120
wo.opdict['safety_margin'] = 20
wo.opdict['dt'] = 0.01
wo.opdict['syn'] = True

# make synthetic data
obs_list, ot, (x0,y0,z0) = make_synthetic_data(wo)

starttime=obs_list[0].stats.starttime
dt=obs_list[0].stats.delta

# split data files to simulate packets of real-time data
obs_split=[]
for obs in obs_list:
    split = obs / 3
    obs_split.append(split)