def getTriples(expnums, ccd): """Pull the three images and then scramble the MJD-OBS keywords""" import pyfits, MOPfits filenames = [] for expnum in expnums: if int(ccd) < 18: cutout = "[-*,-*]" else: cutout = "[*,*]" filenames.append(MOPfits.adGet(str(expnum) + opt.raw, extno=int(ccd), cutout=cutout)) for filename in filenames: if not os.access(filename, os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, "adGet Failed" if not os.access("weight.fits", os.F_OK): os.symlink(MOPfits.adGet("weight", extno=int(ccd), cutout=cutout), "weight.fits") basenames = [] for filename in filenames: filename = os.path.splitext(filename) basenames.append(filename[0]) print filenames, basenames return basenames
def getTriples(expnums,ccd): """Pull the three images and then scramble the MJD-OBS keywords""" import pyfits, MOPfits filenames=[] for expnum in expnums: if int(ccd)<18: cutout="[-*,-*]" else: cutout="[*,*]" filenames.append(MOPfits.adGet(str(expnum)+opt.raw,extno=int(ccd),cutout=cutout)) for filename in filenames: if not os.access(filename,os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, 'adGet Failed' if not os.access('weight.fits',os.F_OK): os.symlink(MOPfits.adGet("weight",extno=int(ccd),cutout=cutout),'weight.fits') basenames=[] for filename in filenames: filename=os.path.splitext(filename) basenames.append(filename[0]) print filenames, basenames return basenames
def get_nailing(expnum,ccd): """Get the 'nailing' images associated with expnum""" sql=""" SELECT e.expnum, (e.mjdate - f.mjdate) dt FROM bucket.exposure e JOIN bucket.exposure f JOIN bucket.association b ON b.expnum=f.expnum JOIN bucket.association a ON a.pointing=b.pointing AND a.expnum=e.expnum WHERE f.expnum=%d AND abs(e.mjdate - f.mjdate) > 0.5 AND abs(e.mjdate - f.mjdate) < 15.0 ORDER BY abs(e.mjdate-f.mjdate) """ % ( expnum ) try: import MOPdbaccess mysql=MOPdbaccess.connect('bucket','cfhls',dbSystem='MYSQL') bucket=mysql.cursor() bucket.execute(sql) nailings = bucket.fetchall() mysql.close() if not os.access("nailing",os.F_OK): os.mkdir("nailing") os.chdir("nailing") if int(ccd) < 18: cutout="[-*,-*]" else: cutout=None import MOPfits for nailing in nailings: filename=MOPfits.adGet(str(nailing[0])+opt.raw,extno=int(ccd),cutout=cutout) except: raise TaskError, "get nailing failed"
def get_nailing(expnum,ccd): """Get the 'nailing' images associated with expnum""" sql=""" SELECT e.expnum, (e.mjdate - f.mjdate) dt FROM bucket.exposure e JOIN bucket.exposure f JOIN bucket.association b ON b.expnum=f.expnum JOIN bucket.association a ON a.pointing=b.pointing AND a.expnum=e.expnum WHERE f.expnum=%d AND abs(e.mjdate - f.mjdate) > 0.5 AND abs(e.mjdate - f.mjdate) < 15.0 ORDER BY abs(e.mjdate-f.mjdate) """ % ( expnum ) try: import MOPdbaccess mysql=MOPdbaccess.connect('bucket','cfhls',dbSystem='MYSQL') bucket=mysql.cursor() bucket.execute(sql) nailings = bucket.fetchall() mysql.close() if int(ccd) < 18: cutout="[-*,-*]" else: cutout=None import MOPfits for nailing in nailings: filename=MOPfits.adGet(str(nailing[0])+opt.raw,extno=int(ccd),cutout=cutout) except: raise TaskError, "get nailing failed"
def get_image(expnum,ccd): try: if int(ccd) < 18: cutout="[-*,-*]" else: cutout=None import MOPfits filename=MOPfits.adGet(str(expnum)+opt.raw,extno=int(ccd),cutout=cutout) except: raise TaskError, "get image failed"
def get_image(expnum, ccd): try: if int(ccd) < 18: cutout = "[-*,-*]" else: cutout = None import MOPfits filename = MOPfits.adGet(str(expnum) + opt.raw, extno=int(ccd), cutout=cutout) except: raise TaskError, "get image failed"
def scrambleTriples(expnums, ccd): """Pull the three images and then scramble the MJD-OBS keywords""" import pyfits, MOPfits mjd = [] fid = [] fs = [] filenames = [] for expnum in expnums: if int(ccd) < 18: cutout = "[-*,-*]" else: cutout = "[*,*]" filenames.append(MOPfits.adGet(str(expnum) + opt.raw, extno=int(ccd), cutout=cutout)) fs.append(pyfits.open(filenames[-1])) mjd.append(fs[-1][0].header.get("MJD-OBS")) fid.append(fs[-1][0].header.get("EXPNUM")) if not os.access("weight.fits", os.F_OK): os.symlink(MOPfits.adGet("weight", extno=int(ccd), cutout=cutout), "weight.fits") for filename in filenames: if not os.access(filename, os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, "adGet Failed" order = [2, 0, 1] basenames = [] for i in range(len(fs)): fs[i][0].header.update("MJD-OBS", mjd[order[i]]) fs[i][0].header.update("EXPNUM", fid[order[i]]) filename = filenames[order[i]].replace(opt.raw, "s") basenames.append(os.path.splitext(filename)[0]) if os.access(filename, os.F_OK): os.unlink(filename) fs[i][0].writeto(filename, output_verify="ignore") os.unlink(filenames[order[i]]) return basenames
def scrambleTriples(expnums,ccd): """Pull the three images and then scramble the MJD-OBS keywords""" import pyfits, MOPfits mjd=[] fid=[] fs=[] filenames=[] for expnum in expnums: if int(ccd)<18: cutout="[-*,-*]" else: cutout="[*,*]" filenames.append(MOPfits.adGet(str(expnum)+opt.raw,extno=int(ccd),cutout=cutout)) fs.append(pyfits.open(filenames[-1])) mjd.append(fs[-1][0].header.get("MJD-OBS")) fid.append(fs[-1][0].header.get("EXPNUM")) if not os.access('weight.fits',os.F_OK): os.symlink(MOPfits.adGet("weight",extno=int(ccd),cutout=cutout),'weight.fits') for filename in filenames: if not os.access(filename,os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, 'adGet Failed' order=[2,0,1] basenames=[] for i in range(len(fs)): fs[i][0].header.update("MJD-OBS",mjd[order[i]]); fs[i][0].header.update("EXPNUM",fid[order[i]]); filename=filenames[order[i]].replace(opt.raw,'s') basenames.append(os.path.splitext(filename)[0]) if os.access(filename,os.F_OK): os.unlink(filename) fs[i][0].writeto(filename,output_verify='ignore') os.unlink(filenames[order[i]]) return basenames
def get_flipped_ext(file_id, ccd): """Given a list of exposure numbers and CCD, get them from the DB""" import MOPfits import os, shutil filename = MOPfits.adGet(file_id, extno=int(ccd)) if int(ccd) < 18: tfname = filename + "F" shutil.move(filename, tfname) os.system("imcopy %s[-*,-*] %s" % (tfname, filename)) os.unlink(tfname) if not os.access(filename, os.R_OK): return (None) return (filename)
def get_flipped_ext(file_id,ccd): """Given a list of exposure numbers and CCD, get them from the DB""" import MOPfits import os, shutil filename=MOPfits.adGet(file_id,extno=int(ccd)) if int(ccd)<18: tfname=filename+"F" shutil.move(filename, tfname) os.system("imcopy %s[-*,-*] %s" % (tfname, filename)) os.unlink(tfname) if not os.access(filename,os.R_OK): return(None) return(filename)
if not opt.triple: sql = """SELECT DISTINCT(t.id) FROM triples t JOIN checkup d ON t.id=d.triple JOIN bucket.association a ON t.pointing=a.pointing JOIN bucket.pointings p ON t.pointing=p.id JOIN bucket.blocks b ON a.expnum=b.expnum WHERE b.qname LIKE '%s'""" % (opt.block, ) if opt.pointing: sql += """ AND p.name LIKE '%s'""" % (opt.pointing, ) print sql cfeps.execute(sql) rows = cfeps.fetchall() else: rows = [ opt.triple, ] print rows for row in rows: triple = row[0] sql = "SELECT expnum FROM triple_members WHERE triple=%d ORDER BY expnum " % ( triple, ) cfeps.execute(sql) exps = cfeps.fetchall() file_ids = [] for exp in exps: if opt.verbose: sys.stderr.write("Getting exposure %s \n" % (exp[0], )) MOPfits.adGet(str(exp[0]) + 'p')
def searchTriples(expnums,ccd): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits,os import MOPdbaccess if len(expnums)!=3: return(-1) mysql=MOPdbaccess.connect('bucket','cfhls','MYSQL') bucket=mysql.cursor() ### Some program Constants proc_file = open("proc-these-files","w") proc_file.write("# Files to be planted and searched\n") proc_file.write("# image fwhm plant\n") import string import os.path filenames=[] import pyfits for expnum in expnums: bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s" , (expnum, ) ) row=bucket.fetchone() fwhm=row[0] if not fwhm > 0: fwhm=1.0 if int(ccd)<18: cutout="\[-*,-*\]" else: cutout=None filename=MOPfits.adGet(str(expnum)+"p",extno=int(ccd),cutout=cutout) print filename if not os.access(filename,os.R_OK): return(-3) filename=os.path.splitext(filename) filenames.append(filename[0]) proc_file.write("%s %f %s \n" % ( filename[0], fwhm/0.183, "no")) proc_file.flush() proc_file.close() command="find.pl -p '' -d ./ " sys.stderr.write(command) try: os.system(command) except: sys.stderr.write("Failed while running find") file_extens=[ "cands.comb", "measure3.cands.astrom", "measure3.WARNING", "measure3.astrom.scatter"] if os.access("find.OK",os.R_OK): os.system("touch /home/cadc/kavelaar/results/05AQ06B/"+filenames[0]+".OK") else: os.system("touch /home/cadc/kavelaar/results/05AQ06B/"+filenames[0]+".FAILED") ### look for the cand.comb file and store in the DB import shutil for ext in file_extens: if os.access(filenames[0]+"."+ext,os.R_OK): shutil.copy(filenames[0]+"."+ext,"/home/cadc/kavelaar/results/05AQ06B") astrom=filenames[0]+".measure3.cands.astrom" print astrom cmd = "mpc_gen.pl -c "+astrom print os.access(astrom,os.R_OK) if os.access(astrom,os.R_OK): print cmd os.system(cmd) os.system("mpcIngest.pl *.MPC") os.system("cp *.MPC /home/cadc/kavelaar/results/05AQ06B") return(0)
def searchTriples(expnums,ccd): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits,os import MOPdbaccess if len(expnums)!=3: return(-1) ### Some program Constants proc_file = open("proc-these-files","w") proc_file.write("# Files to be planted and searched\n") proc_file.write("# image fwhm plant\n") import string import os.path filenames=[] import pyfits for expnum in expnums: try: mysql=MOPdbaccess.connect('bucket','cfhls','MYSQL') bucket=mysql.cursor() except: raise TaskError, "mysql failed" bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s" , (expnum, ) ) row=bucket.fetchone() mysql.close() fwhm=row[0] if not fwhm > 0: fwhm=1.0 if int(ccd)<18: cutout="[-*,-*]" else: cutout=None filename=MOPfits.adGet(str(expnum)+"p",extno=int(ccd),cutout=cutout) if not os.access(filename,os.R_OK): raise TaskError, 'adGet Failed' filename=os.path.splitext(filename) filenames.append(filename[0]) proc_file.write("%s %f %s \n" % ( filename[0], fwhm/0.183, "no")) proc_file.flush() proc_file.close() command="find.pl -p '' -d ./ " try: os.system(command) except: raise TaskErorr, "execute find" file_extens=[ "cands.comb", "measure3.cands.astrom", "measure3.WARNING", "measure3.astrom.scatter"] if not os.access("find.OK",os.R_OK): raise TaskError, "find failed" astrom=filenames[0]+".measure3.cands.astrom" if os.access(astrom,os.R_OK): return(1) else: return(0)
def searchTriples(expnums, ccd): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits, os import MOPdbaccess if len(expnums) != 3: return (-1) mysql = MOPdbaccess.connect('bucket', 'cfhls', 'MYSQL') bucket = mysql.cursor() ### Some program Constants proc_file = open("proc-these-files", "w") proc_file.write("# Files to be planted and searched\n") proc_file.write("# image fwhm plant\n") import string import os.path filenames = [] import pyfits for expnum in expnums: bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s", (expnum, )) row = bucket.fetchone() fwhm = row[0] if not fwhm > 0: fwhm = 1.0 if int(ccd) < 18: cutout = "\[-*,-*\]" else: cutout = None filename = MOPfits.adGet(str(expnum) + "p", extno=int(ccd), cutout=cutout) print filename if not os.access(filename, os.R_OK): return (-3) filename = os.path.splitext(filename) filenames.append(filename[0]) proc_file.write("%s %f %s \n" % (filename[0], fwhm / 0.183, "no")) proc_file.flush() proc_file.close() command = "find.pl -p '' -d ./ " sys.stderr.write(command) try: os.system(command) except: sys.stderr.write("Failed while running find") file_extens = [ "cands.comb", "measure3.cands.astrom", "measure3.WARNING", "measure3.astrom.scatter" ] if os.access("find.OK", os.R_OK): os.system("touch /home/cadc/kavelaar/results/05AQ06B/" + filenames[0] + ".OK") else: os.system("touch /home/cadc/kavelaar/results/05AQ06B/" + filenames[0] + ".FAILED") ### look for the cand.comb file and store in the DB import shutil for ext in file_extens: if os.access(filenames[0] + "." + ext, os.R_OK): shutil.copy(filenames[0] + "." + ext, "/home/cadc/kavelaar/results/05AQ06B") astrom = filenames[0] + ".measure3.cands.astrom" print astrom cmd = "mpc_gen.pl -c " + astrom print os.access(astrom, os.R_OK) if os.access(astrom, os.R_OK): print cmd os.system(cmd) os.system("mpcIngest.pl *.MPC") os.system("cp *.MPC /home/cadc/kavelaar/results/05AQ06B") return (0)
def searchTriples(expnums,ccd,plant=False): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits,os import MOPdbaccess if len(expnums)!=3: raise TaskError, "got %d exposures"%(len(expnums)) ### Some program Constants proc_these_files=[] if not plant: proc_these_files.append("# Files to be planted and searched\n") proc_these_files.append("# image fwhm plant\n") import string import os.path filenames=[] import pyfits for expnum in expnums: ### Get the processed images from AD if int(ccd)<18: cutout="[-*,-*]" else: cutout="[*,*]" filename=MOPfits.adGet(str(expnum)+opt.raw,extno=int(ccd),cutout=cutout) if not os.access(filename,os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, 'adGet Failed' if opt.none: continue filename=os.path.splitext(filename) filenames.append(filename[0]) try: mysql=MOPdbaccess.connect('bucket','cfhls','MYSQL') bucket=mysql.cursor() except: raise TaskError, "mysql failed" bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s" , (expnum, ) ) row=bucket.fetchone() mysql.close() fwhm=row[0] if not fwhm > 0: fwhm=1.0 if not plant: #proc_these_files.append("%s %f %s \n" % ( filename[0], fwhm/0.183, 'no')) pstr='NO' else: pstr='YES' ### since we're planting we need a psf. JMPMAKEPSF will ### update the proc-these-files listing ### run the make psf script .. always. This creates proc-these-files ### which is needed by the find.pl script. command='jmpmakepsf.csh ./ %s %s' % ( filename[0], pstr ) if opt.verbose: sys.stderr.write( command ) try: os.system(command) except: raise TaskError, "jmpmakepsf noexec" if os.access(filename[0]+'.jmpmakepsf.FAILED',os.R_OK) or not os.access(filename[0]+".psf.fits", os.R_OK) : # if plant: # raise TaskError, "jmpmakepsf failed" # do without plant if 1==1 : plant=False pstr='NO' ### we're not planting so, lets keep going ### but check that there is a line in proc_these_files add_line=True if not os.access('proc-these-files',os.R_OK): f=open('proc-these-files','w') for l in proc_these_files: f.write(l) f.close() f=open('proc-these-files','r') ptf_lines=f.readlines() f.close() for ptf_line in ptf_lines: if ptf_line[0]=='#': continue ptf_a=ptf_line.split() import re if re.search('%s' % (filename[0]),ptf_a[0]): ### there's already a line for this one add_line=False break if add_line: f=open('proc-these-files','a') f.write("%s %f %s \n" % ( filename[0], fwhm/0.183, 'no')) f.close() if opt.none: return(-1) prefix='' if plant: command="plant.csh ./ -rmin %s -rmax %s -ang %s -width %s " % ( opt.rmin, opt.rmax, opt.angle, opt.width) try: os.system(command) except: raise TaskError, 'plant exec. failed' if not os.access('plant.OK',os.R_OK): raise TaskError, 'plant failed' prefix='fk' #else: # f=open('proc-these-files','w') # for line in proc_these_files: # f.write(line) # f.flush() # f.close() if opt.rerun and os.access('find.OK',os.R_OK): os.unlink("find.OK") command="find.pl -p "+prefix+" -rn %s -rx %s -a %s -aw %s -d ./ " % ( opt.rmin, opt.rmax, opt.angle, opt.width) #command="find.pl -p "+prefix+" -d ./ " if opt.verbose: sys.stderr.write( command ) try: os.system(command) except: raise TaskErorr, "execute find" if not os.access("find.OK",os.R_OK): raise TaskError, "find failed" ### check the transformation file command = "checktrans -p "+prefix try: os.system(command) except: raise TaskError, "execute checktrans" if not os.access("checktrans.OK",os.R_OK): raise TaskError, "checktrans failed" if os.access("BAD_TRANS"+prefix,os.R_OK): raise TaskError,"BAD TRANS" astrom=prefix+filenames[0]+".cands.comb" if opt.plant: astrom=prefix+filenames[0]+".comb.found" try: #make sure we have +10 lines in this file lines=file(astrom).readlines() if len(lines)<10: raise TaskError,"Too few Found" except: raise TaskError, "Error reading %s" %(astrom) if os.access(astrom,os.R_OK): return(1) else: return(0)
def searchTriples(expnums, ccd): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits, os import MOPdbaccess if len(expnums) != 3: return (-1) ### Some program Constants proc_file = open("proc-these-files", "w") proc_file.write("# Files to be planted and searched\n") proc_file.write("# image fwhm plant\n") import string import os.path filenames = [] import pyfits for expnum in expnums: try: mysql = MOPdbaccess.connect('bucket', 'cfhls', 'MYSQL') bucket = mysql.cursor() except: raise TaskError, "mysql failed" bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s", (expnum, )) row = bucket.fetchone() mysql.close() fwhm = row[0] if not fwhm > 0: fwhm = 1.0 if int(ccd) < 18: cutout = "[-*,-*]" else: cutout = None filename = MOPfits.adGet(str(expnum) + "p", extno=int(ccd), cutout=cutout) if not os.access(filename, os.R_OK): raise TaskError, 'adGet Failed' filename = os.path.splitext(filename) filenames.append(filename[0]) proc_file.write("%s %f %s \n" % (filename[0], fwhm / 0.183, "no")) proc_file.flush() proc_file.close() command = "find.pl -p '' -d ./ " try: os.system(command) except: raise TaskErorr, "execute find" file_extens = [ "cands.comb", "measure3.cands.astrom", "measure3.WARNING", "measure3.astrom.scatter" ] if not os.access("find.OK", os.R_OK): raise TaskError, "find failed" astrom = filenames[0] + ".measure3.cands.astrom" if os.access(astrom, os.R_OK): return (1) else: return (0)
def searchTriples(expnums,ccd,plant=False): """Given a list of exposure numbers, find all the KBOs in that set of exposures""" import MOPfits,os import MOPdbaccess if len(expnums)!=3: raise TaskError, "got %d exposures"%(len(expnums)) ### Some program Constants proc_these_files=[] if not plant: proc_these_files.append("# Files to be planted and searched\n") proc_these_files.append("# image fwhm plant\n") import string import os.path filenames=[] import pyfits for expnum in expnums: ### Get the processed images from AD if int(ccd)<18: cutout="[-*,-*]" else: cutout="[*,*]" filename=MOPfits.adGet(str(expnum)+opt.raw,extno=int(ccd),cutout=cutout) if not os.access(filename,os.R_OK): sys.stderr.write("Ad Get Failed\n") raise TaskError, 'adGet Failed' if opt.none: continue filename=os.path.splitext(filename) filenames.append(filename[0]) try: mysql=MOPdbaccess.connect('bucket','cfhls','MYSQL') bucket=mysql.cursor() except: raise TaskError, "mysql failed" bucket.execute("SELECT obs_iq_refccd FROM exposure WHERE expnum=%s" , (expnum, ) ) row=bucket.fetchone() mysql.close() fwhm=row[0] if not fwhm > 0: fwhm=1.0 if not plant: #proc_these_files.append("%s %f %s \n" % ( filename[0], fwhm/0.183, 'no')) pstr='NO' else: pstr='YES' ### since we're planting we need a psf. JMPMAKEPSF will ### update the proc-these-files listing ### run the make psf script .. always. This creates proc-these-files ### which is needed by the find.pl script. command='jmpmakepsf.csh ./ %s %s' % ( filename[0]+".fits", pstr ) if opt.verbose: sys.stderr.write( command ) try: os.system(command) except: raise TaskError, "jmpmakepsf noexec" if os.access(filename[0]+'.jmpmakepsf.FAILED',os.R_OK) or not os.access(filename[0]+".psf.fits", os.R_OK) : # if plant: # raise TaskError, "jmpmakepsf failed" # do without plant if 1==1 : plant=False pstr='NO' ### we're not planting so, lets keep going ### but check that there is a line in proc_these_files add_line=True if not os.access('proc-these-files',os.R_OK): f=open('proc-these-files','w') for l in proc_these_files: f.write(l) f.close() f=open('proc-these-files','r') ptf_lines=f.readlines() f.close() for ptf_line in ptf_lines: if ptf_line[0]=='#': continue ptf_a=ptf_line.split() import re if re.search('%s' % (filename[0]),ptf_a[0]): ### there's already a line for this one add_line=False break if add_line: f=open('proc-these-files','a') f.write("%s %f %s \n" % ( filename[0], fwhm/0.183, 'no')) f.close() if opt.none: return(-1) prefix='' if plant: command="plant.csh ./ -rmin %s -rmax %s -ang %s -width %s " % ( opt.rmin, opt.rmax, opt.angle, opt.width) try: os.system(command) except: raise TaskError, 'plant exec. failed' if not os.access('plant.OK',os.R_OK): raise TaskError, 'plant failed' prefix='fk' #else: # f=open('proc-these-files','w') # for line in proc_these_files: # f.write(line) # f.flush() # f.close() if opt.rerun and os.access('find.OK',os.R_OK): os.unlink("find.OK") command="find.pl -p "+prefix+" -rn %s -rx %s -a %s -aw %s -d ./ " % ( opt.rmin, opt.rmax, opt.angle, opt.width) #command="find.pl -p "+prefix+" -d ./ " if opt.verbose: sys.stderr.write( command ) try: os.system(command) except: raise TaskErorr, "execute find" if not os.access("find.OK",os.R_OK): raise TaskError, "find failed" ### check the transformation file command = "checktrans -p "+prefix try: os.system(command) except: raise TaskError, "execute checktrans" if not os.access("checktrans.OK",os.R_OK): raise TaskError, "checktrans failed" if os.access("BAD_TRANS"+prefix,os.R_OK): raise TaskError,"BAD TRANS" astrom=prefix+filenames[0]+".cands.comb" if opt.plant: astrom=prefix+filenames[0]+".comb.found" try: #make sure we have +10 lines in this file lines=file(astrom).readlines() if len(lines)<10: raise TaskError,"Too few Found" except: raise TaskError, "Error reading %s" %(astrom) if os.access(astrom,os.R_OK): return(1) else: return(0)
cfeps=mysql.cursor() if not opt.triple: sql="""SELECT DISTINCT(t.id) FROM triples t JOIN checkup d ON t.id=d.triple JOIN bucket.association a ON t.pointing=a.pointing JOIN bucket.pointings p ON t.pointing=p.id JOIN bucket.blocks b ON a.expnum=b.expnum WHERE b.qname LIKE '%s'""" % ( opt.block, ) if opt.pointing: sql+=""" AND p.name LIKE '%s'""" % (opt.pointing, ) print sql cfeps.execute(sql) rows=cfeps.fetchall() else: rows=[opt.triple,] print rows for row in rows: triple=row[0] sql="SELECT expnum FROM triple_members WHERE triple=%d ORDER BY expnum " % ( triple,) cfeps.execute(sql) exps=cfeps.fetchall() file_ids=[] for exp in exps: if opt.verbose: sys.stderr.write("Getting exposure %s \n" % (exp[0],)) MOPfits.adGet(str(exp[0])+'p')