def goSimpleTest(): nt, ni = 481, 2 # number of time samples; number of impulses freq, decay = 0.08, 0.05 # peak frequency and decay for wavelet na, ka = 81, -20 # sampling for inverse wavelet A nh, kh = 181, -90 # sampling for wavelet H dt, ft = 0.004, 0.000 # used for plotting only tmin, tmax = 0, nt - 1 sfac = 1.000 st = Sampling(nt, dt, ft) for mp in [False]: # True, for minimum-phase; False for other hk = getWavelet(freq, decay, nh, kh, mp) # known wavelet for r in [2.0]: # for stretch and squeeze, ... fmin, fmax = 0.0, min(0.5, 0.5 * r) # bandpass (lowpass), if stretching p, q = makeImpulses(r, nt, ni) f = addWavelet(freq, decay, p, mp) g = addWavelet(freq, decay, q, mp) u = rampfloat(0.0, r, nt) if r <= 1.0: u = add((1.0 - r) * (nt - 1), u) ww = WaveletWarping() ww.setFrequencyRange(fmin, fmax) ww.setTimeRange(tmin, tmax) ww.setStabilityFactor(sfac) ak = ww.getWaveletH(nh, kh, hk, na, ka) # known inverse wavelet aw = ww.getInverseA(na, ka, u, f, g) # estimated inverse wavelet hw = ww.getWaveletH(na, ka, aw, nh, kh) # estimated wavelet #dump(ak) #dump(aw) sg = ww.applyS(u, g) af = ww.applyA(na, ka, aw, f) ag = ww.applyA(na, ka, aw, g) lag = ww.applyL(u, ag) # lowpass, if squeezing slag = ww.applyS(u, lag) baf = ww.applyB(af) bslag = ww.applyB(slag) hslag = ww.applyH(nh, kh, hw, slag) nhw = normalize(hw) nhk = normalize(hk) title = "r = " + str(r) #plotSequences(st,[f,g],labels=["f","g"],title=title) plotSequences(st, [f, sg], labels=["f", "Sg"], title=title) #plotSequences(st,[f,g],labels=["f","g"],title=title) #plotSequences(st,[af,ag],labels=["Af","Ag"],title=title) #plotSequences(st,[af,lag],labels=["Af","LAg"],title=title) plotSequences(st, [af, slag], labels=["Af", "SLAg"], title=title) #plotSequences(st,[baf,bslag],labels=["BAf","BSLAg"],title=title) plotSequences(st, [f, hslag], labels=["f", "HSLAg"], title=title) plotWavelets(Sampling(nh, dt, kh * dt), [nhw, nhk], title=title)
def goSimpleTest(): nt,ni = 481,2 # number of time samples; number of impulses freq,decay = 0.08,0.05 # peak frequency and decay for wavelet na,ka = 81,-20 # sampling for inverse wavelet A nh,kh = 181,-90 # sampling for wavelet H dt,ft = 0.004,0.000 # used for plotting only tmin,tmax = 0,nt-1 sfac = 1.000 st = Sampling(nt,dt,ft) for mp in [True,False]: # True, for minimum-phase; False for other hk = getWavelet(freq,decay,nh,kh,mp) # known wavelet for r in [0.5,2.0]: # for stretch and squeeze, ... fmin,fmax = 0.0,min(0.5,0.5*r) # bandpass (lowpass), if stretching p,q = makeImpulses(r,nt,ni) f = addWavelet(freq,decay,p,mp) g = addWavelet(freq,decay,q,mp) u = rampfloat(0.0,r,nt) if r<=1.0: u = add((1.0-r)*(nt-1),u) ww = WaveletWarping() ww.setFrequencyRange(fmin,fmax) ww.setTimeRange(tmin,tmax) ww.setStabilityFactor(sfac) ak = ww.getWaveletH(nh,kh,hk,na,ka) # known inverse wavelet aw = ww.getInverseA(na,ka,u,f,g) # estimated inverse wavelet hw = ww.getWaveletH(na,ka,aw,nh,kh) # estimated wavelet #dump(ak) #dump(aw) sg = ww.applyS(u,g) af = ww.applyA(na,ka,aw,f) ag = ww.applyA(na,ka,aw,g) lag = ww.applyL(u,ag) # lowpass, if squeezing slag = ww.applyS(u,lag) baf = ww.applyB(af) bslag = ww.applyB(slag) hslag = ww.applyH(nh,kh,hw,slag) nhw = normalize(hw) nhk = normalize(hk) title = "r = "+str(r) #plotSequences(st,[f,g],labels=["f","g"],title=title) #plotSequences(st,[f,sg],labels=["f","Sg"],title=title) #plotSequences(st,[f,g],labels=["f","g"],title=title) #plotSequences(st,[af,ag],labels=["Af","Ag"],title=title) #plotSequences(st,[af,lag],labels=["Af","LAg"],title=title) #plotSequences(st,[af,slag],labels=["Af","SLAg"],title=title) #plotSequences(st,[baf,bslag],labels=["BAf","BSLAg"],title=title) plotSequences(st,[f,hslag],labels=["f","HSLAg"],title=title) plotWavelets(Sampling(nh,dt,kh*dt),[nhw,nhk],title=title)