Example #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
    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)
Example #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
  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)
Example #3
0
def goSino():
    na, ka = 81, -20  # sampling for inverse wavelet A
    nh, kh = 181, -90  # sampling for wavelet H
    nt, dt, ft = 501, 0.004, 0.000  # used for plotting only
    nx, dx, fx = 721, 0.015, 0.000
    f, g, u = getSinoImages()
    st = Sampling(nt, dt, ft)
    sx = Sampling(nx, dx, fx)
    tmin, tmax = 88, 363
    fmin, fmax = 0.0, 0.5
    sfac = 1.000
    ww = WaveletWarping()
    ww.setFrequencyRange(fmin, fmax)
    ww.setTimeRange(tmin, tmax)
    ww.setStabilityFactor(sfac)
    aw = ww.getInverseA(na, ka, u, f, g)  # estimated inverse wavelet
    hw = ww.getWaveletH(na, ka, aw, nh, kh)  # estimated wavelet
    nhw = normalize(hw)
    af = ww.applyA(na, ka, aw, f)
    ag = ww.applyA(na, ka, aw, g)
    slag = ww.applyS(u, ww.applyL(u, ag))
    slg = ww.applyS(u, ww.applyL(u, g))
    cmin, cmax = -0.5, 0.5
    #plotImage(st,sx,haslg,fmin=cmin,fmax=cmax,zoom=True)
    #plotImage(st,sx,hslag,fmin=cmin,fmax=cmax,zoom=True)
    plotImage(st, sx, f, fmin=cmin, fmax=cmax, zoom=True)
    plotImage(st, sx, slg, fmin=cmin, fmax=cmax, zoom=True)
    plotImage(st, sx, af, fmin=cmin, fmax=cmax, zoom=True)
    plotImage(st, sx, slag, fmin=cmin, fmax=cmax, zoom=True)
    f0 = ww.rms(f)
    f1 = ww.rms(af)
    g0 = ww.rms(slg)
    g1 = ww.rms(slag)
    e0 = ww.rms(sub(f, slg))
    e1 = ww.rms(sub(af, slag))
    print "f0 =", f0, " f1 =", f1
    print "g0 =", g0, " g1 =", g1
    print "e0 =", e0, " e1 =", e1
Example #4
0
def goSino():
  na,ka = 81,-20 # sampling for inverse wavelet A
  nh,kh = 181,-90 # sampling for wavelet H
  nt,dt,ft = 501,0.004,0.000 # used for plotting only
  nx,dx,fx = 721,0.015,0.000
  f,g,u = getSinoImages()
  st = Sampling(nt,dt,ft)
  sx = Sampling(nx,dx,fx)
  tmin,tmax = 88,363
  fmin,fmax = 0.0,0.5
  sfac = 1.000
  ww = WaveletWarping()
  ww.setFrequencyRange(fmin,fmax)
  ww.setTimeRange(tmin,tmax)
  ww.setStabilityFactor(sfac)
  aw = ww.getInverseA(na,ka,u,f,g) # estimated inverse wavelet
  hw = ww.getWaveletH(na,ka,aw,nh,kh) # estimated wavelet
  nhw = normalize(hw)
  af = ww.applyA(na,ka,aw,f)
  ag = ww.applyA(na,ka,aw,g)
  slag = ww.applyS(u,ww.applyL(u,ag))
  slg = ww.applyS(u,ww.applyL(u,g))
  cmin,cmax = -0.5,0.5
  #plotImage(st,sx,haslg,fmin=cmin,fmax=cmax,zoom=True)
  #plotImage(st,sx,hslag,fmin=cmin,fmax=cmax,zoom=True)
  plotImage(st,sx,f,fmin=cmin,fmax=cmax,zoom=True)
  plotImage(st,sx,slg,fmin=cmin,fmax=cmax,zoom=True)
  plotImage(st,sx,af,fmin=cmin,fmax=cmax,zoom=True)
  plotImage(st,sx,slag,fmin=cmin,fmax=cmax,zoom=True)
  f0 = ww.rms(f)
  f1 = ww.rms(af)
  g0 = ww.rms(slg)
  g1 = ww.rms(slag)
  e0 = ww.rms(sub(f,slg))
  e1 = ww.rms(sub(af,slag))
  print "f0 =",f0," f1 =",f1
  print "g0 =",g0," g1 =",g1
  print "e0 =",e0," e1 =",e1