[frames] | no frames]

# Source Code for Module show_feature_vec

``` 1  """This works with feature_vec.py.   Incomplete."""
2
3 -def plot_xform(descr, fac):
4          DW = 0.5
5          WMAX = 60
6          DF = 0.5
7          FMAX = 80
8          WH = WMAX//2
9          import pylab
10          nin, nout = fac.shape
11          assert len(descr) == nin
12          for i in range(nout):
13                  print 'i=', i
14                  pylab.figure(i)
15                  tmp = Num.zeros((WMAX,FMAX), Num.Float)
16                  norm = math.sqrt(Num.average(fac[:,i]**2))
17                  nf = fac[:,i]/norm
18                  for j in range(nin):
19                          dj = descr[j]
20                          if '|edge|' in dj['type'] or 'haspitch' in dj['type']:
21                                  continue
22                          if 'burst' in dj['type']:
23                                  k = lambda delta: [1.0,-.125][abs(delta)<=1]
24                          elif ' edge' in dj['type']:
25                                  k = lambda delta: [1.0, -1.0][delta<0]
26                          else:
27                                  k = lambda delta: 1.0
28
29                          if dj.has_key('erb') and dj.has_key('width'):
30                                  erbs = [dj['erb']]
31                          elif dj.has_key('erbs') and dj.has_key('width'):
32                                  erbs = dj['erbs']
33                          else:
34                                  continue
35                          nfj = nf[j]/dj['width']
36                          w0 = WH - int(round(dj['width']/(DW*2.0)))
37                          we = WH + int(round(dj['width']/(DW*2.0)))
38                          assert w0>=0 and we<WMAX
39                          for e in erbs:
40                                  ifreq = int(round(e/DF))
41                                  assert ifreq > 0
42                                  print 'w0:we=', w0, we, 'ifreq=', ifreq, 'tmp.shape', tmp.shape, 'nfj=', nfj
43                                  for w in range(w0, we+1):
44                                          tmp[w,ifreq] += k(w-WH)*nfj
45                                          tmp[w,ifreq-1] += k(w-WH)*nfj/2.0
46                                          tmp[w,ifreq+1] += k(w-WH)*nfj/2.0
47                  maxabs = gpkmisc.N_maximum(Num.absolute(Num.ravel(tmp)))
48                  pylab.imshow(Num.transpose(tmp), vmin=-maxabs, vmax=maxabs)
49                  print
50
<!--
expandto(location.href);
// -->

```

 Generated by Epydoc 3.0.1 on Thu Jun 16 20:03:16 2011 http://epydoc.sourceforge.net