Skip to content
6 changes: 3 additions & 3 deletions AstrometryCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@



class AstrometryCheck():
class AstrometryCheck:

def __init__(self,catlistFile):
self.catlist = catlistFile
Expand All @@ -30,7 +30,7 @@ def __init__(self,catlistFile):
if first:
first = False
continue
tokens = string.split(line,',')
tokens = line.split(',')
self.ra_cent.append(float(tokens[7]))
self.dec_cent.append(float(tokens[8]))
self.rac1.append(float(tokens[9]))
Expand Down Expand Up @@ -95,4 +95,4 @@ def checkDiff(self):
if astrT.checkDiff() < 0:
sys.exit(-1)
else:
sys.exit(0)
sys.exit(0)
134 changes: 68 additions & 66 deletions BLISS-expCalib_Y3apass-old.py

Large diffs are not rendered by default.

126 changes: 64 additions & 62 deletions BLISS-expCalib_Y3apass.py

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions SEProc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pyfits
import os
import ConfigParser
import configparser
import sys
import argparse
from despyfits.DESImage import DESImage
Expand All @@ -23,7 +23,7 @@ def __init__(self,confFile):

########### Configuration ############

self.Config = ConfigParser.ConfigParser()
self.Config = configparser.ConfigParser()
self.configFile = self.args.confFile
self.Config.read(self.configFile)
self.template_file = self.ConfigSectionMap("General")['template']
Expand Down Expand Up @@ -126,7 +126,7 @@ def ConfigSectionMap(self,section):
dict1[option] = self.Config.get(section, option)
if dict1[option] == -1:
# DebugPrint("skip: %s" % option)
print "skip: %s" % option
print("skip: %s" % option)
except:
print("exception on %s!" % option)
dict1[option] = None
Expand Down Expand Up @@ -207,7 +207,7 @@ def pixcorrect(self,outname, CCD, **args):
' --flat ' + self.flat.format(**args) + \
' --resaturate --fixcols --addweight'

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -229,7 +229,7 @@ def bleedmask(self,CCD,inname,outname,**args):
' -m -b 5 -f 1.0 -l 7 -n 7 -r 5 -t 20 -v 3 -w 2.0 -y 1.0 -s 100 -v 3 -E 6 -L 30' + \
' -x ' +self.template_file.format(**args)+'_trailbox.fits -o ' +self.template_file.format(**args)+'_satstars.fits'

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -247,7 +247,7 @@ def skycompress(self,CCD,inname,outname,**args):
' --skyfilename ' + self.template_file.format(**args)+'_'+outname+'.fits' + \
' --blocksize 128'

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -269,7 +269,7 @@ def immask(self,CCD, inname,bkgname, outname, **args):
' --bkgfile '+self.template_file.format(**args)+'_'+bkgname+'.fits'+\
' --draw --write_streaks --streaksfile ' + self.template_file.format(**args)+'_streaksfile.fits'

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -293,7 +293,7 @@ def skyCombineFit(self,inputFile,skycombineFile,skyfitinfoFile,**args):
self.copy_from_Dcache(self.correc_dir+'/skypca/'+str(self.year)+str(self.epoch)+'/'+self.PCFILENAME.format(**args))
#-----------------------
cmd = 'ls *'+inputFile+'.fits > listpcain'
print'\n', cmd,'\n'
print('\n', cmd,'\n')
retval = subprocess.call(cmd, shell=True)

if retval != 0:
Expand All @@ -303,7 +303,7 @@ def skyCombineFit(self,inputFile,skycombineFile,skyfitinfoFile,**args):

#------------------------
cmd = 'sky_combine --miniskylist listpcain -o ' + self.exp_template_file.format(**args)+'_'+skycombineFile+'.fits --ccdnums 1,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,49,50,51,52,53,54,55,56,57,58,59,60,62 --invalid S30,N30'
print cmd
print(cmd)
retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)

if retval != 0:
Expand All @@ -315,7 +315,7 @@ def skyCombineFit(self,inputFile,skycombineFile,skyfitinfoFile,**args):
cmd = 'sky_fit --infilename ' + self.exp_template_file.format(**args)+'_'+ skycombineFile+'.fits'
cmd += ' --outfilename '+ self.exp_template_file.format(**args)+'_'+skyfitinfoFile+'.fits --pcfilename '
cmd += (self.PCFILENAME[self.PCFILENAME.rfind("/")+1:]).format(**args)
print cmd
print(cmd)
retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)

