procedure tmask (maskType,maskZER,maskRMS,skyRMS,gn,rn,subBack,newBack,Xc,Yc, rad,Xmax, Ymax) string maskType {"zero", prompt="Mask type (zero|rms|both)"} string maskZER {"-",prompt=" Name of output zero corner mask"} string maskRMS {"--",prompt=" Name of output RMS corner mask"} real skyRMS {7.0, prompt=" RMS: Sky RMS (in rms ADU)"} real gn {1.11, prompt=" RMS: Gain of CCD (e-/ADU)"} real rn {2.0, prompt=" RMS: Read noise of CCD (rms e-)"} bool subBack {yes, prompt=" RMS: Re-adjust background level?"} real newBack {0.0, prompt=" ---> New background level"} real Xc {730.0, prompt="X-coord of circular aperture centre"} real Yc {830.0, prompt="Y-coord of circular aperture centre"} real rad {720.0, prompt="Radius of circular aperture"} int Xmax {0, prompt="Image dimension in X"} int Ymax {0, prompt="Image dimension in Y"} begin # Variable Declarations: string radExpr # current expression used in imexpr string dimens # image dimensions string txtDetails # text string storing details of RMS corner img real backg # Background level in counts # Make sure the IMAGES, UTILITIES and ARTDATA packages are loaded: if (! defpac ("images")) { print("IMAGES package not loaded") bye } if (! defpac ("utilities")) { print("UTILITIES package not loaded") bye } dimens = ""//Xmax//","//Ymax # Constructing the zero corner mask: if ((maskType=="both")||(maskType=="zero")) { print(" ") print ("Constructing the zero corner mask "//maskZER//" ...") print(" ") imdelete (images=maskZER,verify=no,default=yes, go_ahead=yes) radExpr="(( sqrt((I-"//Xc//")**2+(J-"//Yc//")**2) ) < "//rad//")? 1.0 : 0.0" imexpr(expr=radExpr, outp=maskZER, dim=dimens, outtype="real", intype="real") } print (" ") print (" ") # Constructing the RMS corner mask: if ((maskType=="both")||(maskType=="rms")) { if (! defpac ("artdata")) { print("ARTDATA package not loaded") bye } backg=(skyRMS*skyRMS*gn)-(rn*rn/gn) # calculating background level to create the desired sky RMS # (backg level in ADU) print(" ") print ("Constructing the RMS corner mask "//maskRMS//" ...") print(" ") txtDetails = "bg="//backg//" gn="//gn//" rn="//rn print (txtDetails) if (backg<=0) { print(" ") print(" *** Impossible situation: ***") print(" You are measuring less total RMS than the RN") print(" --> will set RN to 0.0, re-calc and continue") print(" ") rn=0.0 backg=(skyRMS*skyRMS*gn)-(rn*rn/gn) txtDetails = "bg="//backg//" gn="//gn//" rn="//rn print (txtDetails) } imdelete (images="temp_mask*",verify=no,default=yes, go_ahead=yes) imdelete (images=maskRMS,verify=no,default=yes, go_ahead=yes) mknoise(input="temp_mask1",output="",title=txtDetails,ncols=Xmax, nlines=Ymax,header="artdata$stdheader.dat",backgro=backg,gain=gn,rdnoise=rn, poisson+,seed=INDEF,cosrays="",ncosray=0,comment+,mode="ql") radExpr="(( sqrt((I-"//Xc//")**2+(J-"//Yc//")**2) ) < "//rad//")? 0.0 : 1.0" imexpr(expr=radExpr,outp="temp_mask2",dim=dimens, outtype="real", intype="real") # N.B.: This is the INVERSE of the zero corner mask if (subBack==yes) { print(" ") print ("(Re-adjusting background level ...)") print(" ") txtDetails = "bg="//backg//";"//newBack//" gn="//gn//" rn="//rn newBack=backg-newBack imrename(oldnames="temp_mask1",newnames="temp_mask3",verb-,flpar-) imarith(operand1="temp_mask3",op="-",operand2=newBack, result="temp_mask1",title=txtDetails,divzero=0,verb-,noact-,flpar-,mode="ql") # subtracting background level and re-adjusting if requested } imarith(operand1="temp_mask1",op="*",operand2="temp_mask2", result=maskRMS,title=txtDetails,divzero=0,verb-,noact-,flpar-,mode="ql") } # Cleaning up stray files: imdelete (images="temp_mask*",verify=no,default=yes, go_ahead=yes) print(" ") print("Done.") print(" ") end