| 1 | # Late in the process, it was discovered that a number of these |
| 2 | # test cases provide only partial overlap between the spectrum and |
| 3 | # bandpass. For some of these, the instrument teams determined that |
| 4 | # the correct thing to do was to emulate the behavior that the ETC will |
| 5 | # use, ie, force the Observation to be simulated anyway, with the |
| 6 | # force='taper' behavior. |
| 7 | # |
| 8 | # To support this, a new countrateOverlapCase class was defined, and |
| 9 | # the relevant subset of cases must be redefined to subclass from this |
| 10 | # new class. |
| 11 | # |
| 12 | # This script modifies the relevant .py file in place to apply these |
| 13 | # changes. |
| 14 | # |
| 15 | # The input filename is hardcoded as apply_overlap_input.txt. This |
| 16 | # file, and all relevant .py files, must be present in the working |
| 17 | # directory. |
| 18 | |
| 19 | import os, stat |
| 20 | import re |
| 21 | |
| 22 | pat = "sed -i '/%s/ s:%s):%s):' %s.py \n" |
| 23 | cshname='apply_overlap.csh' |
| 24 | f=open('apply_overlap_input.txt') |
| 25 | out=open(cshname,'w') |
| 26 | out.write('#! /bin/csh \n') |
| 27 | x=re.compile('[0-9]') |
| 28 | |
| 29 | |
| 30 | for line in f: |
| 31 | fname,cname=line.strip().split() |
| 32 | ctype=re.split(x,cname)[0] |
| 33 | cmd=pat%(cname,ctype,ctype.replace('Case','OverlapCase'),fname) |
| 34 | out.write(cmd) |
| 35 | out.close() |
| 36 | |
| 37 | #Fix the permissions |
| 38 | |
| 39 | os.chmod(cshname,stat.S_IRWXU) |
| 40 | retstat=os.spawnl(os.P_WAIT,cshname) |
| 41 | exit(retstat) |