procedure findstars(imname,answer,rn) # # findstars.cl # # generate data with known PSF and positions # # use daophot to find them and centroid them, # and use known positions to distinguish # true from erroneous identifications # bool answer = no {prompt="New PSF defined?"} int rn = 1 {prompt="enter new seed"} string imname struct *tempfile,*afile begin real xfit[150],yfit[150],width[150] real xtarget[150],ytarget[150],mag[150] real poserr,b,offset,mag0,tol real xt,yt,magt,xsum,ysum,wsum real sky,ar,step string im,daoplot,stemp int nstar,ii,sample,nfound,falsedet,nn real radius,FWHM,mmax real sigy,sig2,xc,yc,sig # fitted parameters real magfit ar = 0.9 # axial ratio FWHM = 2.1 radius = FWHM/2 sky = 8772 mmax = 10.82 # for the brightest targets # nmax=2.5*log(counts) nn = rn tol = 2 datapars.fwhmpsf=FWHM # used by daofind datapars.sigma =sqrt(sky) # used by daofind findpars.ratio =ar # used by daofind findpars.threshold =2.4 # used by daofind centerpars.cbox =2*FWHM centerpars.calg ="centroid" # causes phot to recentre fitskypars.annulus=4*FWHM fitskypars.dannulus=3*FWHM photpars.apertures=FWHM photpars.zmag=0.0 daopars.psfrad =4*FWHM + 1 daopars.fitrad =FWHM daopars.varorder=-1 daoplot="dump" stemp="dump.dat" tempfile=stemp delete(stemp) delete("*.coo.*") # made by daofind delete("*.mag.*") # made by phot delete("*.pst.*") # made by pstselect imdel("*.psf.*") # made by psf delete("*.psg.*") # made by psf delete("run.log") if(answer){ delete(daoplot) imdel("brightstar") mkobject("brightstar",ncol=50,nlin=50,backgr=0, \ objects="bright.dat",star="gaussian", \ radius=radius,ar=ar,magzero=13.0,poisson=no) daofind("brightstar","default",interac-,verify-,verbose-) phot("brightstar","default","default"," ",verify-,verbose-) pstselect("brightstar","default","default",max=1,verify-,verbose-) psf("brightstar","default","default","default","default","default", \ plotfile=daoplot, icomm="daophot$test/cmds.dat", \ verify-,verbose-) } imdel("manystar") afile="stars.dat" for(i=1; i<=150; i+=1){ xfit[i]=0 yfit[i]=0 mag[i]=0.0 } print(" ") print("sky=",sky, "mmax=",mmax, "threshold=", \ findpars.threshold," sigma") print("sky=",sky, "mmax=",mmax, "threshold=", \ findpars.threshold," sigma", >> "run.log") mkobject("manystar",ncol=140,nlin=100,backgr=sky, \ objects="many.dat",star="gaussian", \ radius=radius,ar=ar,magzero=mmax,poisson=yes,seed=nn) daofind("manystar","default",interac-,verify-,verbose-) phot("manystar","default","default"," ",verify-,verbose-) txdump("manystar.mag.1",fields="XCENTER,YCENTER,MAG",expr="yes", >> stemp) i=0 nfound=0 while( fscan(tempfile,xc,yc,magfit) != EOF ){ i=i+1 xfit[i]=xc yfit[i]=yc mag[i]=magfit nfound=nfound+1 } falsedet=nfound print(" ") print(nfound," PNs found") print(" xc \t yc \t mag", >> "run.log") for(step=20;step<=120;step=step+20){ print(" ") print("PNs with x near ",step) print(" ", >> "run.log") for(i=1; i<=nfound; i+=1){ yc=yfit[i] if((abs(yc-20)>tol)&&(abs(yc-40)>tol)&& \ (abs(yc-60)>tol)&&(abs(yc-80)>tol)) goto lend if(abs(xfit[i]-step)>tol) goto lend xc=xfit[i] yc=yfit[i] magfit=mag[i] print("located: xc=",xc," yc=",yc," mag=",magfit ) print(xc, "\t", yc, "\t", magfit, >> "run.log") falsedet=falsedet-1 lend : b=0 } } print(" ") print(falsedet," false detections") print(falsedet," false detections", >> "run.log") end