[frames] | no frames]

# Source Code for Module ortho_batch_x

``` 1  #!/usr/bin/env python
2
3  import ortho_poly
4  import sys
5  import die
6  import avio
7
8
9  """Do a batch reconstruction of orthogonal polynomial fits,
10  based on input which is contains coefficients
11  in avio format, with names specified by PATTERN.
12  Output just one value.
13  """
14
15
16  try:
17          enumerate([])
18  except NameError:
19          from g_enumerate import enumerate
20
21  PATTERN = 'i%02d'
22  N = 100
23  OPNAME = 'Legendre'
24
25
26  if __name__ == '__main__':
27          arglist = sys.argv[1:]
28          k = None
29          while arglist and arglist[0].startswith('-'):
30                  arg = arglist.pop(0)
31                  if arg == '-name':
32                          OPNAME = arglist.pop(0)
33                  elif arg == '-n':
34                          N = int(arglist.pop(0))
35                  elif arg == '-k':
36                          k = int(arglist.pop(0))
37                  elif arg == '--':
38                          break
39                  else:
40                          die.die('Bad arg: %s' % arg)
41          if k is None:
42                  k = (N-1)//2
43
44          out = []
45          op = ortho_poly.F(OPNAME, n=N)
46          for x in sys.stdin:
47                  if x.startswith('#'):
48                          continue
49                  x = x.strip()
50                  if x == '':
51                          continue
52                  a = avio.parse(x)
53                  i = 0
54                  c = []
55                  while PATTERN%i in a:
56                          c.append( float(a[PATTERN%i]) )
57                          i += 1
58                  print '%g' % ( op.expand(c)[k] )
59
<!--
expandto(location.href);
// -->

```

 Generated by Epydoc 3.0.1 on Tue Aug 25 01:53:13 2009 http://epydoc.sourceforge.net