if retval != 0:
Expand All @@ -337,7 +337,7 @@ def pixcorr_starflat(self,inname, outname, CCD,**args):
' --starflat '+ self.starflat.format(**args) +\
' --out '+self.template_file.format(**args)+'_'+outname+'.fits'

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)

Expand Down Expand Up @@ -366,7 +366,7 @@ def skysubtract(self,CCD, inname, outname, skyfitinfoFile,**args ):
' --domefilename ' +self.flat.format(**args) +\
' --weight ' +self.weight

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -387,7 +387,7 @@ def scamp(self,inputFile):
' -ASTREF_CATALOG ' +self.catalog_ref +' -c ' +self.default_scamp +\
' -WRITE_XML Y -XML_NAME scamp.xml -MOSAIC_TYPE SAME_CRVAL -ASTREF_BAND DEFAULT -POSITION_MAXERR 10.0 -NTHREADS 1 '

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand Down Expand Up @@ -425,7 +425,7 @@ def sextractor(self, inname, outname, CCD, **args):
' -DETECT_THRESH 10.0 -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC -WEIGHT_IMAGE ' + self.template_file.format(**args)+'_'+inname+'.fits[2]'+\
' -WEIGHT_TYPE MAP_WEIGHT '

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand All @@ -446,7 +446,7 @@ def sextractorPSFEX(self, inname, outname, CCD, **args):
' -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC -WEIGHT_IMAGE ' + self.template_file.format(**args)+'_'+inname+'.fits[2]'+\
' -WEIGHT_TYPE MAP_WEIGHT '

print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand Down Expand Up @@ -485,7 +485,7 @@ def sextractorsky(self, inname, outname, CCD, **args):
' -PARAMETERS_NAME ' + self.sexbkgparamFile +\
' -CATALOG_TYPE NONE -INTERP_TYPE ALL -INTERP_MAXXLAG 16 -INTERP_MAXYLAG 16 '

print '\n',cmd,'\n'
print('\n',cmd,'\n')
retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
sys.exit(1)
Expand All @@ -500,7 +500,7 @@ def psfex(self, name,CCD, **args):

cmd = 'psfex ' + self.template_file.format(**args)+'_'+name+'.fits -c ' +self.config_filePSF +\
' -OUTCAT_NAME '+ self.template_file.format(**args)+'_psflist.fits -OUTCAT_TYPE FITS_LDAC'
print '\n',cmd,'\n'
print('\n',cmd,'\n')

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
if retval != 0:
Expand Down Expand Up @@ -528,7 +528,7 @@ def sextractorPSF(self, name, name1, outname, filepsf, CCD, **args):
' -DETECT_THRESH 1.5 -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC '+\
' -WEIGHT_IMAGE '+self.template_file.format(**args)+'_'+name1+'.fits[2],'+self.template_file.format(**args)+'_'+name1+'.fits[2]'+ \
' -WEIGHT_TYPE MAP_WEIGHT -CHECKIMAGE_NAME ' + self.template_file.format(**args)+'_segmap.fits -CHECKIMAGE_TYPE SEGMENTATION '
print ' sextractorPSF \n',cmd,'\n'
print(' sextractorPSF \n',cmd,'\n')
# ' -INTERP_TYPE NONE -SEEING_FWHM ' + str(fwhm) +\

retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT)
Expand All @@ -549,31 +549,31 @@ def fwhm(self, incat ,debug):
CLASSLIM = 0.75 # class threshold to define star
MAGERRLIMIT = 0.1 # mag error threshold for stars

if debug: print "!!!! WUTL_STS: (fwhm): Opening scamp_cat to calculate median FWHM & ELLIPTICITY.\n"
if debug: print("!!!! WUTL_STS: (fwhm): Opening scamp_cat to calculate median FWHM & ELLIPTICITY.\n")
hdu = pyfits.open(incat,"readonly")

