Debian Codegraph @

commissioning/effstim_from_rn.py

raw symbols SCIP
1 import re
2 def extract():
3 pat=re.compile("rn\((.*),band\((.*)\),")
4
5 ins=('acs','nicmos','stis')
6 for iname in ins:
7 fname="%s_rn_cases.py"%iname
8 f=open(fname)
9 out=open(fname.replace('rn','effstim').replace('.py','.txt'),'w')
10 for line in f:
11 if '.spectrum' in line:
12 x=re.search(pat,line)
13 out.write("%s ! %s\n"%(x.group(1),x.group(2)))
14 out.close()
15 f.close()
16
17 def construct():
18
19 header="""from pytools import testutil
20 import sys
21 import basecase
22
23 """
24 pattern="""
25 class E%d%s(basecase.effstimCase):
26 def setUp(self):
27 self.spectrum="%s"
28 self.obsmode="%s"
29 self.form="%s"
30 self.setglobal(__file__)
31 self.runpy()
32
33 """
34 ulist=('photlam','flam',
35 'fnu',
36 'vegamag',
37 'abmag',
38 'stmag',
39 'obmag',
40 'counts')
41
42 ins=('acs','nicmos','stis')
43 for iname in ins:
44 fname="%s_effstim_cases.txt"%iname
45 f=open(fname)
46 out=open(fname.replace('.txt','.py'),'w')
47 out.write(header)
48 count=1
49 for line in f:
50 sp,bp=line.strip().split('!')
51 for u in ulist:
52 out.write(pattern%(count,u,sp,bp.strip().lower(),u))
53 count+=1
54 f.close()
55 out.close()