forked from deapplegate/wtgpipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adam_CTcorr_run_correction_para.py
executable file
·48 lines (46 loc) · 2.56 KB
/
adam_CTcorr_run_correction_para.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env python
#adam-does# this makes crosstalk corrected images (OCFX) from uncorrected images (OCF) and the ctcorr difference images (diff) made by adam_CTcorr_make_images_para.sh
#adam-use# use this to correct for the effect of crosstalk further down the pipeline than you would otherwise if you start out using the ctcorr in pre-processing
#adam-example# ./parallel_manager.sh ./adam_CTcorr_run_correction_para.py 'W-C-RC' '2010-02-12' 'MACS1226+21' 'OCF'
#adam-example# ./adam_CTcorr_run_correction_para.py 'W-C-RC' '2011-11-04' 'MACS0416-24' 'OCFR'
# so it's either: ./parallel_manager.sh ./adam_CTcorr_run_correction_para.py ${filter} ${run} ${cluster} ${ending}
# or it's : ./adam_CTcorr_run_correction_para.py ${filter} ${run} ${cluster} ${ending}
import pyfits
import sys
import os
sys.path.append('/u/ki/awright/InstallingSoftware/pythons')
from import_tools import *
import inspect
curfile=os.path.abspath(inspect.getfile(inspect.currentframe()))
FileString=os.path.basename(curfile)
args=imagetools.ArgCleaner(sys.argv,FileString)
try:
filter,run,cluster,ending,chips=args
chips_list=asarray(chips.split(),dtype=int)
except ValueError:
filter,run,cluster,ending=args
chips=" 1 2 3 4 5 6 7 8 9 10"
chips_list=arange(1,11)
print "filter,run,cluster,ending,chips=",filter,run,cluster,ending,chips
## Now the difference images from ctcorr!
endingX=ending+"X"
for chip in chips_list:
fls_diff=glob("/nfs/slac/g/ki/ki18/anja/SUBARU/%s_%s/SCIENCE/IM_diff/SUPA*_%i_diff.fits" % (run,filter,chip))
for fl_diff in fls_diff:
basename_diff=os.path.basename(fl_diff)[:-10]
fl_ending="/nfs/slac/g/ki/ki18/anja/SUBARU/%s/%s/SCIENCE/%s%s.fits" % (cluster,filter,basename_diff,ending)
if not os.path.isfile(fl_ending):
raise Exception("PROBLEM with input file to correct:\nfl_ending=%s\nINPUT args are:\n\tfilter=%s\n\trun=%s\n\tcluster=%s\n\tending=%s\n\tchips=%s" % (fl_ending,filter,run,cluster,ending,chips))
flX="/nfs/slac/g/ki/ki18/anja/SUBARU/%s/%s/SCIENCE/%s%s.fits" % (cluster,filter,basename_diff,endingX)
im_diff=pyfits.open(fl_diff)[0].data
im_diff=asarray(im_diff,dtype=float32)
print "%s: min=%.1f mean=%.1f max=%.1f " % (os.path.basename(fl_diff),im_diff.min(),im_diff.mean(),im_diff.max())
# nanmin(ma.array(logdivXC,mask=logical_not(isfinite(logdivXC))))
# nanmax(ma.array(logdivXC,mask=logical_not(isfinite(logdivXC))))
im_ending=pyfits.open(fl_ending)[0].data
head=pyfits.open(fl_ending)[0].header
head['CTCORR']=True
im_ending=asarray(im_ending,dtype=float32)
imX=im_ending-im_diff
hdu=pyfits.PrimaryHDU(imX,header=head)
hdu.writeto(flX,clobber=True)