| 1 | import basecase |
| 2 | import sys,os |
| 3 | |
| 4 | |
| 5 | pattern="""class stisS%d(countrateCase): |
| 6 | def setUp(self): |
| 7 | self.obsmode="%s" |
| 8 | self.spectrum="%s" |
| 9 | self.setglobal(__file__) |
| 10 | self.runpy()\n""" |
| 11 | |
| 12 | speclist=['/grp/hst/cdbs/calspec/gd71_mod_005.fits', |
| 13 | '/grp/hst/cdbs/calspec/gd153_mod_004.fits', |
| 14 | '/grp/hst/cdbs/calspec/g191b2b_mod_004.fits'] |
| 15 | |
| 16 | |
| 17 | def genacs(inname): |
| 18 | f=open(inname) |
| 19 | out=open(inname+'.py','w') |
| 20 | count=0 |
| 21 | for line in f: |
| 22 | for sp in speclist: |
| 23 | out.write(pattern%(count,line.strip(),sp)) |
| 24 | count+=1 |
| 25 | out.close() |
| 26 | f.close() |
| 27 | |
| 28 | def genstis(outname): |
| 29 | """ Generate TestCases from cmdfile according to the pattern in patternfile""" |
| 30 | pattern="""class stisS%d(countrateCase): |
| 31 | def setUp(self): |
| 32 | self.obsmode="%s" |
| 33 | self.spectrum="%s" |
| 34 | self.setglobal(__file__) |
| 35 | self.runpy()\n""" |
| 36 | |
| 37 | speclist=['/grp/hst/cdbs/calspec/gd71_mod_005.fits', |
| 38 | '/grp/hst/cdbs/calspec/gd153_mod_004.fits', |
| 39 | '/grp/hst/cdbs/calspec/g191b2b_mod_004.fits'] |
| 40 | |
| 41 | glist={'g140l':'fuvmama','g230l':'nuvmama','g430l':'ccd','g750l':'ccd', |
| 42 | 'g230lb':'ccd'} |
| 43 | |
| 44 | out=open(outname,'a') |
| 45 | out.write("""from pytools import testutil |
| 46 | import sys |
| 47 | from basecase import calcphotCase, calcspecCase, countrateCase,SpecSourcerateSpecCase\n |
| 48 | """) |
| 49 | count=0 |
| 50 | for g in glist: |
| 51 | for sp in speclist: |
| 52 | obsmode='stis,%s,fuvmama,s52x2'%g |
| 53 | defn=pattern%(count,obsmode,sp) |
| 54 | out.write(defn) |
| 55 | count+=1 |
| 56 | |
| 57 | out.write("""\n\n |
| 58 | if __name__ == '__main__': |
| 59 | if 'debug' in sys.argv: |
| 60 | testutil.debug(__name__) |
| 61 | else: |
| 62 | testutil.testall(__name__,2) |
| 63 | """) |
| 64 | |
| 65 | out.close() |
| 66 |