Esempio n. 1
0
def goDTW3():
  # errors
  nt = 501
  ns = 101
  lw = 1
  uo = 20
  bg = 10
  #e = makeErrorTest1(nt,ns,uo,bg,lw)
  e = makeErrorTest2(nt,ns,uo,bg,5,0)
  st = Sampling(nt,1,0)
  ss = Sampling(ns,1,0)

  # warping
  rmax =  1.5
  rmin = -1.5
  dw = DynamicWarpingWT(ns,1)
  for ir in range(3):
    dr = 0.01*pow(10,ir)
    nr = int(floor((rmax-rmin)/dr)) + 1
    sr = Sampling(nr,dr,rmin)

    u = dw.findShiftsX(e,sr,uo)
    #es = esum(e,u)
     
    print 'dr= ',dr
    print 'nr= ',nr
    #print 'esum= ',es,'\n'

    plotMatrix(etran(e),st,ss,u=u,title='dr= '+str(dr)+', rmin='+str(rmin)+', rmax='+str(rmax),haxis="time samples",vaxis="shift samples")#,slides='etest'+str(ir+1))

  # plotting
  plotMatrix(etran(e),st,ss,haxis="time samples",vaxis="shift samples",title="errors")#,slides='etest0')
Esempio n. 2
0
def goDTW2(n1,n2,f0,dt,rmsNoise,maxStrain,g,f):
 
  #for uo
  fr = 2
  kmin = -2
  kmax =  2

  rmin = -1.5
  rmax =  1.5

  nl = 1+fr*(n2-n1)
  dst = dt/fr
  sf = Sampling(n1,dt,0.0)
  sl = Sampling(nl,dst,0.0)
  dw = DynamicWarpingWT(nl,fr,kmin,kmax)
  uoi,udmin = dw.finduo(f,g)
  uo = uoi[0]
  #uo = 350 
  print 'uo= ',uo,'\n'
  e = dw.computeErrors(f,g)
  d = dw.accumulate(e)
  for ir in range(4):
    dr = 0.001*pow(10,ir)
    nr = int(floor((rmax-rmin)/dr)) + 1
    sr = Sampling(nr,dr,rmin)

    u = dw.findShiftsX(e,sr,uo)
    u = mul(u,dt)
    dmin = dw.findShiftsX(e,sr,uo,True)
     
    print 'dr= ',dr
    print 'nr= ',nr
    print 'esum= ',dmin[0],'\n'

    #plotMatrix(etran(d),sf,sl)
    plotMatrix(etran(d),sf,sl,u=u,title='dr= '+str(dr))