コード例 #1
0
def build_anxcor(tau,interpolation_method='nearest'):
    broadband_data_dir               = basedir+'test_data/correlation_integration_testing/Broadband'
    broadband_station_location_file  = basedir+'test_data/correlation_integration_testing/broadband_stationlist.txt'
    nodal_data_dir               =     basedir+'test_data/correlation_integration_testing/Nodal'
    nodal_station_location_file  =     basedir+'test_data/correlation_integration_testing/nodal_stationlist.txt'

    broadband_database = DWellsDecimatedReader(broadband_data_dir, broadband_station_location_file)
    nodal_database     = DWellsDecimatedReader(nodal_data_dir,     nodal_station_location_file,extension='d')
    window_length = 10*60.0
    #include_stations = ['Nodal.{}'.format(x) for x in range(1,10)]
    include_stations = ['UU.FORU','DV.1']

    taper_ratio     = 0.05
    target_rate     = 50.0
    correlate_kwargs= dict(max_tau_shift=tau,taper=taper_ratio)
    resample_kwargs = dict(target_rate=target_rate,lowpass=False)

    anxcor_main = Anxcor(interp_method=interpolation_method)
    anxcor_main.set_window_length(window_length)
    anxcor_main.set_must_only_include_station_pairs(include_stations)
    anxcor_main.add_dataset(broadband_database,'BB')
    anxcor_main.add_dataset(nodal_database, 'Nodal')
    anxcor_main.add_process(XArrayTaper(taper=taper_ratio))
    anxcor_main.add_process(XArrayRemoveMeanTrend())
    anxcor_main.add_process(XArrayTaper(taper=taper_ratio))
    anxcor_main.set_task_kwargs('crosscorrelate',correlate_kwargs)
   # anxcor_main.set_task('post-correlate',XArrayCustomComponentNormalizer())
    return anxcor_main
コード例 #2
0
 def test_rotation(self):
     # stations 21, & 22
     # 3 windows say
     #
     anxcor = Anxcor(3600)
     bank = WavebankWrapper(source_dir)
     anxcor.add_dataset(bank, 'nodals')
     anxcor.set_task_kwargs('crosscorrelate', dict(dummy_task=True))
     result = anxcor.process([starttime_stamp])
     rotated_result = anxcor.align_station_pairs(result)
     streams = anxcor.xarray_to_obspy(result)
     assert len(streams) == 9, 'not enough traces retained!'
コード例 #3
0
    def test_tau_is_correct(self):
        target_shift = 15.0
        anxcor = Anxcor(window_length=120.0)
        anxcor.set_task_kwargs('crosscorrelate',
                               dict(max_tau_shift=target_shift))
        anxcor.save_config(save_dir + os.sep + 'config.ini')
        with open(save_dir + os.sep + 'config.ini') as conf:
            config = json.load(conf)

        source_tau_shift = config['crosscorrelate']['max_tau_shift']

        assert target_shift == source_tau_shift
コード例 #4
0
 def test_expected_pair_amount(self):
     anxcor_main = Anxcor(60 * 10.0)
     anxcor_main.add_dataset(IRISWrapper(), 'IMUSH_ST_HELLENS_DATA')
     correlate_kwargs = dict(taper=0.1, max_tau_shift=50.0)
     anxcor_main.set_task_kwargs('crosscorrelate', correlate_kwargs)
     anxcor_main.add_process(XArrayRemoveMeanTrend())
     anxcor_main.add_process(XArrayOneBit())
     starttime = UTCDateTime("2005-6-22 12:00:00").timestamp
     starttimes = []
     for window_number in range(0, 4):
         starttimes.append(starttime + 60 * 10.0 * window_number)
     xarray_dataset = anxcor_main.process(starttimes)
     assert len(list(xarray_dataset.coords['rec'].values)) == 2
コード例 #5
0
 def test_dask_execution_exclude_with_stack_number(self):
     from distributed import Client, LocalCluster
     cluster = LocalCluster(n_workers=1, threads_per_worker=1)
     c = Client(cluster)
     anxcor = Anxcor()
     anxcor.set_window_length(120)
     anxcor.set_task_kwargs('crosscorrelate', dict(max_tau_shift=20.0))
     times = anxcor.get_starttimes(starttime_stamp, endtime_stamp, 0.5)
     bank = WavebankWrapper(source_dir)
     anxcor.set_must_exclude_single_stations('AX.1')
     anxcor.add_dataset(bank, 'nodals')
     result = anxcor.process(times, dask_client=c, stack=10)
     pairs = list(result.coords['rec'].values) + list(result.coords['src'].values)
     c.close()
     cluster.close()
     assert 4 == len(pairs)
コード例 #6
0
 def test_single_execution(self):
     anxcorWavebank = WavebankWrapper(source_dir)
     min_starttime = anxcorWavebank.bank.get_availability_df(
     )['starttime'].min()
     endtime = anxcorWavebank.bank.get_availability_df()['endtime'].max()
     starttime = int(min_starttime + 1)
     endtime = int(endtime)
     overlap = 0.5
     window_length = 3 * 60
     resample_kwargs = dict(taper=0.05, target_rate=20.0)
     correlate_kwargs = dict(taper=0.01, max_tau_shift=60)
     anxcor_main = Anxcor()
     anxcor_main.set_window_length(window_length)
     anxcor_main.add_dataset(anxcorWavebank, 'test')
     anxcor_main.set_task_kwargs('resample', resample_kwargs)
     anxcor_main.set_task_kwargs('crosscorrelate', correlate_kwargs)
     starttime_list = anxcor_main.get_starttimes(starttime,
                                                 starttime + window_length,
                                                 overlap)
     result = anxcor_main.process(starttime_list)
     assert len(result['src:test rec:test'].coords['rec_chan'].values) == 3
     assert len(result['src:test rec:test'].coords['src_chan'].values) == 3
     assert not np.isnan(result['src:test rec:test']).any()