diff --git a/AstrometryCheck.py b/AstrometryCheck.py index 7b69232..176b07e 100755 --- a/AstrometryCheck.py +++ b/AstrometryCheck.py @@ -11,7 +11,7 @@ -class AstrometryCheck(): +class AstrometryCheck: def __init__(self,catlistFile): self.catlist = catlistFile @@ -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])) @@ -95,4 +95,4 @@ def checkDiff(self): if astrT.checkDiff() < 0: sys.exit(-1) else: - sys.exit(0) \ No newline at end of file + sys.exit(0) diff --git a/BLISS-expCalib_Y3apass-old.py b/BLISS-expCalib_Y3apass-old.py index 7450693..3f8c4b1 100755 --- a/BLISS-expCalib_Y3apass-old.py +++ b/BLISS-expCalib_Y3apass-old.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Updated print statements to py3 on 9/28/2021 (Rob Morgan) # Version from 10/09/2017 according to Sahar rounding was changed from 357 to 350. # # @@ -28,7 +29,7 @@ def main(): import argparse import time - print " Start with BLISS-expCalib.py \n" + print(" Start with BLISS-expCalib.py \n") """Create command line arguments""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--expnum', help='expnum is queried', default=350245, type=int) @@ -42,7 +43,7 @@ def main(): args = parser.parse_args() - if args.verbose > 0: print args + if args.verbose > 0: print(args) # sys.exit() @@ -100,7 +101,7 @@ def doset(args): import healpy as hp import sys - if args.verbose >0 : print args + if args.verbose >0 : print(args) # delete previous *Obj.csv files oldfiles = glob.glob("*Obj.csv") @@ -108,19 +109,19 @@ def doset(args): if os.path.isfile(f): os.remove(f) else: - print "Old object file not deleted because it could not be found." + print("Old object file not deleted because it could not be found.") catlistFile="D%08d_r%sp%s_red_catlist.csv" % (args.expnum,str(args.reqnum),str(args.attnum)) -# print " looking for file %s in local directory \n" % catlistFile +# print(" looking for file %s in local directory \n" % catlistFile) if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " file %s found \n" %catlistFile +# print(" file %s found \n" %catlistFile) data=np.genfromtxt(catlistFile,dtype=None,delimiter=',',names=True) # get only data for correct CCD correctccd = (data['CCDNUM'] == args.ccd) data = data[ correctccd ] -# print " before loop \n" +# print(" before loop \n") for i in range(data['FILENAME'].size): # to avoid error when array is not 2D because it only has one entry @@ -186,17 +187,17 @@ def doset(args): desipixlist= desipixc,desipix1,desipix2,desipix3,desipix4,desipix12,desipix23,desipix34,desipix14 desipixlist=uniqlist(desipixlist) - ra1=[];ra2=[];dec1=[];dec2=[] + ra1, ra2, dec1, dec2 = [], [], [], [] matchlistout="""%s_match.csv""" % (filetocheck) objlistFile ="""%s_Obj.csv""" % (filetocheck) stdlistFile ="""%s_std.csv""" % (filetocheck) if not os.path.isfile(objlistFile): - print '%s does not seem to exist... exiting now...' % objlistFile + print('%s does not seem to exist... exiting now...' % objlistFile) sys.exit(1) if not os.path.isfile(stdlistFile): - print '%s does not seem to exist... exiting now...' % stdlistFile + print('%s does not seem to exist... exiting now...' % stdlistFile) sys.exit(1) stdracol=1 @@ -206,7 +207,7 @@ def doset(args): matchTolArcsec=1.0 #1.0arcsec verbose=2 matchSortedStdwithObsCats(stdlistFile,objlistFile,matchlistout,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) - print "after the loop \n" + print("after the loop \n") return 0 @@ -227,11 +228,11 @@ def Wget_data_home(args): #Check first if file exists... if glob.glob(myfile): #Print '%s does seem to exist... exiting now...' % catname - print "relevant cat files already exist in the current directory... no need to wget..." + print("relevant cat files already exist in the current directory... no need to wget...") #sys.exit(1) return 1 else: - print "relevant cat files are not in directory... wgetting them from archive..." + print("relevant cat files are not in directory... wgetting them from archive...") sys.exit(1) @@ -276,14 +277,14 @@ def Read_Sexcatalogfitstocsv(args,fitsname,band): zeropoint=args.sex_mag_zeropoint*(SEXdata[fluxType]/SEXdata[fluxType]) with open(outFile,'w') as csvFile: - writer = csv.writer(csvFile,delimiter=',', quotechar='|', - lineterminator='\n', quoting=csv.QUOTE_MINIMAL) + writer = csv.writer(csvFile,delimiter=',', quotechar='|', + lineterminator='\n', quoting=csv.QUOTE_MINIMAL) - writer.writerow(hdr) - line=[] - for i in range(SEXdata.size): - line=SEXdata['NUMBER'][i],SEXdata['ALPHAWIN_J2000'][i], SEXdata['DELTAWIN_J2000'][i], mag[i], magerr[i], zeropoint[i], magType,band - writer.writerow(line) + writer.writerow(hdr) + line=[] + for i in range(SEXdata.size): + line=SEXdata['NUMBER'][i],SEXdata['ALPHAWIN_J2000'][i], SEXdata['DELTAWIN_J2000'][i], mag[i], magerr[i], zeropoint[i], magType,band + writer.writerow(line) SEXdata=[] Fdata=[] @@ -327,13 +328,13 @@ def getallccdfromGAIA(args): #print NEED Round RA catlistFile="""D%08d_r%sp%s_red_catlist.csv""" % (args.expnum,str(args.reqnum),str(args.attnum)) - print "looking for file %s \n" % catlistFile + print("looking for file %s \n" % catlistFile) if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " found file %s \n" % catlistFile +# print(" found file %s \n" % catlistFile) data=pd.read_csv(catlistFile) -# print " the file is read unpack data \n" +# print(" the file is read unpack data \n") # unpack image data BAND=data['BAND'][0] @@ -470,13 +471,13 @@ def getallccdfromAPASS92MASS(args): #print NEED Round RA catlistFile="""D%08d_r%sp%s_red_catlist.csv""" % (args.expnum,str(args.reqnum),str(args.attnum)) - print "looking for file %s \n" % catlistFile + print("looking for file %s \n" % catlistFile) if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " found file %s \n" % catlistFile +# print(" found file %s \n" % catlistFile) data=pd.read_csv(catlistFile) -# print " the file is read unpack data \n" +# print(" the file is read unpack data \n") BAND=data['BAND'][0] data['desipixc']=getipix(8,data['RA_CENT'], data['DEC_CENT']) data['desipix1']=getipix(8,data['RAC1'],data['DECC1']) @@ -488,9 +489,9 @@ def getallccdfromAPASS92MASS(args): data['desipix23']=getipix(8,data['RA_CENT'],data['DECC2']) data['desipix34']=getipix(8,data['RAC3'],data['DEC_CENT']) data['desipix14']=getipix(8,data['RA_CENT'],data['DECC4']) -# print " first step \n" +# print(" first step \n") desipixlist= pd.unique(data[['desipixc','desipix1','desipix2','desipix3','desipix4','desipix12','desipix23','desipix34','desipix14']].values.ravel()) -# print desipixlist +# print(desipixlist) desipixlist=uniqlist(desipixlist) stdRA = np.std(data['RA_CENT']) if ( stdRA >20 ) : @@ -500,17 +501,17 @@ def getallccdfromAPASS92MASS(args): data['RAC3'] =[roundra(x) for x in data['RAC3']] data['RAC4'] =[roundra(x) for x in data['RAC4']] -# print " stdRA=%f \n" % stdRA +# print(" stdRA=%f \n" % stdRA) # if ( stdRA <=20 ) : -# print " Something goes wrong stdRA=%f exiting \n" % stdRA +# print(" Something goes wrong stdRA=%f exiting \n" % stdRA) # sys.exit(1) -# print " second step \n" +# print(" second step \n") minra=min(min(data['RA_CENT']),min(data['RAC1']),min(data['RAC2']),min(data['RAC3']),min(data['RAC4']))-0.1 mindec=min(min(data['DEC_CENT']),min(data['DECC1']),min(data['DECC2']),min(data['DECC3']),min(data['DECC4']))-0.1 maxra=max(max(data['RA_CENT']),max(data['RAC1']),max(data['RAC2']),max(data['RAC3']),max(data['RAC4']))+0.1 maxdec=max(max(data['DEC_CENT']),max(data['DECC1']),max(data['DECC2']),max(data['DECC3']),max(data['DECC4']))+0.1 -# print minra,maxra, mindec,maxdec +# print(minra,maxra, mindec,maxdec) outfile="""STD%s""" % catlistFile @@ -521,7 +522,7 @@ def getallccdfromAPASS92MASS(args): for i in desipixlist: #myfile="""/data/des20.b/data/sallam/pyPSM_Year2/TWOMASS/ALL-2MASS/2arcsec/apass_TWO_MASS_%d.csv""" %i -# print "before copying file %d from stash " % i +# print("before copying file %d from stash " % i) myfile="""/pnfs/des/persistent/stash/ALLSKY_STARCAT/apass_TWO_MASS_%d.csv""" %i # myfile1 = "/cvmfs/des.osgstorage.org/stash/ALLSKY_STARCAT/apass_TWO_MASS_%d.csv" %i ########## @@ -531,7 +532,7 @@ def getallccdfromAPASS92MASS(args): os.system('ifdh cp -D %s .' %myfile) if not os.path.exists("./"+mmyfile): - print "file was not copyed try to link it \n" + print("file was not copyed try to link it \n") # os.symlink(myfile1,mmyfile) # mmyfile="""apass_TWO_MASS_%d.csv""" %i @@ -571,12 +572,12 @@ def plotradec_sexvsY2Q1(args): import sys import matplotlib.pyplot as plt - if args.verbose >0 : print args + if args.verbose >0 : print(args) catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) data=np.genfromtxt(catlistFile,dtype=None,delimiter=',',names=True) @@ -599,11 +600,11 @@ def plotradec_sexvsY2Q1(args): stdlistFile="""%s_std.csv""" % (catFilename) if not os.path.isfile(objlistFile): - print '%s does not seem to exist... exiting now...' % objlistFile + print('%s does not seem to exist... exiting now...' % objlistFile) sys.exit(1) if not os.path.isfile(stdlistFile): - print '%s does not seem to exist... exiting now...' % stdlistFile + print ('%s does not seem to exist... exiting now...' % stdlistFile) sys.exit(1) # Read in the file... @@ -642,7 +643,7 @@ def matchSortedStdwithObsCats(inputStdFile,inputObsFile,outputMatch,racolStdFile matchTolArcsec=matchArcsec verbose=verbose - #print f1,f2,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose + #print(f1,f2,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) # Initialize "dictionaries"... # Each element of a "dictionary" is associated with a standard star. @@ -719,7 +720,7 @@ def matchSortedStdwithObsCats(inputStdFile,inputObsFile,outputMatch,racolStdFile # Increment line count from observed data file... linecnt += 1 if ( (linecnt/1000.0 == int(linecnt/1000.0)) and (verbose > 1) ): - print '\r'+'Progress (lines read from observed catalog): ',linecnt, + sys.stdout.write('\r'+'Progress (lines read from observed catalog): %i ' %linecnt) sys.stdout.flush() # Read line from observed data file... @@ -913,11 +914,11 @@ def sigmaClipZP(args): import sys import math - if args.verbose >0 : print args + if args.verbose >0 : print(args) catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) data1=np.genfromtxt(catlistFile,dtype=None,delimiter=',',names=True) @@ -945,7 +946,7 @@ def sigmaClipZP(args): matchListFile="%s_match.csv" % (catFilename) if not os.path.isfile(matchListFile): - print '%s does not seem to exist... exiting now...' % matchListFile + print('%s does not seem to exist... exiting now...' % matchListFile) sys.exit(1) try: @@ -989,7 +990,7 @@ def sigmaClipZP(args): ZeroListFile="""Zero_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % ZeroListFile + print('%s does not seem to exist... exiting now...' % ZeroListFile) sys.exit(1) MergedFile="""Merged_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) @@ -1044,7 +1045,7 @@ def sigmaClipZPallCCDs(args): from numpy import mean import numpy.ma as ma - if args.verbose >0 : print args + if args.verbose >0 : print(args) #allZPout="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) allZPout="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) stdfile="""STDD%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) @@ -1071,8 +1072,9 @@ def sigmaClipZPallCCDs(args): verbose=2 matchSortedStdwithObsCats(stdfile,objfile,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) + # Rob Morgan (9/28/21) This indentation seems troublesome. Someone should take a look. if not os.path.isfile(outfile): - print '%s does not seem to exist... exiting now...' % outfile + print('%s does not seem to exist... exiting now...' % outfile) sys.exit(1) try: data11=np.genfromtxt(outfile,dtype=None,delimiter=',',names=True) @@ -1126,16 +1128,16 @@ def ZP_OUTLIERS(args): import matplotlib as mpl - if args.verbose >0 : print args + if args.verbose >0 : print(args) #allZeroFile="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) allZeroFile="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) #if not os.path.isfile(catlistFile): - # print '%s does not seem to exist... exiting now...' % ZeroListFile + # print('%s does not seem to exist... exiting now...' % ZeroListFile) # sys.exit(1) MergedFile="""Merged_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(MergedFile): - print '%s does not seem to exist... exiting now...' % MergedFile + print('%s does not seem to exist... exiting now...' % MergedFile) sys.exit(1) fout="""Merg_allZP_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) @@ -1248,19 +1250,19 @@ def plotradec_ZP(args): import matplotlib as mpl import sys - if args.verbose >0 : print args + if args.verbose >0 : print(args) catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) #ZeroListFile="""Zero_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) #if not os.path.isfile(catlistFile): - # print '%s does not seem to exist... exiting now...' % ZeroListFile + # print('%s does not seem to exist... exiting now...' % ZeroListFile) # sys.exit(1) #Mergedout="""Merged_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) - #print catlistFile,ZeroListFile,Mergedout + #print(catlistFile,ZeroListFile,Mergedout) #jointwocsv(catlistFile,ZeroListFile,Mergedout) #MergedFile="""Merg_allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) @@ -1274,7 +1276,7 @@ def plotradec_ZP(args): data['RAC3'] =[roundra(x) for x in data['RAC3']] data['RAC4'] =[roundra(x) for x in data['RAC4']] - # print " Unexpected value of the RA spred stdRA=%f \n" % stdRA + # print(" Unexpected value of the RA spred stdRA=%f \n" % stdRA) # sys.exit(1) w0=(data['ZP']==-999) w1=(data['ZP']>-999) @@ -1472,16 +1474,16 @@ def apply_ZP_Sexcatalogfitstocsv(catFilename,EXPNUM,CCDNUM,zeropoint,zeropoint_r data['MAGERR_PSF'] = np.where(w1 ,(2.5/math.log(10.))*(data['FLUXERR_PSF']/data['FLUX_PSF']) ,np.int16(-9999)) with open(outFile,'w') as csvFile: - writer = csv.writer(csvFile,delimiter=',', quotechar='|', - lineterminator='\n', quoting=csv.QUOTE_MINIMAL) + writer = csv.writer(csvFile,delimiter=',', quotechar='|', + lineterminator='\n', quoting=csv.QUOTE_MINIMAL) - writer.writerow(col) + writer.writerow(col) - line=[] - for i in range(data.size): - line=EXPNUM,CCDNUM,data['NUMBER'][i],data['ALPHAWIN_J2000'][i],data['DELTAWIN_J2000'][i],data['FLUX_AUTO'][i],data['FLUXERR_AUTO'][i],data['FLUX_PSF'][i],data['FLUXERR_PSF'][i],data['MAG_AUTO'][i],data['MAGERR_AUTO'][i],data['MAG_PSF'][i],data['MAGERR_PSF'][i],data['SPREAD_MODEL'][i],data['SPREADERR_MODEL'][i],data['FWHM_WORLD'][i],data['FWHMPSF_IMAGE'][i],data['FWHMPSF_WORLD'][i],data['CLASS_STAR'][i],data['FLAGS'][i],data['IMAFLAGS_ISO'][i],zeropoint,zeropoint_rms,ZPFLAG + line=[] + for i in range(data.size): + line=EXPNUM,CCDNUM,data['NUMBER'][i],data['ALPHAWIN_J2000'][i],data['DELTAWIN_J2000'][i],data['FLUX_AUTO'][i],data['FLUXERR_AUTO'][i],data['FLUX_PSF'][i],data['FLUXERR_PSF'][i],data['MAG_AUTO'][i],data['MAGERR_AUTO'][i],data['MAG_PSF'][i],data['MAGERR_PSF'][i],data['SPREAD_MODEL'][i],data['SPREADERR_MODEL'][i],data['FWHM_WORLD'][i],data['FWHMPSF_IMAGE'][i],data['FWHMPSF_WORLD'][i],data['CLASS_STAR'][i],data['FLAGS'][i],data['IMAFLAGS_ISO'][i],zeropoint,zeropoint_rms,ZPFLAG - writer.writerow(line) + writer.writerow(line) data=[] @@ -1494,11 +1496,11 @@ def Onefile(args): import pandas as pd from astropy.io import fits - if args.verbose >0 : print args + if args.verbose >0 : print(args) catlistFile="""Merg_allZP_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist...' % catlistFile + print('%s does not seem to exist...' % catlistFile) fout="""D%08d_%02d_r%sp%1d_ZP.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) fitsout="""D%08d_%02d_r%sp%1d_ZP.fits""" % (args.expnum,args.ccd,args.reqnum,args.attnum) diff --git a/BLISS-expCalib_Y3apass.py b/BLISS-expCalib_Y3apass.py index f44ff44..baef9e0 100755 --- a/BLISS-expCalib_Y3apass.py +++ b/BLISS-expCalib_Y3apass.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # +# Version from 09/28/2021 minor updates for python 3. # Version from 10/09/2017 according to Sahar rounding was changed from 357 to 350. # # @@ -28,7 +29,7 @@ def main(): import argparse import time - print " Start with BLISS-expCalib.py \n" + print(" Start with BLISS-expCalib.py \n") """Create command line arguments""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--expnum', help='expnum is queried', default=350245, type=int) @@ -42,7 +43,7 @@ def main(): args = parser.parse_args() - if args.verbose > 0: print args + if args.verbose > 0: print(args) # sys.exit() @@ -100,7 +101,7 @@ def doset(args): import healpy as hp import sys - if args.verbose >0 : print args + if args.verbose >0 : print(args) # delete previous *Obj.csv files oldfiles = glob.glob("*Obj.csv") @@ -108,19 +109,19 @@ def doset(args): if os.path.isfile(f): os.remove(f) else: - print "Old object file not deleted because it could not be found." + print("Old object file not deleted because it could not be found.") catlistFile="D%08d_r%sp%s_red_catlist.csv" % (args.expnum,str(args.reqnum),str(args.attnum)) -# print " looking for file %s in local directory \n" % catlistFile +# print(" looking for file %s in local directory \n" % catlistFile) if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " file %s found \n" %catlistFile +# print(" file %s found \n" %catlistFile) data=np.genfromtxt(catlistFile,dtype=None,encoding=None,delimiter=',',names=True) correctccd = (data['CCDNUM'] == args.ccd) data = data[ correctccd ] -# print " befor loop \n" +# print(" befor loop \n") for i in range(data['FILENAME'].size): # to avoid error when array is not 2D because it only has one entry @@ -185,17 +186,17 @@ def doset(args): desipixlist= desipixc,desipix1,desipix2,desipix3,desipix4,desipix12,desipix23,desipix34,desipix14 desipixlist=uniqlist(desipixlist) - ra1=[];ra2=[];dec1=[];dec2=[] + ra1, ra2, dec1, dec2 = [], [], [], [] matchlistout="""%s_match.csv""" % (filetocheck) objlistFile ="""%s_Obj.csv""" % (filetocheck) stdlistFile ="""%s_std.csv""" % (filetocheck) if not os.path.isfile(objlistFile): - print '%s does not seem to exist... exiting now...' % objlistFile + print('%s does not seem to exist... exiting now...' % objlistFile) sys.exit(1) if not os.path.isfile(stdlistFile): - print '%s does not seem to exist... exiting now...' % stdlistFile + print('%s does not seem to exist... exiting now...' % stdlistFile) sys.exit(1) stdracol=1 @@ -205,7 +206,7 @@ def doset(args): matchTolArcsec=1.0 #1.0arcsec verbose=2 matchSortedStdwithObsCats(stdlistFile,objlistFile,matchlistout,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) - print "after the loop \n" + print("after the loop \n") return 0 @@ -226,11 +227,11 @@ def Wget_data_home(args): #Check first if file exists... if glob.glob(myfile): #Print '%s does seem to exist... exiting now...' % catname - print "relevant cat files already exist in the current directory... no need to wget..." + print("relevant cat files already exist in the current directory... no need to wget...") #sys.exit(1) return 1 else: - print "relevant cat files are not in directory... wgetting them from archive..." + print("relevant cat files are not in directory... wgetting them from archive...") sys.exit(1) @@ -246,7 +247,7 @@ def Read_Sexcatalogfitstocsv(args,fitsname,band): import csv catFilename=fitsname - outFile="""%s_Obj.csv""" % (catFilename) + outFile="""%s_Obj.csv""" % catFilename extension=2 hdr = ["OBJECT_NUMBER","RA","DEC","MAG","MAGERR","ZEROPOINT","MAGTYPE","BAND"] @@ -275,14 +276,14 @@ def Read_Sexcatalogfitstocsv(args,fitsname,band): zeropoint=args.sex_mag_zeropoint*(SEXdata[fluxType]/SEXdata[fluxType]) with open(outFile,'w') as csvFile: - writer = csv.writer(csvFile,delimiter=',', quotechar='|', - lineterminator='\n', quoting=csv.QUOTE_MINIMAL) + writer = csv.writer( + csvFile,delimiter=',', quotechar='|', lineterminator='\n', quoting=csv.QUOTE_MINIMAL) - writer.writerow(hdr) - line=[] - for i in range(SEXdata.size): - line=SEXdata['NUMBER'][i],SEXdata['ALPHAWIN_J2000'][i], SEXdata['DELTAWIN_J2000'][i], mag[i], magerr[i], zeropoint[i], magType,band - writer.writerow(line) + writer.writerow(hdr) + line=[] + for i in range(SEXdata.size): + line=SEXdata['NUMBER'][i],SEXdata['ALPHAWIN_J2000'][i], SEXdata['DELTAWIN_J2000'][i], mag[i], magerr[i], zeropoint[i], magType,band + writer.writerow(line) SEXdata=[] Fdata=[] @@ -326,13 +327,13 @@ def getallccdfromGAIA(args): #print NEED Round RA catlistFile="""D%08d_r%sp%s_red_catlist.csv""" % (args.expnum,str(args.reqnum),str(args.attnum)) - print "looking for file %s \n" % catlistFile + print("looking for file %s \n" % catlistFile) if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " found file %s \n" % catlistFile +# print(" found file %s \n" % catlistFile) data=pd.read_csv(catlistFile) -# print " the file is read unpack data \n" +# print(" the file is read unpack data \n") # unpack image data BAND=data['BAND'][0] @@ -356,7 +357,7 @@ def getallccdfromGAIA(args): # using only the row for the current CCD correctccd = (data['CCDNUM'] == args.ccd) data = data[ correctccd ] - print "data: %s" % data + print("data: %s" % data) ra=data.iloc[0]['RA_CENT'] # in degrees; use iloc to get single cell dec=data.iloc[0]['DEC_CENT'] # in degrees nside=32 @@ -465,11 +466,11 @@ def getallccdfromAPASS92MASS(args): catlistFile="""D%08d_r%sp%s_red_catlist.csv""" % (args.expnum,str(args.reqnum),str(args.attnum)) print "looking for file %s \n" % catlistFile if not os.path.exists(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) -# print " found file %s \n" % catlistFile +# print(" found file %s \n" % catlistFile) data=pd.read_csv(catlistFile) -# print " the file is read unpack data \n" +# print(" the file is read unpack data \n") BAND=data['BAND'][0] data['desipixc']=getipix(8,data['RA_CENT'], data['DEC_CENT']) data['desipix1']=getipix(8,data['RAC1'],data['DECC1']) @@ -481,9 +482,9 @@ def getallccdfromAPASS92MASS(args): data['desipix23']=getipix(8,data['RA_CENT'],data['DECC2']) data['desipix34']=getipix(8,data['RAC3'],data['DEC_CENT']) data['desipix14']=getipix(8,data['RA_CENT'],data['DECC4']) -# print " first step \n" +# print(" first step \n") desipixlist= pd.unique(data[['desipixc','desipix1','desipix2','desipix3','desipix4','desipix12','desipix23','desipix34','desipix14']].values.ravel()) -# print desipixlist +# print(desipixlist) desipixlist=uniqlist(desipixlist) stdRA = np.std(data['RA_CENT']) if ( stdRA >20 ) : @@ -493,17 +494,17 @@ def getallccdfromAPASS92MASS(args): data['RAC3'] =[roundra(x) for x in data['RAC3']] data['RAC4'] =[roundra(x) for x in data['RAC4']] -# print " stdRA=%f \n" % stdRA +# print(" stdRA=%f \n" % stdRA) # if ( stdRA <=20 ) : -# print " Something goes wrong stdRA=%f exiting \n" % stdRA +# print(" Something goes wrong stdRA=%f exiting \n" % stdRA) # sys.exit(1) -# print " second step \n" +# print(" second step \n") minra=min(min(data['RA_CENT']),min(data['RAC1']),min(data['RAC2']),min(data['RAC3']),min(data['RAC4']))-0.1 mindec=min(min(data['DEC_CENT']),min(data['DECC1']),min(data['DECC2']),min(data['DECC3']),min(data['DECC4']))-0.1 maxra=max(max(data['RA_CENT']),max(data['RAC1']),max(data['RAC2']),max(data['RAC3']),max(data['RAC4']))+0.1 maxdec=max(max(data['DEC_CENT']),max(data['DECC1']),max(data['DECC2']),max(data['DECC3']),max(data['DECC4']))+0.1 -# print minra,maxra, mindec,maxdec +# print(minra,maxra, mindec,maxdec) outfile="""STD%s""" % catlistFile @@ -514,7 +515,7 @@ def getallccdfromAPASS92MASS(args): for i in desipixlist: #myfile="""/data/des20.b/data/sallam/pyPSM_Year2/TWOMASS/ALL-2MASS/2arcsec/apass_TWO_MASS_%d.csv""" %i -# print "before copying file %d from stash " % i +# print("before copying file %d from stash " % i) myfile="""/pnfs/des/persistent/stash/ALLSKY_STARCAT/apass_TWO_MASS_%d.csv""" %i # myfile1 = "/cvmfs/des.osgstorage.org/stash/ALLSKY_STARCAT/apass_TWO_MASS_%d.csv" %i ########## @@ -524,7 +525,7 @@ def getallccdfromAPASS92MASS(args): os.system('ifdh cp -D %s .' %myfile) if not os.path.exists("./"+mmyfile): - print "file was not copyed try to link it \n" + print("file was not copyed try to link it \n") # os.symlink(myfile1,mmyfile) # mmyfile="""apass_TWO_MASS_%d.csv""" %i @@ -569,7 +570,7 @@ def plotradec_sexvsY2Q1(args): catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) data=np.genfromtxt(catlistFile,dtype=None,delimiter=',',names=True) @@ -587,16 +588,16 @@ def plotradec_sexvsY2Q1(args): CCDpoints=[[rac2,decc2],[rac,decc2],[rac3,decc3],[rac3,decc],[rac4,decc4],[rac,decc4],[rac1,decc1],[rac1,decc]] ccdline = plt.Polygon(CCDpoints, fill=None, edgecolor='g') - pnglistout="""%s.png""" % (catFilename) - objlistFile="""%s_Obj.csv""" % (catFilename) - stdlistFile="""%s_std.csv""" % (catFilename) + pnglistout="""%s.png""" % catFilename + objlistFile="""%s_Obj.csv""" % catFilename + stdlistFile="""%s_std.csv""" % catFilename if not os.path.isfile(objlistFile): - print '%s does not seem to exist... exiting now...' % objlistFile + print('%s does not seem to exist... exiting now...' % objlistFile) sys.exit(1) if not os.path.isfile(stdlistFile): - print '%s does not seem to exist... exiting now...' % stdlistFile + print('%s does not seem to exist... exiting now...' % stdlistFile) sys.exit(1) # Read in the file... @@ -635,7 +636,7 @@ def matchSortedStdwithObsCats(inputStdFile,inputObsFile,outputMatch,racolStdFile matchTolArcsec=matchArcsec verbose=verbose - #print f1,f2,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose + #print(f1,f2,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) # Initialize "dictionaries"... # Each element of a "dictionary" is associated with a standard star. @@ -712,7 +713,7 @@ def matchSortedStdwithObsCats(inputStdFile,inputObsFile,outputMatch,racolStdFile # Increment line count from observed data file... linecnt += 1 if ( (linecnt/1000.0 == int(linecnt/1000.0)) and (verbose > 1) ): - print '\r'+'Progress (lines read from observed catalog): ',linecnt, + print('\r'+'Progress (lines read from observed catalog): ',linecnt,) sys.stdout.flush() # Read line from observed data file... @@ -906,11 +907,11 @@ def sigmaClipZP(args): import sys import math - if args.verbose >0 : print args + if args.verbose >0 : print(args) catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) data1=np.genfromtxt(catlistFile,dtype=None,encoding=None,delimiter=',',names=True) @@ -938,7 +939,7 @@ def sigmaClipZP(args): matchListFile="%s_match.csv" % (catFilename) if not os.path.isfile(matchListFile): - print '%s does not seem to exist... exiting now...' % matchListFile + print('%s does not seem to exist... exiting now...' % matchListFile) sys.exit(1) try: @@ -982,7 +983,7 @@ def sigmaClipZP(args): ZeroListFile="""Zero_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % ZeroListFile + print('%s does not seem to exist... exiting now...' % ZeroListFile) sys.exit(1) MergedFile="""Merged_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) @@ -1064,8 +1065,9 @@ def sigmaClipZPallCCDs(args): verbose=2 matchSortedStdwithObsCats(stdfile,objfile,outfile,stdracol,stddeccol,obsracol,obsdeccol,matchTolArcsec,verbose) + # Rob Morgan (9/28/21): this indentation looks troublesome if not os.path.isfile(outfile): - print '%s does not seem to exist... exiting now...' % outfile + print('%s does not seem to exist... exiting now...' % outfile) sys.exit(1) try: data11=np.genfromtxt(outfile,dtype=None,encoding=None,delimiter=',',names=True) @@ -1123,12 +1125,12 @@ def ZP_OUTLIERS(args): #allZeroFile="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) allZeroFile="""allZP_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) #if not os.path.isfile(catlistFile): - # print '%s does not seem to exist... exiting now...' % ZeroListFile + # print('%s does not seem to exist... exiting now...' % ZeroListFile) # sys.exit(1) MergedFile="""Merged_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(MergedFile): - print '%s does not seem to exist... exiting now...' % MergedFile + print('%s does not seem to exist... exiting now...' % MergedFile) sys.exit(1) fout="""Merg_allZP_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) @@ -1245,7 +1247,7 @@ def plotradec_ZP(args): catlistFile="""D%08d_r%sp%1d_red_catlist.csv""" % (args.expnum,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist... exiting now...' % catlistFile + print('%s does not seem to exist... exiting now...' % catlistFile) sys.exit(1) #ZeroListFile="""Zero_D%08d_r%sp%1d.csv""" % (args.expnum,args.reqnum,args.attnum) @@ -1466,16 +1468,16 @@ def apply_ZP_Sexcatalogfitstocsv(catFilename,EXPNUM,CCDNUM,zeropoint,zeropoint_r data['MAGERR_PSF'] = np.where(w1 ,(2.5/math.log(10.))*(data['FLUXERR_PSF']/data['FLUX_PSF']) ,np.int16(-9999)) with open(outFile,'w') as csvFile: - writer = csv.writer(csvFile,delimiter=',', quotechar='|', - lineterminator='\n', quoting=csv.QUOTE_MINIMAL) + writer = csv.writer(csvFile,delimiter=',', quotechar='|', + lineterminator='\n', quoting=csv.QUOTE_MINIMAL) - writer.writerow(col) + writer.writerow(col) - line=[] - for i in range(data.size): - line=EXPNUM,CCDNUM,data['NUMBER'][i],data['ALPHAWIN_J2000'][i],data['DELTAWIN_J2000'][i],data['FLUX_AUTO'][i],data['FLUXERR_AUTO'][i],data['FLUX_PSF'][i],data['FLUXERR_PSF'][i],data['MAG_AUTO'][i],data['MAGERR_AUTO'][i],data['MAG_PSF'][i],data['MAGERR_PSF'][i],data['SPREAD_MODEL'][i],data['SPREADERR_MODEL'][i],data['FWHM_WORLD'][i],data['FWHMPSF_IMAGE'][i],data['FWHMPSF_WORLD'][i],data['CLASS_STAR'][i],data['FLAGS'][i],data['IMAFLAGS_ISO'][i],zeropoint,zeropoint_rms,ZPFLAG + line=[] + for i in range(data.size): + line=EXPNUM,CCDNUM,data['NUMBER'][i],data['ALPHAWIN_J2000'][i],data['DELTAWIN_J2000'][i],data['FLUX_AUTO'][i],data['FLUXERR_AUTO'][i],data['FLUX_PSF'][i],data['FLUXERR_PSF'][i],data['MAG_AUTO'][i],data['MAGERR_AUTO'][i],data['MAG_PSF'][i],data['MAGERR_PSF'][i],data['SPREAD_MODEL'][i],data['SPREADERR_MODEL'][i],data['FWHM_WORLD'][i],data['FWHMPSF_IMAGE'][i],data['FWHMPSF_WORLD'][i],data['CLASS_STAR'][i],data['FLAGS'][i],data['IMAFLAGS_ISO'][i],zeropoint,zeropoint_rms,ZPFLAG - writer.writerow(line) + writer.writerow(line) data=[] @@ -1492,7 +1494,7 @@ def Onefile(args): catlistFile="""Merg_allZP_D%08d_%02d_r%sp%1d.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) if not os.path.isfile(catlistFile): - print '%s does not seem to exist...' % catlistFile + print('%s does not seem to exist...' % catlistFile) fout="""D%08d_%02d_r%sp%1d_ZP.csv""" % (args.expnum,args.ccd,args.reqnum,args.attnum) fitsout="""D%08d_%02d_r%sp%1d_ZP.fits""" % (args.expnum,args.ccd,args.reqnum,args.attnum) diff --git a/SEProc.py b/SEProc.py index 69bd542..9ea3b4d 100755 --- a/SEProc.py +++ b/SEProc.py @@ -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 @@ -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'] @@ -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 @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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) @@ -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: @@ -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: @@ -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: @@ -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: @@ -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) @@ -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: @@ -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) @@ -549,23 +549,23 @@ 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 = {} @@ -573,7 +573,7 @@ def fwhm(self, incat ,debug): 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() @@ -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) @@ -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) @@ -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'] @@ -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 @@ -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) diff --git a/SEProcPool.py b/SEProcPool.py index 36eddee..fd436ac 100755 --- a/SEProcPool.py +++ b/SEProcPool.py @@ -15,7 +15,7 @@ import numpy as np import pyfits import os -import ConfigParser +import configparser import argparse from despyfits.DESImage import DESImage @@ -54,7 +54,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'] @@ -238,7 +238,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: @@ -260,7 +260,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: @@ -279,7 +279,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: @@ -301,7 +301,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: @@ -326,7 +326,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: @@ -336,7 +336,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: @@ -348,7 +348,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: @@ -370,7 +370,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) @@ -399,7 +399,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: @@ -424,7 +424,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: @@ -471,7 +471,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: @@ -492,7 +492,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: @@ -531,7 +531,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) @@ -546,7 +546,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: @@ -574,7 +574,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) @@ -596,23 +596,23 @@ 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 = {} @@ -620,7 +620,7 @@ def fwhm(self, incat ,debug): 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() @@ -650,12 +650,12 @@ 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 @@ -853,11 +853,11 @@ def l3p(self,ccdstring): if __name__ == '__main__': nbpar = len(sys.argv) - print sys.argv + print(sys.argv) conF = "confFile" conF = sys.argv[1] multiprocessing.freeze_support() - print " Start SEProc.py with conf File %s\n" % conF + print(" Start SEProc.py with conf File %s\n" % conF) se = SEProcPool(conF) print "instance created \n" EXPNUM = se.ConfigSectionMap("General")['expnum'] @@ -871,10 +871,10 @@ def l3p(self,ccdstring): YEAR = se.ConfigSectionMap("General")['year'] EPOCH = se.ConfigSectionMap("General")['epoch'] ncpu = int(se.ConfigSectionMap("General")['ncpu']) - print "ncpu=%d \n" % ncpu + print("ncpu=%d \n" % ncpu) #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} se.setArgs(**args) #running crosstalk @@ -882,12 +882,12 @@ def l3p(self,ccdstring): # I have to replace NITE with empty string to avoid modification of the file path # as it add to the path NITE and we have different data model # - print " Start crosstalk \n" + print(" Start crosstalk \n") se.crosstalk(EXPFILE,'',**args) nccd = len(CCD) xfiles_list = glob.glob('*_xtalk.fits') if len(xfiles_list) < nccd: - print " Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list)) + print(" Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list))) sys.exit(-1) #running pixelcorrect and bleedmask se.copy_from_Dcache(se.data_conf+'default.psf') @@ -919,19 +919,19 @@ def l3p(self,ccdstring): se.change_head('Scamp_allCCD_r'+rRun+'p'+pRun+'.head', 'sextractor', 'detrend', 'wcs', CCD, **args) # - print "SECOND LOOP \n" + print("SECOND LOOP \n") pool.map(runL2P, pars) se.fileclean('detrend','.fits') se.skyCombineFit('bleedmask-mini','bleedmask-mini-fp','skyfit-binned-fp',**args) # - print "THIRD LOOP \n" + print("THIRD LOOP \n") pool.map(runL3P, pars) se.fileclean('nullwtbkg','.fits') pool.close() pool.join() -# print res +# print(res) - print " End run on exposure \n" + print(" End run on exposure \n") diff --git a/SEProcPoolST.py b/SEProcPoolST.py index af544bd..db2974b 100755 --- a/SEProcPoolST.py +++ b/SEProcPoolST.py @@ -16,7 +16,7 @@ import numpy as np import pyfits import os -import ConfigParser +import configparser import argparse from despyfits.DESImage import DESImage @@ -29,7 +29,8 @@ import pathos from pathos.multiprocessing import ProcessingPool as Pool from scipy.weave.catalog import os_dependent_catalog_name -from setuptools.command.easy_install import sys_executable +# RM: I don't think this will work in py3, but looks like it's not used. +# from setuptools.command.easy_install import sys_executable import shutil @@ -58,7 +59,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'] @@ -161,7 +162,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 @@ -171,7 +172,7 @@ def ConfigSectionMap(self,section): # get link from stash # #---------------------------# def link_from_Dcache(self,fileN): -# print "link file %s \n" % fileN +# print("link file %s \n" % fileN) dest = fileN.split('/')[-1] if not os.path.exists("./"+dest): os.symlink(fileN,dest) @@ -251,7 +252,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: @@ -273,7 +274,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: @@ -292,7 +293,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: @@ -314,7 +315,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: @@ -339,7 +340,7 @@ def skyCombineFit(self,inputFile,skycombineFile,skyfitinfoFile,**args): self.link_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: @@ -349,7 +350,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: @@ -361,7 +362,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: @@ -383,7 +384,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) @@ -412,7 +413,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: @@ -437,15 +438,15 @@ 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') try: retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) except subprocess.CalledProcessError, ex: # error code <> 0 - print "--------error------" - print ex.cmd - print ex.message - print ex.returncode - print ex.output # contains stdout and stderr together + print("--------error------") + print(ex.cmd) + print(ex.message) + print(ex.returncode) + print(ex.output) # contains stdout and stderr together sys.exit(-1) return @@ -489,7 +490,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: @@ -510,7 +511,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: @@ -549,7 +550,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) @@ -564,7 +565,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: @@ -592,7 +593,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) @@ -614,23 +615,23 @@ 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 = {} @@ -638,7 +639,7 @@ def fwhm(self, incat ,debug): 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() @@ -668,19 +669,19 @@ 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) + return fwhm_med,ellp_med,count #------------------------------------# # changing head # @@ -863,7 +864,7 @@ def l3p(self,ccdstring): # self.psfex( 'sextractorPSFEX', ccdstring,**self.inargs) self.sextractorPSF('nullweightimmask', 'nullweightimmask', 'fullcat', 'sextractorPSFEX.psf', ccdstring,**self.inargs) - print "done with Sextractor for CCD %s \n" % ccdstring + print("done with Sextractor for CCD %s \n" % ccdstring) " unpack scamp log to select resolution and number of stars " def unpackLog(self,logFile): @@ -884,7 +885,7 @@ def unpackLog(self,logFile): dy = float(string.split(tokens[7],'"')[0]) chi2 = float(tokens[8]) nstars = int(tokens[9]) -# print tokens +# print(tokens) break return (dx,dy,chi2,nstars) # @@ -911,10 +912,10 @@ def unpackLog(self,logFile): YEAR = se.ConfigSectionMap("General")['year'] EPOCH = se.ConfigSectionMap("General")['epoch'] ncpu = int(se.ConfigSectionMap("General")['ncpu']) - print "ncpu=%d \n" % ncpu + print("ncpu=%d \n" % ncpu) #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} se.setArgs(**args) #running crosstalk @@ -922,12 +923,12 @@ def unpackLog(self,logFile): # I have to replace NITE with empty string to avoid modification of the file path # as it add to the path NITE and we have different data model # - print " Start crosstalk \n" + print(" Start crosstalk \n") se.crosstalk(EXPFILE,'',**args) nccd = len(CCD) xfiles_list = glob.glob('*_xtalk.fits') if len(xfiles_list) < nccd: - print " Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list)) + print(" Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list))) sys.exit(-1) #running pixelcorrect and bleedmask se.link_from_Dcache(se.data_conf+'default.psf') @@ -959,20 +960,20 @@ def unpackLog(self,logFile): se.change_head('Scamp_allCCD_r'+rRun+'p'+pRun+'.head', 'sextractor', 'detrend', 'wcs', CCD, **args) # - print "SECOND LOOP \n" + print("SECOND LOOP \n") pool.map(runL2P, pars) se.fileclean('detrend','.fits') se.skyCombineFit('bleedmask-mini','bleedmask-mini-fp','skyfit-binned-fp',**args) # - print "THIRD LOOP \n" + print("THIRD LOOP \n") pool.map(runL3P, pars) # pool.close() pool.join() se.fileclean('nullwtbkg','.fits') -# print res +# print(res) - print " End run on exposure \n" + print(" End run on exposure \n") diff --git a/SEProcPoolSTN.py b/SEProcPoolSTN.py index 35d6a87..be5c7e6 100755 --- a/SEProcPoolSTN.py +++ b/SEProcPoolSTN.py @@ -16,7 +16,7 @@ import numpy as np import pyfits import os -import ConfigParser +import configparser import argparse from despyfits.DESImage import DESImage @@ -29,7 +29,8 @@ from multiprocessing import Pool from scipy.weave.catalog import os_dependent_catalog_name -from setuptools.command.easy_install import sys_executable +# RM: I don't think this will work in py3, but looks like it's not used. +# from setuptools.command.easy_install import sys_executable import shutil @@ -83,11 +84,11 @@ def pixcorrect(outname, confPars,CCD, **args): ' --flat ' + 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: - print " pixcorrect error \n" + print(" pixcorrect error \n") return -1 return 0 @@ -106,7 +107,7 @@ def nullweight( inname, outname,confPars,CCD,**args): ' --resaturate' retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " nulweight error \n" + print(" nulweight error \n") return -1 return 0 @@ -129,11 +130,11 @@ def sextractor(inname, outname, confPars, CCD, **args): ' -DETECT_THRESH 10.0 -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC -WEIGHT_IMAGE ' + 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: - print " sex error \n" + print(" sex error \n") return -1 return 0 @@ -152,7 +153,7 @@ def nullweightbkg(inname, outname, CCD, confPars, **args): retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " nullweigths error \n" + print(" nullweigths error \n") return -1 return 0 @@ -179,11 +180,11 @@ def bleedmask(CCD,confPars,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 ' +template_file.format(**args)+'_trailbox.fits -o ' +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: - print " bleedmask error \n" + print(" bleedmask error \n") os.remove(template_file.format(**args)+'_'+inname+'.fits') return 0 #------------------------------# @@ -197,11 +198,11 @@ def skycompress(CCD,confPars,inname,outname,**args): ' --skyfilename ' + 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: - print " skycompree error \n" + print(" skycompree error \n") return 0 @@ -249,11 +250,11 @@ def skysubtract(CCD, confPars, inname, outname, skyfitinfoFile,**args ): ' --domefilename ' + flat.format(**args) +\ ' --weight ' + weight - print '\n',cmd,'\n' + print('\n',cmd,'\n') retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " sky_subtract error \n" + print(" sky_subtract error \n") # clean used files os.remove(template_file.format(**args)+'_'+inname+'.fits' ) os.remove(pc_filename.format(**args)) @@ -279,12 +280,12 @@ def pixcorr_starflat(inname, outname, CCD, confPars, **args): ' --starflat '+ starflat.format(**args) +\ ' --out '+ template_file.format(**args)+'_'+outname+'.fits' - print '\n',cmd,'\n' + print('\n',cmd,'\n') retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " starflat error \n" + print(" starflat error \n") os.remove(template_file.format(**args)+'_'+inname+'.fits') return 0 @@ -311,10 +312,10 @@ def sextractorsky(inname, outname, CCD, confPars, **args): ' -PARAMETERS_NAME ' + 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: - print "sextractorsky error \n" + print("sextractorsky error \n") return 0 #----------------------------------------# @@ -331,11 +332,11 @@ def immask(CCD, confParams, inname,bkgname, outname, **args): ' --bkgfile '+ template_file.format(**args)+'_'+bkgname+'.fits'+\ ' --draw --write_streaks --streaksfile ' + 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: - print "immask error \n" + print("immask error \n") os.remove(template_file.format(**args)+'_'+inname+'.fits') return 0 @@ -354,7 +355,7 @@ def rowinterp_nullweight(inname, outname,CCD, confPars, **args): ' BADAMP,EDGEBLEED,EDGE,CRAY' retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " rowinterp error \n" + print(" rowinterp error \n") return 0 #------------------------------------------# # sextractor for PSFEX # @@ -375,11 +376,11 @@ def sextractorPSFEX( inname, outname, CCD, confPars, **args): ' -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC -WEIGHT_IMAGE ' + 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: - print "sextractorPSFEX error \n" + print("sextractorPSFEX error \n") return 0 @@ -397,7 +398,7 @@ def psfex( name,CCD, confPars, **args): retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " pxfex error \n" + print(" pxfex error \n") return 0 @@ -428,12 +429,12 @@ def sextractorPSF( name, name1, outname, filepsf, CCD, confPars, **args): ' -DETECT_THRESH 1.5 -SATUR_KEY SATURATE -CATALOG_TYPE FITS_LDAC '+\ ' -WEIGHT_IMAGE '+template_file.format(**args)+'_'+name1+'.fits[2],'+ template_file.format(**args)+'_'+name1+'.fits[2]'+ \ ' -WEIGHT_TYPE MAP_WEIGHT -CHECKIMAGE_NAME ' + template_file.format(**args)+'_segmap.fits -CHECKIMAGE_TYPE SEGMENTATION ' - print ' sextractorPSF \n',cmd,'\n' + print(' sextractorPSF \n',cmd,'\n') # retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " sextractorPSF error \n" + print(" sextractorPSF error \n") os.remove(template_file.format(**args)+'_'+name+'.fits') return 0 @@ -451,7 +452,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'] @@ -554,7 +555,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 @@ -644,7 +645,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: @@ -666,7 +667,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: @@ -685,7 +686,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: @@ -707,7 +708,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: @@ -732,7 +733,7 @@ def skyCombineFit(self,inputFile,skycombineFile,skyfitinfoFile,**args): self.link_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: @@ -742,7 +743,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: @@ -754,7 +755,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: @@ -776,7 +777,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) @@ -805,7 +806,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: @@ -830,15 +831,15 @@ 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') try: retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) except subprocess.CalledProcessError, ex: # error code <> 0 - print "--------error------" - print ex.cmd - print ex.message - print ex.returncode - print ex.output # contains stdout and stderr together + print("--------error------") + print(ex.cmd) + print(ex.message) + print(ex.returncode) + print)ex.output) # contains stdout and stderr together sys.exit(-1) return @@ -882,11 +883,11 @@ 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: - print "Error in sExtractoe not null status \n" + print("Error in sExtractoe not null status \n") return #------------------------------------------# @@ -903,11 +904,11 @@ 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: - print " Error in sExtractorPSFEX not null status \n" + print(" Error in sExtractorPSFEX not null status \n") return #-----------------------------------# @@ -923,7 +924,7 @@ def nullweightbkg(self, inname, outname,CCD,**args): retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print "Error in nullweightbkg not null status \n" + print("Error in nullweightbkg not null status \n") #--------------------------------------------- # sextractorsky bkg calculator @@ -942,10 +943,10 @@ 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: - print "Error in sExtractorsky not null status \n" + print("Error in sExtractorsky not null status \n") return #--------------------------------------------# @@ -957,11 +958,11 @@ 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: - print " Error in PSFEX not null status \n" + print(" Error in PSFEX not null status \n") return @@ -985,12 +986,12 @@ 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) if retval != 0: - print " Error in sExtractoe not null status \n" + print(" Error in sExtractoe not null status \n") os.remove(self.template_file.format(**args)+'_'+name+'.fits') return @@ -1007,23 +1008,23 @@ 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 = {} @@ -1031,7 +1032,7 @@ def fwhm(self, incat ,debug): 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() @@ -1061,17 +1062,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) @@ -1094,7 +1095,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) @@ -1147,7 +1148,7 @@ def rowinterp_nullweight(self, inname, outname,CCD,**args): ' BADAMP,EDGEBLEED,EDGE,CRAY' retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print " Error in rowinterp !!!!11 \n" + print(" Error in rowinterp !!!!11 \n") #-----------------------------------# @@ -1164,7 +1165,7 @@ def nullweight(self, inname, outname,CCD,**args): ' --resaturate' retval = subprocess.call(cmd.split(),stderr=subprocess.STDOUT) if retval != 0: - print "Error in nullweight \n" + print("Error in nullweight \n") #--------------------------------# # creating regions # @@ -1277,7 +1278,7 @@ def unpackLog(self,logFile): dy = float(string.split(tokens[7],'"')[0]) chi2 = float(tokens[8]) nstars = int(tokens[9]) -# print tokens +# print(tokens) break return (dx,dy,chi2,nstars) # @@ -1318,13 +1319,13 @@ def getConfVals(self): if __name__ == '__main__': nbpar = len(sys.argv) - print sys.argv + print(sys.argv) conF = "confFile" conF = sys.argv[1] multiprocessing.freeze_support() - print " Start SEProc.py with conf File %s\n" % conF + print(" Start SEProc.py with conf File %s\n" % conF) se = SEProcPoolSTN(conF) - print "instance created \n" + print("instance created \n") EXPNUM = se.ConfigSectionMap("General")['expnum'] FILTER = se.ConfigSectionMap("General")['filter'] NITE = se.ConfigSectionMap("General")['nite'] @@ -1336,10 +1337,10 @@ def getConfVals(self): YEAR = se.ConfigSectionMap("General")['year'] EPOCH = se.ConfigSectionMap("General")['epoch'] ncpu = int(se.ConfigSectionMap("General")['ncpu']) - print "ncpu=%d \n" % ncpu + print("ncpu=%d \n" % ncpu) #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} se.setArgs(**args) #running crosstalk @@ -1347,12 +1348,12 @@ def getConfVals(self): # I have to replace NITE with empty string to avoid modification of the file path # as it add to the path NITE and we have different data model # - print " Start crosstalk \n" + print(" Start crosstalk \n") se.crosstalk(EXPFILE,'',**args) nccd = len(CCD) xfiles_list = glob.glob('*_xtalk.fits') if len(xfiles_list) < nccd: - print " Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list)) + print(" Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list))) sys.exit(-1) #running pixelcorrect and bleedmask se.link_from_Dcache(se.data_conf+'default.psf') @@ -1366,11 +1367,11 @@ def getConfVals(self): confPars = se.getConfVals() pool = Pool(processes=ncpu) pars = [[args,confPars,ccdstring] for ccdstring in instrings ] - print " Start first pool \n" + print(" Start first pool \n") pool.map(l1p, pars) # pool.close() # pool.join() - print " Finish first pool \n" + print(" Finish first pool \n") se.fileclean('xtalk','.fits') se.fileclean('nullweight','.fits') @@ -1387,25 +1388,25 @@ def getConfVals(self): se.change_head('Scamp_allCCD_r'+rRun+'p'+pRun+'.head', 'sextractor', 'detrend', 'wcs', CCD, **args) # - print "SECOND LOOP \n" + print("SECOND LOOP \n") # pool = Pool(processes=ncpu) pool.map(l2p, pars) # pool.close() # pool.join() - print "Finish second pool \n" + print("Finish second pool \n") se.fileclean('detrend','.fits') se.skyCombineFit('bleedmask-mini','bleedmask-mini-fp','skyfit-binned-fp',**args) # - print "THIRD LOOP \n" + print("THIRD LOOP \n") # pool = Pool(processes=ncpu) pool.map(l3p, pars) pool.close() pool.join() - print "Finish third pool \n" + print("Finish third pool \n") se.fileclean('nullwtbkg','.fits') -# print res +# print(res) - print " End run on exposure \n" + print(" End run on exposure \n") diff --git a/SEProcSC.py b/SEProcSC.py index 4e9c60b..46ee459 100755 --- a/SEProcSC.py +++ b/SEProcSC.py @@ -15,7 +15,7 @@ import numpy as np import pyfits import os -import ConfigParser +import configparser import argparse from despyfits.DESImage import DESImage @@ -53,7 +53,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'] @@ -238,7 +238,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: @@ -260,7 +260,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: @@ -279,7 +279,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: @@ -301,7 +301,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: @@ -326,7 +326,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: @@ -336,7 +336,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: @@ -348,7 +348,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: @@ -370,7 +370,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) @@ -399,7 +399,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: @@ -424,7 +424,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: @@ -471,7 +471,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: @@ -492,7 +492,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: @@ -531,7 +531,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) @@ -546,7 +546,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: @@ -574,7 +574,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) @@ -596,23 +596,23 @@ 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 = {} @@ -620,7 +620,7 @@ def fwhm(self, incat ,debug): 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() @@ -650,17 +650,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 "NFWHMCNT=%i" % count return (fwhm_med,ellp_med,count) @@ -683,7 +683,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) @@ -852,13 +852,13 @@ def l3p(self,ccdstring): if __name__ == '__main__': nbpar = len(sys.argv) - print sys.argv + print(sys.argv) conF = "confFile" conF = sys.argv[1] multiprocessing.freeze_support() - print " Start SEProc.py with conf File %s\n" % conF + print(" Start SEProc.py with conf File %s\n" % conF) se = SEProcSC(conF) - print "instance created \n" + print("instance created \n") EXPNUM = se.ConfigSectionMap("General")['expnum'] FILTER = se.ConfigSectionMap("General")['filter'] NITE = se.ConfigSectionMap("General")['nite'] @@ -870,10 +870,10 @@ def l3p(self,ccdstring): YEAR = se.ConfigSectionMap("General")['year'] EPOCH = se.ConfigSectionMap("General")['epoch'] ncpu = int(se.ConfigSectionMap("General")['ncpu']) - print "ncpu=%d \n" % ncpu + print("ncpu=%d \n" % ncpu) #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} se.setArgs(**args) #running crosstalk @@ -881,12 +881,12 @@ def l3p(self,ccdstring): # I have to replace NITE with empty string to avoid modification of the file path # as it add to the path NITE and we have different data model # - print " Start crosstalk \n" + print(" Start crosstalk \n") se.crosstalk(EXPFILE,'',**args) nccd = len(CCD) xfiles_list = glob.glob('*_xtalk.fits') if len(xfiles_list) < nccd: - print " Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list)) + print(" Possibly corrupted file expect %d extensions but got only %d \n" % (nccd,len(xfiles_list))) sys.exit(-1) #running pixelcorrect and bleedmask se.copy_from_Dcache(se.data_conf+'default.psf') @@ -917,7 +917,7 @@ def l3p(self,ccdstring): se.scamp('Scamp_allCCD_r'+rRun+'p'+pRun+'.fits') se.change_head('Scamp_allCCD_r'+rRun+'p'+pRun+'.head', 'sextractor', 'detrend', 'wcs', CCD, **args) # - print "SECOND LOOP \n" + print("SECOND LOOP \n") for ccd in CCD: ccdstring= "%02d"%int(ccd) @@ -926,7 +926,7 @@ def l3p(self,ccdstring): se.skyCombineFit('bleedmask-mini','bleedmask-mini-fp','skyfit-binned-fp',**args) # - print "THIRD LOOP \n" + print("THIRD LOOP \n") for ccd in CCD: ccdstring= "%02d"%int(ccd) @@ -935,4 +935,4 @@ def l3p(self,ccdstring): - print " End run on exposure \n" + print(" End run on exposure \n") diff --git a/run_SEproc.py b/run_SEproc.py index 6d0df87..c4cd536 100755 --- a/run_SEproc.py +++ b/run_SEproc.py @@ -120,5 +120,5 @@ def run_stage_3(ccd): os.system('ifdh mkdir '+str(dir_nite) ) os.system('ifdh mkdir '+str(dir_final) ) cmd = 'ifdh cp --force=xrootd -D *.out *fullcat* *_immask.fits.fz ' +str(dir_final) - print cmd + print(cmd) os.system(cmd) diff --git a/run_desdmy1e2.py b/run_desdmy1e2.py index e3a3406..aeaec44 100755 --- a/run_desdmy1e2.py +++ b/run_desdmy1e2.py @@ -71,6 +71,6 @@ cmd = 'ifdh cp -D *.out *sextractor* *fullcat* *immask* D*_ZP.fits ' +str(dir_final) -print cmd +print(cmd) os.system(cmd)