コード例 #1
0
def goSino():
  na,ka = 41,-20 # sampling for inverse A of wavelet in PS image
  nh,kh = 41,-20 # 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
  wha = 0.000 # weight for HA = I terms
  ha = True # True to find h, then a, then h, ...; False, for a, h, a, ...
  niter = 0
  f,g,u = getSinoImages() # PP image, PS image, and warping u(t,x)
  ww = WaveletWarpingHA()
  ww.setTimeRange(tmin,tmax)
  ww.setStabilityFactor(sfac)
  ww.setWeightHA(0.0)
  slg = ww.applyS(u,ww.applyL(u,g)) # PS warping without wavelets
  e1 = ww.rms(sub(f,slg))
  for ha in [True,False]:
    suffix = ""
    if ha:
      ag = zerofloat(na); ag[-ka] = 1.0 # initial inverse a in g
      hf = ww.getWaveletH(nh,kh,na,ka,ag,u,f,g) # wavelet h in f
      for jiter in range(niter):
        ag = ww.getInverseA(na,ka,nh,kh,hf,u,f,g) # inverse a in g
        hf = ww.getWaveletH(nh,kh,na,ka,ag,u,f,g) # wavelet h in f
    else:
      hf = zerofloat(nh); hf[-kh] = 1.0 # initial wavelet h in f
      ag = ww.getWaveletH(na,ka,nh,kh,hf,u,f,g) # inverse a in g
      for jiter in range(niter):
        hf = ww.getWaveletH(nh,kh,na,ka,ag,u,f,g) # 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
    ew = ww.rms(sub(f,hslag))
    print "  e1 =",e1," ew =",ew
    rhslag = ww.rms(hslag); hslag = mul(hslag,1.0/rhslag)
    print "rhslag =",rhslag
    plotImage(st,sx,hslag,zoom=True,png="psww"+suffix)
    plotWaveletsPpPs(sh,hf,hg,png="wavelets"+suffix)
  rf = ww.rms(f); f = mul(f,1.0/rf)
  rslg = ww.rms(slg); slg = mul(slg,1.0/rslg)
  print "rf =",rf," rslg =",rslg
  plotImage(st,sx,f,zoom=True,png="pp")
  plotImage(st,sx,slg,zoom=True,png="psw1")
コード例 #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 = 11,-5 # sampling for inverse wavelet A
  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.00
  wha = 10.0
  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)
      if r<=1.0:
        u = add((1.0-r)*(nt-1),u)
      ww = WaveletWarpingHA()
      ww.setTimeRange(tmin,tmax)
      ww.setStabilityFactor(sfac)
      ww.setWeightHA(wha)
      ak = ww.getWaveletH(nh,kh,hk,na,ka) # known inverse wavelet
      #dump(ak)
      for iter in range(500):
        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
        #dump(aw)
      #hw = ww.getWaveletH(na,ka,aw,nh,kh) # estimated wavelet
      sg = ww.applyS(u,g)
      ag = ww.applyA(na,ka,aw,g)
      lag = ww.applyL(u,ag) # lowpass, if squeezing
      slag = ww.applyS(u,lag)
      hslag = ww.applyH(nh,kh,hw,slag)
      normalizeMax(hw)
      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
ファイル: waveletwarpingha.py プロジェクト: xinwucwp/idh
def goSino():
  na,ka = 81,-40 # sampling for inverse A of wavelet in PS image
  nh,kh = 81,-40 # 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
  wha = 0.000 # weight for HA = I terms
  f,g,u = getSinoImages() # PP image, PS image, and warping u(t,x)
  ww = WaveletWarpingHA()
  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,9]:
    for wha in [0]:
      print "niter =",niter," wha =",wha
      suffix = str(niter)+str(int(wha))
      ww.setWeightHA(wha)
      ag = zerofloat(na); ag[-ka] = 1.0 # initial inverse a in g
      hf = ww.getWaveletH(nh,kh,na,ka,ag,u,f,g) # wavelet h in f
      for jiter in range(niter):
        ag = ww.getInverseA(na,ka,nh,kh,hf,u,f,g) # inverse a in g
        hf = ww.getWaveletH(nh,kh,na,ka,ag,u,f,g) # wavelet h in f
      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)