if debug: print "!!!! WUTL_STS: (fwhm): Checking to see that hdu2 in scamp_cat is a binary table.\n"
if debug: print("!!!! WUTL_STS: (fwhm): Checking to see that hdu2 in scamp_cat is a binary table.\n")
if 'XTENSION' in hdu[2].header:
if hdu[2].header['XTENSION'] != 'BINTABLE':
print "!!!! WUTL_ERR: (fwhm): this HDU is not a binary table"
print("!!!! WUTL_ERR: (fwhm): this HDU is not a binary table")
exit(1)
else:
print "!!!! WUTL_ERR: (fwhm): XTENSION keyword not found"
print("!!!! WUTL_ERR: (fwhm): XTENSION keyword not found")
exit(1)

if 'NAXIS2' in hdu[2].header:
nrows = hdu[2].header['NAXIS2']
print "!!!! WUTL_INF: (fwhm): Found %s rows in table" % nrows
print("!!!! WUTL_INF: (fwhm): Found %s rows in table" % nrows)
else:
print "!!!! WUTL_ERR: (fwhm): NAXIS2 keyword not found"
print("!!!! WUTL_ERR: (fwhm): NAXIS2 keyword not found")
exit(1)

tbldct = {}
for colname in ['FWHM_IMAGE','ELLIPTICITY','FLAGS','MAGERR_AUTO','CLASS_STAR']:
if colname in hdu[2].columns.names:
tbldct[colname] = hdu[2].data.field(colname)
else:
print "!!!! WUTL_ERR: (fwhm): No %s column in binary table" % colname
print("!!!! WUTL_ERR: (fwhm): No %s column in binary table" % colname)
exit(1)

hdu.close()
Expand Down Expand Up @@ -603,17 +603,17 @@ def fwhm(self, incat ,debug):
else:
if count%2:
# Odd number of elements
fwhm_med = fwhm_sel[count/2]
ellp_med = ellp_sel[count/2]
fwhm_med = fwhm_sel[count//2]
ellp_med = ellp_sel[count//2]
else:
# Even number of elements
fwhm_med = 0.5 * (fwhm_sel[count/2]+fwhm_sel[count/2-1])
ellp_med = 0.5 * (ellp_sel[count/2]+ellp_sel[count/2-1])
fwhm_med = 0.5 * (fwhm_sel[count//2]+fwhm_sel[count//2-1])
ellp_med = 0.5 * (ellp_sel[count//2]+ellp_sel[count//2-1])

if debug:
print "FWHM=%.4f" % fwhm_med
print "ELLIPTIC=%.4f" % ellp_med
print "NFWHMCNT=%s" % count
print("FWHM=%.4f" % fwhm_med)
print("ELLIPTIC=%.4f" % ellp_med)
print("NFWHMCNT=%s" % count)

return (fwhm_med,ellp_med,count)

Expand All @@ -636,7 +636,7 @@ def change_head(self, FileN, catalog, image, outname, CCD, **args):
for ii in o:
for oo in info_array:
if oo in ii.split('=')[0] :
#print ii.split('=')[0], ii.split('=')[1].split('/')[0]
#print(ii.split('=')[0], ii.split('=')[1].split('/')[0])
matrix.append(ii.split('=')[1].split('/')[0])

matrix = np.array(matrix)
Expand Down Expand Up @@ -774,11 +774,11 @@ def sanityCheck(self,fName):

if __name__ == "__main__":
nbpar = len(sys.argv)
print sys.argv
print(sys.argv)
conF = "confFile"
conF = sys.argv[1]

print " Start SEProc.py with conf File %s \n" % conF
print(" Start SEProc.py with conf File %s \n" % conF)
se = SEProc(conF)

EXPNUM = se.ConfigSectionMap("General")['expnum']
Expand All @@ -794,7 +794,7 @@ def sanityCheck(self,fName):

#EXPFILE = 'DECam_00'+str(EXPNUM)+'.fits.fz'
EXPFILE = data_file
print "Start working with file %s \n" % EXPFILE
print("Start working with file %s \n" % EXPFILE)
args = {'expnum': EXPNUM, 'filter': FILTER, 'ccd':'0', 'r':rRun, 'p':pRun, 'year': YEAR, 'epoch': EPOCH}

#running crosstalk
Expand Down Expand Up @@ -843,4 +843,4 @@ def sanityCheck(self,fName):
se.psfex( 'sextractorPSFEX', ccdstring, **args)
se.sextractorPSF('nullweightimmask', 'nullweightimmask', 'sextractor_psf', 'sextractorPSFEX.psf', ccdstring, **args)

print " End run on exposure %s \n" % EXPNUM
print(" End run on exposure %s \n" % EXPNUM)
Loading