tr1 = read("preprocessed_data/SULZ.LHZ.CH.2013.219.processed.SAC")[0] tr2 = read("preprocessed_data/VDL.LHZ.CH.2013.219.processed.SAC")[0] # bad example with only one day of correlation dist, az, baz = gps2dist_azimuth(tr1.stats.sac.stla, tr1.stats.sac.stlo, tr2.stats.sac.stla, tr2.stats.sac.stlo) freq, xcorr, n_corr_wins = noise.noisecorr(tr1, tr2, window_length=3600., overlap=0.5) smoothed = noise.velocity_filter(freq, xcorr, dist / 1000., velband=(6.0, 5.0, 1.5, 0.5), return_all=False) crossings,phase_vel = noise.extract_phase_velocity(freq,smoothed,dist/1000.,ref_curve,\ freqmin=0.004,freqmax=0.25, min_vel=1.5, max_vel=5.0,min_amp=0.0,\ horizontal_polarization=False, smooth_spectrum=False,plotting=True) plt.figure(figsize=(16, 10)) plt.subplot(2, 2, 1) plt.plot(freq, np.real(xcorr), label='original') plt.plot(freq, np.real(smoothed), 'r', lw=2, label='smoothed') plt.title("Cross-correlation spectrum") plt.xlabel("Frequency") plt.legend(numpoints=1) plt.subplot(2, 2, 2)
corr_spectrum = [] no_spectra = 0 for corrday in corr_list: if corrday == None: continue if len(corr_spectrum) == 0: freq = corrday[0] corr_spectrum = corrday[1] else: corr_spectrum += corrday[1] no_spectra += 1 corr_spectrum /= no_spectra smoothed = noise.velocity_filter(freq, corr_spectrum, dist / 1000., velband=(6.0, 5.5, 1.5, 0.5), return_all=False) crossings, phase_vel = noise.get_smooth_pv(freq, smoothed, dist / 1000., ref_curve, freqmin=0.004, freqmax=0.25, min_vel=1.5, max_vel=5.5, filt_width=3, filt_height=1.0, pick_threshold=2.0, horizontal_polarization=True,
ref_curve = np.loadtxt("avg.txt") tr1 = read("/Users/tzompantli/Desktop/tr1.mseed")[0] tr2 = read("/Users/tzompantli/Desktop/tr2.mseed")[0] # bad example with only one day of correlation #dist,az,baz = gps2dist_azimuth(tr1.stats.sac.stla,tr1.stats.sac.stlo, # tr2.stats.sac.stla,tr2.stats.sac.stlo) dist = 150 freq, xcorr = noise.noisecorr(tr1, tr2, window_length=30., overlap=0.3) smoothed = noise.velocity_filter(freq, xcorr, dist / 1000., cmin=.1, cmax=1.0, return_all=False) cc = np.real(np.fft.fftshift(np.fft.ifft(smoothed))) tr = Trace(data=cc) tr.stats.sampling_rate = 50 tr.write('test.mseed', format='MSEED') dkjd crossings,phase_vel = noise.extract_phase_velocity(freq,smoothed,dist/1000.,ref_curve,\ freqmin=1,freqmax=20, min_vel=.01, max_vel=2.0,min_amp=0.0,\ horizontal_polarization=False, smooth_spectrum=False,plotting=False)#True) plt.figure(figsize=(16, 10))
print "starting FFT with", no_cores, "cores" p = Pool(no_cores) corr_list = p.map(multiprocess_fft, joblist) p.close() freq = corr_list[0][0] corr_spectrum = np.zeros(len(corr_list[0][0]), dtype=complex) for corrday in corr_list: if corrday == None: continue corr_spectrum += corrday[1] corr_spectrum /= float(len(corr_list)) smoothed = noise.velocity_filter(freq, corr_spectrum, dist / 1000., cmin=1.5, cmax=5.5, return_all=False) crossings,phase_vel = noise.get_smooth_pv(freq,smoothed,dist/1000.,ref_curve,\ freqmin=0.004,freqmax=0.25, min_vel=1.5, max_vel=5.5,\ filt_width=3,filt_height=0.2,x_overlap=0.75,y_overlap=0.75,pick_threshold=1.7,\ horizontal_polarization=False, smooth_spectrum=False,plotting=True) plt.figure(figsize=(16, 10)) plt.subplot(2, 2, 1) plt.plot(freq, np.real(corr_spectrum)) plt.plot(freq, np.real(smoothed)) plt.title("Cross-correlation spectrum Love") plt.xlabel("Frequency") plt.subplot(2, 2, 2)