def run_elli_full(cutimage, output, xcntr, ycntr, eg, pa, sma, sky): #,radd,background): """The function responsible for fit ellipse""" EllGal = c.outdir + 'GalEllFit.fits' fEl = pyfits.open(os.path.join(c.datadir, cutimage)) GaLaXy = fEl[0].data fEl.close() GaLaXy = GaLaXy - sky hdu = pyfits.PrimaryHDU(GaLaXy.astype(n.float32)) hdu.writeto(EllGal) try: iraf.stsdas(_doprint=0) iraf.tables(_doprint=0) iraf.stsdas.analysis(_doprint=0) iraf.stsdas.analysis.isophote(_doprint=0) except: iraf.stsdas() iraf.tables() iraf.stsdas.analysis() iraf.stsdas.analysis.isophote() image_exist = 1 iraf.unlearn('geompar') iraf.geompar.x0 = xcntr iraf.geompar.y0 = ycntr iraf.geompar.ellip0 = eg iraf.geompar.pa0 = pa iraf.geompar.sma0 = 6.0 iraf.geompar.minsma = 0.1 iraf.geompar.maxsma = sma * 5.0 iraf.geompar.step = 0.1 iraf.geompar.recente = "no" iraf.geompar.xylearn = "no" iraf.unlearn('controlpar') iraf.controlpar.conver = 0.05 iraf.controlpar.minit = 10 iraf.controlpar.maxit = 50 iraf.controlpar.hcenter = "no" iraf.controlpar.hellip = "no" iraf.controlpar.hpa = "no" iraf.controlpar.wander = "INDEF" iraf.controlpar.maxgerr = 0.5 iraf.controlpar.olthres = 1 iraf.controlpar.soft = "no" iraf.samplepar.integrm = "bi-linear" iraf.samplepar.usclip = 3 iraf.samplepar.lsclip = 3 iraf.samplepar.nclip = 0 iraf.samplepar.fflag = 0.5 iraf.unlearn('ellipse') iraf.ellipse("".join(EllGal), output="test", interac="no",Stdout="ellip", \ Stderr="err") iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \ showrow="no", orig_row="no", showhdr="no", showunits="no", \ columns="SMA, INTENS, INT_ERR, ELLIP, ELLIP_ERR, PA, PA_ERR, \ MAG, MAG_LERR, MAG_UERR, TMAG_E, TMAG_C, A3, \ A3_ERR, B3, B3_ERR, A4, A4_ERR, B4_ERR" , rows="-", \ option="plain", align="yes", sp_col="", lgroup=0, Stdout=output) for myfile in ['ellip', 'err', 'test.tab', EllGal]: if os.access(c.outdir + myfile, os.F_OK): os.remove(c.outdir + myfile)
def run_ell(file_in, file_tab, file_dat, mag, **ellipse_par): # prochaine etape : mettre en argument sous une certaine forme les parametres associes epar des taches 1) strict minimum sous forme de dico fixe 2) tout pouvoir changer sous forme de dictionnaire et tester les cles ... # import iraf packages iraf.stsdas() iraf.analysis() iraf.isophote() p = Popen("ds9", shell = True) time.sleep(5) iraf.display(file_in, 1) set_iraf_param(ellipse_par) # iraf.lpar(iraf.geompar) iraf.ellipse(file_in, file_tab, mag0 = str(mag), verbose = "no") # iraf.lpar(iraf.isoimap) iraf.isoimap(file_in, file_tab) iraf.tproject(file_tab, "temp.fits", "SMA,INTENS,INT_ERR,ELLIP,ELLIP_ERR, PA, PA_ERR, X0, Y0, TFLUX_C, TMAG_E,NPIX_E") iraf.tprint("temp.fits", pwidth = 200, Stdout = file_dat) iraf.imdel("temp.fits") p.kill()
def run_elli(input, xcntr, ycntr, eg, pa, sma):#,radd,background): iraf.stsdas(_doprint=0) iraf.tables(_doprint=0) iraf.stsdas.analysis(_doprint=0) iraf.stsdas.analysis.isophote(_doprint=0) image_exist = 1 if(str(input)[:3] == 'ima'): output = 'elli_' + input[6:-4] + 'txt' if(str(input)[:3] == 'out'): output = 'out_elli_' + str(input)[4:-7] + 'txt' #unlearn geompar controlpar samplepar magpar ellipse iraf.geompar(x0=xcntr, y0=ycntr, ellip0=eg, pa0=pa, sma0=10, minsma=0.1, \ maxsma=sma*5.0, step=0.1,recente="yes") iraf.controlpar(conver=0.05, minit=10, maxit=50, hcenter="no", hellip="no",\ hpa="no", wander="", maxgerr=0.5, olthres=1,soft="no") iraf.samplepar(integrm="bi-linear", usclip=3,lsclip=3, nclip=0, fflag=0.5) iraf.magpar(mag0=0, refer=1, zerolev=0) iraf.ellipse("".join(input), output="test", interac="no",Stdout="ellip", \ Stderr="err") iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \ showrow="no", orig_row="no", showhdr="no", showunits="no", \ columns="SMA, INTENS, INT_ERR, MAG, MAG_LERR, MAG_UERR",\ rows="-", \ option="plain", align="yes", sp_col="", lgroup=0, Stdout=output) for myfile in ['ellip','err','test.tab']: if os.access(myfile,os.F_OK): os.remove(myfile)
def run_elli_full(input, output, xcntr, ycntr, eg, pa, sma, sky):#,radd,background): """The function responsible for fit ellipse""" EllGal = 'GalEllFit.fits' fEl = pyfits.open(input) GaLaXy = fEl[0].data fEl.close() GaLaXy = GaLaXy - sky hdu = pyfits.PrimaryHDU(GaLaXy.astype(n.float32)) hdu.writeto(EllGal) try: iraf.stsdas(_doprint=0) iraf.tables(_doprint=0) iraf.stsdas.analysis(_doprint=0) iraf.stsdas.analysis.isophote(_doprint=0) except: iraf.stsdas() iraf.tables() iraf.stsdas.analysis() iraf.stsdas.analysis.isophote() image_exist = 1 iraf.unlearn('geompar') iraf.geompar.x0=xcntr iraf.geompar.y0=ycntr iraf.geompar.ellip0=eg iraf.geompar.pa0=pa iraf.geompar.sma0=6.0 iraf.geompar.minsma=0.1 iraf.geompar.maxsma=sma*5.0 iraf.geompar.step=0.1 iraf.geompar.recente="no" iraf.geompar.xylearn="no" iraf.unlearn('controlpar') iraf.controlpar.conver=0.05 iraf.controlpar.minit=10 iraf.controlpar.maxit=50 iraf.controlpar.hcenter="no" iraf.controlpar.hellip="no" iraf.controlpar.hpa="no" iraf.controlpar.wander="INDEF" iraf.controlpar.maxgerr=0.5 iraf.controlpar.olthres=1 iraf.controlpar.soft="no" iraf.samplepar.integrm="bi-linear" iraf.samplepar.usclip=3 iraf.samplepar.lsclip=3 iraf.samplepar.nclip=0 iraf.samplepar.fflag=0.5 iraf.unlearn('ellipse') iraf.ellipse("".join(EllGal), output="test", interac="no",Stdout="ellip", \ Stderr="err") iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \ showrow="no", orig_row="no", showhdr="no", showunits="no", \ columns="SMA, INTENS, INT_ERR, ELLIP, ELLIP_ERR, PA, PA_ERR, \ MAG, MAG_LERR, MAG_UERR, TMAG_E, TMAG_C, A3, \ A3_ERR, B3, B3_ERR, A4, A4_ERR, B4_ERR", rows="-", \ option="plain", align="yes", sp_col="", lgroup=0, Stdout=output) for myfile in ['ellip','err','test.tab', EllGal]: if os.access(myfile,os.F_OK): os.remove(myfile)
def run_elli(input, output, xcntr, ycntr, eg, pa, sma):#,radd,background): """The function resposible for fit ellipse""" iraf.stsdas(_doprint=0) iraf.tables(_doprint=0) iraf.stsdas.analysis(_doprint=0) iraf.stsdas.analysis.isophote(_doprint=0) image_exist = 1 # if(str(input)[:3] == 'ima'): # output = 'elli_' + input[6:-4] + 'txt' # if(str(input)[:3] == 'out'): # output = 'out_elli_' + str(input)[4:-7] + 'txt' # else: # output = 'elli_' + input[:-5] + '.txt' #unlearn geompar controlpar samplepar magpar ellipse iraf.unlearn('geompar') iraf.geompar.x0=xcntr iraf.geompar.y0=ycntr iraf.geompar.ellip0=eg iraf.geompar.pa0=pa iraf.geompar.sma0=10 iraf.geompar.minsma=0.1 iraf.geompar.maxsma=sma*5.0 iraf.geompar.step=0.1 iraf.geompar.recente="no" iraf.geompar.xylearn="no" iraf.unlearn('controlpar') iraf.controlpar.conver=0.05 iraf.controlpar.minit=10 iraf.controlpar.maxit=50 iraf.controlpar.hcenter="no" iraf.controlpar.hellip="no" iraf.controlpar.hpa="no" iraf.controlpar.wander="INDEF" iraf.controlpar.maxgerr=0.5 iraf.controlpar.olthres=1 iraf.controlpar.soft="no" iraf.samplepar.integrm="bi-linear" iraf.samplepar.usclip=3 iraf.samplepar.lsclip=3 iraf.samplepar.nclip=0 iraf.samplepar.fflag=0.5 iraf.magpar.mag0=c.mag_zero iraf.magpar.refer=1 iraf.magpar.zerolev=0 iraf.ellipse("".join(input), output="test", interac="no",Stdout="ellip", \ Stderr="err") iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \ showrow="no", orig_row="no", showhdr="no", showunits="no", \ columns="SMA, INTENS, INT_ERR, MAG, MAG_LERR, MAG_UERR, \ TFLUX_E", rows="-", \ option="plain", align="yes", sp_col="", lgroup=0, Stdout=output) for myfile in ['ellip','err','test.tab']: if os.access(myfile,os.F_OK): os.remove(myfile)
def rerunellipse(files, xcenter, ycenter, minr, initialr, maxr, nframe=1): repeatflag = 1 while (repeatflag > 0.1): mfile = files[i] t = mfile.split('.') k = t[0].split('m') efile = k[1] + '.tab' s = 'rm ' + efile os.system(s) s = "ellipse input=%s output=%s x0=%.1f y0=%.1f hcenter+ sma0=%.1f minsma=%.1f maxsma=%.1f inter+ \n" % ( mfile, efile, xcenter, ycenter, initialr, minr, maxr) # s="ellipse(input=%s, output=%s, x0=%.1f, y0=%.1f, hcenter+, sma0=%.1f, minsma=%.1f, maxsma=%.1f, interactive=+) \n"%(mfile,efile,xcenter,ycenter,initialr,minr,maxr) iraf.ellipse(input=mfile, output=efile, x0=xcenter, y0=ycenter, hcenter='yes', sma0=initialr, minsma=minr, maxsma=maxr, interactive='yes') print 'Displaying isophotes. Hit q to quit' iraf.isoexam(table=efile) flag = str( raw_input('Are you happy with the fit? y=yes n=no x=quit ')) flag = str(flag) print 'this is what I think you typed ', flag if flag.find('y') > -1: s = 'mv *' + t[0] + '* Finished/' os.system(s) repeatflag = 0 print 'i think repeatflag = 0', repeatflag if flag.find('n') > -1: s = 'rm *' + t[0] + '*.tab' os.system(s) s = 'rm m' + t[0] + '*.fits' os.system(s) repeatflag = 1 print 'i think repeatflag = 1', repeatflag if flag.find('x') > -1: repeatflag = 0 print 'i think repeatflag = 0', repeatflag return print 'repeatflag = ', repeatflag
def runellipse(files, xcenter, ycenter, minr, initialr, maxr, nframe=1): for i in range(len(files)): #for i in range(5): mfile = files[i] repeatflag = 1 while (repeatflag > 0.1): iraf.display(mfile, frame=nframe, fill='yes') outfile1 = 'm' + mfile print mfile print 'Running imedit to mask out other sources in the field:' print 'Enter b to mask out a circular region' print 'Enter a to mark the corners of a rectangle' print 'Enter q when finished' try: os.remove(outfile1) except OSError: print 'everything is ok' print 'running imedit ', mfile, outfile1 iraf.imedit(mfile, outfile1) t = mfile.split('.') efile = t[0] + '.tab' print 'Running ellipse to fit isophotes to galaxy:' print 'Enter h to continue fitting' try: os.remove(efile) except OSError: print 'everything is ok' iraf.ellipse(input=outfile1, output=efile, x0=xcenter, y0=ycenter, hcenter='yes', sma0=initialr, minsma=minr, maxsma=maxr) print 'Displaying isophotes. Hit q to quit' iraf.isoexam(table=efile) # try: # iraf.ellipse(input=outfile1,output=efile,x0=xcenter,y0=ycenter,hcenter='yes',sma0=initialr,minsma=minr,maxsma=maxr) # except: # print efile," already exists so I am deleting it. Hit Cntrl-c if you don't want to delete" # s='rm '+efile # os.system(s) # iraf.ellipse(input=outfile1,output=efile,x0=xcenter,y0=ycenter,hcenter='yes',sma0=initialr,minsma=minr,maxsma=maxr) flag = str( raw_input('Are you happy with the fit? y=yes n=no x=quit ')) flag = str(flag) print 'this is what I think you typed ', flag if flag.find('y') > -1: s = 'mv *' + t[0] + '* Finished/' os.system(s) repeatflag = 0 print 'i think repeatflag = 0', repeatflag if flag.find('n') > -1: s = 'rm *' + t[0] + '*.tab' os.system(s) s = 'rm m' + t[0] + '*.fits' os.system(s) repeatflag = 1 print 'i think repeatflag = 1', repeatflag if flag.find('x') > -1: repeatflag = 0 print 'i think repeatflag = 0', repeatflag return print 'repeatflag = ', repeatflag
os.remove('tmp7.fits') if os.path.exists('tmp7.dqf'): os.remove('tmp7.dqf') hdu7 = fits.PrimaryHDU(betav_seg) hdu7.writeto('tmp7.fits') mask = betav_seg mask[np.isnan(mask)] = int(32) mask[np.where(mask != 32)] = int(0) hdu7pl = fits.PrimaryHDU(mask) hdu7pl.writeto('tmp7.dqf') #iraf.ellipse(input='tmp7.fits',output='tmp7.tab',inter='no',inellip=work_dir+'ellipse/pa_ellip/'+name+'_I1.tab',dqf='.c1h') iraf.ellipse(input='tmp7.fits',output='tmp7.tab',inter='no',x0=i,y0=j,dqf='.dqf') iraf.tdump(table='tmp7.tab',datafile=work_dir+'ellipse/pa_ellip/'+name+'_bv_pl9.txt',columns='@colnames.lis') if AV_fit: if os.path.exists('tmp.fits'): os.remove('tmp.fits') if os.path.exists('tmp1.fits'): os.remove('tmp1.fits') if os.path.exists('tmp2.fits'): os.remove('tmp2.fits') if os.path.exists('tmp3.fits'): os.remove('tmp3.fits') if os.path.exists('tmp4.fits'): os.remove('tmp4.fits') if os.path.exists('tmp5.fits'):
if __name__ == "__main__": if (not (len(sys.argv) == 6)): print( "Usage: python preSEx_model.py <input filename> <center x> <center y> <max sma> <backgd>" ) else: #Read command line inputs filename = sys.argv[1] galaxy_name = filename[:-5] center_x = sys.argv[2] center_y = sys.argv[3] sma = sys.argv[4] bg = sys.argv[5] #Load isophote tasks (ellipse, bmodel, geompar) iraf.stsdas() iraf.analysis() iraf.isophote() #Configure geompar pyraf.iraftask.gettask("geompar")[0].setParam("x0", center_x) pyraf.iraftask.gettask("geompar")[0].setParam("y0", center_y) pyraf.iraftask.gettask("geompar")[0].setParam("maxsma", sma) iraf.ellipse(filename, galaxy_name + ".tab") iraf.bmodel(galaxy_name + ".tab", galaxy_name + "_mod.fits", backgr=bg) iraf.imarith(operand1=filename, op="-", operand2=galaxy_name + "_mod.fits", result=galaxy_name + "_modsub.fits")
def runellipse(files, xcenter, ycenter, minr, ipa, initialr, maxr, iellip, nframe=1, myradius=15): initialradius = myradius for i in range(len(files)): myradius = initialradius mfile = files[i] #mask image outfile1 = 'm' + mfile continueWithProgram, continueWithObject = runimedit( mfile, outfile1, nframe) if not continueWithProgram: print "quitting program" return if not continueWithObject: print "going on to next image" continue #run ellipse t = mfile.split('.') efile = t[0] + '.tab' imprefix = t[0] print mfile, imprefix print 'Running ellipse to fit isophotes to galaxy:' try: os.remove(efile) except OSError: print 'everything is ok' print "First pass, letting PA and e vary" iraf.ellipse(input=outfile1, output=efile, x0=xcenter, y0=ycenter, hcenter='no', sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='no', ellip=iellip, hellip='no') print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' iraf.isoexam(table=efile) os.system('rm junk.txt') iraf.tprint(table=efile, pwidth='INDEF', showhdr='no', Stdout='junk.txt') os.system("awk '{print $2, $7, $9, $11, $13}' < junk.txt > junk2.txt") #run ellipse a second time, keeping PA and ellip fixed #allow user to adjust the radius where PA and ellip are measured repeatflag = 1 while (repeatflag > 0.1): infile = open('junk2.txt', 'r') for line in infile: t = line.split() if float(t[0]) > myradius: newellip = float(t[1]) if newellip < .05: #min value that ellipse can handle newellip = .05 newPA = float(t[2]) if newPA < -90: newPA = newPA + 180 elif newPA > 90: newPA = newPA - 180 #11 - X0, 13 - Y0 newxcenter = float(t[3]) newycenter = float(t[4]) break s = 'rm ' + efile os.system(s) iraf.ellipse(input=outfile1, output=efile, x0=newxcenter, y0=newycenter, hcenter='yes', sma0=initialr, minsma=minr, maxsma=maxr, pa=newPA, hpa='yes', ellip=newellip, hellip='yes') print 'Displaying isophotes from second pass using r = ', myradius print 'Hit q in the DS9 window to quit' iraf.isoexam(table=efile) flag = str( raw_input('Are you happy with the fit? y=yes n=no x=quit ')) flag = str(flag) print 'this is what I think you typed ', flag if flag.find('n') > -1: flag2 = str( raw_input( 'What is the problem? c=off-center r=set new radius x=quit ' )) flag2 = str(flag2) if flag2.find('r') > -1: myr = input('Enter new radius to use ') myradius = float(myr) s = 'rm ' + efile os.system(s) repeatflag = 1 elif flag2.find('x') > -1: repeatflag = 0 return elif flag2.find('c') > -1: s = 'mv *' + imprefix + '* OffCenter/' print s os.system(s) repeatflag = 0 print "repeatflag = ", repeatflag elif flag.find('x') > -1: repeatflag = 0 print 'i think repeatflag = 0', repeatflag return else: s = 'mv *' + imprefix + '* Finished/' os.system(s) repeatflag = 0 print 'i think repeatflag = 0 ', repeatflag print 'repeatflag = ', repeatflag
def runellipse(files,xcenter,ycenter,minr,ipa,initialr,maxr,iellip,nframe=1,myradius=15): initialradius=myradius #print 'got here' #print files for i in range(len(files)): myradius=initialradius mfile=files[i] #mask image outfile1='m'+mfile if os.path.isfile(outfile1): print "found masked file ",outfile1 print "skipping imedit and running ellipse interactively" continueWithProgram=1 continueWithObject=1 else: print "can't find masked file ",outfile1 print "running imedit" continueWithProgram,continueWithObject=runimedit(mfile,outfile1,nframe) if not continueWithProgram: print "quitting program" return if not continueWithObject: print "going on to next image" continue #run ellipse t=mfile.split('.') efile=t[0]+'.tab' imprefix=t[0] try: os.remove(efile) except OSError: print 'everything is ok' #continue print "First pass through ellipse to find center" iraf.ellipse(input=outfile1,output=efile,x0=xcenter,y0=ycenter,hcenter='no',sma0=initialr,minsma=minr,maxsma=maxr,pa=ipa,hpa='no',ellip=iellip,hellip='no',interactive='no') #print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' #iraf.isoexam(table=efile) os.system('rm junk.txt') iraf.tprint(table=efile,pwidth='INDEF',showhdr='no', Stdout='junk.txt') os.system("awk '{print $2, $7, $9, $11, $13}' < junk.txt > junk2.txt") #run ellipse a second time, keeping PA and ellip fixed #allow user to adjust the radius where PA and ellip are measured infile=open('junk2.txt','r') for line in infile: t=line.split() if float(t[0]) > myradius: newxcenter=float(t[3]) newycenter=float(t[4]) break s='rm '+efile os.system(s) #draw ellipse with ds9 iraf.display(outfile1,1) (myellip,mypa)=findellipse(outfile1,newxcenter,newycenter) flag2=str(raw_input('Do you want to skip this one? y=skip, any other key to continue ')) if flag2.find('y') > -1: s='mv *'+imprefix+'* ../PeculiarGalaxies/' print s os.system(s) continue #run ellipse interactively #allow user to repeat until satisfied with script repeatflag=1 while repeatflag: s='rm '+efile os.system(s) iraf.ellipse(input=outfile1,output=efile,x0=newxcenter,y0=newycenter,hcenter='yes',sma0=initialr,minsma=minr,maxsma=maxr,pa0=mypa,hpa='yes',ellip0=myellip,hellip='yes',interactive='no') print 'Displaying isophotes from second pass using r = ',myradius print 'Hit q in the DS9 window to quit' iraf.isoexam(table=efile) flag=str(raw_input('Are you happy with the fit? y=yes n=no x=quit ')) flag=str(flag) print 'this is what I think you typed ',flag if flag.find('n') > -1: s='rm '+efile os.system(s) repeatflag=1 elif flag.find('x') > -1: repeatflag=0 print 'i think repeatflag = 0', repeatflag return else: s='mv *'+imprefix+'* ../Finished/' os.system(s) repeatflag=0 print 'i think repeatflag = 0 ', repeatflag print 'repeatflag = ',repeatflag
def runellipseold(files,xcenter,ycenter,minr,ipa,initialr,maxr,iellip,nframe=1,myradius=15): initialradius=myradius for i in range(len(files)): myradius=initialradius mfile=files[i] #mask image outfile1='m'+mfile continueWithProgram,continueWithObject=runimedit(mfile,outfile1,nframe) if not continueWithProgram: print "quitting program" return if not continueWithObject: print "going on to next image" continue #run ellipse t=mfile.split('.') efile=t[0]+'.tab' imprefix=t[0] print mfile, imprefix print 'Running ellipse to fit isophotes to galaxy:' try: os.remove(efile) except OSError: print 'everything is ok' print "First pass, letting PA and e vary" iraf.ellipse(input=outfile1,output=efile,x0=xcenter,y0=ycenter,hcenter='no',sma0=initialr,minsma=minr,maxsma=maxr,pa=ipa,hpa='no',ellip=iellip,hellip='no') print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' iraf.isoexam(table=efile) os.system('rm junk.txt') iraf.tprint(table=efile,pwidth='INDEF',showhdr='no', Stdout='junk.txt') os.system("awk '{print $2, $7, $9, $11, $13}' < junk.txt > junk2.txt") #run ellipse a second time, keeping PA and ellip fixed #allow user to adjust the radius where PA and ellip are measured repeatflag=1 while (repeatflag > 0.1): infile=open('junk2.txt','r') for line in infile: t=line.split() if float(t[0]) > myradius: newellip=float(t[1]) if newellip < .05:#min value that ellipse can handle newellip=.05 newPA=float(t[2]) if newPA < -90: newPA=newPA+180 elif newPA > 90: newPA = newPA-180 #11 - X0, 13 - Y0 newxcenter=float(t[3]) newycenter=float(t[4]) break s='rm '+efile os.system(s) iraf.ellipse(input=outfile1,output=efile,x0=newxcenter,y0=newycenter,hcenter='yes',sma0=initialr,minsma=minr,maxsma=maxr,pa=newPA,hpa='yes',ellip=newellip,hellip='yes') print 'Displaying isophotes from second pass using r = ',myradius print 'Hit q in the DS9 window to quit' iraf.isoexam(table=efile) flag=str(raw_input('Are you happy with the fit? y=yes n=no x=quit ')) flag=str(flag) print 'this is what I think you typed ',flag if flag.find('n') > -1: flag2=str(raw_input('What is the problem? c=off-center r=set new radius x=quit ')) flag2=str(flag2) if flag2.find('r') > -1: myr=input('Enter new radius to use ') myradius=float(myr) s='rm '+efile os.system(s) repeatflag=1 elif flag2.find('x') > -1: repeatflag=0 return elif flag2.find('c') > -1: s='mv *'+imprefix+'* OffCenter/' print s os.system(s) repeatflag=0 print "repeatflag = ",repeatflag elif flag.find('x') > -1: repeatflag=0 print 'i think repeatflag = 0', repeatflag return else: s='mv *'+imprefix+'* Finished/' os.system(s) repeatflag=0 print 'i think repeatflag = 0 ', repeatflag print 'repeatflag = ',repeatflag
def measure_disk(input_image, xcenter, ycenter, ipa, iellip, initialr, minr, maxr, zp, band=0, nframe=1, myradius=25, keepfixed=0, einteractive=0, mask_image=None): print 'inside measure disk' print 'mask image = ', mask_image myradius = initialr recentervalue = 'yes' interactivevalue = 'no' print '\n Running ellipse on ', input_image, '\n' mfile = input_image xcenter_cutout = xcenter ycenter_cutout = ycenter t = mfile.split('.') efile = t[0] + '.tab' efile_ascii = t[0] + '.dat' imprefix = t[0] print 'Running ellipse to fit isophotes to galaxy:', mfile if os.path.exists(efile): os.remove(efile) if keepfixed: print input_image, efile, xcenter_cutout, ycenter_cutout, initialr, minr, maxr, ipa iraf.ellipse(input=input_image, output=efile, dqf=mask_image, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='yes', recenter=recentervalue, sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='yes', ellip=iellip, hellip='yes', interactive='yes', step=0.1, linear='no') else: print "First pass, letting PA and e vary" print input_image, efile, xcenter_cutout, ycenter_cutout, initialr, minr, maxr, ipa, if mask_image == None: iraf.ellipse(input=input_image, output=efile, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='no', recenter=0, sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='no', ellip=iellip, hellip='no', interactive=einteractive, step=0.1, linear='no') else: iraf.ellipse(input=input_image, output=efile, dqf=mask_image, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='no', recenter=0, sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='no', ellip=iellip, hellip='no', interactive='yes', step=0.1, linear='no') print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' iraf.isoexam(table=efile) try: os.system('rm tp.00*') except: print 'no tp.00? files to remove' iraf.isoimap(input_image, table=efile) # get final ellipse parameters to return to the user if os.path.exists('junk.txt'): os.remove('junk.txt') iraf.tprint(table=efile, pwidth='INDEF', showhdr='no', Stdout='junk.txt') s = "awk '{print $2, $7, $9, $11, $13}' < " + "junk.txt > " + "junk2.txt" os.system(s) infile = open('junk2.txt', 'r') for line in infile: t = line.split() if float(t[0]) > myradius: newellip = float(t[1]) if newellip < .05: # min value that ellipse can handle newellip = .05 newPA = float(t[2]) if newPA < -90: newPA = newPA + 180 elif newPA > 90: newPA = newPA - 180 newxcenter = float(t[3]) newycenter = float(t[4]) if os.path.exists(efile_ascii): os.remove(efile_ascii) iraf.tprint(table=efile, pwidth='INDEF', showhdr='no', Stdout=efile_ascii) return newxcenter, newycenter, newellip, newPA
pa = ngc_match.iloc[0, 21] if math.isnan(pa): pa = 0 ellip = 0.05 elif pa > 90: pa = pa - 180.0 # iraf.ellipse.controlpar.minit = 10 # iraf.ellipse.controlpar.maxit = 100 # iraf.ellipse.controlpar.olthresh = 0.0 # iraf.ellipse(input=cur_dir+'tmp_V.fits',output=cur_dir+'tmp_V.tab',inter='no',x0=i,y0=j,ellip0=ellip,pa0=pa,sma0=thumb/10.0, \ # minsma=1,maxsma=thumb,linear='no',recenter='no',hcenter='yes',hellip='yes',hpa='yes',integrmode='median',refer=1.0, \ # zerolevel=0.0,mag0=22.5,nclip=0,step=0.3) iraf.ellipse(input=cur_dir+'tmp_V.fits',output=cur_dir+'tmp_V.tab',inter='no',x0=i,y0=j,ellip0=ellip,pa0=pa,sma0=thumb/10.0, \ minsma=1,maxsma=thumb,linear='no',recenter='yes',hcenter='no',hellip='no',hpa='no',integrmode='median',refer=1.0, \ zerolevel=0.0,mag0=22.5,nclip=0,step=0.3) iraf.tdump(table=cur_dir + 'tmp_V.tab', datafile='/Users/dhk/work/data/NGC_IC/ellipse/pa_ellip/' + name + '.txt', columns='@colnames.lis') copyfile(cur_dir + 'tmp_V.tab', '/Users/dhk/work/data/NGC_IC/ellipse/pa_ellip/' + name + '.tab') iraf.ellipse(input=work_dir + 'SHA/SHA_NGC_IC_LONG_mean/' + name + '.fits', output=cur_dir + 'tmp_I1.tab', inter='no', inellip=cur_dir + 'tmp_V.tab', mag0=21.5814) iraf.tdump(table=cur_dir + 'tmp_I1.tab',
def runEllipse24UsingSDSS(self): agcnumber=self.agcnumber[self.ellipseflag] #mcutoutpath='/home/rfinn/research/LocalClusters/MaskedCutouts/'+self.prefix+'/' mcutoutpath='/home/rfinn/research/LocalClusters/MaskedCutouts/'+self.prefix+'/' os.chdir(mcutoutpath) s=outpathroot+'research/LocalClusters/Ellipse24UsingSDSS/'+self.prefix try: os.mkdir(s) except OSError: pass for i in range(len(agcnumber)): print agcnumber[i] sdssEllipseTable= '/home/rfinn/research/LocalClusters/EllipseTables/'+self.prefix+'/'+self.prefix+'-'+str(agcnumber[i])+'-cutout-sdss.tab' #mipsImage=mcutoutpath+'m'+self.prefix+'-'+str(agcnumber[i])+'-cutout-24-rot.fits' mipsImage='m'+self.prefix+'-'+str(agcnumber[i])+'-cutout-24-rot.fits' #outim=cutoutpath+self.prefix+'-'+str(agcSpiral[i])+'-cutout-sdss.fits \n' os.system('rm junk.txt') if os.path.isfile(sdssEllipseTable): iraf.tprint(table=sdssEllipseTable,pwidth='INDEF',showhdr='no', Stdout='junk.txt') os.system("awk '{print $2, $7, $9, $11, $13}' < junk.txt > junk2.txt") else: print 'Warning: ',sdssEllipseTable,' does not exist' sdssEllipseTable= '/home/rfinn/research/LocalClusters/EllipseTables/'+self.prefix+'/'+self.prefix+'-'+str(agcnumber[i])+'-cutout-sdss.dat' s="awk '{print $2, $7, $9, $11, $13}' <"+sdssEllipseTable+" > junk2.txt" os.system(s) #run ellipse a second time, keeping PA and ellip fixed infile=open('junk2.txt','r') for line in infile: t=line.split() if float(t[0]) > myradius: newellip=float(t[1]) if newellip < .05:#min value that ellipse can handle newellip=.05 newPA=float(t[2]) if newPA < -90: newPA=newPA+180 elif newPA > 90: newPA = newPA-180 #11 - X0, 13 - Y0 newxcenter=float(t[3]) newycenter=float(t[4]) t=mipsImage.split('.') efile=self.prefix+'-'+str(agcnumber[i])+'.24UsingSDSS.tab' copyefile=outpathroot+'research/LocalClusters/Ellipse24UsingSDSS/'+self.prefix+'/'+self.prefix+'-'+str(agcnumber[i])+'.24UsingSDSS.tab' #iraf.ellipse(input=mipsImage,output=efile,inellip=sdssEllipseTable)#trying to use sdss input if os.path.exists(efile): s=efile+' exists. Rerun? (y=yes, any key to skip)' rerunFlag=raw_input(s) if rerunFlag.find('y') > -1: os.remove(efile) iraf.ellipse(input=mipsImage,output=efile,x0=xcenter,y0=ycenter,hcenter='yes',recenter='no',sma0=initialr,minsma=minr,maxsma=maxr,pa=newPA,hpa='yes',ellip=newellip,hellip='yes') else: continue else: iraf.ellipse(input=mipsImage,output=efile,x0=xcenter,y0=ycenter,hcenter='yes',recenter='no',sma0=initialr,minsma=minr,maxsma=maxr,pa=newPA,hpa='yes',ellip=newellip,hellip='yes') #outfile24=homedir+'research/LocalClusters/EllipseTables/'+self.prefix+'/'+self.prefix+'-'+str(agcSpiral[i])+'-cutout-24-rot.dat \n' print 'Displaying isophotes from ellipse fit. Hit q in DS9 window to quit' iraf.isoexam(table=efile) s='cp '+efile+' '+copyefile print s os.system(s)
def ellipse(image, outname, verbose=False, **kwargs): """run ellipse task image : input image name outname : output filename Keywords: *geompar* x0, y0 -- required ellip0 : initial ellipticity (default=0.2) pa0 : initial PA in degrees ccw from +y (default=20) sma0 : initial semi-major axis (default=10) minsma : minimum sma (default=1) maxsma : maximum sma (default='INDEF') step : sma step size (default=0.1) linear : linear sampling of sma? (default='no') *controlpar* conver : """ # verify input if 'x0' not in kwargs.keys() or 'y0' not in kwargs.keys(): raise KeyError('x0 or y0 is not found') # load packages iraf.stsdas(_doprint=0, motd=False) iraf.analysis(_doprint=0) iraf.isophote(_doprint=0) # reset all parameters iraf.unlearn('ellipse', 'geompar', 'controlpar', 'samplepar') iraf.ellipse.interactive = False iraf.ellipse.xylearn = False # if True, it prompts input upon faling to find center # geompar iraf.ellipse.x0 = kwargs.pop('x0') iraf.ellipse.y0 = kwargs.pop('y0') iraf.ellipse.ellip0 = kwargs.pop('ellip0', 0.2) iraf.ellipse.pa0 = kwargs.pop('pa0', 20.0) iraf.ellipse.sma0 = kwargs.pop('sma0', 10.0) iraf.ellipse.minsma = kwargs.pop('minsma', 1.) iraf.ellipse.maxsma = kwargs.pop('maxsma', 'INDEF') iraf.ellipse.step = kwargs.pop('step', 0.1) iraf.ellipse.linear = kwargs.pop('linear', 0) iraf.ellipse.verbose = verbose # controlpar iraf.ellipse.conver = kwargs.pop('conver', 0.05) iraf.ellipse.minit = kwargs.pop('minit', 10) iraf.ellipse.maxit = kwargs.pop('maxit', 50) iraf.ellipse.hcenter = kwargs.pop('hcenter', 'no') # samplepar iraf.ellipse.tsample = kwargs.pop('tsample', 'none') iraf.ellipse.harmonics = kwargs.pop('harmonics', 'none') if verbose: iraf.lparam('ellipse') iraf.lparam('geompar') iraf.lparam('controlpar') iraf.lparam('samplepar') # run ellipse tempname = shorten_iauname(image) + str(uuid.uuid4()) + '.tab' try: iraf.ellipse(image, tempname) # print ascii table iraf.tprint(tempname, pwidth='INDEF', Stdout=outname) os.remove(tempname) except: print 'ellipse failed'
def measure_disk(input_image, xcenter, ycenter, ipa, iellip, initialr, minr, maxr, zp, band=0, nframe=1, myradius=20, keepfixed=0, einteractive=0, mask_image=None): print 'inside measure disk' print 'mask image = ', mask_image #myradius=initialr recentervalue = 'yes' interactivevalue = 'yes' print '\n Running ellipse on ', input_image, '\n' print ' Enter ? for a list of options \n' print ' Enter c to continue fitting ellipses automatically \n' mfile = input_image xcenter_cutout = xcenter ycenter_cutout = ycenter t = mfile.split('.') efile = t[0] + '.tab' efile_ascii = t[0] + '.dat' imprefix = t[0] print 'Running ellipse to fit isophotes to galaxy:', mfile if os.path.exists(efile): os.remove(efile) if keepfixed: print input_image, efile, xcenter_cutout, ycenter_cutout, initialr, minr, maxr, ipa iraf.ellipse(input=input_image, output=efile, dqf=mask_image, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='yes', recenter=recentervalue, sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='yes', ellip=iellip, hellip='yes', interactive='yes', step=0.1, linear='no') else: print "First pass, letting PA and e vary" print input_image, efile, xcenter_cutout, ycenter_cutout, initialr, minr, maxr, ipa, if mask_image == None: iraf.ellipse(input=input_image, output=efile, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='no', recenter='yes', sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='no', ellip=iellip, hellip='no', interactive='yes', step=0.1, linear='no') else: iraf.ellipse(input=input_image, output=efile, dqf=mask_image, x0=xcenter_cutout, y0=ycenter_cutout, hcenter='no', recenter=0, sma0=initialr, minsma=minr, maxsma=maxr, pa=ipa, hpa='no', ellip=iellip, hellip='no', interactive='yes', step=0.1, linear='no') print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' iraf.isoexam(table=efile) try: os.system('rm tp.00*') except: print 'no tp.00? files to remove' iraf.isoimap(input_image, table=efile) # get final ellipse parameters to return to the user if os.path.exists('junk.txt'): os.remove('junk.txt') iraf.tprint(table=efile, pwidth='INDEF', showhdr='no', Stdout='junk.txt') s = "awk '{print $2, $7, $9, $11, $13}' < " + "junk.txt > " + "junk2.txt" os.system(s) redo = 1 while redo: infile = open('junk2.txt', 'r') print 'within redo loop' for line in infile: t = line.split() if float(t[0]) > myradius: #print 'got here',myradius, t[0] newellip = float(t[1]) if newellip < .05: # min value that ellipse can handle newellip = .05 newPA = float(t[2]) if newPA < -90: newPA = newPA + 180 elif newPA > 90: newPA = newPA - 180 newxcenter = float(t[3]) newycenter = float(t[4]) break infile.close() print 'ellipse values at r = ', myradius print ' ellip = ', newellip print ' PA = ', newPA t = raw_input('are you happy? (n = no, enter to continue) ') if t.find('n') > -1: newr = raw_input( 'Enter radius where ellipse best represents galaxy ') myradius = float(newr) else: redo = 0 continue if os.path.exists(efile_ascii): os.remove(efile_ascii) iraf.tprint(table=efile, pwidth='INDEF', showhdr='no', Stdout=efile_ascii) return newxcenter, newycenter, newellip, newPA
## ----- este valor pode ser maior ou menor; depende da imagem ## iraf.geompar.maxsma = 1000 ## Muda parametros default do display para podermos ver o centro da galaxia #so descomentar quando quiser visualizar # !ds9& # iraf.display.zscale='no' # iraf.display.ztrans="log" ## =====>>>> Roda o stsdas/ellipse print(x0) print(y0) iraf.ellipse(input=fich_comb, output=tab, interactive='no', masksz=1, region='yes') ## ====>>>> Constroi um modelo baseado no ellipse iraf.bmodel(table=tab, output=model) iraf.imarith(operand1=fich_comb, op="-", operand2=model, result=resid) ## ====>>>> Faz o grafico mag X R^(1/4) (perfil de de Vaucouleurs) # iraf.isoplot(input=tab, xaxis="RSMA", yaxis="INTENS") ### ------ Saida de uma tabela ascii (.txt) para ajuste em outro programa colunas = "SMA,RSMA,INTENS,INT_ERR,RMS,MAG,MAG_LERR,MAG_UERR" colunas_2 = [ 'SMA', 'RSMA', 'INTENS', 'INT_ERR', 'RMS', 'MAG', 'MAG_LERR', 'MAG_UERR'
# 10. Make sure the Interactive Mode is turned off iraf.ellipse.interactive = "no" #Error 1: interactive mode parameter error. IrafError: Attempt to set unknown lone parameter interactive. # 11. Turn the flag fraction to 0.8. If this value is too low, the fit would stop when the sample region contain too many flagged pixels. iraf.ellipse.samplepar.fflag=0.99 # Check and remove outputs from the previous Ellipse run, or Ellipse will report # error (Quite stupid!) if os.path.exists(outBin): os.remove(outBin) if os.path.exists(outTab): os.remove(outTab) if os.path.exists(outCdf): os.remove(outCdf) # Start the fitting iraf.ellipse(input=inputImg, output=outBin) # TODO: Demonstrate the direct photometry mode using input catalog # inBin = input_bin_file ## The inBin is a Binary result from previous Ellipse run(where?), and the isophote ## stored in it will overwrite all the above settings. Ellipse will simply ## extract surface brightness profile using these isophote instead of doing any ## fitting # iraf.ellipse(input=inputImg, output=outBin, inellip=inBin) # The Ellipse output is a binary table file, which is very hard to deal with # "Dump" it into a nice ASCII table iraf.tdump.columns='RSMA, A4' iraf.tdump(table=outBin, datafile=outTab, cdfile=outCdf) os.remove(outCdf) os.remove(outBin) os.remove(outPl)
def measure_disk(input_image,xcenter,ycenter,ipa,iellip,initialr,minr,maxr,zp,band=0,nframe=1,myradius=20,keepfixed=0,einteractive=0,mask_image=None): print 'inside measure disk' print 'mask image = ',mask_image #myradius=initialr recentervalue='yes' interactivevalue='yes' print '\n Running ellipse on ',input_image,'\n' print ' Enter ? for a list of options \n' print ' Enter c to continue fitting ellipses automatically \n' mfile=input_image xcenter_cutout=xcenter ycenter_cutout=ycenter t=mfile.split('.') efile=t[0]+'.tab' efile_ascii=t[0]+'.dat' imprefix=t[0] print 'Running ellipse to fit isophotes to galaxy:',mfile if os.path.exists(efile): os.remove(efile) if keepfixed: print input_image,efile,xcenter_cutout,ycenter_cutout,initialr,minr,maxr,ipa iraf.ellipse(input=input_image,output=efile,dqf=mask_image,x0=xcenter_cutout,y0=ycenter_cutout,hcenter='yes',recenter=recentervalue,sma0=initialr,minsma=minr,maxsma=maxr,pa=ipa,hpa='yes',ellip=iellip,hellip='yes',interactive='yes',step=0.1,linear='no') else: print "First pass, letting PA and e vary" print input_image,efile,xcenter_cutout,ycenter_cutout,initialr,minr,maxr,ipa, if mask_image == None: iraf.ellipse(input=input_image,output=efile,x0=xcenter_cutout,y0=ycenter_cutout,hcenter='no',recenter='yes',sma0=initialr,minsma=minr,maxsma=maxr,pa=ipa,hpa='no',ellip=iellip,hellip='no',interactive='yes',step=0.1,linear='no') else: iraf.ellipse(input=input_image,output=efile,dqf=mask_image,x0=xcenter_cutout,y0=ycenter_cutout,hcenter='no',recenter=0,sma0=initialr,minsma=minr,maxsma=maxr,pa=ipa,hpa='no',ellip=iellip,hellip='no',interactive='yes',step=0.1,linear='no') print 'Displaying isophotes from first pass. Hit q in DS9 window to quit' iraf.isoexam(table=efile) try: os.system('rm tp.00*') except: print 'no tp.00? files to remove' iraf.isoimap(input_image,table=efile) # get final ellipse parameters to return to the user if os.path.exists('junk.txt'): os.remove('junk.txt') iraf.tprint(table=efile,pwidth='INDEF',showhdr='no', Stdout='junk.txt') s="awk '{print $2, $7, $9, $11, $13}' < "+"junk.txt > "+"junk2.txt" os.system(s) redo = 1 while redo: infile=open('junk2.txt','r') print 'within redo loop' for line in infile: t=line.split() if float(t[0]) > myradius: #print 'got here',myradius, t[0] newellip=float(t[1]) if newellip < .05: # min value that ellipse can handle newellip=.05 newPA=float(t[2]) if newPA < -90: newPA=newPA+180 elif newPA > 90: newPA = newPA-180 newxcenter=float(t[3]) newycenter=float(t[4]) break infile.close() print 'ellipse values at r = ',myradius print ' ellip = ',newellip print ' PA = ',newPA t=raw_input('are you happy? (n = no, enter to continue) ') if t.find('n') >-1: newr=raw_input('Enter radius where ellipse best represents galaxy ') myradius=float(newr) else: redo = 0 continue if os.path.exists(efile_ascii): os.remove(efile_ascii) iraf.tprint(table=efile,pwidth='INDEF',showhdr='no', Stdout=efile_ascii) return newxcenter,newycenter,newellip,newPA
background = sys.argv[3] file = fits.open(filename) x0 = (file[0].header[3]) / 2 y0 = (file[0].header[4]) / 2 iraf.stsdas() iraf.analysis() iraf.isophote() pyraf.iraftask.gettask("geompar")[0].setParam("x0", x0) pyraf.iraftask.gettask("geompar")[0].setParam("y0", y0) pyraf.iraftask.gettask("geompar")[0].setParam("maxsma", sma) iraf.ellipse(filename, galaxyname + ".tab") iraf.bmodel(galaxyname + ".tab", galaxyname + "_mod.fits", backgr=background) iraf.imarith(operand1=filename, op="-", operand2=galaxyname + "_mod.fits", result=galaxyname + "_modsub.fits") sew = sewpy.SEW(params=["NUMBER"], config={ "DETECT_MINAREA": 2, "DETECT_MAXAREA": 700, "DETECT_THRESH": 3, "ANALYSIS_THRESH": 5.0,
iraf.ellipse.geompar.sma0 = 40 iraf.ellipse.geompar.step = 0.01 iraf.ellipse.geompar.linear = False iraf.ellipse.geompar.recenter = True # iraf.ellipse.geompar.saveParList(filename="ellipse.par") # samplepar iraf.ellipse.samplepar.nclip = 1 iraf.ellipse.samplepar.sdevice = "stdgraph" # iraf.ellipse.samplepar.saveParList(filename="ellipse.par") # magpar : zero point photometry iraf.ellipse.magpar.mag0 = 20.3 # ellipse parameters iraf.ellipse(input=input_filename, output=output_bin) iraf.tdump(table=output_bin, datafile=output_table, cdfile=output_cdf) # model image construction iraf.bmodel.unlearn() iraf.bmodel(table=output_bin, output=model_image) # subtraction image = fits.open(input_filename)[0].data model = fits.open(model_image)[0].data fn = lambda x: np.nanmean((image - x[0] * model - np.nanmedian(image))**2) res = minimize(fn, (0.1, ), method="Nelder-Mead") iraf.imarith.unlearn()
iraf.ellipse.controlpar.maxit = 100 # 9. Threshold for the object locator algorithm # By lowering this value, the locator become less strict. iraf.ellipse.controlpar.olthresh = 1.00000 # 10. Make sure the Interactive Mode is turned off iraf.ellipse.controlpar.interactive = "no" # Check and remove outputs from the previous Ellipse run, or Ellipse will report # error (Quite stupid!) if os.path.exists(outBin): os.remove(outBin) if os.path.exists(outTab): os.remove(outTab) if os.path.exists(outCdf): os.remove(outCdf) # Start the fitting iraf.ellipse(input=inputImg, output=outTab) # TODO: Demonstrate the direct photometry mode using input catalog # inBin = input_bin_file ## The inBin is a Binary result from previous Ellipse run, and the isophote ## stored in it will overwrite all the above settings. Ellipse will simply ## extract surface brightness profile using these isophote instead of doing any ## fitting # iraf.ellipse(input=inputImg, output=outBin, inellip=inBin) # The Ellipse output is a binary table file, which is very hard to deal with # "Dump" it into a nice ASCII table iraf.tdump(table=outBin, datafile=outTab, cdfile=outCdf) os.remove(outCdf)