Пример #1
0
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
  #na,ka = 5,-2 # 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]: # 0.5 for stretch; 2.0 for squeeze
      aw = zerofloat(na); aw[-ka] = 1.0
      hw = zerofloat(nh); hw[-kh] = 1.0
      p,q = makeImpulses(r,nt,ni)
      f = addWavelet(freq,decay,p,mp)
      g = addWavelet(freq,decay,q,mp)
      u = rampfloat(0.0,r,nt)
      bpf = None
      if r<=1.0:
        u = add((1.0-r)*(nt-1),u)
        bpf = BandPassFilter(0,0.5*r,0.10*r,0.01)
      ww = WaveletWarpingH()
      ww.setTimeRange(tmin,tmax)
      ww.setStabilityFactor(sfac)
      ak = ww.getWaveletH(nh,kh,hk,na,ka) # known inverse wavelet
      #dump(ak)
      for iter in range(5):
        #if bpf: bpf.apply(hw,hw)
        aw = ww.getInverseA(na,ka,nh,kh,hw,u,f,g) # estimated inverse
        #hw = ww.getWaveletH(nh,kh,na,ka,aw,u,f,g) # estimated wavelet
        hw = ww.getWaveletH(na,ka,aw,nh,kh) # estimated wavelet
        #dump(aw)
      sg = ww.applyS(u,g)
      hslag = ww.applyHSLA(na,ka,aw,nh,kh,hw,u,g)
      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,[f,hslag],labels=["f","HSLAg"],title=title)
      plotWavelets(Sampling(nh,dt,kh*dt),[nhw,nhk],title=title)
Пример #2
0
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
  #na,ka = 5,-2 # 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]: # 0.5 for stretch; 2.0 for squeeze
      aw = zerofloat(na); aw[-ka] = 1.0
      hw = zerofloat(nh); hw[-kh] = 1.0
      p,q = makeImpulses(r,nt,ni)
      f = addWavelet(freq,decay,p,mp)
      g = addWavelet(freq,decay,q,mp)
      u = rampfloat(0.0,r,nt)
      bpf = None
      if r<=1.0:
        u = add((1.0-r)*(nt-1),u)
        bpf = BandPassFilter(0,0.5*r,0.10*r,0.01)
      ww = WaveletWarpingH()
      ww.setTimeRange(tmin,tmax)
      ww.setStabilityFactor(sfac)
      ak = ww.getWaveletH(nh,kh,hk,na,ka) # known inverse wavelet
      #dump(ak)
      for iter in range(5):
        if bpf: bpf.apply(hw,hw)
        aw = ww.getInverseA(na,ka,nh,kh,hw,u,f,g) # estimated inverse
        hw = ww.getWaveletH(na,ka,aw,nh,kh) # estimated wavelet
        #dump(aw)
      sg = ww.applyS(u,g)
      hslag = ww.applyHSLA(na,ka,aw,nh,kh,hw,u,g)
      nhw = normalizeMax(hw)
      nhk = normalizeMax(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,[f,hslag],labels=["f","HSLAg"],title=title)
      plotWavelets(Sampling(nh,dt,kh*dt),[nhw,nhk],title=title)
Пример #3
0
def goSino():
  na,ka = 21,-10 # sampling for inverse A of wavelet in PS image
  nh,kh = 21,-10 # sampling for wavelet H in PP image
  nt,dt,ft = 501,0.004,0.000 # used for plotting only
  nx,dx,fx = 721,0.015,0.000
  sa = Sampling(na,dt,ka*dt)
  sh = Sampling(nh,dt,kh*dt)
  st = Sampling(nt,dt,ft)
  sx = Sampling(nx,dx,fx)
  tmin,tmax = 100,400 # PP time window
  sfac = 1.000 # stabilization factor
  f,g,u = getSinoImages() # PP image, PS image, and warping u(t,x)
  ww = WaveletWarpingH()
  ww.setTimeRange(tmin,tmax)
  ww.setStabilityFactor(sfac)
  slg = ww.applyS(u,ww.applyL(u,g)) # PS warping without wavelets
  plotImage(st,sx,f,zoom=True,png="pp")
  plotImage(st,sx,slg,zoom=True,png="psw1")
  e1 = ww.rms(sub(f,slg))
  for niter in [0]:
    print "niter =",niter
    suffix = str(niter)
    hf = zerofloat(nh); hf[-kh] = 1.0 # initial wavelet h in f
    ag = ww.getInverseA(na,ka,nh,kh,hf,u,f,g) # inverse a in g
    for jiter in range(niter):
      hf = ww.getWaveletH(na,ka,ag,nh,kh) # wavelet h in f
      ag = ww.getInverseA(na,ka,nh,kh,hf,u,f,g) # inverse a in g
    hg = ww.getWaveletH(na,ka,ag,nh,kh) # wavelet in g
    hslag = ww.applyHSLA(na,ka,ag,nh,kh,hf,u,g) # PS warping with wavelets
    hslag = mul(hslag,ww.rms(f)/ww.rms(hslag))
    ew = ww.rms(sub(f,hslag))
    print "  e1 =",e1," ew =",ew
    plotImage(st,sx,hslag,zoom=True,png="psww"+suffix)
    plotWaveletsPpPs(sh,hf,hg,png="wavelets"+suffix)