Module ortho_reconstruct
[frames] | no frames]

Source Code for Module ortho_reconstruct

 1  #!/usr/bin/env python 
 2   
 3  """Expand a set of coefficients of orthogonal polynomials 
 4  into a list of x, y points. 
 5  """ 
 6   
 7  import ortho_poly 
 8  import sys 
 9  import die 
10   
11   
12   
13  try: 
14          enumerate([]) 
15  except NameError: 
16          from g_enumerate import enumerate 
17   
18   
19   
20  if __name__ == '__main__': 
21          N = 100 
22          xa = None 
23          name = 'Legendre' 
24          arglist = sys.argv[1:] 
25          while arglist and arglist[0].startswith('-'): 
26                  arg = arglist.pop(0) 
27                  if arg == '-name': 
28                          name = arglist.pop(0) 
29                  elif arg == '-n': 
30                          N = int(arglist.pop(0)) 
31                  elif arg == '-x': 
32                          N = None 
33                          xa = [] 
34                          for l in sys.stdin: 
35                                  if l.startswith('#'): 
36                                          continue 
37                                  l = l.strip() 
38                                  if l == '': 
39                                          continue 
40                                  xa.append(float(l)) 
41                  elif arg == '--': 
42                          break 
43                  else: 
44                          die.die('Bad arg: %s' % arg) 
45          c = [ float(x) for x in arglist ] 
46          op = ortho_poly.F(name, n=N, x=xa) 
47          s = op.expand(c) 
48   
49          for i in range(len(s)): 
50                  print i, op.x[i], s[i] 
51