pax_global_header00006660000000000000000000000064145566651640014534gustar00rootroot0000000000000052 comment=6dfc2de85f27669c2a2c9a3f0d7934deba461515 iraf-xdimsum-main/000077500000000000000000000000001455666516400144275ustar00rootroot00000000000000iraf-xdimsum-main/COPYRIGHT000066400000000000000000000031241455666516400157220ustar00rootroot00000000000000Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. The IRAF software is publicly available, but is NOT in the public domain. The difference is that copyrights granting rights for unrestricted use and redistribution have been placed on all of the software to identify its authors. You are allowed and encouraged to take this software and use it as you wish, subject to the restrictions outlined below. Permission to use, copy, modify, and distribute this software and its documentation is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that references to the Association of Universities for Research in Astronomy Inc. (AURA), the National Optical Astronomy Observatories (NOAO), or the Image Reduction and Analysis Facility (IRAF) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission from NOAO. NOAO makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. NOAO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NOAO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. iraf-xdimsum-main/README000066400000000000000000000451211455666516400153120ustar00rootroot00000000000000 XDIMSUM -- Experimental Deep Infrared Mosaicing Software THIS VERSION OF XDIMSUM WILL ONLY RUN UNDER IRAF VERSION 2.12 AND LATER. IT REQUIRES TASKS IN THE PROTO PACKAGE THAT ARE NOT AVALILABLE IN IRAF 2.11 AS WELL AS THE IMRED.CRUTIL PACKAGE WHICH IS NOT INSTALLED UNDER IRAF 2.11. PLEASE WAIT TO INSTALL THIS VERSION OF XDIMSUM UNTIL AFTER IRAF 2.12 IS RELEASED. XDIMSUM is a package for creating accurate sky subtracted images from sets of dithered observations. While the observations need not be in the infrared, the dominance of the variable sky background in infrared data requires dithering of many short exposures and recombination with careful sky subtraction to produce deep images. Hence the package is called "Experimental Deep Infrared Mosaicing Software" or XDIMSUM. XDIMSUM is a variant of the DIMSUM package developed by P. Eisenhardt, M. Dickensen, S.A. Stanford, and J. Ward. F. Valdes (IRAF group) modified DIMSUM to support FITS format images, added the DIMSUM tutorial demos script, wrote the original version of this document, and repackaged DIMSUM for distribution as an IRAF external package. L. Davis (IRAF group) rewrote the the major DIMSUM scripts to improve their clarity, robustness, and efficiency, added new scripts for computing relative offsets, and documented the tasks. The new package uses the same default algorithms as DIMSUM but is sufficiently different in format that it has been renamed XDIMSUM. A short summary of the major differences between XDIMSUM and DIMSUM is provided below and is duplicated in the on-line user's guide. XDIMSUM is being made available to the community as an external pacakge in the hope that some of the new features may prove useful to others. Users should direct XDIMSUM installation questions, bug reports, questions about technical details, and comments and suggestions to the the IRAF group (iraf@noao.edu) not the original authors. The current contents of the XDIMSUM package are xmosaic - Driver sript for first pass and mask pass processing steps xfirstpass - Driver script for first pass processing steps xmaskpass - Driver script for mask pass processing steps xslm - Sky subtract images using running median maskfix - Fix bad pixel in images using a bad pixel mask xzap - Remove cosmic rays from images using median filtering xnzap - Remove cosmis rays from images using averaging filter badpixupdate - Update bad pixel mask to include bad pixels detected by xzap xnregistar - Mosaic the images using sub-pixel replication and masking mkmask - Create the initial master object mask maskdereg - Deregister master object mask to individual object masks xdshifts - Compute shifts using image display and centroiding techniques xfshifts - Compute shifts using star finding and centroiding techniques xmshifts - Compute shifts using star finding and list matching techniques xrshifts - Compute shifts using x-correlation techniques iterstat - Compute image statistics using iterative rejection xlist - Create image sublists used by xslm makemask - Make an object mask for a single image orient - Reorient image to N up and E left or undo re-orientation sigmanorm - Renormalize mosaic image to uniform pixel-to-pixel rms maskstat - Compute mask statistics using iterative rejection demos - Xdimsum demo data script guide - Guide to using xdimsum with the xmosaic task ------------------------------------------------------------------------------- New Release: January 24, 2003 Modification to xdshifts to avoid problem with IMEXAMINE and DS9. If you use XIMTOOL then there is no need to update. ------------------------------------------------------------------------------- New Release: August 6, 2002 The xnregistar step was not maintaining the proper exposure time factors. ------------------------------------------------------------------------------- New Release: June 27, 2002 Fixed an undefined variable problem in the xmskcombine task. ------------------------------------------------------------------------------- New Release: June 25, 2002 Fixed some problems related to the default mask names in xnregistar. ------------------------------------------------------------------------------- New Release: June 19, 2002 The cmimglist variable was undefined in the xnregistar script causing it to fail if interpolation instead of block replication is used. ------------------------------------------------------------------------------- New Release: May 02, 2002 Fixed various problems with the ximcombine task. ------------------------------------------------------------------------------- New Release: January 30, 2002 Fixed an ximcombine problem in handling offsets which resulted in gross inefficiences when combining large images. ------------------------------------------------------------------------------- New Release: December 4, 2001 Fixed an ximcombine problem that only showed up on Linux. ------------------------------------------------------------------------------- New Release: November 28, 2001 Replaced ximcombine with the latest enhanced, bug fixed, and repackaged version from Frank which preserves the existing parameter set and behavior. ------------------------------------------------------------------------------- New Release: August 11, 2001 Fixed a segvio error in ximcombine that was triggered when trying to combine large numbers >~ 250 pixel masks. ------------------------------------------------------------------------------- New Release: July 17, 2001 Fixed an infinite loop problem in the interactive threshold determining algorithm in the xmosaic task. ------------------------------------------------------------------------------- New Release: June 01, 2001 Added the negthresh parameter to the makemask task and made the parameter visible to the xfirstpass, xmaskpass, and xmosaic tasks. If negthresh is yes both positive and negative masking threshold are used otherwise only positive masking threshold are used. Negthresh is set to no in the xzap makemask call. Made the badpixupdate task nrepeats parameter visible to the xfirstpass, xmaskpass, and xmosaic tasks. Made the regions growing parameter ngrow visible to the xmaskpass and xmosaic scripts. Rearranged the listing of the xmosaic task switch parameters to be back at the beginning of the task listing. Removed the nprev_omask parameter from the maskdereg task and added it to the xnregistar task. Also made the parameter visible to the xmaskpass and mosaic scripts. Added the omasks parameter to the xnregistar task. Correct various minor bugs to do with check for input file existence and switch values. ------------------------------------------------------------------------------- First Release: January 08, 2001 ------------------------------------------------------------------------------- Standard Installation Instructions For The Xdimsum Package Installation of this external package consists ofobtaining the files, creating a directory containing the package, compiling the executables or installing precompiled executables, and defining the environment to load and run the package. The package may be installed for a site or as a personal installation. If you need help with these installation instructions contactiraf@noao.edu or call the IRAF HOTLINE at 520-318-8160. [arch] In the following steps you will need to know the IRAF architecture identifier for your IRAF installation. This identifier is similar to the host operating system type. The identifiers are things like "ssun" for Solaris, "alpha" for Dec Alpha, and "linux" or "redhat" for most Linux systems. The IRAF architecture identifier is defined when you run IRAF. Start the CL and then type cl> show arch .ssun This is the value you need to know without the leading '.', i.e. the IRAF architecture is "ssun" in the above example. [1-site] If you are installing the package for a site login as IRAF and edit the IRAF file defining the packages. % cd $hlib Define the environment variable xdimsum to be the pathnames to the xdimsum package root directory and the instrument database. The '$' character must be escaped in the VMS pathname and UNIX pathnames must be terminated with a '/'. Edit extern.pkg to include the following. reset xdimsum = /local/xdimsum/ task xdimsum.pkg = xdimsum$xdimsum.cl Near the end of the hlib$extern.pkg file, update the definition of helpdb so it includes the xdimsum help database, copying the syntax already used in the string. Add this line before the line containing a closing quote: ,xdimsum$lib/helpdb.mip\ [1-personal] If you are installing the package for personal use define a host environment variable with the pathname of the directory where the package will be located (needed in order to build the package from the source code). Note that pathnames must end with '/'. For example: % setenv xdimsum /local/xdimsum/ In your login.cl or loginuser.cl file make the following definitions somewhere before the "keep" statement. reset xdimsum = /local/xdimsum/ task xdimsum.pkg = xdimsum$xdimsum.cl printf ("reset helpdb=%s,xdimsum$lib/helpdb.mip\nkeep\n", envget("helpdb")) | cl flpr If you will be compiling the package, as opposed to installing a binary distribution, then you need to define various environment variables. The following is for Unix/csh which is the main supported environment. # Example % setenv iraf /iraf/iraf/ # Path to IRAF root (example) % source $iraf/unix/hlib/irafuser.csh # Define rest of environment % setenv IRAFARCH ssun # IRAF architecture where you need to supply the appropriate path to the IRAF installation root in the first step and the IRAF architecture identifier for your machine in the last step. [2] Login into IRAF. Create a directory to contain the package files and the instrument database files. These directory should be outside the standard IRAF directory tree. cl> mkdir xdimsum$ cl> cd xdimsum [3] The package is distributed as a tar archive of sources. Note that IRAF includes a tar reader. The tar file is most commonly obtained via anonymous ftp. Below is an example from a Unix machine where the compressed files have the ".Z" extension. Files with ".gz" or ".tgz" can be handled similarly. cl> ftp iraf.noao.edu (140.252.1.1) login: anonymous password: [your email address] ftp> cd iraf/extern ftp> get xdimsum[v212].readme ftp> binary ftp> get xdimsum[v212].tar.Z ftp> quit cl> !uncompress xdimsum[v212].tar.Z The readme file contains these instructions. The in the optional executable distribution is replaced by the IRAF architecture identification for your computer. [4] Extract the source files from the tar archive using 'rtar". cl> softools so> rtar -xrf xdimsum[v212].tar so> bye On some systems, an error message will appear ("Copy 'bin.generic' to './bin fails") which can be ignored. Sites should leave the symbolic link 'bin' in the package root directory pointing to 'bin.generic' but can delete any of the bin. directories that won't be used. If there is no binary directory for the system you are installing it will be created when the package is compiled later or when the binaries are installed. If the binary executables have been obtained these are now extracted into the appropriate bin. directory. # Example of sparc installation. cl> cd xdimsum cl> rtar -xrf xdimsum-bin.sparc # Creates bin.sparc directory The tar file can be deleted once it has been successfully installed. [5] For a source installation you now have to build the package executable(s). First you configure the package for the particular architecture. cl> cd xdimsum cl> mkpkg # Substitute sparc, ssun, alpha, etc. This will change the bin link from bin.generic to bin.. The binary directory will be created if not present. If an error occurs in setting the architecture then you may need to add an entry to the file "mkpkg". Just follow the examples in the file. To create the executables and move them to the binary directory cl> mkpkg -p xdimsum update >& xdimsum.spool # build executables cl> mkpkg generic # optionally restore generic setting Check for errors. If the executables are not moved to the binary directory then step [1] to define the path for the package was not done correctly. The last step restores the package to a generic configuration. This is not necessary if you will only have one architecture for the package. This should complete the installation. You can now load the package and begin testing and use. ----------------------------------------------------------------------------- Summary of Major Differences between XDIMSUM and DIMSUM Input and Output Image and Mask Lists All input and output image and file names and input and output image and file lists are now task parameters rather than being silently passed as keyword names, silently assumed to have already been created by a previous step, or silently created by the current step. For example the input object mask list required by the xslm task is now a parameter. Similarly the output sky subtraction and holes mask lists produced the the xslm task are now parameters. These changes make tracing the data flow from one processing step to another simpler. Default Image and Mask Names In most cases the output images and masks are assigned sensible default names if explicit output image and mask lists are not provided. For example in the case of the sky subtraction task xslm the suffix ".sub" is appended to the input images names to produce the output sky subtracted image names, and the suffixes ".ssm" and ".hom" are appended to sky subtracted image names to create the sky subtraction and holes mask names. In general if an output image or mask list parameter value begins with a '.' it is assumed to be a suffix rather than a complete name. The default image and mask name scheme means that users need not concern themselves with the names of the intermediate data products. Use of Suffixes instead of Prefixes to Define Default Names Suffixes instead of prefixes are used to create default names. Using suffixes means that the input and output image lists no longer need to be in the same directory. New Tasks A new sky subtraction task xnslm has been added to the XDIMSUM package. Xnslm is a script wrapper for the rskysub task. Xnslm is an alternative to the default xslm task. It is significantly faster than xslm. A new cosmic ray removal task xnzap has been added to the XDIMSUM package. Xnzap is a script wrapper for the craverage task. Xnzap is an alternative to the default xzap task. It is significantly faster than xzap but not yet as well tested. Users are encouraged to experiment with xnzap and / or xcraverage on their own. User feedback on their effectiveness is welcome. The code for interactively computing the relative shifts in a set of dithered images has been rewritten and moved into a separate task called xdshifts. Three new script tasks for computing shifts for images taken in series with approximately constant shifts between adjacent images: xmshifts, xfshifts, and xrshifts, have been added to XDIMSUM. These scripts use modified versions of the existing starfind and imcentroid tasks called xstarfind and ximcentroid. A new mask combining task xmskcombine has been added to the XDIMSUM package. Xmskcombine combines the badpix mask, the cosmic ray mask, the holes mask, and optionally the object mask for the previous image into a single bad pixel mask used the the xnregistar task. The xnregistar task no longer performs the mask combining step it used to. New Algorithms The main processing scripts xmosaic, xfirstpass, and xmaskpass can now be run repeatedly from scratch without requiring the user to delete any intermediate files. It has also been made simpler to restart these scripts at an intermediate point in the processing. The mask deregistration task maskdereg now permits the user to create individual object masks which are a combination of the current mask and the N previous ones. This feature is useful in cases where the detector retains significant memory of previous exposures. The image and mask statistics computation parameters used by the sky subtraction and cosmic ray removal tasks xslm and xzap, statsec, mstatsec, maxiter, and nreject can now be set by the user. Their default values are now "", "", 20, and 3.0 respectively, instead of being fixed at the values "", "", 10, and 5.0. The maskstat task now outputs the computed mask statistics to the output parameters mean, msigma, median, and mmode in the same manner as the iterstat itask does. The first pass image combining step performed by the xmosaic or xfirstpass tasks now includes an option for doing fractional pixel shifts. The mask pass image combining step performed by the xmosaic or xmaskpass tasks now includes an option for doing image magnification using bilinear interpolation rather than block replication. This means that non-integer magnification factors are supported. Internal Changes Calls to existing IRAF tasks have been reviewed to make sure that all the task parameters are set in order to avoid unpleasant surprises if these parameters are not set at the expected defaults. Complicated image operations requiring several steps have been replaced by a single call to the imexpr task where appropriate. The image registration and combining step has been rewritten to use a new version of the imcombine task called xcombine which does not suffer from the number of open file limit and has better support for pixel masks. The registration should be much faster in most cases. The sections, fileroot, imgets, minmax, iterstat, and maskstat tasks which return values to their parameters have been cached so that XDIMSUM tasks will work correctly in the background. On normal task termination there are now no temporary files or images left either in the tmp$ directory or in the current working directory. iraf-xdimsum-main/bin000077700000000000000000000000001455666516400172232bin.genericustar00rootroot00000000000000iraf-xdimsum-main/demos/000077500000000000000000000000001455666516400155365ustar00rootroot00000000000000iraf-xdimsum-main/demos/demos.cl000066400000000000000000000005551455666516400171720ustar00rootroot00000000000000# DEMOS -- Run specified demo provided a demo file exists. procedure demos (demoname) file demoname {prompt="Demo name"} begin file demo, demofile if ($nargs == 0 && mode != "h") type ("demos$demos.men") demo = demoname demofile = "demos$" // demo // ".cl" if (access (demofile)) cl (< demofile) else error (1, "Unknown demo " // demo) end iraf-xdimsum-main/demos/demos.men000066400000000000000000000001361455666516400173460ustar00rootroot00000000000000 MENU of XDIMSUM Demonstrations mkxdimsum - Make XDIMSUM test data (25 100x100 images) iraf-xdimsum-main/demos/demos.par000066400000000000000000000000571455666516400173530ustar00rootroot00000000000000demoname,f,a,"",,,"Demo name" mode,s,h,"ql",,, iraf-xdimsum-main/demos/mkxdimsum.cl000066400000000000000000000116561455666516400201050ustar00rootroot00000000000000string root, temp, imtype int dx, dy, xs1, ys1, xs2, ys2 int i1, i2, j1, j2 file dat real bkg artdata root = "demo" imtype = "." // envget ("imtype") dx = 25 dy = 25 xs1 = 100 ys1 = 100 xs2 = 4 * xs1 ys2 = 4 * ys1 s2 = "" for (k=1; k<=25; k+=1) { printf ("%s%02d\n", root, k) | scan (s2) if (!access (s2//imtype)) break ; } if (k<=25) { printf ("Creating master field (please be patient) ...\n") dat = mktemp ("art") gallist (dat, 100, interactive=no, spatial="hubble", xmin=1., xmax=512., ymin=1., ymax=512., xcenter=INDEF, ycenter=INDEF, core_radius=50., base=0., sseed=2, luminosity="schecter", minmag=-7., maxmag=0., mzero=15., power=0.6, alpha=-1.24, mstar=-21.41, lseed=2, egalmix=0.8, ar=0.7, eradius=20., sradius=1., absorption=1.2, z=0.05, sfile="", nssample=100, sorder=10, lfile="", nlsample=100, lorder=10, rbinsize=10., mbinsize=0.5, dbinsize=0.5, ebinsize=0.1, pbinsize=20., graphics="stdgraph", cursor="") gallist (dat, 500, interactive=no, spatial="uniform", xmin=1., xmax=512., ymin=1., ymax=512., xcenter=INDEF, ycenter=INDEF, core_radius=50., base=0., sseed=2, luminosity="powlaw", minmag=-7., maxmag=0., mzero=15., power=0.6, alpha=-1.24, mstar=-21.41, lseed=2, egalmix=0.4, ar=0.7, eradius=20., sradius=1., absorption=1.2, z=0.05, sfile="", nssample=100, sorder=10, lfile="", nlsample=100, lorder=10, rbinsize=10., mbinsize=0.5, dbinsize=0.5, ebinsize=0.1, pbinsize=20., graphics="stdgraph", cursor="") starlist (dat, 100, "", "", interactive=no, spatial="uniform", xmin=1., xmax=512., ymin=1., ymax=512., xcenter=INDEF, ycenter=INDEF, core_radius=30., base=0., sseed=1, luminosity="powlaw", minmag=-7., maxmag=0., mzero=-4., power=0.6, alpha=0.74, beta=0.04, delta=0.294, mstar=1.28, lseed=1, nssample=100, sorder=10, nlsample=100, lorder=10, rbinsize=10., mbinsize=0.5, graphics="stdgraph", cursor="") i1 = (512 - xs2 / 2) + 1 j1 = (512 - ys2 / 2) + 1 i2 = mod ((25 - 1) * dx, 5 * dx) + (512 - xs2 / 2) + 6 j2 = mod (((25 - 1) / 5) * dy, 5 * dy) + (512 - ys2 / 2) + 6 i2 = i2 + xs2 - 1 j2 = j2 + ys2 - 1 temp = mktemp ("art") artdata.dynrange = 1000. i1 = (512 - xs2 / 2) j1 = (512 - xs2 / 2) i2 = xs2 + 4 * dx + 6 j2 = ys2 + 4 * dy + 6 mkobjects (temp, output="", ncols=i2, nlines=j2, title="Example artificial galaxy cluster", header="artdata$stdheader.dat", background=0., objects=dat, xoffset=-i1, yoffset=-j1, star="moffat", radius=4.0, beta=2.5, ar=1., pa=0., distance=0.5, exptime=1., magzero=6., gain=1., rdnoise=0., poisson=no, seed=1, comments=no) artdata.dynrange = 100000. delete (dat, verify=no) s1 = root // "_truth" printf ("Creating truth image %s ...\n", s1) if (access (s1//imtype)) imdelete (s1, verify=no) bkg = 5000. mknoise (temp, output=s1, background=bkg, gain=100., rdnoise=10., poisson=yes, seed=1, cosrays="", ncosrays=0, energy=30000., radius=0.5, ar=1., pa=0., comments=no) printf ("Creating XDIMSUM bad pixel mask %s ...\n", root//".pl") if (access (root//".pl")) imdelete (root//".pl", verify=no) mkpattern (root//".pl", output="", pattern="constant", option="replace", v1=1., title="", pixtype="short", ndim=2, ncols=xs1, nlines=ys1, header="") mkpattern (root//".pl[20,*]", output="", pattern="constant", option="replace", v1=0., title="", pixtype="short", ndim=2, ncols=xs1, nlines=ys1, header="") mkpattern (root//".pl[30:32,10]", output="", pattern="constant", option="replace", v1=0., title="", pixtype="short", ndim=2, ncols=xs1, nlines=ys1, header="") mkpattern (root//".pl[10,30:32]", output="", pattern="constant", option="replace", v1=0., title="", pixtype="short", ndim=2, ncols=xs1, nlines=ys1, header="") printf ("Creating image list %s ...\n", root//".list") if (access (root//".list")) delete (root//".list", verify=no) printf ("Creating XDIMSUM shift list %s ...\n", root//".slist") if (access (root//".slist")) delete (root//".slist", verify=no) printf ("Creating imcombine offset file %s ...\n", root//".imc") if (access (root//".imc")) delete (root//".imc", verify=no) for (k=1; k<=25; k+=1) { i1 = mod ((k - 1) * dx, 5*dx) + 1 + mod (k-1, 7) j1 = mod (((k - 1) / 5) * dy, 5*dy) + 1 + mod (k-1, 7) i2 = i1 + xs2 - 1 j2 = j1 + ys2 - 1 printf ("%s[%d:%d,%d:%d]\n", temp, i1, i2, j1, j2) | scan (s1) printf ("%s%02d\n", root, k) | scan (s2) printf ("Creating %s ...\n", s2) if (access (s2//imtype)) imdelete (s2, verify=no) blkavg (s1, s2, 4, 4, option="average") wcsreset (s2, "physical", verbose-) imarith (s2, "*", root//".pl", s2) bkg = 4500. + k * 40 mknoise (s2, output="", background=bkg, gain=2., rdnoise=10., poisson=yes, seed=k, cosrays="", ncosrays=3, energy=20000., radius=0.1, ar=1., pa=0., comments=no) i = (i1 + 1) / 4 j = (j1 + 1) / 4 print (s2, >> root//".list") print (i, j, >> root//".imc") print (s2//".sub"//" ", -i, -j, 1, >> root//".slist") } imdelete (temp, verify=no) } else ; iraf-xdimsum-main/doc/000077500000000000000000000000001455666516400151745ustar00rootroot00000000000000iraf-xdimsum-main/doc/badpixupdate.hlp000066400000000000000000000031561455666516400203600ustar00rootroot00000000000000.help badpixupdate Sep00 xdimsum .ih NAME badpixupdate -- update the bad pixel mask using a list of input masks .ih USAGE badpixupdate inlist nrepeats bpmask .ih PARAMETERS .ls inlist The list of input bad pixel masks normally produced by the cosmic ray correction tasks xzap or xnzap. The masks in inlist are assumed to consist entirely of 1's and 0's with the candidate bad pixels set to 1. .le .ls nrepeats If the same pixel is bad in nrepeats or more candidate bad pixel masks then it is set to 0 in bpmask. .le .ls bpmask The name of the bad pixel mask to be updated. Bpmask is assumed to consist entirely of 1's and 0's with bad pixels set to 0.0. Note that the pixels in bpmask are defined in the opposite sense to those in inlist. .le .ih DESCRIPTION BADPIXUPDATE sums the candidate bad pixel masks in \fIinlist\fR, detects which pixels are bad \fInrepeats\fR or more images, sets those pixels to be bad in \fIbpmask\fR. The input candidate bad pixel masks are normally the output of the cosmic ray detection tasks XZAP or XNZAP and are assumed to consist entirely of 1's and 0's with 1 defined to be bad. The output bad pixel mask is usually the bad pixel mask common to all the input images and is assumed to consist entirely of 1's and 0's with 0 defining a bad pixel. .ih EXAMPLES 1. Search a list of cosmic ray masks computed by xnzap, detect pixel with more than 3 "cosmic ray" hits and set those pixel to be bad in the bad pixel mask demo.pl. .nf cl> type crmlist demo01.sub.crm.pl demo02.sub.crm.pl ... demo25.sub.crm.pl cl> badpixupdate @crmlist 3 demo.pl .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xzap,xnzap .endhelp iraf-xdimsum-main/doc/demos.hlp000066400000000000000000000015051455666516400170110ustar00rootroot00000000000000.help demos Sep00 xdimsum .ih NAME demos -- create the demo data for xdimsum .ih USAGE demos demoname .ih PARAMETERS .ls demoname The name of the demo data set to be created. At present the only option is "mkxdimsum". .le .ih DESCRIPTION Demos creates a set of artificial test data for the XDIMSUM package. .ih EXAMPLES 1. Create the demo data for the xdimsum package and run the xmosaic task on it. Define the parameters to give results as close as possible to the original DIMSUM. .nf cl> cd ... move to an empty test directory which has write permission cl> demos mkxdimsum ... create the demo data cl> xmosaic @demo.list demo13 mosaic ".exp" nsigrej=5.0 maxiter=10 \ bpmask=demo.pl shiftslist=demo.slist .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xmosaic, xfirstpass, xmaskpass .endhelp iraf-xdimsum-main/doc/guide.hlp000066400000000000000000002154641455666516400170120ustar00rootroot00000000000000.help guide Nov00 xdimsum .ce \fBXDIMSUM: Experimental Deep Infrared Mosaicing Software\fR .ce \fBGuide to Using the XMOSAIC Task\fR .ce F. Valdes .ce Revised by .ce L. Davis (davis@noao.edu) .ce November 2000 .nh Introduction \fBXDIMSUM\fR is a package for creating accurate sky subtracted images from sets of dithered observations. While the observations need not be in the infrared, the dominance of the variable sky background in infrared data requires the dithering and recombination of many short carefully sky subtracted exposures to produce deep images. Hence the package is called "Experimental Deep Infrared Mosaicing Software" or XDIMSUM. There's no published reference. Generally people footnote it in the text and say something like: .nf DIMSUM is the Deep Infrared Mosaicing Software package developed by Peter Eisenhardt, Mark Dickinson, Adam Stanford, and John Ward, and is available via ftp from ftp://iraf.noao.edu/iraf/extern/xdimsum/. .fi XDIMSUM is a variant of the \fBDIMSUM\fR package developed by P. Eisenhardt, M. Dickensen, S.A. Stanford, and J. Ward. F. Valdes (IRAF group) added FITS image format support, wrote the tutorial task \fIdemos\fR, wrote the original version of this document, and repackaged DIMSUM for distribution as an IRAF external package. More recently L. Davis (IRAF group) rewrote the major \fIDIMSUM\fR scripts to improve their clarity, robustness, and efficiency, added several new tasks for computing relative offsets, and wrote help pages for all the DIMSUM tasks. This new version of DIMSUM uses the same default algorithms as the original DIMSUM but has diverged sufficiently from the original that it has been renamed XDIMSUM. XDIMSUM is being made available to the community as an external package in the hope that some of the enhancements may prove useful to others. Users should direct XDIMSUM installation questions, bug reports, questions about technical details, and comments and suggestions to the the IRAF group (iraf@noao.edu) not the original authors. The main body of this document is a guide to the XDIMSUM \fBxmosaic\fR task which executes all the major XDIMSUM processing steps in turn. These processing steps are outlined in Section 2. Each major processing step is executed by one or more XDIMSUM tasks. By setting the xmosaic processing switches appropriately users can use \fBxmosaic\fR to perform any combination of these steps. The input data required by XDIMSUM and and the output data produced by it are described in Section 3. A detailed example is provided in Section 4. The \fBxmosaic\fR task and most of the XDIMSUM subtasks are CL scripts. Users are encouraged to examine the scripts in orer to gain an understanding of the xmosaic algorithms and default parameter settings. The script source is located in the logical directory xdimsum$src and its subdirectories. Older versions of the current scripts and obsolete scripts are located in the logical directory xdimsum$src/obsolete. .nh Outline Of the Major XDIMSUM Processing Steps This section describes the processing steps performed by the main XDIMSUM processing task \fBxmosaic\fR. These processing steps divide logically into two groups the first pass step and the mask pass step. Both steps perform similar operations and produce a sky subtracted, bad pixel corrected, cosmic ray corrected, registered, and combined image and exposure map. The first pass step produces a good first estimate of the true combined image and exposure map by sky subtracting, bad pixel correcting, and cosmic ray correcting the input individual images, and creating a combined image fro the corrected input images. The combined image goes deeper than the individual images and is used to create an object mask which defines the location, size, and shape of all the objects in the combined image. The object mask is split or deregistered into a set of individual input image object masks. The mask pass step repeats all the first pass step but uses the object masks to improve the sky subtraction, cosmic ray correction, and image combining steps to produce a more accurate and if desired higher resolution version of the combined image. If first and mask pass processing steps can be executed separately by running the \fBxfirstpass\fR and \fIxmaskpass\fR tasks in sequence, which is exactly what the \fIxmosaic\fR task itself does. .nh 2 First Pass The first pass processing steps are: sky subtraction, bad pixel correction, cosmic ray correction, bad pixel mask updating, and image registration. The required input data are a list of dithered input images, a bad pixel, mask, and optionally a list of image offsets and scaling factors. If no offset list is provided the offsets the user must determine the offsets interactively. .nh 3 Sky Subtraction with the Xslm Task If the \fIfp_xslm\fR switch is yes the xslm task produces a sky subtracted image for each images by computing its sky image from a set of neighboring images and subtracting this sky image from the input image. The scaling factor for each input image is computed using an \fInsigrej\fR sigma iterated rejection about the mean of the pixels in the image section defined by \fIstatsec\fR. The number of iterations must be less than or equal to \fImaxiter\fR. The scaling factor is the reciprocal of the median of the unrejected pixels and is stored in the input and sky subtracted image header KEYWORD "SKYMED". For each image in the input image list \fInmean\fR neighboring images in the list are selected, scaled, and combined to form the sky image. Except at the ends of the list there is usually an equal number of images before and after the image to be sky subtracted. There must be at least \fInskymin\fR images for sky subtraction to be performed. At each pixel \fInreject\fR low and high pixels in the scaled images are rejected and the average of the remainder becomes the sky value for that pixel. The sky values are subtracted from the input image to create a sky subtracted image. .nh 3 Fixing Bad Pixels with the Maskfix Task If the \fIfp_maskfix\fR switch is yes the \fImaskfix\fR task removes known bad pixels from the sky subtracted images. The bad pixel mask \fIbpmask\fR is used to identify and replace the bad pixels by interpolation. The bad pixel mask is an image containing 0's in bad pixel regions and 1's elsewhere. .nh 3 Removing Cosmic Rays with the Xzap or Znap Tasks If the \fIfp_xzap\fR switch is yes cosmic rays are removed from the sky subtracted images using the \fIxzap\fR task if \fInewxzap\fR is no, or the \fIxnzap\fR task if it is yes. Xzap creates an internal object mask from the sky subtracted image data which is used to locate the strongest objects. The cosmic rays are detected with a threshold algorithm applied to the ratio of the original input image to the median filtered input image. Only pixels outside the internal object mask are considered to be cosmic ray candidates. The detected cosmic rays are replaced by the local median and a cosmic ray mask is prodiced which records the location of the cosmic rays. Xnzap is a script task which calls the compiled task xcraverage task. Xcraverage detects and removes cosmic rays using a moving average combined with a central and deviant pixel rejection filter, a local sky estimate equal to the running median of the pixels around the averaging filter box, and a local sky sigma estimated by dividing the image into blocks and determining the percentile points of the pixels in the box. The cosmic rays are replaced by the local average and a cosmic ray mask is produced to record the location of the cosmic rays. Cosmic ray masks contain 1's at the locations of detected cosmic rays and 0's elsewhere. If the \fIfp_badpixupdate\fR switch is yes the badpixupdate task and the cosmic ray masks are used to update the bad pixel mask. Bad pixel mask pixels are updated, i.e. flagged as bad, if they are detected as cosmic rays in more than two images. .nh 3 Making the Shift List with the Xdshifts Task The shift list \fIshiftlist\fR defines the relative offsets between the individual input images. If the \fIfp_mkshifts\fR switch is yes the \fIxdshifts\fR task and the image display are used to create it interactively. For this method to work there must be at least one object common to all the images. Rough offsets are estimated by displaying each image and prompting the user to mark and measure the position of a reference object common to all the images. True offsets are computed by prompting the user to measure and mark a set of registration objects in the reference image \fIreference\fR, applying the initial offsets, centroiding on the registration objects in each sky subtracted image, and computing final shifts relative to the reference image. The final shift list is a file containing four columns. These columns contain the image name, the pixel shifts in x and y, and a weight value which by default is 1.0. If the weight for an image is < 0, that image is excluded from the final mosaic. .nh 3 Combining Images with the Xnregistar Task If the \fIfp_xnregistar\fR switch is yes the \fIxnregistar\fR task is used to combine the images. The input sky subtracted, bad pixel corrected, and cosmic ray corrected images are shifted, scaled, combined, and reoriented to produce the first guess combined image and exposure map. The corrected input images are shifted by integer pixel amounts if \fIfractional\fR is no, otherwise they are shifted by the full fractional pixel offset. .nh 2 Mask Pass .nh 3 Making Masks with the Mkmask and Maskdereg Tasks If the \fImp_mkmask\fR switch is yes the \fImkmask\fR task is used to create two object masks from the first pass combined image and exposure map. The first mask sets the detection threshold to \fImp_nsigcrmsk\fR and identifies only the brighter parts of the objects. This mask is used to check that the cores of those objects in the individual images are not identified as cosmic rays. The second mask sets the threshold to \fImp_nsigobjmsk\fR and identifies extended object regions. This mask is used to improve the sky subtraction step. The combined image masks are made from the first pass combined image as follows. First the combined image is divided by the square root of the exposure map to normalize for variations in the sky noise due to varying exposure times in each pixel. The sky RMS is computed using iterative sigma rejection and a recommended threshold value in terms of this RMS is determined. If \fImp_chkmasks\fR is yes the uniform RMS image is displayed, the user examines it with the \fBimexamine\fR task, and determine a suitable threshold interactively. An algorithm which tracks and threshold detects above the sky is used to create an object mask containing 1's in object regions and 0's elsewhere. If the \fImp_maskdereg\fR switch is yes the \fImaskdereg\fR task and the sections file \fIsections\fR created by \fIxnregistar\fR during the first pass, are used to create object masks for the individual input images. .nh 3 Sky Subtraction with the Xslm Task and Object Masks If the \fImp_xslm\fR switch is yes the sky subtraction step is repeated using the \fIxslm\fR task and the individual object masks. The object masks are used to, reject object pixels from the scaling factor computation if \fIuse_omask\fR is yes, and to reject object pixels from the sky image computation. .nh 3 Fixing Bad Pixels with the Maskfix Task If the \fImp_maskfix\fR switch the bad pixel mask fixing step is repeated using the \fImaskfix\fR task and the bad pixel mask. However in the mask step it is probable that the bad pixel mask is different from the one used in the first pass having been updated in the first pass step. .nh 3 Correcting Cosmic Rays with the Xzap or Xznap Tasks If the \fImp_xzap\fR switch is the cosmic ray removal step is repeated using either the \fIxzap\fR or \fIxnzap\fR tasks. However in the mask step the object core mask created from the first pass combined image is used to prevent cosmic rays from being detected in the object core regions. If the \fImp_badpixupdate\fR switch is set the bad pixel mask updating step is removed using the \fIbadpixupdate\fR task, the bad pixel mask, and the cosmic ray masks. .nh 3 Combining Images with the Xnregistar Task If the \fImp_xnregistar\fR switch is yes then the images combining step is repeated using the \fIxnregistar\fR task. The final sky subtracted, bad pixel corrected, and cosmic ray corrected images are shifted, scaled, combined, and reoriented to create the final mosaic. In this second, more careful, pass subpixel shifts are used by default. The default algorithm block replicates each image by a factor of \fImag\fR and shifts the images to a resolution of 1/\fImag\fR of a pixel. The final mosaic image from the mask pass is, therefore, approximately \fImag\fR times larger in each dimension with \fImag * mag\fR times more pixels than the first pass image. As before an exposure map with the same resolution is also created. .nh 1 Data Input and Data Products .nh 2 Individual Input Images The individual images may be of any type supported by IRAF, e.g. ".fits" or ".imh" but are assumed to be of the same size. They should have been dark and flat field corrected prior to entering xdimsum. .nh 2 The Input Bad Pixel Mask The input bad pixel file is an IRAF mask or ".pl" image consisting of 1's and 0's where the 0's define the bad pixels. It is assumed to be the same size as the input images and to be the same for all the input images. The bad pixel mask may be updated during the course of the reductions by the badpixupdate task. .nh 2 The Individual Output Corrected Images The output corrected images have been sky subtracted by the xslm task, bad pixel corrected by the maskfix task, and cosmic ray corrected by the xzap or xnzap tasks. These images should be free of defects with mean background values around 0.0. .nh 2 The Output Cosmic Ray Masks The output cosmic ray masks are IRAF pixel mask, i.e. ".pl" images produced by the xzap or xnzap tasks. Cosmic ray masks consist of 1's in cosmic ray regions and 0's elsewhere. .nh 2 The Output Shifts File The output shifts file contains the image name, x and y shifts relative to the reference image, and weight required to combine the individual corrected images into a single output image and exposure map. The shifts file can be produced with the xdshifts task. .nh 2 The Output Objects Masks The output objects masks are IRAF pixel masks, i.e. ".pl" images produced by the mkmask and maskdereg tasks from the first pass combined image and exposure map. They are of two kinds: the inverse object core masks used by the xzap or xnzap tasks to unzap cosmic rays in object cores, and the object masks used by the xslm task to improve the sky subtraction. The object masks consist of 1's in object regions and 0's elsewhere. The inverse object masks are the reverse. .nh 2 The Output Holes Masks The output holes masks are IRAF pixel masks, i.e. ".pl" images produced by the sky subtraction task xslm during the mask pass. They define regions in the individual images where the sky subtraction is undefined. Holes masks consist of 0's in undefined regions and 1's elsewhere. .nh 2 The Output Combined Image and Exposure Map The first and maskpass steps each produced a combined image and an associated exposure map. .nh 1 Example The following example uses artificial data created by the \fIdemos\fR task to illustrate the main features of the \fIxmosaic\fR task. To load the package type \fIxdimsum\fR. .nf cl> \fBxdimsum\fR badpixupdate maskfix xdshifts xmosaic xslm demos maskstat xfirstpass xmshifts xzap iterstat mkmask xfshifts xnregistar makemask orient xlist xnzap maskdereg sigmanorm xmaskpass xrshifts .fi The main tasks are \fBdemos\fR and \fBxmosaic\fR. The remaining tasks are called directly by \fBxmosaic\fR. The artificial demonstration data is created by the \fIdemos\fR task. By default the image format is ".imh". The the IRAF environment variable \fIimdir\fR which defines where the ".pix" pixel files are stored must be set before running xmosaic, as shown below. .nf cl> set imdir = "HDR$pixels/ .fi In this the pixel file directory is the subdirectory of the current directory called pixels. To use FITS images set the IRAF environment variable as follows .nf cl> set imtype = fits cl> flpr .fi Now run the demos script and examine the data directory. .nf xd> \fBdemos mkxdimsum\fR Creating master field (please be patient) ... Creating truth image demo_truth ... Creating XDIMSUM bad pixel mask demo.pl ... Creating image list demo.list ... Creating XDIMSUM shift list demo.slist ... Creating imcombine offset file demo.imc ... Creating demo01 ... Creating demo02 ... Creating demo03 ... Creating demo04 ... Creating demo05 ... Creating demo06 ... Creating demo07 ... Creating demo08 ... Creating demo09 ... Creating demo10 ... Creating demo11 ... Creating demo12 ... Creating demo13 ... Creating demo14 ... Creating demo15 ... Creating demo16 ... Creating demo17 ... Creating demo18 ... Creating demo19 ... Creating demo20 ... Creating demo21 ... Creating demo22 ... Creating demo23 ... Creating demo24 ... Creating demo25 ... xd> \fBdir\fR demo.imc demo04.imh demo11.imh demo18.imh demo25.imh demo.list demo05.imh demo12.imh demo19.imh demo_truth.imh demo.pl demo06.imh demo13.imh demo20.imh pixels demo.slist demo07.imh demo14.imh demo21.imh demo01.imh demo08.imh demo15.imh demo22.imh demo02.imh demo09.imh demo16.imh demo23.imh demo03.imh demo10.imh demo17.imh demo24.imh .fi The files demo??.imh are 25 dithered 100x100 images with low S/N "taken" in an approximately 5x5 pattern. The dither is small so there are large overlaps between adjacent images. Each image has a bad column and a few bad pixels. The bad pixel mask is in the file demo.pl. Each image also contains a few cosmic rays. The input image list is in the file demo.list. The file demo.slist contains the relative offsets and weight for each sky subtracted input image. The image demo_truth.imh is the image from which the dithered images were extracted. The goal of \fBxdimsum\fR is to come as close to reproducing this image as possible. Set up the \fBxmosaic\fR task parameters as shown below using the \fBeparam\fR task. Note that all the processing options are set to "yes" and all the interactive switches are enabled. Because all the interactive processing options are enabled the image display window must be open before xmosaic is started. .nf xd> \fBunlearn xmosaic\fR xd> \fBepar xmosaic\fR I R A F Image Reduction and Analysis Facility PACKAGE = xdimsum TASK = xmosaic inlist = \fI@demo.list\fR The list of input images referenc= \fIdemo13\fR The reference image in input image list output = \fImosaic\fR Root name for output combined images expmap = .exp Root name for output exposure map image or suffix (statsec= ) The image section for computing sky stats (nsigrej= \fI5.\fR) The nsigma rejection for computing sky stats (maxiter= \fI10\fR) The maximum number of iterations fo computing sk (fp_xslm= yes) Do the first pass sky subtraction step ? (mp_xslm= yes) Do the mask pass sky subtraction step ? (mp_useo= yes) Use object mask to compute sky statistics ? (sslist = .sub) The output sky-subtracted images or suffix (hmasks = .hom) The output holes masks or suffix (forcesc= yes) Force recalculation of image medians ? (nmean = 6) Number of images to use in sky image (nreject= 1) Number of pixels for sky image minmax reject (nskymin= 3) Minimum number of image to use for sky image (fp_mask= yes) Do first pass bad pixel correction step ? (mp_mask= yes) Do mask pass bad pixel correction step ? (bpmask = \fIdemo.pl\fR) The input pixel mask image (forcefi= yes) Force bad pixel fixing ? (fp_xzap= yes) Do first pass cosmic ray correction step ? (mp_xzap= yes) Do mask pass cosmic ray correction step ? (crmasks= .crm) The output cosmic ray masks or suffix (newxzap= no) Use new version of xzap ? (fp_badp= yes) Do first pass bad pixel mask update ? (mp_badp= yes) Do mask pass bad pixel mask update ? (fp_mksh= \fIyes\fR) Determine shifts interactively ? (fp_chks= yes) Check and confirm new shifts ? (fp_crad= 5.) Centroiding radius in pixels for mkshifts (fp_maxs= 5.) Maximum centroiding shift in pixels for mkshifts (fp_xnre= yes) Do first pass image combining step ? (mp_xnre= yes) Do mask pass image combining step ? (mp_mag = 4) Magnification factor for mask pass output image (mp_blk = yes) Use block replication to magnify the image ? (shiftli= \fImyshiftlist\fR) Input or output shifts file (section= .corners) The output sections file or suffix (fractio= no) Use fractional pixel shifts if mag = 1 ? (pixin = yes) Are input coords in ref object pixels ? (ab_sens= yes) Is A through B counterclockwise ? (xscale = 1.) X pixels per A coordinate unit (yscale = 1.) Y pixels per B coordinate unit (a2x_ang= 0.) Angle in degrees from A CCW to X (ncoavg = 1) Number of internal coaverages per frame (secpexp= \fI60.\fR) Seconds per unit exposure time (y2n_ang= 0.) Angle in degrees from Y to N N through E (rotatio= yes) Is N through E counterclockwise? (mp_mkma= yes) Create the combined image object mask ? (omask = .msk) The output combined image mask or suffix (mp_chkm= \fIyes\fR) Check the object masks ? (mp_kpch= yes) Keep checking the object masks ? (mp_stat= ) The combined image section for computing mask st (mp_nsig= 1.5) The nsigma factor for cosmic ray masking (mp_nsig= 1.1) The nsigma factor for object masking (mp_mask= yes) Deregister masks ? (ocrmask= .ocm) The output cosmic ray unzapping masks or suffix (objmask= .obm) The output object masks or suffix (mp_npre= 0) Number of previous object masks to combine (del_big= no) Delete combined image masks at task termination (del_sma= no) Delete the individual object masks at task termi (mode = ql) .fi The \fIxmosaic\fR parameters have been set to produce the same results as the original DIMSUM package \fIreduce\fR task. Before starting \fIxmosaic|fR make sure that the hidden \fInsigrej\fR, \fImaxiter\fR, \fIbpmask\fR, \fIshiftlist\fR, \fIsecpexp\fR, and \fIncoavg\fR parameters are set correctly. If either of the \fIfp_mkshifts\fR or \fImp_chkmasks\fR parameters are set to yes then make sure the image display server is running before starting xmosaic. To view the xmosaic help page use the \fIphelp\fR task as shown below. .nf cl> phelp xmosaic .fi .nf xd> \fBxmosaic\fR ... Xmosaic starts by querying for the input image list, the reference image name, and the root output image and exposure map names as shown below. ... The list of input images (@demo.list): The reference image in input image list (demo13): Root name for output combined images (mosaic): Root name for output exposure map image or suffix (.exp): .fi ... First some time and data information is printed. ... .nf start xmosaic Wed 16:24:50 29-Nov-2000 start xfirstpass Wed 16:24:54 29-Nov-2000 .fi ... Now the xslm task computes the scaling factor for each input image and stores it in the input image header keyword SKYMED. ... .nf Begin first pass sky subtraction Wed 16:24:55 29-Nov-2000 -------Sky subtracting images with xslm-------------- Calculating scaling for demo01 Setting scaling factor to 1 / 4542.815 Calculating scaling for demo02 Setting scaling factor to 1 / 4581.675 Calculating scaling for demo03 Setting scaling factor to 1 / 4622.226 Calculating scaling for demo04 Setting scaling factor to 1 / 4662.35 Calculating scaling for demo05 Setting scaling factor to 1 / 4701.921 Calculating scaling for demo06 Setting scaling factor to 1 / 4742.414 Calculating scaling for demo07 Setting scaling factor to 1 / 4781.861 Calculating scaling for demo08 Setting scaling factor to 1 / 4821.828 Calculating scaling for demo09 Setting scaling factor to 1 / 4862.715 Calculating scaling for demo10 Setting scaling factor to 1 / 4900.551 Calculating scaling for demo11 Setting scaling factor to 1 / 4942.805 Calculating scaling for demo12 Setting scaling factor to 1 / 4983.287 Calculating scaling for demo13 Setting scaling factor to 1 / 5021.519 Calculating scaling for demo14 Setting scaling factor to 1 / 5061.425 Calculating scaling for demo15 Setting scaling factor to 1 / 5101.519 Calculating scaling for demo16 Setting scaling factor to 1 / 5141.901 Calculating scaling for demo17 Setting scaling factor to 1 / 5183.9 Calculating scaling for demo18 Setting scaling factor to 1 / 5221.122 Calculating scaling for demo19 Setting scaling factor to 1 / 5262.929 Calculating scaling for demo20 Setting scaling factor to 1 / 5303.046 Calculating scaling for demo21 Setting scaling factor to 1 / 5342.895 Calculating scaling for demo22 Setting scaling factor to 1 / 5382.554 Calculating scaling for demo23 Setting scaling factor to 1 / 5421.473 Calculating scaling for demo24 Setting scaling factor to 1 / 5460.839 Calculating scaling for demo25 Setting scaling factor to 1 / 5500.626 .fi ... Once the scaling factors are determined a set of neighboring images and are scaled and combined to produce the sky image for each input image. The sky image is subtracted from the input image to produce the sky subtracted image. ... .nf Creating sky subtracted image demo01.sub Frame 1 Sky frames: start = 1 finish = 4 nreject = 1 Creating sky subtracted image demo02.sub Frame 2 Sky frames: start = 1 finish = 4 nreject = 1 Creating sky subtracted image demo03.sub Frame 3 Sky frames: start = 1 finish = 5 nreject = 1 Creating sky subtracted image demo04.sub Frame 4 Sky frames: start = 1 finish = 7 nreject = 1 Creating sky subtracted image demo05.sub Frame 5 Sky frames: start = 2 finish = 8 nreject = 1 Creating sky subtracted image demo06.sub Frame 6 Sky frames: start = 3 finish = 9 nreject = 1 Creating sky subtracted image demo07.sub Frame 7 Sky frames: start = 4 finish = 10 nreject = 1 Creating sky subtracted image demo08.sub Frame 8 Sky frames: start = 5 finish = 11 nreject = 1 Creating sky subtracted image demo09.sub Frame 9 Sky frames: start = 6 finish = 12 nreject = 1 Creating sky subtracted image demo10.sub Frame 10 Sky frames: start = 7 finish = 13 nreject = 1 Creating sky subtracted image demo11.sub Frame 11 Sky frames: start = 8 finish = 14 nreject = 1 Creating sky subtracted image demo12.sub Frame 12 Sky frames: start = 9 finish = 15 nreject = 1 Creating sky subtracted image demo13.sub Frame 13 Sky frames: start = 10 finish = 16 nreject = 1 Creating sky subtracted image demo14.sub Frame 14 Sky frames: start = 11 finish = 17 nreject = 1 Creating sky subtracted image demo15.sub Frame 15 Sky frames: start = 12 finish = 18 nreject = 1 Creating sky subtracted image demo16.sub Frame 16 Sky frames: start = 13 finish = 19 nreject = 1 Creating sky subtracted image demo17.sub Frame 17 Sky frames: start = 14 finish = 20 nreject = 1 Creating sky subtracted image demo18.sub Frame 18 Sky frames: start = 15 finish = 21 nreject = 1 Creating sky subtracted image demo19.sub Frame 19 Sky frames: start = 16 finish = 22 nreject = 1 Creating sky subtracted image demo20.sub Frame 20 Sky frames: start = 17 finish = 23 nreject = 1 Creating sky subtracted image demo21.sub Frame 21 Sky frames: start = 18 finish = 24 nreject = 1 Creating sky subtracted image demo22.sub Frame 22 Sky frames: start = 19 finish = 25 nreject = 1 Creating sky subtracted image demo23.sub Frame 23 Sky frames: start = 21 finish = 25 nreject = 1 Creating sky subtracted image demo24.sub Frame 24 Sky frames: start = 22 finish = 25 nreject = 1 Creating sky subtracted image demo25.sub Frame 25 Sky frames: start = 22 finish = 25 nreject = 1 .fi ... The subtracted images are stored in the "*.sub.imh" images. ... ... Next the maskfix task uses the bad pixel mask file demo.pl to interpolate over the bad pixel regions in the sky subtracted images. ... .nf Begin first pass bad pixel correction Wed 16:28:45 29-Nov-2000 -------Correcting bad pixels with maskfix------------ Fixing bad pixels in file demo01.sub using mask demo.pl Fixing bad pixels in file demo02.sub using mask demo.pl Fixing bad pixels in file demo03.sub using mask demo.pl Fixing bad pixels in file demo04.sub using mask demo.pl Fixing bad pixels in file demo05.sub using mask demo.pl Fixing bad pixels in file demo06.sub using mask demo.pl Fixing bad pixels in file demo07.sub using mask demo.pl Fixing bad pixels in file demo08.sub using mask demo.pl Fixing bad pixels in file demo09.sub using mask demo.pl Fixing bad pixels in file demo10.sub using mask demo.pl Fixing bad pixels in file demo11.sub using mask demo.pl Fixing bad pixels in file demo12.sub using mask demo.pl Fixing bad pixels in file demo13.sub using mask demo.pl Fixing bad pixels in file demo14.sub using mask demo.pl Fixing bad pixels in file demo15.sub using mask demo.pl Fixing bad pixels in file demo16.sub using mask demo.pl Fixing bad pixels in file demo17.sub using mask demo.pl Fixing bad pixels in file demo18.sub using mask demo.pl Fixing bad pixels in file demo19.sub using mask demo.pl Fixing bad pixels in file demo20.sub using mask demo.pl Fixing bad pixels in file demo21.sub using mask demo.pl Fixing bad pixels in file demo22.sub using mask demo.pl Fixing bad pixels in file demo23.sub using mask demo.pl Fixing bad pixels in file demo24.sub using mask demo.pl Fixing bad pixels in file demo25.sub using mask demo.pl .fi ... Next the xzap task is used to detect and remove cosmic rays from the sky subtracted images. ... .nf Begin first pass cosmic ray removal Wed 16:29:03 29-Nov-2000 -------Zapping cosmic rays using xzap ------------- Creating cosmic ray corrected image demo01.sub Creating cosmic ray corrected image demo02.sub Creating cosmic ray corrected image demo03.sub Creating cosmic ray corrected image demo04.sub Creating cosmic ray corrected image demo05.sub Creating cosmic ray corrected image demo06.sub Creating cosmic ray corrected image demo07.sub Creating cosmic ray corrected image demo08.sub Creating cosmic ray corrected image demo09.sub Creating cosmic ray corrected image demo10.sub Creating cosmic ray corrected image demo11.sub Creating cosmic ray corrected image demo12.sub Creating cosmic ray corrected image demo13.sub Creating cosmic ray corrected image demo14.sub Creating cosmic ray corrected image demo15.sub Creating cosmic ray corrected image demo16.sub Creating cosmic ray corrected image demo17.sub Creating cosmic ray corrected image demo18.sub Creating cosmic ray corrected image demo19.sub Creating cosmic ray corrected image demo20.sub Creating cosmic ray corrected image demo21.sub Creating cosmic ray corrected image demo22.sub Creating cosmic ray corrected image demo23.sub Creating cosmic ray corrected image demo24.sub Creating cosmic ray corrected image demo25.sub ... The cosmic ray masks are stored in the files "*.sub.crm.pl". ... ... Next the badpixupdate task and the cosmic ray masks are used to update the bad pixel mask. Pixels that are bad in 3 or more cosmic ray masks are assumed to be bad in the bad pixel mask. ... Begin first pass bad pixel mask update Wed 16:29:43 29-Nov-2000 -------Updating bad pixel file with badpixupdate ---- .fi By default the image registration step is non-interactive, i.e. \fIfp_mkshifts\fR = no. In this case the user must supply a shifts file \fIshiftlist\fR which contains the image name, xshift, yshift, and weight or exposure time of the images to be combined. See the file demo.slist for a sample shifts file. In general it is usually easier to determine the shifts outside of the main xmosaic script with the \fIxdshifts\fR task than it is to determine it inside the xmosaic task where a mistake is more costly. Users with time series data, i.e. data where each image is shifted by a comparable amount from the previous one, the \fIxmshifts\fR, \fIxfshifts\fR, or \fIxrshifts\fR tasks can be used to compute the required shifts file. The following example shows show to make the shift list interactively from the mosaic task. .nf ... The first sky subtracted image is loaded into the image display by the \fBimexamine\fR task and the n and p keys are used to examine each image in order to select an object common to all. ... Examine images ... Select reference star which is present in all images Type n key to display next image Type p key to display previous image Type q key to quit .fi ... Examine all the images and select the star above and slightly to the right of the galaxy as the reference star. Type 'q' to quit the image examining menu. ... ... Now the first image in the sky subtracted image list is displayed, the temporary file \fImyshiftlist.exam\fR is opened. Mark the reference object with the 'a' keystroke, move to the next image with 'n' keystroke, mark the reference object with the 'a' key, ... Repeat until all the images have been displayed and the reference object marked. The reference object selected must be common to all images. The first image is display automatically and then subsequent images are displayed by typing 'n'. DO NOT TYPE 'q' UNTIL ALL IMAGES HAVE BEEN MARKED. ... .nf Determine relative shifts using above reference star ... Move cursor to the selected star Type a key to measure the selected star Type n key to move to the next image Type q key to quit Log file myshiftlist.exam open # COL LINE COORDINATES # R MAG FLUX SKY PEAK E PA ENCLOSED GAUSSIAN DIRECT 63.90 47.13 63.90 47.13 13.18 15.80 4778. -1.094 325.2 INDEF -6 3.96 4.20 4.16 57.42 47.25 57.42 47.25 7.79 16.38 2810. 3.951 424.7 INDEF -55 3.99 3.38 3.61 50.86 46.68 50.86 46.68 9.29 15.93 4244. 5.545 396.2 INDEF 8 3.46 3.21 3.10 44.51 46.73 44.51 46.73 7.30 15.58 5837. -1.388 463.3 0.61 68 3.65 2.93 2.44 37.93 46.40 37.93 46.40 8.47 15.70 5257. -1.161 463.6 INDEF 29 3.36 2.82 2.55 62.60 40.00 62.60 40.00 10.79 15.34 7332. 1.875 352.8 0.69 -52 3.94 4.24 3.15 56.06 39.90 56.06 39.90 9.33 15.68 5326. 6.569 358. 1.02 5 3.66 3.73 3.88 51.00 40.90 51.00 40.90 9.88 15.80 4782. 7.608 408.1 INDEF -64 3.89 3.26 3.19 44.88 40.71 44.88 40.71 6.64 15.79 4829. 6.467 517.4 1.62 28 2.86 2.42 2.16 38.05 40.83 38.05 40.83 8.44 15.77 4916. -0.1289 439.2 7.41 76 3.98 2.90 3.17 63.07 34.29 63.07 34.29 14.95 15.75 5014. 1.413 378.6 0.08 -22 17.97 3.74 13.72 56.74 33.84 56.74 33.84 10.58 15.59 5797. 1.553 384.7 1.19 83 3.83 3.39 3.78 50.11 33.58 50.11 33.58 13.60 15.60 5768. 4.054 352.1 49.8 -66 5.24 4.14 6.12 43.37 33.46 43.37 33.46 8.73 15.72 5159. -0.7891 381.1 INDEF 5 3.99 3.58 3.25 39.14 34.82 39.14 34.82 9.22 15.64 5549. -1.216 381.9 INDEF 51 4.14 3.38 3.08 63.10 28.36 63.10 28.36 9.78 15.24 8045. -2.753 353. 0.43 -82 6.23 3.74 3.19 57.05 28.32 57.05 28.32 7.34 15.48 6430. 1.968 400.7 0.44 -60 4.41 3.28 3.08 50.47 28.01 50.47 28.01 17.98 INDEF -5523. 9.998 INDEF INDEF INDEF 37.04 INDEF 33.41 43.59 27.71 43.59 27.71 13.87 16.20 3311. 3.808 353.9 INDEF -50 7.69 3.61 4.73 37.66 27.21 37.66 27.21 7.27 15.39 6972. 0.3169 464.5 0.16 -56 4.07 2.59 2.23 62.16 21.07 62.16 21.07 9.41 15.13 8856. -0.9043 415.9 0.14 -30 6.50 3.27 3.22 57.73 22.19 57.73 22.19 11.48 16.06 3754. 1.908 346.4 INDEF 80 4.52 3.87 4.43 51.10 22.17 51.10 22.17 8.89 15.76 4978. 4.53 420.9 INDEF 86 3.68 3.20 2.92 44.61 21.66 44.61 21.66 7.61 15.59 5794. 4.416 376.1 0.88 -81 4.25 3.56 3.28 38.24 21.86 38.24 21.86 12.19 16.08 3703. 8.723 319.3 INDEF -21 8.00 3.85 5.54 .fi Because \fImp_chkshifts\fR = yes the output of \fBimexamine\fR is displayed with the editor. This allows deleting multiple measurements or other incorrect data. In the above example there are no mistakes and the file does not need to be modified. The final file looks like this .nf # [1] demo01.sub.imh - Example artificial galaxy cluster # COL LINE COORDINATES R MAG FLUX SKY PEAK E PA ENCLOSED GAUSSIAN DIRECT 63.90 47.13 63.90 47.13 13.18 15.80 4778. -1.094 325.2 INDEF -6 3.96 4.20 4.16 # [2] demo02.sub.imh - Example artificial galaxy cluster 57.42 47.25 57.42 47.25 7.79 16.38 2810. 3.951 424.7 INDEF -55 3.99 3.38 3.61 # [3] demo03.sub.imh - Example artificial galaxy cluster 50.86 46.68 50.86 46.68 9.29 15.93 4244. 5.545 396.2 INDEF 8 3.46 3.21 3.10 # [4] demo04.sub.imh - Example artificial galaxy cluster 44.51 46.73 44.51 46.73 7.30 15.58 5837. -1.388 463.3 0.61 68 3.65 2.93 2.44 # [5] demo05.sub.imh - Example artificial galaxy cluster 37.93 46.40 37.93 46.40 8.47 15.70 5257. -1.161 463.6 INDEF 29 3.36 2.82 2.55 # [6] demo06.sub.imh - Example artificial galaxy cluster 62.60 40.00 62.60 40.00 10.79 15.34 7332. 1.875 352.8 0.69 -52 3.94 4.24 3.15 # [7] demo07.sub.imh - Example artificial galaxy cluster 56.06 39.90 56.06 39.90 9.33 15.68 5326. 6.569 358. 1.02 5 3.66 3.73 3.88 # [8] demo08.sub.imh - Example artificial galaxy cluster 51.00 40.90 51.00 40.90 9.88 15.80 4782. 7.608 408.1 INDEF -64 3.89 3.26 3.19 # [9] demo09.sub.imh - Example artificial galaxy cluster 44.88 40.71 44.88 40.71 6.64 15.79 4829. 6.467 517.4 1.62 28 2.86 2.42 2.16 # [10] demo10.sub.imh - Example artificial galaxy cluster 38.05 40.83 38.05 40.83 8.44 15.77 4916. -0.1289 439.2 7.41 76 3.98 2.90 3.17 # [11] demo11.sub.imh - Example artificial galaxy cluster 63.07 34.29 63.07 34.29 14.95 15.75 5014. 1.413 378.6 0.08 -22 17.97 3.74 13.72 # [12] demo12.sub.imh - Example artificial galaxy cluster 56.74 33.84 56.74 33.84 10.58 15.59 5797. 1.553 384.7 1.19 83 3.83 3.39 3.78 # [13] demo13.sub.imh - Example artificial galaxy cluster 50.11 33.58 50.11 33.58 13.60 15.60 5768. 4.054 352.1 49.8 -66 5.24 4.14 6.12 # [14] demo14.sub.imh - Example artificial galaxy cluster 43.37 33.46 43.37 33.46 8.73 15.72 5159. -0.7891 381.1 INDEF 5 3.99 3.58 3.25 # [15] demo15.sub.imh - Example artificial galaxy cluster 39.14 34.82 39.14 34.82 9.22 15.64 5549. -1.216 381.9 INDEF 51 4.14 3.38 3.08 # [16] demo16.sub.imh - Example artificial galaxy cluster 63.10 28.36 63.10 28.36 9.78 15.24 8045. -2.753 353. 0.43 -82 6.23 3.74 3.19 # [17] demo17.sub.imh - Example artificial galaxy cluster 57.05 28.32 57.05 28.32 7.34 15.48 6430. 1.968 400.7 0.44 -60 4.41 3.28 3.08 # [18] demo18.sub.imh - Example artificial galaxy cluster 50.47 28.01 50.47 28.01 17.98 INDEF -5523. 9.998 INDEF INDEF INDEF 37.04 INDEF 33.41 # [19] demo19.sub.imh - Example artificial galaxy cluster 43.59 27.71 43.59 27.71 13.87 16.20 3311. 3.808 353.9 INDEF -50 7.69 3.61 4.73 # [20] demo20.sub.imh - Example artificial galaxy cluster 37.66 27.21 37.66 27.21 7.27 15.39 6972. 0.3169 464.5 0.16 -56 4.07 2.59 2.23 # [21] demo21.sub.imh - Example artificial galaxy cluster 62.16 21.07 62.16 21.07 9.41 15.13 8856. -0.9043 415.9 0.14 -30 6.50 3.27 3.22 # [22] demo22.sub.imh - Example artificial galaxy cluster 57.73 22.19 57.73 22.19 11.48 16.06 3754. 1.908 346.4 INDEF 80 4.52 3.87 4.43 # [23] demo23.sub.imh - Example artificial galaxy cluster 51.10 22.17 51.10 22.17 8.89 15.76 4978. 4.53 420.9 INDEF 86 3.68 3.20 2.92 # [24] demo24.sub.imh - Example artificial galaxy cluster 44.61 21.66 44.61 21.66 7.61 15.59 5794. 4.416 376.1 0.88 -81 4.25 3.56 3.28 # [25] demo25.sub.imh - Example artificial galaxy cluster 38.24 21.86 38.24 21.86 12.19 16.08 3703. 8.723 319.3 INDEF -21 8.00 3.85 5.54 .fi Next mark as many stars (or compact objects) as can be reliably measured in the reference image as instructed below. In this example only the star we selected as the reference stars is suitable. .nf Select reference image registration stars ... Move to reference star measured previously Type a to measure reference star Move to other promising looking stars Type a to measure other registration stars Type q key to quit Log file myshiftlist.stars open # COL LINE COORDINATES # R MAG FLUX SKY PEAK E PA ENCLOSED GAUSSIAN DIRECT 50.17 33.61 50.17 33.61 13.56 15.90 4378. 5027. 376.8 INDEF -51 4.79 3.84 4.75 .fi As before the marked objects are displayed with the editor and again the file does not have to be edited. The final file appears as shown below. .nf [1] demo13 - Example artificial galaxy cluster # COL LINE COORDINATES R MAG FLUX SKY PEAK E PA ENCLOSED GAUSSIAN DIRECT 50.20 33.54 50.20 33.54 13.56 15.88 4439. 5027. 359.3 INDEF -53 4.79 4.02 4.75 .fi The position of the reference objects in each of the input images is measured with the \fBxdimsum.ximcentroid\fR task using the initial shifts determined from the object common to all the images and final offsets relative to the reference image are computed. The measurements are recorded in the file \fIshiftlist\fR which can be reviewed using the editor. The final shifts file is shown below. .nf demo01.sub.imh 13.966 13.554 1.0 demo02.sub.imh 7.718 13.360 1.0 demo03.sub.imh 0.751 12.866 1.0 demo04.sub.imh -5.438 12.733 1.0 demo05.sub.imh -11.825 12.675 1.0 demo06.sub.imh 12.663 6.243 1.0 demo07.sub.imh 6.204 5.880 1.0 demo08.sub.imh 1.320 7.394 1.0 demo09.sub.imh -5.090 7.054 1.0 demo10.sub.imh -11.789 7.198 1.0 demo11.sub.imh 13.352 0.354 1.0 demo12.sub.imh 6.719 0.039 1.0 demo13.sub.imh -0.064 -0.073 1.0 demo14.sub.imh -6.832 -0.273 1.0 demo15.sub.imh -11.140 0.899 1.0 demo16.sub.imh 13.723 -5.582 1.0 demo17.sub.imh 6.996 -5.604 1.0 demo18.sub.imh 0.500 -5.827 1.0 demo19.sub.imh -6.102 -6.268 1.0 demo20.sub.imh -12.949 -6.568 1.0 demo21.sub.imh 12.097 -12.923 1.0 demo22.sub.imh 8.005 -11.602 1.0 demo23.sub.imh 1.074 -11.789 1.0 demo24.sub.imh -5.114 -12.033 1.0 demo25.sub.imh -12.087 -11.925 1.0 .fi The shifts file is used to register the images and combine them with exposure time weighting. An exposure map is also created. These images are the first pass mosaic and exposure map. The images are stored in the file mosaic_fp.imh and mosaic_fp.exp.imh. The xnregistar task is used to do the image combining step. .nf ------- Checking the shiftlist--------------------------- Begin first pass image combining Wed 16:29:46 29-Nov-2000 -------Coadding images using xnregistar -------------- Creating individual composite masks ... Using bad pixel mask file: demo.pl Creating mask for image: demo01.sub Creating mask for image: demo02.sub Creating mask for image: demo03.sub Creating mask for image: demo04.sub Creating mask for image: demo05.sub Creating mask for image: demo06.sub Creating mask for image: demo07.sub Creating mask for image: demo08.sub Creating mask for image: demo09.sub Creating mask for image: demo10.sub Creating mask for image: demo11.sub Creating mask for image: demo12.sub Creating mask for image: demo13.sub Creating mask for image: demo14.sub Creating mask for image: demo15.sub Creating mask for image: demo16.sub Creating mask for image: demo17.sub Creating mask for image: demo18.sub Creating mask for image: demo19.sub Creating mask for image: demo20.sub Creating mask for image: demo21.sub Creating mask for image: demo22.sub Creating mask for image: demo23.sub Creating mask for image: demo24.sub Creating mask for image: demo25.sub Combining the input images ... Combining the exposure time images ... ... After registration the final mosaic and exposure map are reoriented so that north is up and east is to the left. In this example the images are left in their observed orientation. The effective exposure time and other header parameters in the final mosaic are updated. ... finish xfirstpass Wed 16:30:19 29-Nov-2000 .fi This marks the end of the first pass. The mask pass begins by calling the mkmask task to create a mask of the object cores. Mkmask uses the first pass combined image, first pass exposure map, and first pass offsets file, to create the mask object cores mask. The maskdereg task "deregisters" this mask to create object core masks for the individual images. The object cores masks are used to unzap cosmic rays detected in the cores of images during the first pass. .nf Wed 16:30:19 29-Nov-2000 start xmaskpass Wed 16:30:19 29-Nov-2000 Begin mask pass inverse object mask creation Wed 16:30:20 29-Nov-2000 -------Making mask for unzapping object cores ------------ Recommended thresholding level for mask is 0.32639925 z1=-0.6386976 z2=1.241897 .fi By default the main object cores mask is created automatically. However if \fIchkmasks\fR is yes the process is interactive. In this case the first pass combined image normalized by the exposure map is displayed with \fBimexamine\fR and the recommended threshold value is printed on the terminal, and the user is prompted for a new cutoff value which is interpreted as a value above the median background. The user can use the imexamine commands like 'm', 'l', and 'c' to determine this cutoff. .nf Cutoff point for replacement: \fB.32\fR .fi Now the first pass mosaic image and the computed mask are displayed and the user can decide whether or not to make a new mask with a different threshold. In the example type "no". The mask is then deregistered. .nf z1=-1.261593 z2=1.342784 z1=0. z2=1. Keep checking mask? (yes): \fBno\fR -------Inverting mask for unzapping ---------------------- Begin mask pass individual inverse object mask creation Wed 16:30:37 29-Nov-2000 -------Deregistering unzap mask subsections --------------- Making object masks for image: demo01 Making object masks for image: demo02 Making object masks for image: demo03 Making object masks for image: demo04 Making object masks for image: demo05 Making object masks for image: demo06 Making object masks for image: demo07 Making object masks for image: demo08 Making object masks for image: demo09 Making object masks for image: demo10 Making object masks for image: demo11 Making object masks for image: demo12 Making object masks for image: demo13 Making object masks for image: demo14 Making object masks for image: demo15 Making object masks for image: demo16 Making object masks for image: demo17 Making object masks for image: demo18 Making object masks for image: demo19 Making object masks for image: demo20 Making object masks for image: demo21 Making object masks for image: demo22 Making object masks for image: demo23 Making object masks for image: demo24 Making object masks for image: demo25 .fi The individual object core masks are stored in the file "*.sub.ocm.pl. The master object core mask is stored in the file "mosaic_fp.mski.pl". Next a lower threshold mask of the full objects is now made. The same steps of image display and threshold adjustment are performed as in the previous step and the new object mask is also deregistered. The object masks are used in a second pass of sky subtraction to avoid using pixels covered by faint objects as part of the sky. .nf Begin mask pass object mask creation Wed 16:30:39 29-Nov-2000 -------Making mask for sky subtraction ------------------- Recommended thresholding level for mask is 0.32639925 z1=-0.6386976 z2=1.241897 Cutoff point for replacement: \fB.32\fR z1=-1.261593 z2=1.342784 z1=0. z2=1. Keep checking mask? (yes): \fBno\fR Begin mask pass individual object mask creation Wed 16:30:59 29-Nov-2000 -------Deregistering sky subtraction mask subsections ----- Making object masks for image: demo01 Making object masks for image: demo02 Making object masks for image: demo03 Making object masks for image: demo04 Making object masks for image: demo05 Making object masks for image: demo06 Making object masks for image: demo07 Making object masks for image: demo08 Making object masks for image: demo09 Making object masks for image: demo10 Making object masks for image: demo11 Making object masks for image: demo12 Making object masks for image: demo13 Making object masks for image: demo14 Making object masks for image: demo15 Making object masks for image: demo16 Making object masks for image: demo17 Making object masks for image: demo18 Making object masks for image: demo19 Making object masks for image: demo20 Making object masks for image: demo21 Making object masks for image: demo22 Making object masks for image: demo23 Making object masks for image: demo24 Making object masks for image: demo25 .fi The individual object masks are stored in the file "*.sub.obm.pl" and the mask object mask is stored in the file "mosaic_fp.msk.pl". Next the sky subtracted images are recomputed using the object masks created above to eliminate objects from both the sky statistics computation and the image combining step. For some images a holes mask may also be created. Holes mask define regions of the sky subtracted data which are undefined, i.e. contain no data. The holes mask are used in the image combining step to compute the combined image and the exposure map. .nf Begin mask pass sky subtraction Wed 16:31:01 29-Nov-2000 Calculating scaling for demo01 Using object mask : demo01.sub.obm.pl Setting scaling factor to 1 / 4540.263 Calculating scaling for demo02 Using object mask : demo02.sub.obm.pl Setting scaling factor to 1 / 4580.704 Calculating scaling for demo03 Using object mask : demo03.sub.obm.pl Setting scaling factor to 1 / 4621.996 Calculating scaling for demo04 Using object mask : demo04.sub.obm.pl Setting scaling factor to 1 / 4660.359 Calculating scaling for demo05 Using object mask : demo05.sub.obm.pl Setting scaling factor to 1 / 4701.139 Calculating scaling for demo06 Using object mask : demo06.sub.obm.pl Setting scaling factor to 1 / 4739.956 Calculating scaling for demo07 Using object mask : demo07.sub.obm.pl Setting scaling factor to 1 / 4780.889 Calculating scaling for demo08 Using object mask : demo08.sub.obm.pl Setting scaling factor to 1 / 4820.484 Calculating scaling for demo09 Using object mask : demo09.sub.obm.pl Setting scaling factor to 1 / 4860.14 Calculating scaling for demo10 Using object mask : demo10.sub.obm.pl Setting scaling factor to 1 / 4899.388 Calculating scaling for demo11 Using object mask : demo11.sub.obm.pl Setting scaling factor to 1 / 4941.429 Calculating scaling for demo12 Using object mask : demo12.sub.obm.pl Setting scaling factor to 1 / 4981.195 Calculating scaling for demo13 Using object mask : demo13.sub.obm.pl Setting scaling factor to 1 / 5019.37 Calculating scaling for demo14 Using object mask : demo14.sub.obm.pl Setting scaling factor to 1 / 5061.904 Calculating scaling for demo15 Using object mask : demo15.sub.obm.pl Setting scaling factor to 1 / 5100.764 Calculating scaling for demo16 Using object mask : demo16.sub.obm.pl Setting scaling factor to 1 / 5140.057 Calculating scaling for demo17 Using object mask : demo17.sub.obm.pl Setting scaling factor to 1 / 5181.636 Calculating scaling for demo18 Using object mask : demo18.sub.obm.pl Setting scaling factor to 1 / 5220.013 Calculating scaling for demo19 Using object mask : demo19.sub.obm.pl Setting scaling factor to 1 / 5261.546 Calculating scaling for demo20 Using object mask : demo20.sub.obm.pl Setting scaling factor to 1 / 5300.255 Calculating scaling for demo21 Using object mask : demo21.sub.obm.pl Setting scaling factor to 1 / 5340.667 Calculating scaling for demo22 Using object mask : demo22.sub.obm.pl Setting scaling factor to 1 / 5379.909 Calculating scaling for demo23 Using object mask : demo23.sub.obm.pl Setting scaling factor to 1 / 5420.455 Calculating scaling for demo24 Using object mask : demo24.sub.obm.pl Setting scaling factor to 1 / 5460.285 Calculating scaling for demo25 Using object mask : demo25.sub.obm.pl Setting scaling factor to 1 / 5498.279 Creating sky subtracted image demo01.sub Frame 1 Sky frames: start = 1 finish = 4 nreject = 1 Using object mask : demo01.sub.obm.pl Creating sky subtracted image demo02.sub Frame 2 Sky frames: start = 1 finish = 4 nreject = 1 Using object mask : demo02.sub.obm.pl Creating sky subtracted image demo03.sub Frame 3 Sky frames: start = 1 finish = 5 nreject = 1 Using object mask : demo03.sub.obm.pl Creating sky subtracted image demo04.sub Frame 4 Sky frames: start = 1 finish = 7 nreject = 1 Using object mask : demo04.sub.obm.pl Creating sky subtracted image demo05.sub Frame 5 Sky frames: start = 2 finish = 8 nreject = 1 Using object mask : demo05.sub.obm.pl Creating sky subtracted image demo06.sub Frame 6 Sky frames: start = 3 finish = 9 nreject = 1 Using object mask : demo06.sub.obm.pl Creating sky subtracted image demo07.sub Frame 7 Sky frames: start = 4 finish = 10 nreject = 1 Using object mask : demo07.sub.obm.pl Creating sky subtracted image demo08.sub Frame 8 Sky frames: start = 5 finish = 11 nreject = 1 Using object mask : demo08.sub.obm.pl Creating sky subtracted image demo09.sub Frame 9 Sky frames: start = 6 finish = 12 nreject = 1 Using object mask : demo09.sub.obm.pl Creating sky subtracted image demo10.sub Frame 10 Sky frames: start = 7 finish = 13 nreject = 1 Using object mask : demo10.sub.obm.pl Creating sky subtracted image demo11.sub Frame 11 Sky frames: start = 8 finish = 14 nreject = 1 Using object mask : demo11.sub.obm.pl Creating sky subtracted image demo12.sub Frame 12 Sky frames: start = 9 finish = 15 nreject = 1 Using object mask : demo12.sub.obm.pl Creating sky subtracted image demo13.sub Frame 13 Sky frames: start = 10 finish = 16 nreject = 1 Using object mask : demo13.sub.obm.pl Creating sky subtracted image demo14.sub Frame 14 Sky frames: start = 11 finish = 17 nreject = 1 Using object mask : demo14.sub.obm.pl Creating sky subtracted image demo15.sub Frame 15 Sky frames: start = 12 finish = 18 nreject = 1 Using object mask : demo15.sub.obm.pl Creating sky subtracted image demo16.sub Frame 16 Sky frames: start = 13 finish = 19 nreject = 1 Using object mask : demo16.sub.obm.pl Creating sky subtracted image demo17.sub Frame 17 Sky frames: start = 14 finish = 20 nreject = 1 Using object mask : demo17.sub.obm.pl Creating sky subtracted image demo18.sub Frame 18 Sky frames: start = 15 finish = 21 nreject = 1 Using object mask : demo18.sub.obm.pl Creating sky subtracted image demo19.sub Frame 19 Sky frames: start = 16 finish = 22 nreject = 1 Using object mask : demo19.sub.obm.pl Creating sky subtracted image demo20.sub Frame 20 Sky frames: start = 17 finish = 23 nreject = 1 Using object mask : demo20.sub.obm.pl Creating sky subtracted image demo21.sub Frame 21 Sky frames: start = 18 finish = 24 nreject = 1 Using object mask : demo21.sub.obm.pl Creating sky subtracted image demo22.sub Frame 22 Sky frames: start = 19 finish = 25 nreject = 1 Using object mask : demo22.sub.obm.pl Creating sky subtracted image demo23.sub Frame 23 Sky frames: start = 21 finish = 25 nreject = 1 Using object mask : demo23.sub.obm.pl Creating sky subtracted image demo24.sub Frame 24 Sky frames: start = 22 finish = 25 nreject = 1 Using object mask : demo24.sub.obm.pl Creating sky subtracted image demo25.sub Frame 25 Sky frames: start = 22 finish = 25 nreject = 1 Using object mask : demo25.sub.obm.pl Creating holes mask: demo25.sub.hom.pl .fi The new sky subtracted images are stored in the files "*.sub.imh". The holes masks are stored in the file "*.sub.hom.pl". As before the bad pixels are interpolated away in the new sky subtracted images. One possible difference is that the bad pixel mask may have additional bad pixels due to earlier detection as apparent cosmic ray events occurring repeatedly in the same pixel. .nf Begin mask pass bad pixel correction Wed 16:36:21 29-Nov-2000 -------Correcting bad pixels with maskfix------------------ Fixing bad pixels in file demo01.sub using mask demo.pl Fixing bad pixels in file demo02.sub using mask demo.pl Fixing bad pixels in file demo03.sub using mask demo.pl Fixing bad pixels in file demo04.sub using mask demo.pl Fixing bad pixels in file demo05.sub using mask demo.pl Fixing bad pixels in file demo06.sub using mask demo.pl Fixing bad pixels in file demo07.sub using mask demo.pl Fixing bad pixels in file demo08.sub using mask demo.pl Fixing bad pixels in file demo09.sub using mask demo.pl Fixing bad pixels in file demo10.sub using mask demo.pl Fixing bad pixels in file demo11.sub using mask demo.pl Fixing bad pixels in file demo12.sub using mask demo.pl Fixing bad pixels in file demo13.sub using mask demo.pl Fixing bad pixels in file demo14.sub using mask demo.pl Fixing bad pixels in file demo15.sub using mask demo.pl Fixing bad pixels in file demo16.sub using mask demo.pl Fixing bad pixels in file demo17.sub using mask demo.pl Fixing bad pixels in file demo18.sub using mask demo.pl Fixing bad pixels in file demo19.sub using mask demo.pl Fixing bad pixels in file demo20.sub using mask demo.pl Fixing bad pixels in file demo21.sub using mask demo.pl Fixing bad pixels in file demo22.sub using mask demo.pl Fixing bad pixels in file demo23.sub using mask demo.pl Fixing bad pixels in file demo24.sub using mask demo.pl Fixing bad pixels in file demo25.sub using mask demo.pl .fi Another round of cosmic ray detection is done using the more sensitive object masks based on the first pass mosaic rather than generating a mask for each individual observation. As before any repeated cosmic ray detections are flagged as likely bad pixels in the bad pixel file. .nf Begin mask pass cosmic ray correction Wed 16:36:39 29-Nov-2000 -------Zapping cosmic rays using xzap -------------------- Creating cosmic ray corrected image demo01.sub Using object mask : demo01.sub.ocm.pl Creating cosmic ray corrected image demo02.sub Using object mask : demo02.sub.ocm.pl Creating cosmic ray corrected image demo03.sub Using object mask : demo03.sub.ocm.pl Creating cosmic ray corrected image demo04.sub Using object mask : demo04.sub.ocm.pl Creating cosmic ray corrected image demo05.sub Using object mask : demo05.sub.ocm.pl Creating cosmic ray corrected image demo06.sub Using object mask : demo06.sub.ocm.pl Creating cosmic ray corrected image demo07.sub Using object mask : demo07.sub.ocm.pl Creating cosmic ray corrected image demo08.sub Using object mask : demo08.sub.ocm.pl Creating cosmic ray corrected image demo09.sub Using object mask : demo09.sub.ocm.pl Creating cosmic ray corrected image demo10.sub Using object mask : demo10.sub.ocm.pl Creating cosmic ray corrected image demo11.sub Using object mask : demo11.sub.ocm.pl Creating cosmic ray corrected image demo12.sub Using object mask : demo12.sub.ocm.pl Creating cosmic ray corrected image demo13.sub Using object mask : demo13.sub.ocm.pl Creating cosmic ray corrected image demo14.sub Using object mask : demo14.sub.ocm.pl Creating cosmic ray corrected image demo15.sub Using object mask : demo15.sub.ocm.pl Creating cosmic ray corrected image demo16.sub Using object mask : demo16.sub.ocm.pl Creating cosmic ray corrected image demo17.sub Using object mask : demo17.sub.ocm.pl Creating cosmic ray corrected image demo18.sub Using object mask : demo18.sub.ocm.pl Creating cosmic ray corrected image demo19.sub Using object mask : demo19.sub.ocm.pl Creating cosmic ray corrected image demo20.sub Using object mask : demo20.sub.ocm.pl Creating cosmic ray corrected image demo21.sub Using object mask : demo21.sub.ocm.pl Creating cosmic ray corrected image demo22.sub Using object mask : demo22.sub.ocm.pl Creating cosmic ray corrected image demo23.sub Using object mask : demo23.sub.ocm.pl Creating cosmic ray corrected image demo24.sub Using object mask : demo24.sub.ocm.pl Creating cosmic ray corrected image demo25.sub Using object mask : demo25.sub.ocm.pl begin badpixupdate Wed 16:37:34 29-Nov-2000 -------Updating bad pixel file with badpixupdate ---------- .fi The final step is to block replicate each image by the factor \fImag\fR and shift and combine with quarter pixel accuracy. This produces the final mosaic image with extension "_mp" and a final exposure map. The bad pixel mask, the final cosmic ray masks, and the holes masks are used to computed the final image and exposure map. .nf Begin mask pass image combining Wed 16:37:36 29-Nov-2000 -------Magnifying and coadding images with xnregistar ----- Creating individual composite masks ... Using bad pixel mask file: demo.pl Creating mask for image: demo01.sub Cannot find holes mask file: demo01.sub.hom.pl Using crmask file: demo01.sub.crm.pl Creating mask for image: demo02.sub Cannot find holes mask file: demo02.sub.hom.pl Using crmask file: demo02.sub.crm.pl Creating mask for image: demo03.sub Cannot find holes mask file: demo03.sub.hom.pl Using crmask file: demo03.sub.crm.pl Creating mask for image: demo04.sub Cannot find holes mask file: demo04.sub.hom.pl Using crmask file: demo04.sub.crm.pl Creating mask for image: demo05.sub Cannot find holes mask file: demo05.sub.hom.pl Using crmask file: demo05.sub.crm.pl Creating mask for image: demo06.sub Cannot find holes mask file: demo06.sub.hom.pl Using crmask file: demo06.sub.crm.pl Creating mask for image: demo07.sub Cannot find holes mask file: demo07.sub.hom.pl Using crmask file: demo07.sub.crm.pl Creating mask for image: demo08.sub Cannot find holes mask file: demo08.sub.hom.pl Using crmask file: demo08.sub.crm.pl Creating mask for image: demo09.sub Cannot find holes mask file: demo09.sub.hom.pl Using crmask file: demo09.sub.crm.pl Creating mask for image: demo10.sub Cannot find holes mask file: demo10.sub.hom.pl Using crmask file: demo10.sub.crm.pl Creating mask for image: demo11.sub Cannot find holes mask file: demo11.sub.hom.pl Using crmask file: demo11.sub.crm.pl Creating mask for image: demo12.sub Cannot find holes mask file: demo12.sub.hom.pl Using crmask file: demo12.sub.crm.pl Creating mask for image: demo13.sub Cannot find holes mask file: demo13.sub.hom.pl Using crmask file: demo13.sub.crm.pl Creating mask for image: demo14.sub Cannot find holes mask file: demo14.sub.hom.pl Using crmask file: demo14.sub.crm.pl Creating mask for image: demo15.sub Cannot find holes mask file: demo15.sub.hom.pl Using crmask file: demo15.sub.crm.pl Creating mask for image: demo16.sub Cannot find holes mask file: demo16.sub.hom.pl Using crmask file: demo16.sub.crm.pl Creating mask for image: demo17.sub Cannot find holes mask file: demo17.sub.hom.pl Using crmask file: demo17.sub.crm.pl Creating mask for image: demo18.sub Cannot find holes mask file: demo18.sub.hom.pl Using crmask file: demo18.sub.crm.pl Creating mask for image: demo19.sub Cannot find holes mask file: demo19.sub.hom.pl Using crmask file: demo19.sub.crm.pl Creating mask for image: demo20.sub Cannot find holes mask file: demo20.sub.hom.pl Using crmask file: demo20.sub.crm.pl Creating mask for image: demo21.sub Cannot find holes mask file: demo21.sub.hom.pl Using crmask file: demo21.sub.crm.pl Creating mask for image: demo22.sub Cannot find holes mask file: demo22.sub.hom.pl Using crmask file: demo22.sub.crm.pl Creating mask for image: demo23.sub Cannot find holes mask file: demo23.sub.hom.pl Using crmask file: demo23.sub.crm.pl Creating mask for image: demo24.sub Cannot find holes mask file: demo24.sub.hom.pl Using crmask file: demo24.sub.crm.pl Creating mask for image: demo25.sub Using holes mask file: demo25.sub.hom.pl Using crmask file: demo25.sub.crm.pl Block replicating the input images ... Block replicating the exposure time images ... Combining the input images ... Combining the exposure time images ... finish xmaskpass Wed 16:40:47 29-Nov-2000 finish xmosaic Wed 16:40:47 29-Nov-2000 .fi Now examine the results. Load the truth image, the first pass mosaic, and the mask pass mosaic into the image display. Note that the final sizes are different so things will not appear exactly registered. .nf di> \fBdisplay demo_truth 1 fill+\fR di> \fBdisplay mosaic_fp 2 fill+\fR di> \fBdisplay mosaic_mp 3 fill+\fR .fi .nh 1 Appendix 1: Summary of Major Differences between XDIMSUM and DIMSUM .nh 2 Input and Output Image and Mask Lists All input and output image and file names and input and output image and file lists are now task parameters rather than being silently passed as keyword names, silently assumed to have already been created by a previous step, or silently created by the current step. For example the input object mask list required by the xslm task is now a parameter. Similarly the output sky subtraction and holes mask lists produced the the xslm task are now parameters. These changes make tracing the data flow from one processing step to another simpler. .nh 2 Default Image and Mask Names In most cases the output images and masks are assigned sensible default names if explicit output image and mask lists are not provided. For example in the case of the sky subtraction task xslm the suffix ".sub" is appended to the input images names to produce the output sky subtracted image names, and the suffixes ".ssm" and ".hom" are appended to sky subtracted image names to create the sky subtraction and holes mask names. In general if an output image or mask list parameter value begins with a '.' it is assumed to be a suffix rather than a complete name. The default image and mask name scheme means that users need not concern themselves with the names of the intermediate data products. .nh 2 Use of Suffixes instead of Prefixes to Define Default Names Suffixes instead of prefixes are used to create default names. Using suffixes means that the input and output image lists no longer need to be in the same directory. .nh 2 New Tasks A new cosmic ray removal task \fIxnzap\fR has been added to the XDIMSUM package. Xnzap is a script wrapper for the \fIxcraverage\fR task. Xnzap is an alternative to the default xzap task. It is significantly faster than xzap but not yet as well tested. Users are encouraged to experiment with xnzap and / or xcraverage on their own. User feedback on their effectiveness is welcome. The code for interactively computing the relative shifts in a set of dithered images has been rewritten and moved into a separate task called \fIxdshifts\fR. Three new script tasks for computing shifts for images taken in series with approximately constant shifts between adjacent images: \fIxmshifts\fR, \fIxfshifts\fR, and \fIxrshifts\fR, have been added to XDIMSUM. These scripts use modified versions of the existing starfind and imcentroid tasks called \fIxstarfind\fR and \fIximcentroid\fR. .nh 2 New Algorithms The main processing scripts \fIxmosaic\fR, \fIxfirstpass\fR, and \fIxmaskpass\fR can now be run repeatedly from scratch without requiring the user to delete any intermediate files. It has also been made simpler to restart these scripts at an intermediate point in the processing. The mask deregistration task \fImaskdereg\fR now permits the user to create individual object masks which are a combination of the current mask and the N previous ones. This feature is useful in cases where the detector retains significant memory of previous exposures. The image and mask statistics computation parameters used by the sky subtraction and cosmic ray removal tasks \fIxslm\fR and \fIxzap\fR, \fIstatsec\fR, \fImstatsec\fR, \fImaxiter\fR, and \fInreject\fR can now be set by the user. Their default values are now "", "", 20, and 3.0 respectively, instead of being fixed at the values "", "", 10, and 5.0. The \fImaskstat\fR task now outputs the computed mask statistics to the output parameters mean, msigma, median, and mmode in the same manner as the \fIiterstat\fR itask does. The first pass image combining step performed by the \fIxmosaic\fR or \fIxfirstpass\fR tasks now includes an option for doing fractional pixel shifts. The mask pass image combining step performed by the \fIxmosaic\fR or \fIxmask pass\fR tasks now includes an option for doing image magnification using bilinear interpolation rather than block replication. This means that non-integer magnification factors are supported. .nh 2 Internal Changes Calls to existing IRAF tasks have been reviewed to make sure that all the task parameters are set in order to avoid unpleasant surprises if these parameters are not set at the expected defaults. Complicated image operations requiring several steps have been replaced by a single call to the \fIimexpr\fR task where appropriate. The image registration and combining step has been rewritten to use a new version of the imcombine task called \fIxcombine\fR which does not suffer from the number of open file limit and has better support for pixel masks. The registration should be much faster in most cases. The \fIsections\fR, \fIfileroot\fR, \fIimgets\fR, \fIminmax\fR, \fIiterstat\fR, and \fImaskstat\fR tasks which return values to their parameters have been cached so that XDIMSUM tasks will work correctly in the background. On normal task termination there are now no temporary files or images left either in the tmp$ directory or in the current working directory. .endhelp iraf-xdimsum-main/doc/guide.hlp.old000066400000000000000000001374531455666516400175700ustar00rootroot00000000000000.help guide May96 dimsum .ce \fBDIMSUM: Deep Infrared Mosaicing Software, um...\fR .ce \fBGuide to Using the REDUCE Task\fR .ce P. Eisenhardt (prme@kromos.jpl.nasa.gov) .ce M. Dickinson (med@stsci.edu) .ce S.A. Stanford .ce J. Ward .ce F. Valdes (fvaldes@noao.edu) .ce June 1996 .nh Introduction \fBDIMSUM\fR is a package for producing accurate sky subtracted images from sets of dithered observations. While the observations need not be in the infrared, the dominance of the variable sky background in infrared data requires dithering of many short exposures and the recombination of the images with careful sky subtraction to produce deep images. Hence the package is called "Deep Infrared Mosaicing Software, um" or DIMSUM. The \fBdimsum\fR package was developed, and continues to be developed, by practicing astronomers. Thus, the documentation is limited. However, the software is of sufficient generality and usefulness that we are making it available to the community. Users may contact the IRAF group (iraf@noao.edu) for help with the software installation. Questions about the technical details and comments and suggestions may be directed to the authors. We will attempt to be responsive given the constraints of our professional work. This guide describes the master processing task \fBreduce\fR. This task combines the various steps described below. Each step is performed by one or more of the subtasks of the package. By use of the option switches one may use \fBreduce\fR alone to perform any combination of operations. The \fBreduce\fR task and most of the subtasks are CL scripts. Users are welcomed and encouraged to examine the scripts to gain an understanding of the algorithms and parameters. The script source code is found in the logical directory dimsum$src. Of course, keep in mind, as noted earlier, that the authors developed this software over time as they reduced their own data and they are not primarily software developers. .nh Outline The following is a brief outline of the steps performed by \fBdimsum.reduce\fR. The are two major stages called the first pass and the mask pass. Both passes have similar steps and produce a sky subtracted, registered, and combined final image. The first pass produces an integer registered image with no knowledge from the final mosaic image. The mask pass feeds back information about the positions of the objects in the first pass mosaic image, which will be better defined and go fainter than the individual exposures, to improve the sky subtraction. It also does subpixel registration in producing the final mosaic image. .nh 2 First Pass .nh 3 Sky Subtraction A scaling factor for each image is computed using a 5 sigma iterated rejection about the mean. The scaling factor is the median of the unrejected pixels. For each image in the input list a specified number of neighboring images (\fInmed\fR) in the list are selected. Except at the ends of the list (see \fInskymin\fR) there is usually an equal number of images before and after the image to be sky subtracted. At each pixel a specified number of low and high pixels (\fIrjct\fR) in the scaled images are rejected and the average of the remainder is computed as the sky for that pixel. The sky values are subtracted from the scaled image to create a sky subtracted image. .nh 3 Fixing Bad Pixels A bad pixel file (\fIbpimage\fR) is used to replace bad pixels by interpolation. The bad pixel file is an image with values of zero for bad pixels and one for good pixels. .nh 3 Zapping Cosmic Rays An object mask is made (see "Making Masks" below) from the image data. Note that this will only find the strongest objects and later in the mask pass an object mask determined from the combined frame will be used. Cosmic rays are found using a theshold algorithm applied to the ratio of the image and a median filtered image ("unsharp masking"). Only pixels outside the object mask are considered. The detected cosmic rays are replaced by the local median. A cosmic ray mask is created to record the location of the cosmic rays. If any pixel is found to have cosmic rays occuring in more than two images the pixel is considered suspect and the pixel is flagged in the bad pixel mask if \fIfp_badpixupdate\fR is set. .nh 3 Making the Shift List A shift list is used to define the offsets between the images. This list may be created in \fBreduce\fR provided there is at least one common object in all the images. This is done by displaying each image and allowing you to mark and measure the positions of the objects. During this process you can also evaluate the quality of each sky subtracted image and eliminate poor ones from the later registration and combining. The task \fBimexamine\fR is used to display the images. There are two stages. First the position of one object which is common to all images is marked using the 'a' or 'r' keystrokes. The measured positions are written to a logfile. To scroll through the list of images use the 'n' keystroke and use 'q' to finish. The measurements are used to provide a first guess for the shifts. The parameter \fIchk\fR allows checking and editing the measurments after quiting \fBimexamine\fR. The second stage is to select a set of objects to be used in determining the shifts. A reference image (\fIref_img\fR) near the center of the dithering pattern is display with \fBimexamine\fR and the objects are again marked with 'a' or 'r' and the results written to a different logfile. The objects need not be in common with all images. This step is completed using the 'q' keystroke. The parameter \fIchk\fR will also allow you to review and edit this logfile. The set of objects from the second stage are used to construct the shift list using the task \fBimcentroid\fR. The last step is then to review the shift list with an editor. The shift list is a file with lines having four columns. The columns are the image name, the shifts in x and y, and a weight value. The weight value is generally one to include the image using its exposure time. A value of zero may used to exclude an image from the final mosaic. .nh 3 Registration This step shifts the images, combines them, and orients the final image. In the first pass the images are shifted by integer amounts. A matching exposure map is also created. .nh 2 Mask Pass .nh 3 Making Masks There are two masks of where the objects in the images are located which are created from the first pass mosaic image and used in this pass. The first mask uses a higher threshold to identify only the brighter parts of the objects. This is used to check that the cores of the objects not seen in the individual images were not identified earlier as cosmic rays. The second mask uses a lower threshold to identify extended regions of the images covered by the objects. This mask is used to exclude those regions from the sky subtraction. A mask is made from the first pass image as follows. The image is divided by the square root of the exposure map to account for variations in the sky noise due to varying exposure times at each pixel. The sky RMS is computed using iterative sigma rejection and a threshold value in terms of this RMS is determined. The user may examine the uniform RMS image with \fBimexamine\fR in order to recommend a threshold or the \fInsig_cr_msk\fR value will be used. Finally an algorithm which tracks the sky and threshold detects above the sky is applied. A mask of zero (sky) and one (object) is created from the pixels above the threshold. If the \fIchk\fR parameter is set the mosaic and mask images are displayed in two frames and you may blink them. A query is given to allow repeating the mask making with a new threshold. Once the masks are made from the objects in the first pass mosaic, the shiftlist is used to make masks for each original image. Any cosmic rays identifications in the cosmic ray masks of the object which are within the individual object masks are then removed. .nh 3 Sky Subtraction The sky subtraction is repeated much as was done in the first pass except that the pixels in the individual masks derived from the first pass mosaic image are ignored. .nh 3 Fixing Bad Pixels The bad pixels from the bad pixel image are used to replace bad pixels as before. Note that the bad pixel file may have been updated by the detection of multiple cosmic ray events at the same pixel. .nh 3 Zapping Cosmic Rays The same algorithm as in the first pass is used except that the object mask for the image created from the first pass mosaic is used to exclude object pixels from being found as cosmic rays. Also, as before, pixels found to have cosmic rays occuring in more than two images the pixel are flagged in the bad pixel mask if \fIfp_badpixupdate\fR is set. .nh 3 Registration The final step is to again shift, combine, and orient the final mosaic. In this second, more careful, pass subpixel shifts are considered. The current algorithm block replicates each image by a factor of four and shifts the images to a resolution of 1/4 of a pixel. The final mosaic image from the mask pass is, therefore, approximately four times larger in each dimension with sixteen times more pixels than the first pass image. As before an exposure map is also created. .nh 1 Example One of the best ways to learn the use of a task is through an example. The following example uses artificial data which you may also create and then follow along with the reduction. This example shows all the steps in the most interactive mode. The first step is to load the package. .nf cl> \fBdimsum\fR +--------------------------------------------------------------------+ | DIMSUM | | Deep Infrared Mosaicing Softwear, um... | | Painstakingly created by P. Eisenhardt, M. Dickinson, | | S.A. Stanford, J. Ward, etc. etc. etc. | | Contact prme@kromos.jpl.nasa.gov or md@copacabana.berkeley.edu | | with your questions, accolades and brickbats. | +--------------------------------------------------------------------+ badpixupdate maskdereg orient registar xfirstpass bundle maskstat photcheck shiftfix xlist demos mkmask photdiff shiftset xmaskpass magshiftfix mosaic reduce sigmanorm xslm .fi The only tasks to be concerned about are \fBdemos\fR and \fBreduce\fR. The other tasks are called by \fBreduce\fR. The artificial demonstration data is created by .nf di> \fBdemos\fR MENU of DIMSUM Demonstrations mkdimsum - Make DIMSUM test data (25 100x100 images) Demo name: \fBmkdimsum\fR Creating master field (please be patient) ... Creating truth image demo_truth ... Creating DIMSUM bad pixel mask demo.pl ... Creating image list demo.list ... Creating DIMSUM shift list demo.shiftlist ... Creating imcombine offset file demo.imc ... Creating demo01 ... Creating demo02 ... Creating demo03 ... Creating demo04 ... Creating demo05 ... Creating demo06 ... Creating demo07 ... Creating demo08 ... Creating demo09 ... Creating demo10 ... Creating demo11 ... Creating demo12 ... Creating demo13 ... Creating demo14 ... Creating demo15 ... Creating demo16 ... Creating demo17 ... Creating demo18 ... Creating demo19 ... Creating demo20 ... Creating demo21 ... Creating demo22 ... Creating demo23 ... Creating demo24 ... Creating demo25 ... di> \fBdir\fR demo.imc demo04.imh demo11.imh demo18.imh demo25.imh demo.list demo05.imh demo12.imh demo19.imh demo_truth.imh demo.pl demo06.imh demo13.imh demo20.imh pixels demo.slist demo07.imh demo14.imh demo21.imh demo01.imh demo08.imh demo15.imh demo22.imh demo02.imh demo09.imh demo16.imh demo23.imh demo03.imh demo10.imh demo17.imh demo24.imh .fi The files demo??.imh are 25 dithered 100x100 images with low S/N in an approximate 5x5 pattern. The dither is small so there are large amounts of overlap. There is also a bad column and a couple of bad pixels are shown by the pixel mask file demo.pl. Finally each image has a few cosmic rays. The list of images is given in the file demo.list which can be used as an @file. The image demo_truth.imh is the image from which the dithered images were extracted. The goal of \fBdimsum\fR is to come as close to this image as possible. Now we are ready to set up \fBreduce\fR. Because of small changes in the tasks called by the \fBdimsum\fR scripts there is a package parameter that is used to indicate the version of IRAF you are using. The values are "V2.10.2", "V2.10.3", "V2.10.4", and "V2.11". The first one also may be used with "V2.10-V2.10.1". So look at the first line of the login banner when you start the \fBcl\fR and enter the appropriate version (ignoring the patch levels). .nf di> \fBdimsum.iraf = "V2.10.4"\fR .fi Now use \fBeparam\fR to set the task parameters. In the example we will set all the processing options to "yes" to do all the steps and to use the most interactive option. Be sure to have an image display window open. .nf di> \fBunlearn reduce\fR di> \fBepar reduce\fR I R A F Image Reduction and Analysis Facility PACKAGE = dimsum TASK = reduce img_lst = \fB@demo.list\fR List of images out_img = \fBdemo\fR Base name for output firstpass and maskpass imag (ref_img= \fBdemo13\fR) Name of a reference image (WITHOUT prefix) in im (prefix = ss_) Prefix for sky-subtracted images (chk = \fByes\fR) Do you want chances to check shifts and masks? kpchking= yes Keep checking mask? (fp_xslm= yes) Do firstpass xslm? (fp_fixp= yes) Do firstpass fixpix? (fp_xzap= yes) Do firstpass xzap? (fp_badp= yes) Do firstpass bad pixel file update? (mk_shif= yes) Determine shifts? (fp_regi= yes) Do firstpass registar? (masking= yes) Make masks? (maskder= yes) Deregister masks? (mp_xslm= yes) Do maskpass xslm? (mp_fixp= yes) Do maskpass fixpix? (mp_xzap= \fByes\fR) Do maskpass xzap? (mp_badp= yes) Do maskpass bad pixel file update? (mp_regi= yes) Do maskpass registar? (nmed = 6) Number of images to use in sky frame (bpimage= \fBdemo.pl\fR) Bad pixel mask image (mfac = 4) Mag factor for maskpass image (secpexp= 60.) Seconds per unit exposure time (ncoavg = 1) Number of internal coaverages per frame (rjct = 1) Number of pixels for xslm minmax reject (nskymin= 3) Minimum number of frames to use for sky (forcesc= yes) Force recalculation of image medians in sky scal (premask= yes) Mask working sky images in maskpass? (pixin = yes) Are input coords measured pixels of ref object? (scale_x= 1.) x pixels per ab coord unit (scale_y= 1.) y pixels per ab coord unit (ang_a2x= 0.) Angle in degrees from a CCW to x (senseab= yes) Is a through b counterclockwise? (ang_y2N= 0.) Angle in degrees from y to N dir N through E (rotatio= yes) Is N through E counterclockwise? (nsig_ob= 1.1) factor x suggested threshold for object masking (nsig_cr= 1.5) factor x suggested threshold for cr masking (ilist = ) (mode = q) .fi Now we are ready to reduce the data set. Below we will intersperse comments with the output. The task starts by querying for parameters. The base name will be used for creating output images with various extensions. The hidden parameter \fIprefiX\fR is also used to create new image names for the sky subtracted images. .nf di> \fBreduce\fR Type 'phelp reduce' and 'phelp guide' for a modicum of help Remember to set dimsum.iraf, badpix, secpexp, and ncoavg parameters List of images (@demo.list): Base name for output firstpass and maskpass images (demo): .fi The first step is computing sky scaling factors using the algorithm described earlier. .nf --------Sky Subtracting------------ Calculating scaling for demo01 Calculating scaling for demo02 Calculating scaling for demo03 Calculating scaling for demo04 Calculating scaling for demo05 Calculating scaling for demo06 Calculating scaling for demo07 Calculating scaling for demo08 Calculating scaling for demo09 Calculating scaling for demo10 Calculating scaling for demo11 Calculating scaling for demo12 Calculating scaling for demo13 Calculating scaling for demo14 Calculating scaling for demo15 Calculating scaling for demo16 Calculating scaling for demo17 Calculating scaling for demo18 Calculating scaling for demo19 Calculating scaling for demo20 Calculating scaling for demo21 Calculating scaling for demo22 Calculating scaling for demo23 Calculating scaling for demo24 Calculating scaling for demo25 .fi Once the scaling factors are determined the neighboring images from the input list are used to determine a sky for subtraction. The parameters are set to use the three previous and three following images. .nf Sky subtracting demo01 Frame no. 1 sky frames: start = 1 finish = 4 nreject = 1 Sky subtracting demo02 Frame no. 2 sky frames: start = 1 finish = 4 nreject = 1 Sky subtracting demo03 Frame no. 3 sky frames: start = 1 finish = 5 nreject = 1 Sky subtracting demo04 Frame no. 4 sky frames: start = 1 finish = 7 nreject = 1 Sky subtracting demo05 Frame no. 5 sky frames: start = 2 finish = 8 nreject = 1 Sky subtracting demo06 Frame no. 6 sky frames: start = 3 finish = 9 nreject = 1 Sky subtracting demo07 Frame no. 7 sky frames: start = 4 finish = 10 nreject = 1 Sky subtracting demo08 Frame no. 8 sky frames: start = 5 finish = 11 nreject = 1 Sky subtracting demo09 Frame no. 9 sky frames: start = 6 finish = 12 nreject = 1 Sky subtracting demo10 Frame no. 10 sky frames: start = 7 finish = 13 nreject = 1 Sky subtracting demo11 Frame no. 11 sky frames: start = 8 finish = 14 nreject = 1 Sky subtracting demo12 Frame no. 12 sky frames: start = 9 finish = 15 nreject = 1 Sky subtracting demo13 Frame no. 13 sky frames: start = 10 finish = 16 nreject = 1 Sky subtracting demo14 Frame no. 14 sky frames: start = 11 finish = 17 nreject = 1 Sky subtracting demo15 Frame no. 15 sky frames: start = 12 finish = 18 nreject = 1 Sky subtracting demo16 Frame no. 16 sky frames: start = 13 finish = 19 nreject = 1 Sky subtracting demo17 Frame no. 17 sky frames: start = 14 finish = 20 nreject = 1 Sky subtracting demo18 Frame no. 18 sky frames: start = 15 finish = 21 nreject = 1 Sky subtracting demo19 Frame no. 19 sky frames: start = 16 finish = 22 nreject = 1 Sky subtracting demo20 Frame no. 20 sky frames: start = 17 finish = 23 nreject = 1 Sky subtracting demo21 Frame no. 21 sky frames: start = 18 finish = 24 nreject = 1 Sky subtracting demo22 Frame no. 22 sky frames: start = 19 finish = 25 nreject = 1 Sky subtracting demo23 Frame no. 23 sky frames: start = 21 finish = 25 nreject = 1 Sky subtracting demo24 Frame no. 24 sky frames: start = 22 finish = 25 nreject = 1 Sky subtracting demo25 Frame no. 25 sky frames: start = 22 finish = 25 nreject = 1 .fi This step produces the files "ss_*". The bad pixels, as defined in the bad pixel file, are interpolated away in the sky subtracted images. .nf ---------Fixing bad pixels---------- Fixing bad pixels in file ss_demo01 demo.pl -> demo.imh Image: demo.imh (int) -> Image: demo.imh (short) Fixing bad pixels in file ss_demo02 Fixing bad pixels in file ss_demo03 Fixing bad pixels in file ss_demo04 Fixing bad pixels in file ss_demo05 Fixing bad pixels in file ss_demo06 Fixing bad pixels in file ss_demo07 Fixing bad pixels in file ss_demo08 Fixing bad pixels in file ss_demo09 Fixing bad pixels in file ss_demo10 Fixing bad pixels in file ss_demo11 Fixing bad pixels in file ss_demo12 Fixing bad pixels in file ss_demo13 Fixing bad pixels in file ss_demo14 Fixing bad pixels in file ss_demo15 Fixing bad pixels in file ss_demo16 Fixing bad pixels in file ss_demo17 Fixing bad pixels in file ss_demo18 Fixing bad pixels in file ss_demo19 Fixing bad pixels in file ss_demo20 Fixing bad pixels in file ss_demo21 Fixing bad pixels in file ss_demo22 Fixing bad pixels in file ss_demo23 Fixing bad pixels in file ss_demo24 Fixing bad pixels in file ss_demo25 .fi Cosmic rays are found and replaced in the next step. .nf ---------------Zapping cosmic rays--------------- Working on ss_demo01 ---ZAP!--> ss_demo01 Thresholding image at level 123.2522592 Working on ss_demo02 ---ZAP!--> ss_demo02 Thresholding image at level 121.266304 Working on ss_demo03 ---ZAP!--> ss_demo03 Thresholding image at level 112.1568816 Working on ss_demo04 ---ZAP!--> ss_demo04 Thresholding image at level 110.7964415 Working on ss_demo05 ---ZAP!--> ss_demo05 Thresholding image at level 111.3760094 Working on ss_demo06 ---ZAP!--> ss_demo06 Thresholding image at level 113.7805911 Working on ss_demo07 ---ZAP!--> ss_demo07 Thresholding image at level 111.9656453 Working on ss_demo08 ---ZAP!--> ss_demo08 Thresholding image at level 109.6498382 Working on ss_demo09 ---ZAP!--> ss_demo09 Thresholding image at level 109.0383668 Working on ss_demo10 ---ZAP!--> ss_demo10 Thresholding image at level 111.0720215 Working on ss_demo11 ---ZAP!--> ss_demo11 Thresholding image at level 115.3913998 Working on ss_demo12 ---ZAP!--> ss_demo12 Thresholding image at level 114.1535733 Working on ss_demo13 ---ZAP!--> ss_demo13 Thresholding image at level 111.7433494 Working on ss_demo14 ---ZAP!--> ss_demo14 Thresholding image at level 114.78424 Working on ss_demo15 ---ZAP!--> ss_demo15 Thresholding image at level 115.6892042 Working on ss_demo16 ---ZAP!--> ss_demo16 Thresholding image at level 119.1768534 Working on ss_demo17 ---ZAP!--> ss_demo17 Thresholding image at level 115.94367044 Working on ss_demo18 ---ZAP!--> ss_demo18 Thresholding image at level 119.9937241 Working on ss_demo19 ---ZAP!--> ss_demo19 Thresholding image at level 114.9838365 Working on ss_demo20 ---ZAP!--> ss_demo20 Thresholding image at level 118.6553041 Working on ss_demo21 ---ZAP!--> ss_demo21 Thresholding image at level 121.2542776 Working on ss_demo22 ---ZAP!--> ss_demo22 Thresholding image at level 117.9077447 Working on ss_demo23 ---ZAP!--> ss_demo23 Thresholding image at level 121.44092993 Working on ss_demo24 ---ZAP!--> ss_demo24 Thresholding image at level 128.5635335 Working on ss_demo25 ---ZAP!--> ss_demo25 Thresholding image at level 130.121414 ------- Updating bad pixel file with badpixupdate. ------- .fi The last output line indicated that any pixels which had three or more cosmic rays are marked as bad pixels. The next step is the interative making of the shift list. The sky subtracted images will be loaded into the image display by \fBimexamine\fR and the star above and slightly to the right of the galaxy is marked in each image by pointing the cursor at the star and typing 'a'. The object selected must be common to all images. The first image is display automatically and then subsequent images are displayed by typing 'n'. DO NOT TYPE 'q' UNTIL ALL IMAGES HAVE BEEN MARKED. .nf --------Making the shiftlist---------- Entering imexamine, select a star present in all images and measure it with keystroke (a or r) in each image, go on to each image with n and q after last image. Log file demo.exam open z1=-147.1968 z2=197.6396 # COL LINE RMAG FLUX SKY N RMOM ELLIP PA PEAK FWHM 64.43 47.45 20.48 6406.6 1.91 79 4.23 0.084 -66.6 348.96 3.90 z1=-196.8535 z2=147.1025 57.65 46.79 20.34 7289.9 -12.75 80 4.38 0.247 -62.8 358.13 4.02 z1=-196.7153 z2=146.0894 50.81 46.65 20.69 5298.5 -4.37 80 3.64 0.404 85.7 390.29 3.38 z1=-129.751 z2=173.2378 44.28 46.46 20.36 7167.0 -24.44 80 4.25 0.104 -77.7 336.21 4.33 z1=-166.1011 z2=185.98 37.91 46.59 20.55 5999.2 -15.16 79 3.98 0.314 64.7 433.21 3.06 z1=-141.7368 z2=334.6152 62.36 39.82 20.54 6108.9 -6.06 79 4.09 0.052 75.4 283.43 4.56 z1=-180.7764 z2=309.7374 55.94 39.68 20.39 7012.2 -5.26 78 3.96 0.037 48.6 435.88 3.60 z1=-153.4556 z2=257.8784 51.14 41.34 20.36 7159.2 -17.86 78 4.40 0.120 26.6 389.83 3.66 z1=-202.3242 z2=232.0098 44.62 40.71 20.66 5445.6 -5.26 80 3.88 0.134 -48.0 366.77 3.53 z1=-140.5879 z2=310.1313 38.09 40.69 20.60 5759.9 -3.92 78 3.76 0.115 -14.9 359.87 3.73 z1=-172.2832 z2=228.1123 62.91 34.36 20.62 5646.8 1.21 78 3.70 0.159 86.3 371.63 3.61 z1=-182.394 z2=188.1392 56.78 33.65 20.50 6337.4 4.74 80 3.89 0.353 60.4 423.85 3.28 z1=-238.5684 z2=231.3682 50.42 33.72 20.73 5104.7 13.96 81 3.35 0.252 -83.1 309.83 4.08 z1=-159.8403 z2=253.0239 43.78 33.37 20.71 5185.7 -9.61 80 2.92 0.509 11.5 355.13 3.85 z1=-207.0259 z2=187.7573 38.87 35.02 20.95 4181.9 3.05 77 2.53 0.388 50.1 413.95 2.97 z1=-178.7661 z2=178.6211 63.77 28.22 20.45 6634.2 -8.94 79 4.28 0.182 -9.9 367.28 3.79 z1=-180.5317 z2=174.3682 57.22 28.40 20.63 5622.1 -4.92 80 3.19 0.620 82.8 450.25 3.27 z1=-152.6626 z2=179.3413 50.57 27.98 20.31 7538.0 -15.53 78 4.25 0.035 4.4 461.57 3.39 z1=-190.6323 z2=220.793 44.13 27.44 20.66 5469.8 -3.15 79 3.35 0.285 -79.0 358.91 3.80 z1=-142.9517 z2=161.8154 37.78 27.41 20.46 6570.0 -3.22 80 4.25 0.122 -53.7 385.34 3.66 z1=-159.7183 z2=371.5781 62.59 21.10 20.63 5598.3 1.60 79 3.38 0.454 62.7 365.72 3.77 z1=-198.7695 z2=351.3057 57.55 22.98 20.67 5380.2 -5.57 79 3.64 0.207 57.4 281.00 4.47 z1=-169.0625 z2=357.7622 51.31 22.19 20.52 6202.0 -3.33 79 3.63 0.181 8.0 367.96 3.95 z1=-174.8667 z2=326.6787 45.01 21.72 20.25 7931.4 -33.02 77 4.12 0.161 87.2 527.28 2.96 z1=-230.1367 z2=347.0215 37.91 21.61 20.49 6372.8 -5.36 79 3.75 0.149 -78.4 334.88 4.30 .fi Because we have \fIchk\fR = yes the output of \fBimexamine\fR is shown with an editor. This allows deleting multiple measurements or other unnecessary data. In this example there are not mistakes and this is what the file should look like. .nf # [1] ss_demo01 - Example artificial galaxy cluster # COL LINE RMAG FLUX SKY N RMOM ELLIP PA PEAK FWHM 64.43 47.45 20.48 6406.6 1.91 79 4.23 0.084 -66.6 348.96 3.90 # [2] ss_demo02 - Example artificial galaxy cluster 57.65 46.79 20.34 7289.9 -12.75 80 4.38 0.247 -62.8 358.13 4.02 # [3] ss_demo03 - Example artificial galaxy cluster 50.81 46.65 20.69 5298.5 -4.37 80 3.64 0.404 85.7 390.29 3.38 # [4] ss_demo04 - Example artificial galaxy cluster 44.28 46.46 20.36 7167.0 -24.44 80 4.25 0.104 -77.7 336.21 4.33 # [5] ss_demo05 - Example artificial galaxy cluster 37.91 46.59 20.55 5999.2 -15.16 79 3.98 0.314 64.7 433.21 3.06 # [6] ss_demo06 - Example artificial galaxy cluster 62.36 39.82 20.54 6108.9 -6.06 79 4.09 0.052 75.4 283.43 4.56 # [7] ss_demo07 - Example artificial galaxy cluster 55.94 39.68 20.39 7012.2 -5.26 78 3.96 0.037 48.6 435.88 3.60 # [8] ss_demo08 - Example artificial galaxy cluster 51.14 41.34 20.36 7159.2 -17.86 78 4.40 0.120 26.6 389.83 3.66 # [9] ss_demo09 - Example artificial galaxy cluster 44.62 40.71 20.66 5445.6 -5.26 80 3.88 0.134 -48.0 366.77 3.53 # [10] ss_demo10 - Example artificial galaxy cluster 38.09 40.69 20.60 5759.9 -3.92 78 3.76 0.115 -14.9 359.87 3.73 # [11] ss_demo11 - Example artificial galaxy cluster 62.91 34.36 20.62 5646.8 1.21 78 3.70 0.159 86.3 371.63 3.61 # [12] ss_demo12 - Example artificial galaxy cluster 56.78 33.65 20.50 6337.4 4.74 80 3.89 0.353 60.4 423.85 3.28 # [13] ss_demo13 - Example artificial galaxy cluster 50.42 33.72 20.73 5104.7 13.96 81 3.35 0.252 -83.1 309.83 4.08 # [14] ss_demo14 - Example artificial galaxy cluster 43.78 33.37 20.71 5185.7 -9.61 80 2.92 0.509 11.5 355.13 3.85 # [15] ss_demo15 - Example artificial galaxy cluster 38.87 35.02 20.95 4181.9 3.05 77 2.53 0.388 50.1 413.95 2.97 # [16] ss_demo16 - Example artificial galaxy cluster 63.77 28.22 20.45 6634.2 -8.94 79 4.28 0.182 -9.9 367.28 3.79 # [17] ss_demo17 - Example artificial galaxy cluster 57.22 28.40 20.63 5622.1 -4.92 80 3.19 0.620 82.8 450.25 3.27 # [18] ss_demo18 - Example artificial galaxy cluster 50.57 27.98 20.31 7538.0 -15.53 78 4.25 0.035 4.4 461.57 3.39 # [19] ss_demo19 - Example artificial galaxy cluster 44.13 27.44 20.66 5469.8 -3.15 79 3.35 0.285 -79.0 358.91 3.80 # [20] ss_demo20 - Example artificial galaxy cluster 37.78 27.41 20.46 6570.0 -3.22 80 4.25 0.122 -53.7 385.34 3.66 # [21] ss_demo21 - Example artificial galaxy cluster 62.59 21.10 20.63 5598.3 1.60 79 3.38 0.454 62.7 365.72 3.77 # [22] ss_demo22 - Example artificial galaxy cluster 57.55 22.98 20.67 5380.2 -5.57 79 3.64 0.207 57.4 281.00 4.47 # [23] ss_demo23 - Example artificial galaxy cluster 51.31 22.19 20.52 6202.0 -3.33 79 3.63 0.181 8.0 367.96 3.95 # [24] ss_demo24 - Example artificial galaxy cluster 45.01 21.72 20.25 7931.4 -33.02 77 4.12 0.161 87.2 527.28 2.96 # [25] ss_demo25 - Example artificial galaxy cluster 37.91 21.61 20.49 6372.8 -5.36 79 3.75 0.149 -78.4 334.88 4.30 .fi The second stage is to mark as many stars (or compact objects) as can be reliably measured in the middle image. In this case only the star we measured before is reliable. .nf Entering imexamine on reference image, measure stars to align on beginning with the star in all images. Log file demo.stars open z1=-238.5684 z2=231.3682 # COL LINE RMAG FLUX SKY N RMOM ELLIP PA PEAK FWHM 50.43 33.64 20.73 5094.6 13.96 80 3.33 0.243 -87.8 319.94 3.96 .fi As before we review the marked objects with an editor. The file looks as shown below. .nf # [1] ss_demo13 - Example artificial galaxy cluster # COL LINE RMAG FLUX SKY N RMOM ELLIP PA PEAK FWHM 50.43 33.64 20.73 5094.6 13.96 80 3.33 0.243 -87.8 319.94 3.96 .fi Now \fBimcentroid\fR is run to measure the same objects in all the frames when they overlap using the shifts from the object in common in all the frames. The measurements then produce the "shiftlist" described previously. The shiftlist is reviewed using your editor. .nf ss_demo01 -14.04 -13.59 1. ss_demo02 -6.98 -13.39 1. ss_demo03 -0.57 -13.13 1. ss_demo04 6.06 -12.86 1. ss_demo05 12.45 -12.55 1. ss_demo06 -12.25 -6.43 1. ss_demo07 -5.88 -6.01 1. ss_demo08 -1.12 -7.58 1. ss_demo09 5.43 -7.19 1. ss_demo10 12.19 -6.95 1. ss_demo11 -12.97 -0.63 1. ss_demo12 -6.43 -0.07 1. ss_demo13 0. 0. 1. ss_demo14 6.43 0.33 1. ss_demo15 11.32 -1.09 1. ss_demo16 -13.55 5.43 1. ss_demo17 -6.89 5.32 1. ss_demo18 -0.31 6.02 1. ss_demo19 6.16 5.99 1. ss_demo20 12.65 6.22 1. ss_demo21 -12.32 12.72 1. ss_demo22 -7.52 11.01 1. ss_demo23 -0.89 11.44 1. ss_demo24 5.33 11.94 1. ss_demo25 12.4 11.9 1. .fi The shiftlist is used to register the images and combine them with exposure weighting. An exposure map is also created at this point. These are the "first pass" mosaic and exposure map. The images have the specified base name and the extension "_fp". The exposure map has the additional prefix "exp". .nf -------Shifting and coadding images ---------- Shifting ss_demo01 Total effective exposure time for this frame is 60. Shifting ss_demo02 Total effective exposure time for this frame is 60. Shifting ss_demo03 Total effective exposure time for this frame is 60. Shifting ss_demo04 Total effective exposure time for this frame is 60. Shifting ss_demo05 Total effective exposure time for this frame is 60. Shifting ss_demo06 Total effective exposure time for this frame is 60. Shifting ss_demo07 Total effective exposure time for this frame is 60. Shifting ss_demo08 Total effective exposure time for this frame is 60. Shifting ss_demo09 Total effective exposure time for this frame is 60. Shifting ss_demo10 Total effective exposure time for this frame is 60. Shifting ss_demo11 Total effective exposure time for this frame is 60. Shifting ss_demo12 Total effective exposure time for this frame is 60. Shifting ss_demo13 Total effective exposure time for this frame is 60. Shifting ss_demo14 Total effective exposure time for this frame is 60. Shifting ss_demo15 Total effective exposure time for this frame is 60. Shifting ss_demo16 Total effective exposure time for this frame is 60. Shifting ss_demo17 Total effective exposure time for this frame is 60. Shifting ss_demo18 Total effective exposure time for this frame is 60. Shifting ss_demo19 Total effective exposure time for this frame is 60. Shifting ss_demo20 Total effective exposure time for this frame is 60. Shifting ss_demo21 Total effective exposure time for this frame is 60. Shifting ss_demo22 Total effective exposure time for this frame is 60. Shifting ss_demo23 Total effective exposure time for this frame is 60. Shifting ss_demo24 Total effective exposure time for this frame is 60. Shifting ss_demo25 Total effective exposure time for this frame is 60. .fi The orientation of the final image is done next if needed. In this example the images are left in their observed orientation. The effective exposure time and other header parameters are updated. .nf Updating header information. demo_fp,exptime: 1. -> 1 demo_fp updated demo_fp,i_title: shifted -> "Register mosaic sum: Example artificial galaxy cluster" demo_fp updated expdemo_fp,i_title: scaling -> "Exposure time map: Example artificial galaxy cluster" expdemo_fp updated demo_fp,SKYMED deleted demo_fp updated .fi This marks the end of the first pass. The "mask pass" begins by creating a mask of the object cores in the first pass mosaic, "deregistering" it to correspond to each individual image in the dither pattern, and removing any cosmic rays previously found in areas covered by the objects. .nf ---------Making masks for unzapping object cores--------- Recommended thresholding level for mask is 0.24144105 z1=-0.5070791 z2=0.8764511 .fi With the \fIchk\fR flag the exposure map and RMS balanced mosaic image is display with \fBimexamine\fR after the recommended threshold value is printed. You can check the pixel levels with the display or using the \fBimexam\fR commands. When done type 'q'. You are asked for a cutoff value. This is a value above the median background. The reported threshold will differ from your input because of the median background level which will not be exactly zero. .nf Cutoff point for replacement: \fB.24\fR Thresholding image at level 0.234075731 .fi Now the first pass mosaic image and the mask are displayed and you can decide if you want to make a new mask with a different threshold. In the example with say "no". The mask is then deregistered to each observation and any cosmic rays candidates within the objects in the mask are restored. .nf z1=-1.261593 z2=1.342784 z1=0. z2=1. Keep checking mask? (yes): \fBno\fR ------ Deregistering unzap mask subsections ------ Making mask images for demo01 Making mask images for demo02 Making mask images for demo03 Making mask images for demo04 Making mask images for demo05 Making mask images for demo06 Making mask images for demo07 Making mask images for demo08 Making mask images for demo09 Making mask images for demo10 Making mask images for demo11 Making mask images for demo12 Making mask images for demo13 Making mask images for demo14 Making mask images for demo15 Making mask images for demo16 Making mask images for demo17 Making mask images for demo18 Making mask images for demo19 Making mask images for demo20 Making mask images for demo21 Making mask images for demo22 Making mask images for demo23 Making mask images for demo24 Making mask images for demo25 ------ Unzapping existing crmasks ------ .fi A lower threshold mask of the objects is now made. The same steps of display and threshold adjustment are given when \fIchk\fR is yes. After being satisfied with the object mask it is also deregistered. The object masks are used in a second pass of sky subtraction to avoid using pixels covered by faint objects as part of the sky. .nf ---------Making masks for sky subtraction--------- Recommended thresholding level for mask is 0.24144105 z1=-0.5070791 z2=0.8764511 Cutoff point for replacement: .18 Thresholding image at level 0.174075731 z1=-1.261593 z2=1.342784 z1=0. z2=1. Keep checking mask? (yes): \fBno\fR ------ Deregistering skysub mask subsections ------ Making mask images for demo01 Making mask images for demo02 Making mask images for demo03 Making mask images for demo04 Making mask images for demo05 Making mask images for demo06 Making mask images for demo07 Making mask images for demo08 Making mask images for demo09 Making mask images for demo10 Making mask images for demo11 Making mask images for demo12 Making mask images for demo13 Making mask images for demo14 Making mask images for demo15 Making mask images for demo16 Making mask images for demo17 Making mask images for demo18 Making mask images for demo19 Making mask images for demo20 Making mask images for demo21 Making mask images for demo22 Making mask images for demo23 Making mask images for demo24 Making mask images for demo25 ---------- Sky subtracting images ------------- Calculating scaling for demo01 Calculating scaling for demo02 Calculating scaling for demo03 Calculating scaling for demo04 Calculating scaling for demo05 Calculating scaling for demo06 Calculating scaling for demo07 Calculating scaling for demo08 Calculating scaling for demo09 Calculating scaling for demo10 Calculating scaling for demo11 Calculating scaling for demo12 Calculating scaling for demo13 Calculating scaling for demo14 Calculating scaling for demo15 Calculating scaling for demo16 Calculating scaling for demo17 Calculating scaling for demo18 Calculating scaling for demo19 Calculating scaling for demo20 Calculating scaling for demo21 Calculating scaling for demo22 Calculating scaling for demo23 Calculating scaling for demo24 Calculating scaling for demo25 Sky subtracting demo01 Frame no. 1 sky frames: start = 1 finish = 4 nreject = 1 There are 2 holes in output image ss_demo01 Sky subtracting demo02 Frame no. 2 sky frames: start = 1 finish = 4 nreject = 1 There are 3 holes in output image ss_demo02 Sky subtracting demo03 Frame no. 3 sky frames: start = 1 finish = 5 nreject = 1 Sky subtracting demo04 Frame no. 4 sky frames: start = 1 finish = 7 nreject = 1 Sky subtracting demo05 Frame no. 5 sky frames: start = 2 finish = 8 nreject = 1 Sky subtracting demo06 Frame no. 6 sky frames: start = 3 finish = 9 nreject = 1 Sky subtracting demo07 Frame no. 7 sky frames: start = 4 finish = 10 nreject = 1 Sky subtracting demo08 Frame no. 8 sky frames: start = 5 finish = 11 nreject = 1 Sky subtracting demo09 Frame no. 9 sky frames: start = 6 finish = 12 nreject = 1 Sky subtracting demo10 Frame no. 10 sky frames: start = 7 finish = 13 nreject = 1 Sky subtracting demo11 Frame no. 11 sky frames: start = 8 finish = 14 nreject = 1 Sky subtracting demo12 Frame no. 12 sky frames: start = 9 finish = 15 nreject = 1 Sky subtracting demo13 Frame no. 13 sky frames: start = 10 finish = 16 nreject = 1 Sky subtracting demo14 Frame no. 14 sky frames: start = 11 finish = 17 nreject = 1 Sky subtracting demo15 Frame no. 15 sky frames: start = 12 finish = 18 nreject = 1 Sky subtracting demo16 Frame no. 16 sky frames: start = 13 finish = 19 nreject = 1 Sky subtracting demo17 Frame no. 17 sky frames: start = 14 finish = 20 nreject = 1 Sky subtracting demo18 Frame no. 18 sky frames: start = 15 finish = 21 nreject = 1 Sky subtracting demo19 Frame no. 19 sky frames: start = 16 finish = 22 nreject = 1 Sky subtracting demo20 Frame no. 20 sky frames: start = 17 finish = 23 nreject = 1 Sky subtracting demo21 Frame no. 21 sky frames: start = 18 finish = 24 nreject = 1 Sky subtracting demo22 Frame no. 22 sky frames: start = 19 finish = 25 nreject = 1 Sky subtracting demo23 Sky subtracting demo23 Frame no. 23 sky frames: start = 21 finish = 25 nreject = 1 There are 1 holes in output image ss_demo23 Sky subtracting demo24 Frame no. 24 sky frames: start = 22 finish = 25 nreject = 1 There are 2 holes in output image ss_demo24 Sky subtracting demo25 Frame no. 25 sky frames: start = 22 finish = 25 nreject = 1 There are 3 holes in output image ss_demo25 .fi As before the bad pixels are interpolated away in the new sky subtracted images. One possible difference is that the bad pixel mask may have additional bad pixels due to earlier detection as apparent cosmic ray events occuring repeatedly in the same pixel. .nf ----------Correcting bad pixels ------------- Fixing bad pixels in file ss_demo01 demo.pl -> demo.imh Image: demo.imh (int) -> Image: demo.imh (short) Fixing bad pixels in file ss_demo02 Fixing bad pixels in file ss_demo03 Fixing bad pixels in file ss_demo04 Fixing bad pixels in file ss_demo05 Fixing bad pixels in file ss_demo06 Fixing bad pixels in file ss_demo07 Fixing bad pixels in file ss_demo08 Fixing bad pixels in file ss_demo09 Fixing bad pixels in file ss_demo10 Fixing bad pixels in file ss_demo11 Fixing bad pixels in file ss_demo12 Fixing bad pixels in file ss_demo13 Fixing bad pixels in file ss_demo14 Fixing bad pixels in file ss_demo15 Fixing bad pixels in file ss_demo16 Fixing bad pixels in file ss_demo17 Fixing bad pixels in file ss_demo18 Fixing bad pixels in file ss_demo19 Fixing bad pixels in file ss_demo20 Fixing bad pixels in file ss_demo21 Fixing bad pixels in file ss_demo22 Fixing bad pixels in file ss_demo23 Fixing bad pixels in file ss_demo24 Fixing bad pixels in file ss_demo25 .fi Another round of cosmic ray detection is done using the more sensitive object masks based on the first pass mosaic rather than generating a mask for each individual observation. As before any repeated cosmic ray detections are flagged as likely bad pixels in the bad pixel file. .nf ---------- Zapping cosmic rays ------------- No object masking will be used during zapping. Working on ss_demo01 ---ZAP!--> ss_demo01 Working on ss_demo02 ---ZAP!--> ss_demo02 Working on ss_demo03 ---ZAP!--> ss_demo03 Working on ss_demo04 ---ZAP!--> ss_demo04 Working on ss_demo05 ---ZAP!--> ss_demo05 Working on ss_demo06 ---ZAP!--> ss_demo06 Working on ss_demo07 ---ZAP!--> ss_demo07 Working on ss_demo08 ---ZAP!--> ss_demo08 Working on ss_demo09 ---ZAP!--> ss_demo09 Working on ss_demo10 ---ZAP!--> ss_demo10 Working on ss_demo11 ---ZAP!--> ss_demo11 Working on ss_demo12 ---ZAP!--> ss_demo12 Working on ss_demo13 ---ZAP!--> ss_demo13 Working on ss_demo14 ---ZAP!--> ss_demo14 Working on ss_demo15 ---ZAP!--> ss_demo15 Working on ss_demo16 ---ZAP!--> ss_demo16 Working on ss_demo17 ---ZAP!--> ss_demo17 Working on ss_demo18 ---ZAP!--> ss_demo18 Working on ss_demo19 ---ZAP!--> ss_demo19 Working on ss_demo20 ---ZAP!--> ss_demo20 Working on ss_demo21 ---ZAP!--> ss_demo21 Working on ss_demo22 ---ZAP!--> ss_demo22 Working on ss_demo23 ---ZAP!--> ss_demo23 Working on ss_demo24 ---ZAP!--> ss_demo24 Working on ss_demo25 ---ZAP!--> ss_demo25 ------- Updating bad pixel file --------- .fi The final step is to block replicate each image by four and shift and combine with quarter pixel accuracy. This produces the final mosaic image with extension "_mp" and a final exposure map. .nf ------Magshifting and coadding images ------ Shifting ss_demo01 Using prefixed cosmic ray mask file: crmask_ss_demo01.pl Using 'holes' mask file holes_ss_demo01.pl Total effective exposure time for this frame is 60. Shifting ss_demo02 Using prefixed cosmic ray mask file: crmask_ss_demo02.pl Using 'holes' mask file holes_ss_demo02.pl Total effective exposure time for this frame is 60. Shifting ss_demo03 Using prefixed cosmic ray mask file: crmask_ss_demo03.pl Total effective exposure time for this frame is 60. Shifting ss_demo04 Using prefixed cosmic ray mask file: crmask_ss_demo04.pl Total effective exposure time for this frame is 60. Shifting ss_demo05 Using prefixed cosmic ray mask file: crmask_ss_demo05.pl Total effective exposure time for this frame is 60. Shifting ss_demo06 Using prefixed cosmic ray mask file: crmask_ss_demo06.pl Total effective exposure time for this frame is 60. Shifting ss_demo07 Using prefixed cosmic ray mask file: crmask_ss_demo07.pl Total effective exposure time for this frame is 60. Shifting ss_demo08 Using prefixed cosmic ray mask file: crmask_ss_demo08.pl Total effective exposure time for this frame is 60. Shifting ss_demo09 Using prefixed cosmic ray mask file: crmask_ss_demo09.pl Total effective exposure time for this frame is 60. Shifting ss_demo10 Using prefixed cosmic ray mask file: crmask_ss_demo10.pl Total effective exposure time for this frame is 60. Shifting ss_demo11 Using prefixed cosmic ray mask file: crmask_ss_demo11.pl Total effective exposure time for this frame is 60. Shifting ss_demo12 Using prefixed cosmic ray mask file: crmask_ss_demo12.pl Total effective exposure time for this frame is 60. Shifting ss_demo13 Using prefixed cosmic ray mask file: crmask_ss_demo13.pl Total effective exposure time for this frame is 60. Shifting ss_demo14 Using prefixed cosmic ray mask file: crmask_ss_demo14.pl Total effective exposure time for this frame is 60. Shifting ss_demo15 Using prefixed cosmic ray mask file: crmask_ss_demo15.pl Total effective exposure time for this frame is 60. Shifting ss_demo16 Using prefixed cosmic ray mask file: crmask_ss_demo16.pl Total effective exposure time for this frame is 60. Shifting ss_demo17 Using prefixed cosmic ray mask file: crmask_ss_demo17.pl Total effective exposure time for this frame is 60. Shifting ss_demo18 Using prefixed cosmic ray mask file: crmask_ss_demo18.pl Total effective exposure time for this frame is 60. Shifting ss_demo19 Using prefixed cosmic ray mask file: crmask_ss_demo19.pl Total effective exposure time for this frame is 60. Shifting ss_demo20 Using prefixed cosmic ray mask file: crmask_ss_demo20.pl Total effective exposure time for this frame is 60. Shifting ss_demo21 Using prefixed cosmic ray mask file: crmask_ss_demo21.pl Total effective exposure time for this frame is 60. Shifting ss_demo22 Using prefixed cosmic ray mask file: crmask_ss_demo22.pl Total effective exposure time for this frame is 60. Shifting ss_demo23 Using prefixed cosmic ray mask file: crmask_ss_demo23.pl Using 'holes' mask file holes_ss_demo23.pl Total effective exposure time for this frame is 60. Shifting ss_demo24 Using prefixed cosmic ray mask file: crmask_ss_demo24.pl Using 'holes' mask file holes_ss_demo24.pl Total effective exposure time for this frame is 60. Shifting ss_demo25 Using prefixed cosmic ray mask file: crmask_ss_demo25.pl Using 'holes' mask file holes_ss_demo25.pl Total effective exposure time for this frame is 60. Updating header information. demo_mp,exptime: 1. -> 1 demo_mp updated demo_mp,i_title: shifted -> "Register mosaic sum: Example artificial galaxy cluster" demo_mp updated expdemo_mp,i_title: scaling -> "Exposure time map: Example artificial galaxy cluster" expdemo_mp updated demo_mp,BPM deleted demo_mp,HOLES deleted demo_mp,SKYMED deleted demo_mp updated .fi Now that we are done we can look at the results. We will load the truth image, the first pass mosaic, and the mask pass mosaic into the image display. With XImtool this will allow blinking. With SAOimage you would have to actively setup the psuedoblink option. Note that the final sizes are different so things will not appear exactly registered. .nf di> \fBdisplay demo_truth 1 fill+\fR z1=4980.423 z2=5045.703 di> \fBdisplay demo_fp 2 fill+\fR z1=-1.261593 z2=1.342784 di> \fBdisplay demo_mp 3 fill+\fR z1=-0.08657328 z2=0.1074913 .fi .endhelp iraf-xdimsum-main/doc/iterstat.hlp000066400000000000000000000045711455666516400175470ustar00rootroot00000000000000.help iterstat Sep00 xdimsum .ih NAME iterstat -- compute image statistics using iterative rejection .ih USAGE iterstat inlist .ih PARAMETERS .ls inlist The list of images for which the statistics are to be computed. .le .ls statsec = "" The input image section used to compute the statistics. Statsec is ignored if the input image name includes a section specification. .le .ls lower = INDEF The initial lower bad data limit. .le .ls upper = INDEF The initial upper bad data limit. .le .ls nsigrej = 3.0 The k-sigma bad data rejection criterion. .le .ls maxiter = 20 The maximum number of bad data rejection cycles. .le .ls show = yes Print the results for the final iteration ? .le .ls verbose = yes Print the results for each iteration ? .le .ls imean The returned image mean estimate. .le .ls isigma The returned image standard deviation estimate. .le .ls imedian The returned image median estimate. .le .ls imode The returned image mode estimate. .le .ih DESCRIPTION The mean, standard deviation, median, and mode are estimated for each input image in \fIinlist\fR using iterative rejection around the mean and stored in the output parameters \fIimean\fR, \fIisigma\fR, \fIimedian\fR, and \fIimode\fR. Results for each iteration are printed on the terminal if \fIverbose\fR = yes, and for the final result only if \fIshow\fR = yes. If \fIstatsec\fR is defined and the input image name does not include an image section then the statistics are computed inside statsec. If the input image name does include an image section statsec is ignored. Initial values for the image statistics are computed after rejected data outside the limits defined by the \fIlower\fR and \fIupper\fR parameters. New bad data limits are computed using the mean and sigma computed by the previous iteration and value of the \fInsigrej\fR parameter. ITERSTAT terminates if the number of iterations >= \fImaxiter\fR or if no new bad pixels are detected. ITERSTAT is a script task which makes repeated calls to IMSTATISTICS to compute the actual statistics. More information about the ITERSTAT algorithms can be found in the help page for the IMSTATISTICS task. .ih EXAMPLES 1. Compute the statistics for an image. .nf cl> iterstat demo01 .fi 2. Compute the statistics for the list of demo images but print only the final result. .nf cl> iterstat @demo.list verbose- .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO imstatistics .endhelp iraf-xdimsum-main/doc/makemask.hlp000066400000000000000000000113311455666516400174710ustar00rootroot00000000000000.help makemask Sep00 xdimsum .ih NAME makemask -- create object masks for a list of input images .ih USAGE makemask inlist outlist .ih PARAMETERS .ls inlist The list of input images for which object masks are to be created. .le .ls outlist The list of output masks. The number output masks must be the same as the number of input images. list of output masks. The number output masks must be the same as the number of input images. .le .ls hinlist = "" The list of images to which BPM keywords containing the name of the output maks are to be added. Hinlist may be the same as or different from inlist. .le .ls subsample = 1 The block averaging factor applied to the input image before median filtering. .le .ls checklimits = yes Check the input image data limits for the fast median filter ? If checklimits is yes then the lower and upper data limits are set to max (\fIzmin\fR, image_min) and min (\fIzmax\fR, image_max) respectively. If checklimits is no no image data limits checking is done. .le .ls zmin = -32767, zmax = 32767 The default data limits supplied to the fast median filter if \fIchecklimits\fR is yes. .le .ls filtsize = 15 The size of the fast median filter used to determine the background. The effective size of the median filter is \fIsubsample\fR * filtsize. .le .ls nsmooth = 3 The size of the boxcar smoothing filter applied to the median filtered image. .le .ls statsec = "" The input image section used to compute the recommended object detection threshold. .le .ls nsigrej = 3.0 The bad pixel rejection criterion used to compute the recommended object detection threshold. .le .ls maxiter = 20 The maximum number of bad pixel rejection iterations used to compute the recommended object detection threshold. .le .ls threshtype = "nsigma" The threshold setting algorithm. The options are "nsigma" and "constant". .ls nsigma Set the threshold to the background sky value plus the value of \fInsigthresh\R * the sky background sigma. .le .ls constant Set the threshold to the background sky value plus the value of \fIconstthresh\fR. .le .le .ls nsigthresh = 2.0 The number of sky background sigma used to defined the threshold value for background detection. .le .ls constthresh = 0.0 The constant threshold value .le .ls negthresh = no Set a negative as well as a positive masking threshold ? .le .ls ngrow = 0 The half_width of the region growing box. Only positive features are subject to region growing. .le .ls verbose = no Print messages about the progress of the task. .le .ih DESCRIPTION MAKEMASK creates object masks called \fIoutlist\fR for the input images \fIinlist\fR using a median filtering and thresholding technique. If \fIhinlist\fR is defined the output object mask names are written to image header BPM keyword. Hinlist does not have to be the same as \fIinlist\fR. Before median filtering the normalized input image is block-averaged by a factor of \fIsubsample\fR. The size of the median filter \fIfiltsize\fR refers to the block-averaged image. Therefore the effective size of the median filter is actually subsample * filtsize. The median filter can be protected against deviant values by setting \fIchecklimits\fR to yes and \fIzmin\fR and \fIzmax\fR to reasonable values. If \fIfiltsize\fR < 1 then no block averaging, median filtering, or block replication is done. The median value of the input image pixels is computed using pixels in \fIstatsec\fR and iterative rejection with rejection parameters of \fInsigrej\fR and \fImaxiter\fR. After the image statistics computation but before thresholding the image is smoothed using a boxcar filter of size \fInsmooth\fR. If \fIthreshtype\fR = "nsigma" the threshold value is set to .nf pthreshold = median + \fInsigthresh\fR * sigma / \fInsmooth\fR if (negthresh) nthreshold = median - \fInsigthresh\fR * sigma / \fInsmooth\fR else nthreshold = -1.0e37 .fi otherwise it is set to .nf pthreshold = median + \fIconstthresh\fR if (negthresh) nthreshold = median - \fIconstthresh\fR else nthreshold = -1.0e37 .fi The image pixels greater than or or less than the detection threshold are set to 1 in the output object mask. The remaining pixels are set to 0. If \fIngrow\fR > 0 pixels within a box of half-width \fIngrow\fR pixels around positive "objects" are assumed to be object pixels. If \fIverbose \f R= yes then detailed messages about the progress of the task are printed on the screen. .ih EXAMPLES 1. Create object masks for a list of sky subtracted images .nf cl> type imlist demo01.sub demo02.sub ... demo25.sub cl> type outlist demo01.sub.msk demo02.sub.msk ... demo25.sub.msk cl> makemask @imlist @outlist nsigrej=5.0 maxiter=10 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO mkmask, blkavg, fmedian, boxcar, imexpr .endhelp iraf-xdimsum-main/doc/maskdereg.hlp000066400000000000000000000066061455666516400176530ustar00rootroot00000000000000.help maskdereg Sep00 xdimsum .ih NAME maskdereg -- create individual object masks from the combined image mask .ih USAGE maskdereg omask sections outlist .ih PARAMETERS .ls omask The input object mask for the combined image. Omask is usually created by the mkmask task for the combined image created by the xnregistar task. The input object mask is assumed to consist entirely of 1's and 0's with object regions set to 1. .le .ls sections The input sections or corners file usually written by the xnregistar task. Sections contains the name of the original input images, the x and y coordinates of the lower left corner of the input image in the combined image, and the x and y coordinates of the upper right corner of the input image in the combined image, in columns 1 through 5 respectively. .le .ls outlist The list of output image masks or the string appended to the input image names in \fIsections\fR to create the output individual mask names. .le .ls y2n_angle = 0.0 The angle in degrees from the image y axis to the north axis measured from north through east. Y2n_angle is used to reorient the input object mask before creating the individual output object masks. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? Y2n_angle is used to reorient the input object mask before creating the individual output object masks. .le .ls mkcrmask = no Create object masks for comparison with the cosmic ray masks or for use with the second pass sky subtraction task xslm ? .le .ls update = yes Write the names of the output object masks to the headers of the input images. If mkcrmask is "no" the object mask name keyword is "OBJMASK", if mkcrmask is "yes" it is "CROBJMAS". .le .ih DESCRIPTION MASKDEREG creates individual object masks for the original input images using the object mask \fIomask\fR for the combined image written by the MKMASK task and the sections file \fIsections\fR written by the XNREGISTAR task. The sections file contains the name of the original input image, the x and y coordinates of the lower left corner of the input image in the combined image, and the x and y coordinates of the upper right corner of the input image in the combined image, in columns 1 through 5. The output object masks are assigned names of the form input image name // outlist if outlist begins with a ".", e.g. "demo01.msk.pl" if outlist = ".msk", and the original image name is "demo01.fits". All object masks are assumed to consist entirely of 0's and 1's with the object regions assigned values of 1. By default XNREGISTAR orients the combined image to within 45 degrees of north pointing up and east pointing left. Therefore the input object mask created by MKMASK will normally have this orientation is well. The parameters \fIy2n_angle\fR and \fIrotation\fR are used to reorient the input object mask so that the orientation of the individual output object masks matches the orientation of the original images. If \fIupdate\fR is "yes" then the name of output object mask is written into the header of the original input image. If \fImkcrmask\fR is "no" the object mask keyword is "OBJMASK", otherwise it is "CROBJMAS". .ih EXAMPLES 1. Create individual object masks from a combined image mask. .nf cl> maskdereg mosaic.msk mosaic.corners ".obm" y2n_angle=0.0 \ rotation+ mkcrmask- update+ .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xnregistar,mkmask,orient .endhelp iraf-xdimsum-main/doc/maskfix.hlp000066400000000000000000000032441455666516400173460ustar00rootroot00000000000000.help maskfix Sep00 xdimsum .ih NAME maskfix -- replace bad pixels in images .ih USAGE maskfix inlist bpmasks bpvalue .ih PARAMETERS .ls inlist The list of input images in which the bad pixels are to be fixed. .le .ls bpmasks The list of bad pixel masks corresponding to inlist. Bad pixel masks are assumed to be the same size as the input images and to consist entirely of 0's and 1's with bad pixel values equal to badval. The number of bad pixel masks must be 1 or equal to the number of input images. .le .ls badval The input mask bad pixel value which must be 0 or 1. .le .ls forcefix = no If forcefix = yes then all bad pixels in inlist are replaced. If forcefix = no and the input images contain the keyword "MASKFIX" then maskfix assumes that the bad pixels have already been fixed and no further pixel editing is done. .le .ih DESCRIPTION MASKFIX replaces bad pixels in \fIinlist\fR by linearly interpolating across bad columns within each image line. The bad pixels are assumed to be those pixels in the bad pixel masks \fIbpmasks\fR which have a value of \fIbadval\fR. MASKFIX writes the keyword "MASKFIX" to the input image header when it completes replacing the bad pixels. If \fIforcefix\fR = no and the keyword "MASKFIX" already exists in the input image header then no further image editing is done. If \fIforcefix\fR = yes bad pixel replacement is performed regardless of the presence or absence of "MASKFIX". .ih EXAMPLES 1. Replace bad pixels in an image. .nf cl> maskfix demo01.sub.imh demo.pl 0 .fi 1. Replace bad pixels in a list of images using a single bad pixel mask. .nf cl> maskfix @sslist demo.pl 0 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO .endhelp iraf-xdimsum-main/doc/maskstat.hlp000066400000000000000000000064051455666516400175350ustar00rootroot00000000000000.help maskstat Sep00 xdimsum .ih NAME maskstat -- compute image statistics through a mask .ih USAGE maskstat inlist masks goodvalue .ih PARAMETERS .ls inlist The list of images for which the statistics are to be computed. .le .ls masks The good data masks associated with inlist. Good data masks are assumed to consist entirely of 1's and 0's and to be the same size as the images in inlist. The number of masks must be one or equal to the number of input images. .le .ls goodvalue The input mask good data value which must be 1 or 0. .le .ls statsec = "" The input image section used to compute the statistics. If statsec is defined the input image and input mask names must not include an image section. .le .ls lower = INDEF The initial lower bad data limit. .le .ls upper = INDEF The initial upper bad data limit. .le .ls iterstat = no Use the iterstat task to compute the image statistics rather than imstatistics. .le .ls nsigrej = 3.0 The k-sigma bad data rejection criterion. .le .ls maxiter = 20 The maximum number of bad data rejection cycles. .le .ls show = yes Print the results for the final iteration ? .le .ls verbose = yes Print the results for each iteration ? .le .ls mean The returned image mean estimate. .le .ls msigma The returned image standard deviation estimate. .le .ls median The returned image median estimate. .le .ls mode The returned image mode estimate. .le .ih DESCRIPTION The mean, standard deviation, median, and mode are estimated for each masked input image in \fIinlist\fR and stored in the output parameters \fImean\fR, \fImsigma\fR, \fImedian\fR, and \fImode\fR. \fIMasks\fR defines either a single mask to be applied to every input image or an individual mask for every input image. If \fIiterstat\fR = yes then the image statistics are computed using iterative rejection, otherwise no iterative rejection is performed. Results for each iteration are printed on the terminal if \fIverbose\fR = yes, and for the final result only if \fIshow\fR = yes. If \fIstatsec\fR is defined then the statistics are computed inside an image section. In that case the input image and mask names must not include an image section. Initial values for the image statistics are computed after applying the mask and rejecting data outside the limits defined by the \fIlower\fR and \fIupper\fR parameters. New bad data limits are computed using the mean and sigma computed by the previous iteration and value of the \fInsigrej\fR parameter. MASKSTAT terminates if the number of iterations >= \fImaxiter\fR or if no new bad pixels are detected. MASKSTAT is a script task which calls ITERSTAT if \fIiterstat\fR = yes or IMSTATISTICS if \fIiterstat\fR = no. More information about the ITERSTAT and IMSTATISTICS algorithms can be found in the help pages for the ITERSTAT and IMSTATISTICS tasks. .ih EXAMPLES 1. Compute the statistics for an image through a mask where the good pixels are defined by mask values of 1. .nf cl> maskstat demo01 demo.pl 1 .fi 2. Repeat the previous example but do the rejection iteratively. .nf cl> maskstat demo01 demo.pl 1 iterstat+ .fi 3. Repeat the previous example but operate on a list of images and print only the final result. .nf cl> maskstat @demo.list demo.pl 1 iterstat+ verbose- .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO imstatistics, iterstat .endhelp iraf-xdimsum-main/doc/miterstat.hlp000066400000000000000000000051061455666516400177170ustar00rootroot00000000000000.help miterstat May02 xdimsum .ih NAME miterstat -- compute image statistics using iterative rejection .ih USAGE miterstat inlist .ih PARAMETERS .ls inlist The list of images for which the statistics are to be computed. .le .ls inmsklist The input mask list. Masks are assumed to consist of 0's and 1's with the 0's defining the good values. To invert the mask on input prefix the name by '^'. .le .ls statsec = "" The input image section used to compute the statistics. Statsec is ignored if the input image name includes a section specification. .le .ls lower = INDEF The initial lower bad data limit. .le .ls upper = INDEF The initial upper bad data limit. .le .ls nsigrej = 3.0 The k-sigma bad data rejection criterion. .le .ls maxiter = 20 The maximum number of bad data rejection cycles. .le .ls show = yes Print the results for the final iteration ? .le .ls verbose = yes Print the results for each iteration ? .le .ls imean The returned image mean estimate. .le .ls isigma The returned image standard deviation estimate. .le .ls imedian The returned image median estimate. .le .ls imode The returned image mode estimate. .le .ih DESCRIPTION The mean, standard deviation, median, and mode are estimated for each input image in \fIinlist\fR using iterative rejection around the mean and stored in the output parameters \fIimean\fR, \fIisigma\fR, \fIimedian\fR, and \fIimode\fR. Results for each iteration are printed on the terminal if \fIverbose\fR = yes, and for the final result only if \fIshow\fR = yes. If \fIstatsec\fR is defined and the input image name does not include an image section then the statistics are computed inside statsec. If the input image name does include an image section statsec is ignored. Initial values for the image statistics are computed after rejected data outside the limits defined by the \fIlower\fR and \fIupper\fR parameters. New bad data limits are computed using the mean and sigma computed by the previous iteration and value of the \fInsigrej\fR parameter. ITERSTAT terminates if the number of iterations >= \fImaxiter\fR or if no new bad pixels are detected. ITERSTAT is a script task which makes repeated calls to IMSTATISTICS to compute the actual statistics. More information about the ITERSTAT algorithms can be found in the help page for the IMSTATISTICS task. .ih EXAMPLES 1. Compute the statistics for an image. .nf cl> miterstat demo01 demo01.pl .fi 2. Compute the statistics for the list of demo images but print only the final result. .nf cl> miterstat @demo.list @ demo.msklist verbose- .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO mimstatistics .endhelp iraf-xdimsum-main/doc/mkmask.hlp000066400000000000000000000103411455666516400171630ustar00rootroot00000000000000.help mkmask Sep00 xdimsum .ih NAME mkmask -- create an object mask for an image with or without an exposure map using a median filter .ih USAGE mkmask input expmap output nthreshold .ih PARAMETERS .ls input The input image name. The input image is assumed but not required to be a mosaic of several input images. .le .ls expmap The input exposure map image which defines the total expsoure per pixel. Expmap is used normalize the input image to uniform pixel-to-pixel noise. If the exposure map is undefined then a uniform exposure level for all the pixels is assumed. .le .ls output The name of the output object mask. .le .ls nthreshold If interactive = no then the object detection threshold used to create the object mask equals nthreshold times the internally computed recommended threshold. .le .ls negthresh = no Use negative as well as positive masking thresholds ? .le .ls statsec = "" The input image section used to compute the recommended object detection threshold. .le .ls nsigrej = 3.0 The bad pixel rejection criterion used to compute the recommended object detection threshold. .le .ls maxiter = 20 The maximum number of bad pixel rejection iterations used to compute the recommended object detection threshold. .le .ls subsample = 1 The block averaging factor applied to the normalized input image before median filtering. .le .ls filtsize = 15 The size of the median filter. The effective size of the median filter is \fIsubsample\fR * filtsize. .le .ls nsmooth = 3 The size of the boxcar smoothing filter applied to the median filtered image. .le .ls ngrow = 0 The half_width of the region growing box. .le .ls interactive = yes Set the value of the object detection threshold interactively ? .le .ls threshold The value of threshold if interactive is yes. .le .ih DESCRIPTION MKMASK creates an object mask called \fIoutput\fR for the input image \fIinput\fR using an optional exposure map \fIexpmap\fR and an object detection threshold set by the user if \fIinteractive\fR is yes or equal to \fInthreshold\fR times an internally computed recommeded number if \fIinteractive\fR is no. MKMASK normalizes the input image to a uniform pixel-to-pixel rms by multiplying by a factor of sqrt (expmap / maxexpmap) where maxexpmap is the maximum exposure level in the exposure map. The standard deviation of the normalized input image pixels is computed using pixels in \fIstatsec\fR and iterative rejection with rejection parameters of \fInsigrej\fR and \fImaxiter\fR. Pixels with 0's in the exposure map are excluded from the image statistics computation. If the exposure map is undefined then a uniform exposure level is assumed. If \fIinteractive\fR = yes the user is prompted for the detection threshold \fIthreshold\fR. If interactive = no the detection threshold is set to \fInthreshold\fR * the recommended threshold where the recommended threshold is defined to be .nf recthreshold = 4.5 * sigma / nsmooth .fi Sigma is the standard deviation of the sky pixels. If \fInegthresh\fR is set to "yes" then both negative and positive masking threshold are used. Before median filtering the normalized input image is block-averaged by a factor of \fIsubsample\fR. The size of the median filter \fIfiltsize\fR refers to the block-averaged image. Therefore the effective size of the median filter is actually subsample * filtsize. After median filtering but before thresholding the image block-replicated to its original size and is smoothed using a boxcar filter of size \fInsmooth\fR. The filtered and smoothed image pixels greater than or equal to the detection threshold are set to 1 in the output object mask. The remaining pixels are set to 0. If \fIngrow\fR > 0 pixels within a box of half-width ngrow pixels are assumed to be object pixels. The actual mask creation is done by the MAKEMASK task. More information on MAKEMASK can be found in the task help page. If \fIinteractive\fR is yes then the final object mask is displayed on the image display. .ih EXAMPLES 1. Create the object mask for the combined image created with xnregistar. .nf cl> mkmask mosaic mosaic.exp mosaic.pl 1.1 statsec="" nsigrej=5.0 \ maxiter=10 nsmooth=3 subsample=2 filtsize=15 ngrow=0 interactive- .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO makemask, blkavg, fmedian, boxcar .endhelp iraf-xdimsum-main/doc/orient.hlp000066400000000000000000000033221455666516400172010ustar00rootroot00000000000000.help orient Sep00 xdimsum .ih NAME orient -- orient an image to with 45 degrees of north is up and east is left .ih USAGE orient input y2n_angle .ih PARAMETERS .ls input The name of the input image to be reoriented. .le .ls y2n_angle The angle in degrees from the image y axis to the north axis measured from north through east. Y2n_angle must be between 0.0 and 360.0 degrees. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? .le .ls invert = no Invert the original reorientation ? If invert = yes then the input image is returned to its original orientation. .le .ih DESCRIPTION ORIENT orients the input image \fIinput\fR to within 45 degrees of north up and east to the left using the geometry parameters \fIy2n_angle\fR and \fIrotation\fR. The reorientation operation can be undone by setting \fIinvert\fR = yes. ORIENT is used by the XNREGISTAR task to orient the output combined image to within 45 degrees of north up and east left, and by the MASKDEREG task to return the object mask created from the combined image to the original orientation before creating object masks for the individual images. .ih EXAMPLES 1. Reorient an image which is already in the default orientation, i.e. do nothing. .nf cl> orient ss_demo01 0.0 rotation+ invert- .fi 2. Reorient an image with north pointing left and east pointing down. .nf cl> orient ss_demo01 90.0 rotation+ invert- .fi 3. Reorient an image with north pointing left and east pointing up and then return it to the original orientation. .nf cl> orient ss_demo01 90.0 rotation- invert- cl> orient ss_demo01 90.0 rotation- invert+ .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xnregistar, maskdereg .endhelp iraf-xdimsum-main/doc/pe.notes000066400000000000000000000400351455666516400166540ustar00rootroot00000000000000Peter, In response to requests for the NOAO Deep Wide Survey team I made some substantial modifications to DIMSUM over the summer. In the fall I revisited what I had done and made some more changes mostly in the area of image and files list handling, default output image and file names, and documention. These changes became substantial enough that I decided to package them up into new version of DIMSUM called XDIMSUM. I would like to distribute this as an external package because I think some of the changes may be of general interest to people. However I would like to check that this is ok with you since XDIMSUM is derived from DIMSUM and if so that you are happy with my introduction. I have already run the pacakge changes by Frank Valdes to make sure his contributions are acknowledged in the introduction. Below is the README file for the modified package. Please make sure I have the credits right! A short summary of some of the differences between XDIMSUM and DIMSUM are listed at the end of the README. If you would like to look at the software ftp to, 140.250.1.1, login as anonymous, cd iraf/extern, retrieve the xdimsum.readme file, and follow the installation instructions. I have quietly put the software there for your easy retrieval but not yet made any anouncement of the fact. I am planning to make some changes to the sky subtraction task in the near term but decided to go ahead and release the current version of the software at the present time. I will be at the AAS beginning tomorrow so may not respond to any comments until later in the week. Regards, Lindsey Davis ----------------------------------------------------------------------------- XDIMSUM -- Experimental Deep Infrared Mosaicing Software XDIMSUM is a package for creating accurate sky subtracted images from sets of dithered observations. While the observations need not be in the infrared, the dominance of the variable sky background in infrared data requires dithering of many short exposures and recombination with careful sky subtraction to produce deep images. Hence the package is called "Experimental Deep Infrared Mosaicing Software" or XDIMSUM. XDIMSUM is a variant of the DIMSUM package developed by P. Eisenhardt, M. Dickensen, S.A. Stanford, and J. Ward. F. Valdes (IRAF group) modified DIMSUM to support FITS format images, added the DIMSUM tutorial demos script, wrote the original version of this document, and repackaged DIMSUM for distribution as an IRAF external package. L. Davis (IRAF group) rewrote the the major DIMSUM scripts to improve their clarity, robustness, and efficiency, added new scripts for computing relative offsets, and documented the tasks. The new package uses the same default algorithms as DIMSUM but is sufficiently different in format that it has been renamed XDIMSUM. A short summary of the major differences between XDIMSUM and DIMSUM is provided below and is duplicated in the on-line user's guide. XDIMSUM is being made available to the community as an external pacakge in the hope that some of the new features may prove useful to others. Users should direct XDIMSUM installation questions, bug reports, questions about technical details, and comments and suggestions to the the IRAF group (iraf@noao.edu) not the original authors. The current contents of the XDIMSUM package are xmosaic - Driver sript for first pass and mask pass processing steps xfirstpass - Driver script for first pass processing steps xmaskpass - Driver script for mask pass processing steps xslm - Sky subtract images using running median maskfix - Fix bad pixel in images using a bad pixel mask xzap - Remove cosmic rays from images using median filtering xnzap - Remove cosmis rays from images using averaging filter badpixupdate - Update bad pixel mask to include bad pixels detected by xzap xnregistar - Mosaic the images using sub-pixel replication and masking mkmask - Create the initial master object mask maskdereg - Deregister master object mask to individual object masks xdshifts - Compute shifts using image display and centroiding techniques xfshifts - Compute shifts using star finding and centroiding techniques xmshifts - Compute shifts using star finding and list matching techniques xrshifts - Compute shifts using x-correlation techniques iterstat - Compute image statistics using iterative rejection xlist - Create image sublists used by xslm makemask - Make an object mask for a single image orient - Reorient image to N up and E left or undo re-orientation sigmanorm - Renormalize mosaic image to uniform pixel-to-pixel rms maskstat - Compute mask statistics using iterative rejection demos - Xdimsum demo data script guide - Guide to using xdimsum with the xmosaic task ------------------------------------------------------------------------------- First Release: January 08, 2000 ------------------------------------------------------------------------------- Standard Installation Instructions For The Xdimsum Package Installation of this external package consists ofobtaining the files, creating a directory containing the package, compiling the executables or installing precompiled executables, and defining the environment to load and run the package. The package may be installed for a site or as a personal installation. If you need help with these installation instructions contactiraf@noao.edu or call the IRAF HOTLINE at 520-318-8160. [arch] In the following steps you will need to know the IRAF architecture identifier for your IRAF installation. This identifier is similar to the host operating system type. The identifiers are things like "ssun" for Solaris, "alpha" for Dec Alpha, and "linux" or "redhat" for most Linux systems. The IRAF architecture identifier is defined when you run IRAF. Start the CL and then type cl> show arch .ssun This is the value you need to know without the leading '.', i.e. the IRAF architecture is "ssun" in the above example. [1-site] If you are installing the package for a site login as IRAF and edit the IRAF file defining the packages. % cd $hlib Define the environment variable xdimsum to be the pathnames to the xdimsum package root directory and the instrument database. The '$' character must be escaped in the VMS pathname and UNIX pathnames must be terminated with a '/'. Edit extern.pkg to include the following. reset xdimsum = /local/xdimsum/ task xdimsum.pkg = xdimsum$xdimsum.cl Near the end of the hlib$extern.pkg file, update the definition of helpdb so it includes the xdimsum help database, copying the syntax already used in the string. Add this line before the line containing a closing quote: ,xdimsum$lib/helpdb.mip\ [1-personal] If you are installing the package for personal use define a host environment variable with the pathname of the directory where the package will be located (needed in order to build the package from the source code). Note that pathnames must end with '/'. For example: % setenv xdimsum /local/xdimsum/ In your login.cl or loginuser.cl file make the following definitions somewhere before the "keep" statement. reset xdimsum = /local/xdimsum/ task xdimsum.pkg = xdimsum$xdimsum.cl printf ("reset helpdb=%s,xdimsum$lib/helpdb.mip\nkeep\n", envget("helpdb")) | cl flpr If you will be compiling the package, as opposed to installing a binary distribution, then you need to define various environment variables. The following is for Unix/csh which is the main supported environment. # Example % setenv iraf /iraf/iraf/ # Path to IRAF root (example) % source $iraf/unix/hlib/irafuser.csh # Define rest of environment % setenv IRAFARCH ssun # IRAF architecture where you need to supply the appropriate path to the IRAF installation root in the first step and the IRAF architecture identifier for your machine in the last step. [2] Login into IRAF. Create a directory to contain the package files and the instrument database files. These directory should be outside the standard IRAF directory tree. cl> mkdir xdimsum$ cl> cd xdimsum [3] The package is distributed as a tar archive of sources. Note that IRAF includes a tar reader. The tar file is most commonly obtained via anonymous ftp. Below is an example from a Unix machine where the compressed files have the ".Z" extension. Files with ".gz" or ".tgz" can be handled similarly. cl> ftp iraf.noao.edu (140.252.1.1) login: anonymous password: [your email address] ftp> cd iraf/extern ftp> get xdimsum.readme ftp> binary ftp> get xdimsum.tar.Z ftp> quit cl> !uncompress xdimsum.tar.Z The readme file contains these instructions. The in the optional executable distribution is replaced by the IRAF architecture identification for your computer. [4] Extract the source files from the tar archive using 'rtar". cl> softools so> rtar -xrf xdimsum.tar so> bye On some systems, an error message will appear ("Copy 'bin.generic' to './bin fails") which can be ignored. Sites should leave the symbolic link 'bin' in the package root directory pointing to 'bin.generic' but can delete any of the bin. directories that won't be used. If there is no binary directory for the system you are installing it will be created when the package is compiled later or when the binaries are installed. If the binary executables have been obtained these are now extracted into the appropriate bin. directory. # Example of sparc installation. cl> cd xdimsum cl> rtar -xrf xdimsum-bin.sparc # Creates bin.sparc directory The tar file can be deleted once it has been successfully installed. [5] For a source installation you now have to build the package executable(s). First you configure the package for the particular architecture. cl> cd xdimsum cl> mkpkg # Substitute sparc, ssun, alpha, etc. This will change the bin link from bin.generic to bin.. The binary directory will be created if not present. If an error occurs in setting the architecture then you may need to add an entry to the file "mkpkg". Just follow the examples in the file. To create the executables and move them to the binary directory cl> mkpkg -p xdimsum update >& xdimsum.spool # build executables cl> mkpkg generic # optionally restore generic setting Check for errors. If the executables are not moved to the binary directory then step [1] to define the path for the package was not done correctly. The last step restores the package to a generic configuration. This is not necessary if you will only have one architecture for the package. This should complete the installation. You can now load the package and begin testing and use. ----------------------------------------------------------------------------- Summary of Major Differences between XDIMSUM and DIMSUM Input and Output Image and Mask Lists All input and output image and file names and input and output image and file lists are now task parameters rather than being silently passed as keyword names, silently assumed to have already been created by a previous step, or silently created by the current step. For example the input object mask list required by the xslm task is now a parameter. Similarly the output sky subtraction and holes mask lists produced the the xslm task are now parameters. These changes make tracing the data flow from one processing step to another simpler. Default Image and Mask Names In most cases the output images and masks are assigned sensible default names if explicit output image and mask lists are not provided. For example in the case of the sky subtraction task xslm the suffix ".sub" is appended to the input images names to produce the output sky subtracted image names, and the suffixes ".ssm" and ".hom" are appended to sky subtracted image names to create the sky subtraction and holes mask names. In general if an output image or mask list parameter value begins with a '.' it is assumed to be a suffix rather than a complete name. The default image and mask name scheme means that users need not concern themselves with the names of the intermediate data products. Use of Suffixes instead of Prefixes to Define Default Names Suffixes instead of prefixes are used to create default names. Using suffixes means that the input and output image lists no longer need to be in the same directory. New Tasks A new cosmic ray removal task xnzap has been added to the XDIMSUM package. Xnzap is a script wrapper for the xcraverage task. Xnzap is an alternative to the default xzap task. It is significantly faster than xzap but not yet as well tested. Users are encouraged to experiment with xnzap and / or xcraverage on their own. User feedback on their effectiveness is welcome. The code for interactively computing the relative shifts in a set of dithered images has been rewritten and moved into a separate task called xdshifts. Three new script tasks for computing shifts for images taken in series with approximately constant shifts between adjacent images: xmshifts, xfshifts, and xrshifts, have been added to XDIMSUM. These scripts use modified versions of the existing starfind and imcentroid tasks called xstarfind and ximcentroid. New Algorithms The main processing scripts xmosaic, xfirstpass, and xmaskpass can now be run repeatedly from scratch without requiring the user to delete any intermediate files. It has also been made simpler to restart these scripts at an intermediate point in the processing. The mask deregistration task maskdereg now permits the user to create individual object masks which are a combination of the current mask and the N previous ones. This feature is useful in cases where the detector retains significant memory of previous exposures. The image and mask statistics computation parameters used by the sky subtraction and cosmic ray removal tasks xslm and xzap, statsec, mstatsec, maxiter, and nreject can now be set by the user. Their default values are now "", "", 20, and 3.0 respectively, instead of being fixed at the values "", "", 10, and 5.0. The maskstat task now outputs the computed mask statistics to the output parameters mean, msigma, median, and mmode in the same manner as the iterstat itask does. The first pass image combining step performed by the xmosaic or xfirstpass tasks now includes an option for doing fractional pixel shifts. The mask pass image combining step performed by the xmosaic or xmaskpass tasks now includes an option for doing image magnification using bilinear interpolation rather than block replication. This means that non-integer magnification factors are supported. Internal Changes Calls to existing IRAF tasks have been reviewed to make sure that all the task parameters are set in order to avoid unpleasant surprises if these parameters are not set at the expected defaults. Complicated image operations requiring several steps have been replaced by a single call to the imexpr task where appropriate. The image registration and combining step has been rewritten to use a new version of the imcombine task called xcombine which does not suffer from the number of open file limit and has better support for pixel masks. The registration should be much faster in most cases. The sections, fileroot, imgets, minmax, iterstat, and maskstat tasks which return values to their parameters have been cached so that XDIMSUM tasks will work correctly in the background. On normal task termination there are now no temporary files or images left either in the tmp$ directory or in the current working directory. iraf-xdimsum-main/doc/sigmanorm.hlp000066400000000000000000000015721455666516400177020ustar00rootroot00000000000000.help sigmanorm Sep00 xdimsum .ih NAME sigmanorm - normalize the input image to uniform pixel-to-pixel rms noise using an exposure map image .ih USAGE sigmanorm input expmap output .ih PARAMETERS .ls input The name of the input image. .le .ls expmap The name of the input exposure map image. .le .ls output The name of the output normalized image. .le .ih DESCRIPTION SIGMANORM divides the input image \fIinput\fR by a factor equal to the square root of the exposure map image \fIexpmap\fR divided by the the maximum exposure value to create the output normalized image \fIoutput\fR which has a uniform pixel-to-pixel rms noise. SIGMANORM is currently used by the MKMASK task. .ih EXAMPLES 1. Create a normalized input image for a first pass mosaic image. .nf cl> sigmanorm fp_mosaic exp_fp_mosaic norm_fp_mosaic .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO mkmask .endhelp iraf-xdimsum-main/doc/xcraverage.hlp000066400000000000000000000240351455666516400200340ustar00rootroot00000000000000.help xcraverage Sep00 xdimsum .ih NAME xcraverage -- detect CRs and objects using average filter .ih USAGE .nf xcraverage input output .fi .ih PARAMETERS .ls input List of input images in which to detect cosmic rays and objects. .le .ls output List of output images in which cosmic rays are replaced by the block average value excluding the cosmic ray. If no output image name is given then no output image will be created. .le .ls crmask = "" List of input and output cosmic ray and object masks. If the mask exists then the mask values are used to exclude data pixels from the calculations and zero mask values are candidates for cosmic rays or objects. Detected cosmic rays and objects are identified in the mask with values given by the \fIcrval\fR and \fIobjval\fR parameters. If no output cosmic ray mask is given then no mask will be created. .le .ls average = "" List of output block average filtered images. If no image name is given then no image will be created. .le .ls sigma = "" List of output sigma images. If no image name is given then no image will be created. .le .ls navg = 5 (minimum of 3) Square block average filter size given as the number of pixels along an edge. The value will be rounded up to an odd value to be symmetrical around the center pixel excluded from the average. .le .ls nrej = 0 (minimum of 0) Number of additional highest pixels to exclude, in addition to the central pixel, in the block average. The value should be small but it is needed to deal with cosmic rays that are bigger than a single pixel. .le .ls nbkg = 5 (minimum of 1) Background annulus width around the box average filter in pixels. The median of the pixels in this annulus is used to estimate the background. .le .ls nsig = 25 (minimum of 10) Square box size for empirical sigma estimates given as the number of pixels along an edge. The sigma is estimated using percentile points of the pixels in the box. The size of the box should contain of order 100 pixels or more. .le .ls var0 = 0., var1 = 0., var2 = 0. Variance coefficients for the variance model. The variance model is .nf variance = var0 + var1 * data + var2 * data^2 .fi where data is the maximum of zero and the average filtered pixel value and the variance is in data numbers. All the coefficients must be positive or zero. If they are all zero then empirical data sigmas are estimated by a percentile method in boxes of size given by \fInsig\fR. .le .ls crval = 1 Mask value for detected cosmic rays. It is legal for the value to be zero to not mark the cosmic rays in the output mask. .le .ls lcrsig = 10., hcrsig = 5. Low and high sigma factors for detecting cosmic rays. These factors multiply the computed or estimated sigma at each pixel and these threshold values are compared to the difference between the candidate pixel and the block average filter value (average of box around the pixel). This only applies to pixels where the block average filter value is within a specified threshold of the background estimate; i.e. the average value is not considered as part of an object. .le .ls crgrow = 0. Cosmic ray growing radius. Pixels detected and marked in the output cosmic ray mask by the \fIcrval\fR value are increased in size in the mask (but not replaced in the output image) by also flagging all zero valued mask pixels within this specified radius with the cosmic ray mask value. This is done after the detection phase is complete. The separation between pixels is the distance between pixel centers computed as a real value. Note a value of at least one is required to affect other mask pixels. .le .ls objval = 0 Mask value for detected objects. It is legal for the value to be zero to not mark the objects in the output mask. .le .ls lobjsig = 10., hobjsig = 5. Low and high sigma factors for detecting objects. These factors multiply the computed or estimated sigma at each pixel and these threshold values are compared to the difference between the block average filter value and the background annulus median. If the values are made very large then object detection can be eliminated and cosmic rays will be detected everywhere. .le .ls objgrow = 0. Object detection growing radius. Pixels detected and marked in the output mask by the \fIobjval\fR value are increased in size in the mask by also flagging all zero valued mask pixels within this specified radius with the cosmic ray mask value. This is done after the detection phase is complete and so object grown pixels are not used in excluding cosmic ray candidates. The separation between pixels is the distance between pixel centers computed as a real value. Note a value of at least one is required to affect other mask pixels. .le .ih DESCRIPTION \fBCraverage\fR detects cosmic rays and objects using a moving block average filter with the central pixel and a specified number of additional highest pixels excluded and a median of an annulus around the block average box. It avoids identification of the cores of objects as cosmic rays by excluding pixels within the detected objects as cosmic ray candidates. The block average filter computes the average of pixels in a box with the central or target pixel excluded. In addition the \fInrej\fR parameter can be used to exclude that number of highest remaining pixels as possible contamination from cosmic rays which are larger than one pixel or possibly a very nearby additional cosmic ray. The \fInrej\fR value should be kept small relative to the total number of pixels in the average so that the average will still be elevated over the median in real underlying objects. The resulting average is used as the prediction for the value of the target pixel. The median of the pixels in a square background annulus around the block average box provides the prediction for the background at the target pixel. The target pixel is considered part of an object if the difference between the average value and the median background exceeds a specified threshold. If the pixel is NOT considered to be part of an object then if the difference between the pixel value and the average value exceeds a different specified threshold it is identified as a cosmic ray. The thresholds are defined in terms of sigma factors, which may be different for positive and negative deviations and for object and cosmic ray identification. The sigma factors multiply an estimate for the statistical sigma of the target pixel. The estimate is either based on a noise model or sigma of pixels in a box near the target pixel. The \fIcrmask\fR parameter specifies a pixel mask for the image. If the mask exists then non-zero mask values will be used to exclude pixels from the average, background median, and empirical sigma estimates. Also any pixels with non-zero mask values will not be altered either in the output image or in the final mask. If the mask does not exist then it behaves as if all mask values are zero. If all pixels in the average box or median annulus are previously flagged then the estimates will be undefined and nothing will be done to the output image or mask. Because the task can use an input mask to mark pixels not to be considered it can be used in an iterative fashion. The noise model is given by the formula .nf variance = var0 + var1 * data + var2 * data^2 .fi where data is the maximum of zero and the average estimate for the target pixel. The coefficients are all given in terms of the data numbers. This model can be related to common detector parameters. For CCDs var0 is the readout noise expressed as a variance in data numbers and var1 is the inverse gain (DN/electrons). The second order coefficient has the interpretation of flat field introduced variance. If all the coefficients are zero then an empirical sigma is estimated as follows. The input image is divided into square blocks of size \fInsig\fR. The (unmasked) pixel values in a block are sorted and the pixel values nearest the 15.9 and 84.1 percentiles are selected. These are the one sigma points in a Gaussian distribution. The sigma estimate is the difference of these two values divided by two. This algorithm is used to avoid contamination of the sigma estimate by the bad pixel values. The block size must be at least 10 pixels in each dimension to provide sufficient pixels for a good estimate of the percentile points. The sigma estimate for a pixel is the sigma from the nearest block. A moving box is not used for reasons of efficiency. If an output image name is specified then the output image is produced as a copy of the input image but with the identified cosmic ray pixels replaced by the average predicted value. Other optional output images are the average filtered values and the sigma values. If a mask is specified the detected cosmic rays will be identified with values given by the \fIcrval\fR parameter and object pixels will be identified with values given by the \fIobjval\fR parameter. Note that one does not need to use an output image and the cosmic rays can be replaced by interpolation in the data using the tasks \fIcrfix\fR, \fIfixpix\fR, or \fIccdproc\fR. One final step may be applied to the output mask. The mask values identified with the \fIcrval\fR and \fIobjval\fR values may be grown by identifying pixel values within a specified radius with the same mask value. Note that this step is done at the end and so any pixels in a preexisting input mask with the same values will also be grown. Also the grown pixels will not affect the output cosmic ray replaced image. See \fIcrgrow\fR for a further discussion. .ih EXAMPLES This example illustrates using the \fBxcraverage\fR task to create a mask with cosmic rays and objects identified and displayed. The image is a CCD image with a readout noise of 5 electrons and a gain of 3 electrons per data number. This implies variance model coefficients of .nf var0 = (5/3)^2 = 2.78 var1 = 1/3 = 0.34 .fi .nf cl> display obj001 1 # Display in first frame cl> xcraverage obj001 "" crmask=mask001 var0=2.78 var1=0.34\ >>> crval=1 objval=2 cl> display crobj001 2 overlay=mask001 ocol="1=green,2=red" .fi .ih SEE ALSO cosmicrays, crnebula, median, crfix, crgrow, crmedian .endhelp iraf-xdimsum-main/doc/xdshifts.hlp000066400000000000000000000105761455666516400175460ustar00rootroot00000000000000.help xdshifts Sep00 xdimsum .ih NAME xdshifts -- compute image offsets by displaying images and marking reference objects .ih USAGE xdshifts inlist refim shiftlist cradius .ih PARAMETERS .ls inlist The list of input images for which offsets are to be computed. .le .ls refim The reference image which defines the origin of the offsets. The reference images must be one of the images in the input image list. If refim is undefined the first input image is the reference image. .le .ls shiftlist The output offsets file suitable for input to the xnregistar task. The output file contains the input image name, the x offset in pixels, the y offset in pixels, and the default exposure time which is always 1 in columns 1 through 4. .le .ls cradius The centroiding radius in pixels. .le .ls datamin = INDEF, datamax = INDEF The lower and upper bad data limits used by the centroiding algorithm. .le .ls background = INDEF The mean background level for the centroiding algorithm. .le .ls niterate = 3 The maximum number of iterations performed by the centroiding algorithm. .le .ls maxshifts = 5 The maximum difference in pixels between the final computed offset and the offset predicted by displaying the images and marking reference stars in each image. .le .ls chkshifts = no Edit the lists of input image reference stars, the list of registration stars, and the final offsets interactively? .le .ih DESCRIPTION XDSHIFTS computes the offsets required to mosaic the images in the input image list \fIinlist\fR to the reference image \fIrefim\fR using the image display and the IMEXAMINE and IMCENTROID tasks and writes the results to the output file \fIshiftlist\fR. XDSHIFTS calls IMEXAMINE 3 times to perform the following functions: .nf o display the images so that the user can select a reference star common to all the images o display the images so that the user can mark the position of the reference star in each image and create a reference star list o display the reference image so that the user can mark the positions of several registration stars that will be used to a registration star list .fi The IMEXAMINE 'p' and 'n' keystroke commands or the ":select " commands are used to select which image to display. The IMEXAMINE 'a' or 'r' keystroke command are used to mark and centroid the stars using pixels within \fIcradius\fR of the current best position. The 'q' keystroke terminates the current invocation of IMEXAMINE. More details on how IMEXAMINE computes the centroids and how to use the many features of IMEXAMINE can be found in the IMEXAMINE help page. If \fIchkshifts\fR is yes the user is given the opportunity to edit the reference star list and the registration star list. Given the input image list, the reference image, the reference star list, the registration star list, and the centroiding parameters \fIcradius\fR, \fIdatamin\fR, \fIdatamax\fR, \fIbackground\fR, \fIniterate\fR, and \fImaxshifts\fR, XDSHIFTS calls the IMCENTROID task to recenter the registration objects and compute the offsets of each input image relative to the reference image \fIrefim\fR. Detailed descriptions of the IMCENTROID task algorithms can be found in the IMCENTROID help page. If \fIchkshifts\fR is yes then the user is given the opportunity to edit the offsets file before it is finally output. .ih EXAMPLES 1. Compute the offsets file for the 25 sky subtracted demo images. Go ahead and register the images with xnregistar. The output image will appear in demo.mosaic and the output exposure map will appear in exp_demo.mosaic. .nf cl> type simlist demo01.sub.imh demo02.sub.imh demo03.sub.imh ... demo24.sub.imh demo25.sub.imh cl> xdshifts @simlist "" offsets 5.0 ... the first image in simlist is displayed and imexamine starts ... use the n and p keystrokes to step though the image list ... select a reference object common to all image ... type q to quit imexamine ... the first image in simlist is displayed and imexamine starts ... move cursor to reference object and type a ... type n to display next image ... repeat previous 2 steps until first image is redisplayed ... type q to quit imexamine ... the reference image is displayed ... move cursor to registration objects and type a ... type q to quit ... results will appear in output cl> xnregistar offsets demo.pl "" "" mosaic mosaic.exp mosaic.corners .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO imexamine,imcentroid .endhelp iraf-xdimsum-main/doc/xfirstpass.hlp000066400000000000000000000375131455666516400201200ustar00rootroot00000000000000.help xfirstpass Sep00 xdimsum .ih NAME xfirstpass -- sky subtract, cosmic ray correct, and combine a list of images without object masks .ih USAGE xfirstpass inlist reference output expmap .ih PARAMETERS .ls inlist The list of input images to be combined. .le .ls reference The name of the reference image used to compute offsets if \fImkshifts\fR is yes. If reference is undefined the first image in \fIinlist\fR is assigned to be the reference image. .le .ls output The name of the output combined image. .le .ls expmap = ".exp" The name of the output exposure map image or the string appended to the output combined image name \fIoutput\fR to create the output exposure map image name. .le .ls statsec = "" The input image section used to compute the sky statistics for each input image in the sky subtraction and cosmic ray removal steps. By default the entire input image is used. .le .ls nsigrej = 3.0 The rejection limits used to compute the sky statistics. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the sky statistics. .le .ls xslm = yes Perform the sky subtraction step using the xnslm task id \fInewxslm\fR is yes or the xslm task if it is no ? The input images must be sky subtracted before the bad pixel fixing, cosmic ray removal, and image combining steps can be performed. .le .ls sslist = ".sub" The output sky subtracted image list or the string appended to the input image names in \fIinlist\fR to create the names of the output sky subtracted images. .le .ls newxslm = no Use the new xnslm task rather than the original xslm task ? .le .ls forcescale = yes Force recalculation of the input image statistics by even though they have been computed previously and stored in the keyword "SKYMED". .le .ls nmean = 6 The number of neighboring images used by the sky subtraction task to computed the sky image for each input image. .le .ls nskymin = 3 The minimum number of input images used by the sky subtraction task to compute the sky image. .le .ls nreject = 1 The number of high and low side pixels to be rejected by the sky subtraction task when it computes the sky image. .le .ls cache = yes Enable image cacheing fro improved efficiency in the new xnslm task ? .le .ls maskfix = yes Use the bad pixel mask \fIbpmask\fR to fix bad pixels in the sky subtracted images ? .le .ls bpmask The name of the input image bad pixel mask used to fix bad pixel in the sky subtracted images. Bpmask is assumed to be the same for all the input images and to consist of 0's in the bad pixel regions and 1's elsewhere. If bpmask is undefined the bad pixel fixing step is skipped. .le .ls forcefix = yes Force bad pixel fixing even though the images have been previously fixed as indicated by the presense of the keyword "MASKFIX" in their headers. .le .ls xzap = yes Remove cosmic rays from the sky subtracted images using the xnzap task if \fInewxzap\fR = yes or the xzap task if \fInewxzap\fR = no ? .le .ls crmasks = ".crm" The list of output cosmic ray masks or the string appended to the input image names in \fIinlist\fR to create the names of the output cosmic ray masks. Cosmic ray masks consist of 1's in the cosmic ray regions and 0's elsewhere. .le .ls newxzap = no Use the new xnzap task rather than the original xzap task ? .le .ls badpixupdate = yes Update the bad pixel mask \fIbpmask\fR by adding cosmic ray pixels detected in \fInrepeats\fR or more sky subtracted images to the bad pixel mask. Bad pixel mask updating is only done if \fIxzap\fR is yes. .le .ls nrepeats = 3 If a pixel is detected as a cosmic ray in \fInrepeats\fR or more images and \fIbadpixupdate\fR is yes then the pixel is set to bad in the bad pixel mask \fIbpmask\fR. .le .ls mkshifts = no Determine the shifts required to combine the sky subtracted images interactively using image display and image cursor ? In order to use this option the image display server must be running before xfirstpass is called. .le .ls chkshifts = no Edit the lists of input image reference stars, the list of registration stars, and the final offsets created by the user in the interactive shift computation step. .le .ls cradius = 5.0 The centroiding radius in pixels used in the interactive offset computation step. .le .ls maxshift = 5.0 The maximum permitted difference in pixels between the final computed offset and the predicted offset determined in the interactive offset computation step. .le .ls xnregistar = yes Compute the combined output image and exposure map image using offsets and exposure time scaling ? .le .ls shiftlist = "" The input shifts file used to combine the sky subtracted images if \fImkshifts\fR = no or the output shifts file if \fImkshifts\fR is yes. Shiftlist consists of the sky subtracted image name, the x and y offsets in user units (usually pixels), and the exposure time used to scale the image (usually 1). If shiftlist is undefined and \fImkshifts\fR = no then xfirstpass terminates with a warning message. .le .ls sections = ".corners" The name of the output sections file or the string appended to the output image name \fIoutput\fR to create the output sections file name. The sections file contains the input image name from \fIinlist\fR, the coordinates of the lower left corner of the input image in the output combined image, and the coordinates of the upper right corner of the input image in the output combined image in columns 1 through 5 respectively. .le .ls fractional = no Use the fractional as well as integer part of the sky subtracted image offsets. The imshift task and bilinear interpolation are used to do the fractional part of the shift. .le .ls pixin = yes If pixin is yes the input offsets called a and b are assumed to be defined in the reference image pixel coordinate system x and y, and ab_sense, xscale, yscale, and a2x_angle default to yes, -1.0, -1.0, and 0.0 respectively. .le .ls ab_sense = yes Is the rotation of the a to b axis counter-clockwise ? The a and b axes are the axes along which the input offsets are measured. Ab_sense defaults to yes if pixin is yes. .le .ls xscale = 1.0, yscale = 1.0 The number of pixel coordinates x and y per input coordinates a and b. For example if the input offsets are measured in arcseconds and the pixel scale is 0.25 arcseconds per pixel then xscale and yscale should be set to 4.0. Xscale and yscale default to -1.0 and -1.0 if pixin is yes. .le .ls a2x_angle = 0 The angle in degrees of the a offset axis measured counter-clockwise to the image x axis. A2x_angle defaults to 0.0 if pixin is yes. .le .ls ncoavg = 1 The number of co-averages per input image. The total exposure time for an image is ncoavg * exptime * secpexp where exptime is read from \fIshiftlist\fR. .le .ls secpexp = 1.0 The number of seconds per unit exposure time. .le .ls y2n_angle = 0.0 The angle in degrees from the image y axis to the north axis measured from north through east. If set correctly y2n_angle can be used to orient the output image to within 45 degrees of N up and E left. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? .le .ih DESCRIPTION XFIRSTPASS sky subtracts, bad pixel corrects, and cosmic ray corrects the input images \fIinlist\fR and combines them into a single output image \fIoutput\fR. The associated exposure map is written to the image \fIexpmap\fR. The individual output sky subtracted, bad pixel corrected, and cosmic ray corrected images are stored in \fIsslist\fR, and associated output cosmic ray masks are stored in \fIcrmasks\fR. The locations of the input images in the output combined image are stored in \fIsections\fR for later use by the XMASKPASS task. If \fIxslm\fR is yes XFIRSTPASS sky subtracts the input images using the XNSLM task if \fInewxslm\fR is yes or XSLM task if it is no and writes the results to the output images \fIsslist\fR. For each input image XNSLM/XSLM computes the running mean of the \fInmean\fR neighboring images, after scaling them by the median pixel values, and rejecting the \fInreject\fR highest scaled pixels. There must be at least \fInskymin\fR neighboring images for a sky image to be computed and subtracted from the input image. The input image medians are computed using pixels in the region defined by \fIstatsec\fR and an iterative \fInsigrej\fR rejection algorithm with the maximum number of iterations set to \fImaxiter\fR. The reciprocal of the computed median is stored in the image header keyword "SKYMED". If \fIforcescale\fR is no and the "SKYMED" keyword already exists in the input image header then the image medians are not recomputed. When sky subtraction is complete the keyword SKYSUB is written to the output image header. More information about the XSLM/XNSLM task can be found in the XSLM/XNSLM help pages. If \fImaskfix\fR is yes XFIRSTPASS removes known bad pixels from the sky subtracted images \fIsslist\fR using the MASKFIX task and the bad pixel mask \fIbpmask\fR. The bad pixel mask consists of 0's in bad pixel regions and 1's elsewhere and must be the same size as the input sky subtracted images. The bad pixels are removed by linearly interpolating across bad columns in each image line. When bad pixel removal is complete the keyword "MASKFIX" is written to the header of the sky subtracted image. If \fIforcefix\fR is no and "MASKFIX" exists in the image header then the bad pixel removal step is skipped. More information on the MASKFIX task can be found in the MASKFIX help page. If \fIxzap\fR is yes XFIRSTPASS removes cosmic rays from the sky subtracted images \fIsslist\fR using the XNZAP task if \fInewxzap\fR is yes or the XZAP task if it is no, and writes the cosmic ray masks to \fIcrmasks\fR. The output cosmic ray masks contain 1's in the cosmic ray regions and 0's elsewhere. Both XZAP and XNZAP write the keyword CRMASK which contains the name of the output cosmic ray MASK to the cosmic ray corrected image. If the CRMASK keyword is present in the sky subtracted image headers cosmic ray cleaning is skipped. XZAP is the tried and true XDIMSUM cosmic ray removal task. XNZAP is experimental but promises to be a faster technique. XZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the median of the surrounding box of 5 by 5 pixels, and which are not part of an object where an object is any pixel more than 2.0 sky sigma above the median of the surrounding 15 by 15 box of pixels. XZAP uses a sky subsampling factor of 2 and cosmic ray and region growing box widths of 0.0 and 0.0 respectively. The sky sigma is computed using the region of the input sky subtracted images specified by \fIstatsec\fR and iterative \fInsigrej\fR rejection with the maximum number of rejections set to \fImaxiter\fR. The cosmic rays in the input sky subtracted images are replaced with the local median value. More information on the XZAP task can be found in the XZAP help page. XNZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the mean of the surrounding box of 5 by 5 pixels with the central pixel and the highest pixel removed, and which are not part of an object where an object is als more than 5.0 sky sigma above the local background. The local background is defined as the median of the pixels in an annulus 5.0 pixels wide around the averaging box. The local sky sigma is estimated by computing the percentile points of pixels in 25 by 25 pixel subsections evenly distributed over the image. The cosmic ray and object growing radii are set to 0.0 and 0.0 respectively. The cosmic rays in the input sky subtracted images are replaced with the local average value. More information on the XNZAP task can be found in the XNZAP help page. If \fIxzap\fR is yes and \fIbadpixupdate\fR is yes then XFIRSTPASS updates the bad pixel mask \fIbpmask\fR using the BADPIXUPDATE task. BADPIXUPDATE examines the list of cosmic rays image produced by XZAP or XNZAP, searches for pixels that are bad in 3 or more images, and sets those pixels in \fIbpmask\fR to 0. If \fImkshifts\fR = yes then XFIRSTPASS calls the XDSHIFTS task to determine the x and y shifts required to accurately combine the sky subtracted, bad pixel corrected, and cosmic ray corrected images. XDSHIFTS displays the corrected images and requests the user to identify a reference object common to all of them, then displays the reference image \fIreference\fR and requests the user to identify a set of registration objects. The reference objects are used to compute initial shifts. The positions of the registration objects in each image are computed using a centroiding algorithm and a centering radius of \fIcradius\fR pixels. Objects with shifts that are more than \fImaxshifts\fR pixels larger than the initial shifts are rejected from the registration list and the shifts of the remaining objects are averaged to compute the final shift for each image. If \fIchkshifts\fR is yes the user is permitted to edit the reference object list, the registration list, and the list of final shifts. The final shifts are written to \fIshiftfile\fR Currently XDSHIFTS sets the exposure times of the input sky subtracted images to 1.0. If \fImkshifts\fR = no then the name of the sky subtracted image, its x and y shifts relative to the reference image and its exposure time are read from the file \fIshiftlist\fR. Shiftlist may have been written by the XDSHIFTS, XMSHIFTS, XFSHIFTS, or XRSHIFTS tasks. If \fIxnregistar\fR is yes then XFIRSTPASS combines the corrected images into the output combined image \fIoutput\fR and output exposure map image \fIexpmap\fR using the badpixel mask \fIbpmask\fR, offsets and scaling factors in \fIshiftlist\fR if \fImkshifts\fR is no, or computed by XDSHIFTS if the \fImkshifts\fR is yes. If \fIfractional\fR is no only the integer part of the shifts is used. XFIRSTPASS call the XNREGISTAR task to do the actual image combining. The parameters \fIpixin\fR, \fIab_sense\fR, \fIxscale\fR, \fIyscale\fR, and \fIa2x_angle\fR are used to convert shifts from user units, e.g. arcseconds to units of pixels in the reference image. The units of \fIncoavg\fR and \fIsecpexp\fR are used to normalize the input exposure times. The parameters \fIy2n_angle\fR and \fIrotation\fR are used to orient the final combined image and exposure map to within 45 degrees of north up and east to the left. Finally the pixel positions of the input images in the output combined images are stored stored in the file \fIsections\fR suffix. .ih EXAMPLES 1. Do a first pass image combining operation on the demo images. .nf cl> demos mkxdimsum cl> xfirstpass @demo.list demo13 fpmosaic ".exp" bpmask=demo.pl \ shiftlist=demo.slist nsigrej=5.0 maxiter=10 secpexp=60.0 .fi 2. Repeat the first pass image combining operation on the demo images but determine the shifts interactively. .nf cl> xfirstpass @demo.list demo13 fpmosaic ".exp" bpmask=demo.pl \ mkshifts+ nsigrej=5.0 maxiter=10 secpexp=60.0 ... do sky subtraction with xslm ... do badpix correction with maskfix ... do cosmic ray cleaning with xzap ... do bad pixel mask updating with badpixupdate ... enter the interactive xdshifts task ... the first sky subtracted image is displayed and imexamine starts ... use the n and p keystrokes to step though the image list ... select a reference object common to all image ... type q to quit imexamine ... the first sky subtracted image is displayed and imexamine starts ... move cursor to reference object and type a ... type n to display next image ... repeat previous 2 steps until first image is redisplayed ... type q to quit imexamine ... the task enters the default editor ... edit in any required changes ... quit the editor ... the reference sky subtracted image is displayed ... move cursor to registration objects and type a ... type q to quit xdisplay ... the task enters the default editor ... edit in any required changes ... quit the editor ... do image combining with xnregistar .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xslm, xnslm, maskfix, xzap, xnzap, badpixupdate, xdshifts, xnregistar .endhelp iraf-xdimsum-main/doc/xfshifts.hlp000066400000000000000000000141531455666516400175430ustar00rootroot00000000000000.help xfshifts Sep00 xdimsum .ih NAME xfshifts -- compute total offsets for an ordered sequence of images using object detection and centroiding techniques .ih USAGE xfshifts inlist output shifts hwhmpsf threshold xlag ylag cbox .ih PARAMETERS .ls inlist The list of input sky subtracted images. The input image list must be in order with each image offset from the previous one by approximately \fIxlag\fR pixels in x and \fIylag\fR pixels in y. .le .ls output The output total offsets file suitable for input to the xnregistar task. Output contains the input image name, the total x offset, the total y offset, and the default exposure time in columns 1 through 4 respectively. The total x and y offsets of image N are defined as the shifts x(N) - x(1) and y(N) - y(1) required to place image N in the same coordinate system as image 1. The default exposure time is 1 time unit. .le .ls shifts = "" The optional relative offsets file. Shifts contains the input image name, the relative x offset and the relative y offset in columns 1 through 3 respectively. The relative offsets of image N are defined as the shifts x(N-1) - x(N) and y(N-1) - y(N) required to register image N to image N-1. .le .ls hwhmpsf = 1.25 The approximate half-width at half-maximum of the image PSF in pixels. If the PSF width varies significantly over the sequence hwhmpsf should be set to the average value for the sequence. .le .ls threshold = 50.0 The object detection threshold above local background in ADU. Threshold should be set no lower than 4 * sigma where sigma is the standard deviation of the background pixels in ADU. .le .ls xlag = 0.0, ylag = 0.0 The approximate relative offsets x(N) - x(N-1) and y(N) - y(N-1) between adjacent images in the input image list. .le .ls cbox = 7.0 The centering box size in pixels. .le .ls fradius = 2.5 (hwhmpsf) The fitting radius in units of hwhmpsf. Fradius defines the size of the Gaussian kernel used to compute the density enhancement image and the size of the image region used to do the moment analysis in the object detection step. .le .ls sepmin = 5.0 (hwhmpsf) The minimum separation for detected objects in units of hwhmpsf. .le .ls datamin = INDEF, datamax = INDEF The minimum and maximum good data values in ADU. Datamin and datamax default to the constants -MAX_REAL and MAX_REAL respectively. .le .ls roundlo = 0.0, roundhi = 0.5 The minimum and maximum ellipticity values for detected objects, where ellipticity is defined as 1 - b / a, and a and b are the semi-major and semi-minor object axis lengths respectively. .le .ls sharplo = 0.5, sharphi = 2.0 The minimum and maximum sharpness values of the detected objects, where sharpness is defined to be the ratio of the object size determined by moments analysis to the hwhmpsf parameter value. .le .ls niterate = 3 The maximum number of centroiding iterations. .le .ls maxshift = 5.0 The maximum centroiding x and y shifts in pixels. .le .ls nxblock = INDEF, nyblock = INDEF The working block size. If undefined nxblock and nyblock default to the number of columns and rows in the input image respectively. .le .ih DESCRIPTION XFSHIFTS computes total offsets for the images in the input image list \fIinlist\fR and writes the results in a form suitable for input to the xnregistar task to \fIoutput\fR. If the \fIshifts\fR parameter is defined the relative offsets for adjacent images are written to the file \fIshifts\fR. XFSHIFTS requires the input image list to be ordered and also requires that the relative offsets between adjacent images are approximately equal to \fIxlag\fR and \fIylag\fR pixels. XFSHIFTS computes the relative offsets between adjacent images by first detecting objects in each input image using the STARFIND task, and then centroidiing the object lists in adjacent images and computing relative shifts using the IMCENTROID task. STARFIND searches the input images for local density maxima with half-widths at half-maxima of ~ \fIhwhmpsf\fR and peak amplitudes greater than \fIthreshold\fR counts above the local background, which are brighter than all surrounding objects within a radius of \fIsepmin\fR * \fIhwhmpsf\fR pixels. Data within \fIfradius\fR * \fIhwhmpsf\fR pixels of the detected density maximum and within the good data range defined by the \fIdatamin\fR and \fIdatamax\fR parameters are used to estimate the object position, shape, and size relative to the PSF. Objects outside the shape and size limits specified by the \fIroundlo\fR, \fIroundhi\fR, \fIsharplo\fR, and \fIsharphi\fR parameters are eliminated from the final object list. By default STARFIND reads the entire input image into memory. If the input images become too large or memory is limited the \fInyblock\fR parameter can be set. For the sake of efficiency \fInxblock\fR should be left set to INDEF so that XFSHIFTS always operates on an integral number of image lines. More information on the STARFIND algorithms can be found in the STARFIND task help page. IMCENTROID computes accurate centers for all the detected objects in adjacent image pairs using a simple centroiding algorithm and a centering box size of \fIcbox\fR. Objects that cannot be centered in \fIniterate\fR or fewer iterations or whose x and y shifts deviate by more than \fImaxshift\fR pixels from the expected shifts in both image are rejected. The remaining objects are used to compute the relative offsets between adjacent images. If adjacent frames contain no objects in common the relative offsets are set to \fIxlag\fR and \fIylag\fR. Total offsets are computed by summing the relative offsets. .ih EXAMPLES 1. Compute the total offsets for a series of 250 ONIS sky subtracted images which are offset by approximately 50 pixels in x and 0.5 pixels in y. Output both the total and relative offsets. Since the noise in the sky background for these images is around 12 ADU use a detection threshold of 50 ADU. .nf cl> type simlist ss_kk07_001 ss_kk07_002 ss_kk07_003 ... ... ss_kk07_249 ss_kk07_250 cl> xfshifts @simlist offsets shifts 1.5 50.0 50.0 0.5 9.0 cl> xnregistar offsets "" "" "" kk07.mosaic kk07.corners .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xmshifts,xrshifts,xdshifts,starfind,imcentroid .endhelp iraf-xdimsum-main/doc/xlist.hlp000066400000000000000000000031161455666516400170450ustar00rootroot00000000000000.help xlist Sep00 xdimsum .ih NAME xlist -- create an output image list from an input image list .ih USAGE xlist inlist outlist start finish exclude .ih PARAMETERS .ls inlist The input image list. .le .ls outlist The output image list. .le .ls start The sequence number of the first image in the input list to include in the output list. .le .ls finish The sequence number of the first image in the input list to include in the output list. .le .ls exclude The sequence number of the image in the input image list that lies between start and finish to exclude from the output list. .le .ls suffix = "" The prefix to append to the selected input image names before they are written to the output list. .le .ih DESCRIPTION XLIST creates an output images list \fIoutlist\fR consisting of images \fIstart\fR to \fIfinish\fR in the input image list \fIinlist\fR. If \fIexclude\fR is between start and finish the input image with that sequence number will be excluded from the output image list. The string \fIsuffix\fR will be appended to the input image names before they are written to the output image list. XLIST is a simple script task currently used by the XSLM and MASKDEREG tasks to create subsets image lists sky subtraction and object mask combination. .ih EXAMPLES 1. Assemble the list of 6 nearest images to be used to create a sky image for image number 13 in the demo image sequence. .nf cl> type inlist demo01 demo02 demo03 ... demo24 demo25 cl> xlist inlist outlist 10 16 13 cl> type outlist demo10 demo11 demo12 demo14 demo15 demo16 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO .endhelp iraf-xdimsum-main/doc/xmaskpass.hlp000066400000000000000000000472561455666516400177310ustar00rootroot00000000000000.help xmaskpass Sep00 xdimsum .ih NAME xmaskpass -- sky subtract, cosmic ray correct, and combine a list of images using the combined image and exposure map produced by xfirstpass and object masking .ih USAGE xmaskpass input expinput sections output outexpmap .ih PARAMETERS .ls input The first pass combined image. .le .ls inexpmap The first pass exposure map image associated with the input combined image \fIinput\fR. .le .ls sections The first pass sections file the location of the individual input images in the combined image \fIinput\fR. .le .ls output The name of the final output combined image. .le .ls outexpmap = ".exp" The name of the output exposure map image or the string appended to the output image name \fIoutput\fR to create the output exposure map image name. The exposure map contains the total exposure time for each output image pixel after rejecting bad pixels, cosmic rays, and undefined pixels. .le .ls statsec = "" The image section used to compute the sky statistics for the individual input image in the sky subtraction and cosmic ray removal steps. By default the entire input image is used. .le .ls nsigrej = 3.0 The nsigma rejection limits used to compute the sky statistics in the sky subtraction and cosmic ray removal tasks. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the sky statistics by the sky subtraction and cosmic ray removal tasks. .le .ls mkmask = yes Create the combined image object mask and inverse object core mask ? If mkmask is no and the object mask or inverse object core mask do not exist the task will terminate. .le .ls omask = ".msk" The output combined image object mask name or the string appended to the input image name \fIinput\fR to create the output combined object mask name. An additional "i" is added to the combined object mask name to create the inverse object core mask name. Object masks consist of 1's in object regions and 0's elsewhere. Inverse object masks are the reverse. .le .ls chkmasks = no Check the displayed mask and optionally enter a new threshold value ? .le .ls kpchking = yes Repeatedly check the mask until satisfied ? .le .ls mstatsec = "" The combined image section used to compute the sky statistics in the mask creation step. By default the entire input image is used. .le .ls nsigcrmsk = 1.5 The factor times the recommended threshold used by the mask creation task to compute the combined image inverse object core mask for cosmic ray unzapping. .le .ls nsigobjmsk = 1.1 The factor times the recommended threshold used by the mask creation task to compute the combined input image object mask. .le .ls negthresh = no Use negative as well as positive threshold when creating the input image object mask ? .le .ls ngrow = 0 The object growing box half-width in pixels. .le .ls maskdereg = yes Create object masks and inverse object core masks for the individual input images by extracting the appropriate sections from the parent combined image masks ? .le .ls ocrmasks = ".ocm" The list of output individual inverse core object masks or the string appended to the individual sky subtracted image names to create the individual output inverse core object mask names. The inverse object masks consist of 0's in the object regions and 1's elsewhere and are used for unzapping cosmic rays detected in object regions. .le .ls objmasks = ".objm" The list of output individual image object masks or the string appended to the individual sky subtracted image names to create the individual output object mask names. The object masks consist of 1's in the object regions and 0's elsewhere and are used for improving the sky subtraction. .le .ls xslm = yes Do the sky subtraction step using object masking with the xnslm task if \fInewslm\fR is yes or \fIxslm\fR is no ? The input images must be sky subtracted before the bad pixel correction, cosmic ray correction, and image combining steps can be performed. .le .ls sslist = ".sub" The output sky subtracted image list or the string appended to the input image names in \fIsections\fR to create the names of the output sky subtracted images. .le .ls hmasks = ".hom" The output holes mask list or the string appended to the sky subtracted image names to create the names of the output holes masks. Holes mask consist of 0's in undefined regions and 1's' elsewhere and are only created if object masking is enabled. .le .ls newxslm = no Use the new xnslm task rather than the original xslm task ? .le .ls forcescale = yes Force recomputation of the input image statistics regardless of whether or not they have been previously computed and stored in the keyword "SKYMED". .le .ls useomask = yes Use the individual object masks \fIobjmasks\fR tocomputw the individual image sky statistics ? The object masks are used to create the sky images regardless of the value of useomask. .le .ls nmean = 6 The number of neighboring images used by the sky subtraction task to compute the sky image for each input image. .le .ls nskymin = 3 The minimum number of input images used by the sky subtraction task to compute the sky image. .le .ls nreject = 1 The number of high and low side pixels to reject when the sky image is computed by the sky subtraction task. .le .ls cache = yes Enable image cacheing for improved efficiency in the new xnslm task ? .le .ls maskfix = yes Use the bad pixel mask \fIbpmask\fR to fix bad pixels in the sky subtracted images ? .le .ls bpmask The name of the input bad pixel mask used to fix bad pixels in the sky subtracted images. Bpmask is assumed to be the same for all the input images and to consist of 0's in the bad pixel regions and 1's elsewhere. If bpmask is undefined the bad pixel fixing step is skipped. .le .ls forcefix = yes Force bad pixel fixing by the even though the image haves been previously fixed as indicated by the presense of the keyword "MASKFIX". .le .ls xzap = yes Remove cosmic rays from the sky subtracted images using the xnzap task if \fInewxzap\fR = yes or xzap if \fInewxzap\fR is no ? If xzap is no the existing cosmic ray masks after unzapping with the individual inverse object masks \fIocrmasks\fR are used in later processing steps. .le .ls crmasks = ".crm" The list of input first pass cosmic ray masks if \fIxzap\fR = no, or the list of output cosmic ray masks if \fIxzap\fR = yes. Crmasks may also be a string appended to the sky subtracted image names to create the names of the input / output cosmic ray masks. Cosmic ray masks consist of 1's in the cosmic ray regions and 0's elsewhere. .le .ls newxzap = no Use the new xnzap task rather than the original xzap task ? .le .ls badpixupdate = yes Update the bad pixel mask \fIbpmask\fR. The bad pixel mask updating task adds those bad pixels detected in 3 or more sky subtracted images to the bad pixel mask using the current cosmic ray mask list. Bad pixel mask updating is only done if \fIxzap\fR is yes. .le .ls nrepeats = 3 If a pixel is detected as a cosmic ray in \fInrepeats\fR or more images and \fIbadpixupdate\fR is yes then the pixel is set to bad in the bad pixel mask \fIbpmask\fR. .le .ls xnregistar = yes Compute the final combined output image and exposure map image using offsets and exposure time scaling ? .le .ls shiftlist = "" The input shifts file used to combine the corrected images. Shiftlist consists of the corrected image name, the x and y offsets in user units (usually pixels), and the exposure time used to scale the image. If shiftlist is undefined xmaskpass terminates with a warning message. .le .ls rmasks = ".rjm" The list of output mask pass rejection masks. Rmasks may also be a string appended to the sky subtracted image names to create the names of the output rejection masks. Rejection masks consist of 1's in the good data regions and 0's elsewhere. .le .ls nprev_omask = 0 The number of previous individual object masks that are combined to create the object mask used in the image combine step. .le .ls fractional = no Use the fractional as well as integer part of the corrected image offsets if \fImag\fR = 1. The imshift task and bilinear interpolation are used to do the fractional part of the shift. .le .ls pixin = yes If pixin is yes the input offsets called a and b are assumed to be defined in the reference image pixel coordinate system x and y, and ab_sense, xscale, yscale, and a2x_angle default to yes, -1.0, -1.0, and 0.0 respectively. .le .ls ab_sense = yes Is the rotation of the a to b axis counter-clockwise ? The x and b axes are the axes along which the input offsets are measured. Ab_sense defaults to yes if pixin is yes. .le .ls xscale = 1.0, yscale = 1.0 The number of pixel coordinates x and y per input coordinates a and b. For example if the input offsets are measured in arcseconds and the pixel scale is 0.25 arcseconds per pixel then xscale and yscale should be set to 4.0. Xscale and yscale default to -1.0 and -1.0 if pixin is yes. .le .ls a2x_angle = 0 The angle in degrees of the a offset axis measured counter-clockwise to the image x axis. A2x_angle defaults to 0.0 if pixin is yes. .le .ls mag = 4.0 The factor by which the output image and output exposure map image are block replicated with respect to the input image and input exposure map. .le .ls blkrep = yes Use block replication rather than bilinear interpolation to magnify the images if \fImag\fR > 1. .le .ls ncoavg = 1 The number of co-averages per input image. The total exposure time for an image is ncoavg * exptime * secpexp where exptime is read from shiftlist. .le .ls secpexp = 1.0 The number of seconds per unit exposure time. .le .ls y2n_angle = 0.0 The angle in degrees from the image y axis to the north axis measured from north through east. Y2n_angle can be used to orient the output image to within 45 degrees of N up and E left if set correctly. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? .le .ls del_bigmasks = no Delete \fIomask\fR and its related inverse mask on task termination ? .le .ls del_smallmasks = no Delete \fIocrmasks\fR and \fIobjmasks\fR and their related inverse on task termination ? .le .ih DESCRIPTION XMASKPASS sky subtracts, bad pixel corrects, and cosmic ray corrects the input images in \fIsections\fR, and combines the corrected images into a single output image \fIoutput\fR and accompanying exposure map image \fIoutexpmap\fR, using the input combined image \fIinput\fR and associated exposure map \fIinexpmap\fR produced by XFIRSTPASS to derive object masks for the combined and individual images. The object mask and inverse object core mask for the input combined image are stored in the mask \fIomask\fR. The individual image object masks and inverse object core masks are stored in \fIobjmasks\fR and \fIocrmasks\fR respectively. Object masks consist of 1's in the object regions and 0's elsewhere. Inverse object masks consist of 0's in the object regions and 1's elsewhere. The final output sky subtracted, bad pixel corrected, and cosmic ray corrected images are stored in \fIsslist\fR. The output holes masks and cosmic ray masks are stored in \fIhmasks\fR and \fIcrmasks\fR respectively. If \fImkmask\fR is yes the combined image object mask \fIomask\fR and inverse object core mask \fIomask\fR are created with the MKMASK task using thresholding factors \fInsigobjmask\fR and \fInsigcrmask\fR times the recommand thresholding factor respectively. If \fInegthresh\fR is "yes" both negative and positive thresholds are used to created the combined image object mask. The standard deviation of the background is computed using pixels in the section specified by \fImstatsec\fR and iterative rejection with parameters \fInsigrej\fR and \fImaxiter\fR. MKMASK uses default values of 2, 15, and 3 for the MKMASK subsampling factor, median filter size, and smoothing size respectively. More about the MKMASK task can be found in the MKMASK help page. If \fIchkmasks\fR is yes, the recommended threshold is printed, the input combined image normalized by the exposure time is displayed in the image display, the imexamine task is invloked, the user is prompted for a new thresholding value, and the input image and new mask are displayed. If \fIkpchking\fR is set to yes the whole process is repeated until the user is satisfied and sets it to no. If \fImkmask\fR is no and the combined object mask and inverse object core mask do not already exist XMASKPASS terminates. If \fImaskdereg\fR is yes then the individual object masks and inverse object core masks \fIobjmasks\fR and \fIocrmasks\fR are created from the combined image object masks \fIomask\fR using positional information in the \fIsections\fR file. The object masks are used to improve the sky subtraction. The inverse object core masks are used to unzap the cosmic rays in object regions where the cosmic rays are defined by the cosmic ray masks \fIcrmasks\fR. The object mask and inverse object core mask names are stored in the image header keywords "OBJMASK" and "CROBJMAS" respectively. If \fImaskdereg\fR is no then the object masks and inverse object core masks are assumed to already exist. If \fIxslm\fR is yes XMASKPASS sky substracts the input images using the XNSLM task if \fInewxslm\fR is yes and XSLM task if it is no with object masking enabled, and writes the results to the output images \fIsslist\fR. Existing sky subtracted images are overwritten. The indivdual object masks are assumed to have been created by the MASKDEREG task. XSLM/XNSLM computes the running mean of the \fInmean\fR neighboring images, after scaling them by their median pixel values, and rejecting the \fInreject\fR highest scaled pixels. There must be at least \fInskymin\fR neighboring images for a sky image to be computed and subtracted from the input image. The input image medians are computed using pixels in the region defined by \fIstatsec\fR, the object mask defined in \fIobjmasks\fR if \fIuseomask\fR is yes, and iterative rejection using rejection parameters \fInsigrej\fR and \fImaxiter\fR. The reciprocal of the computed median is stored in the image header keyword "SKYMED". If \fIforcescale\fR is no and the "SKYMED" keyword already exists in the image header then the image medians are not recomputed and the value of SKYMED is used as the scaling factor. If use of the object masks results in sky background pixels which are undefined then a holes mask \fIhmasks\fR is written. Holes masks consist of 0's in undefined regions and 1's elsewhere. If a holes mask was created then the keyword "HOLES" containing the name of the holes mask is written to the sky subtracted image. When sky subtraction is complete the keyword SKYSUB is written to the output image headers. More information about the XSLM/XNSLM task can be found in the XSLM/XNSLM help pages. If \fImaskfix\fR is yes XMASKPASS removes bad pixels from sky subtracted images \fIsslist\fR using the MASKFIX task and the bad pixel mask \fIbpmask\fR. The bad pixel mask consists of 0's in bad pixel regions and 1's elsewhere and must be the same size as the input sky subtracted image. The bad pixels are removed by linearly interpolating across bad columns in each image line. When bad pixel removal is complete the keyword "MASKFIX" is written to the header of the sky subtracted image. If \fIforcefix\fR is no and "MASKFIX" exists in the image header then the bad pixel removal step is skipped. More information on the MASKFIX task can be found in the MASKFIX help page. If \fIxzap\fR is yes XMASKPASS removes cosmic rays from the sky subtracted images \fIsslist\fR using the XNZAP task if \fInewxzap\fR is yes or the XZAP task if it is no, and writes the cosmic ray masks to \fIcrmasks\fR. Existing cosmic ray masks are overwritten. The output cosmic ray masks contain 1's in the cosmic ray regions and 0's elsewhere. Both XZAP and XNZAP write the keyword CRMASK which contains the name of the output cosmic ray MASK to the cosmic ray corrected image. If the CRMASK keyword is present in the sky subtracted image headers cosmic ray cleaning is skipped. XZAP is the tried and true XDIMSUM cosmic ray removal task. XNZAP is experimental but promises to be a faster technique. If \fIxzap\fR is no then the cosmic rays masks created by XFIRSTPASS are used. Cosmic rays in the cores of objects are unzapped using the inverse object core masks \fIocrlist\fR. XZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the median of the surrounding box of 5 by 5 pixels and are not part of an object, where an object is any pixel located in an object region defined by the inverse object masks \fIocrmasks\fR stored in the header keyword "CROBJMAS". The cosmic rays in the input sky subtracted images are replaced with the local median value. More information on the XZAP task can be found in the XZAP help page. XNZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the mean of the surrounding box of 5 by 5 pixels with the central pixel and the highest pixel removed, and which are not part of an object where an object is defined by the inverse object mask \fIocrmasks\fR stored in the image header keyword "CROBJMAS". The local background is defined as the median of the pixels in an annulus 5.0 pixels wide around the averaging box. The local sky sigma is estimated by computing the percentile points of pixels in 25 by 25 pixel subsections evenly distributed over the image. The cosmic ray and object growing radii are set to 0.0 and 0.0 respectively. The cosmic rays in the input sky subtracted images are replaced with the local average value. More information on the XNZAP task can be found in the XNZAP help page. If \fIxzap\fR is yes and \fIbadpixupdate\fR is yes then XMASKPASS updates the bad pixel mask \fIbpmask\fR using the BADPIXUPDATE task. BADPIXUPDATE examines the list of cosmic ray masks produced by XZAP or XNZAP, searches for pixels that are bad in 3 or more masks, and sets those pixels in \fIbpmask\fR to 0. In preparation for image combining the name of the corrected image, its x and y shifts relative to the reference image, and its exposure time are read from the file \fIshiftlist\fR. Shiftlist may have been written by the XDSHIFTS, XMSHIFTS, XFSHIFTS, or XRSHIFTS tasks. If \fIxnregistar\fR is yes then XMASKPASS combines the corrected images into the output combined image \fIoutput\fR and output exposure map image \fIoutexpmap\fR using the badpixel mask \fIbpmask\fR, the cosmic ray masks \fIcrmasks\fR, the holes masks \fIhmasks\fR, the \fInprev_omask\fR objects masks, and offsets and scaling factors read from \fIshiftlist\fR. The combined rejection masks are written to \fIrmasks\fR. If \fIfractional\fR is no only the integer parts of the shifts are used. XMASKPASS calls the XNREGISTAR task to do the actual image combining. The parameters \fIpixin\fR, \fIab_sense\fR, \fIxscale\fR, \fIyscale\fR, and \fIa2x_angle\fR are used to convert shifts from user units, e.g. arseconds to units of pixels in the reference image. The magnification factor \fImag\fR determines the magnification of the final combined image with respect the the initial combined image. if \fIblkrep\fR the magnification is done via block replication, otherwise it is done using bilinear interpolation. The parameters \fIncoavg\fR and \fIsecpexp\fR are used to normalize the input exposure times. The parameters \fIy2n_angle\fR and \fIrotation\fR are used to orient the final combined image and eposure map to within 45 degrees of north up and east to the left. .ih EXAMPLES 1. Perform a first pass image combining operation on the demo images using the default shiftlist demo.slist and follow it with a mask pass. .nf cl> demos mkdimsum cl> xfirstpass @demo.list demo13 fpmosaic ".exp" bpmask=demo.pl \ shiftlist=demo.slist nsigrej=5.0 maxiter=10 secpexp=60.0 cl> xmaskpass fpmosaic fpmosaic.exp fpmosaic.corners mpmosaic \ ".exp" bpmask=demo.pl shiftlist=demo.slist nsigrej=5.0 \ maxiter=10 secpexp=60.0 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xslm, xnslm, maskfix, xzap, xnzap, badpixupdate, xnregistar .endhelp iraf-xdimsum-main/doc/xmosaic.hlp000066400000000000000000000717771455666516400173670ustar00rootroot00000000000000.help xmosaic Sep00 xdimsum .ih NAME xmosaic - sky subtract, cosmic ray correct, and combine a list of images in two passes, an initial first guess pass, followed by a mask pass .ih USAGE xmosaic inlist reference output expmap .ih PARAMETERS .ls inlist The list of input images to be combined. .le .ls reference The name of the reference image in \fIinlist\fR used to compute shifts if \fIfp_mkshifts\fR is yes. If reference is undefined the first image in \fIinlist\fR is assigned to be the reference image. .le .ls output The root name of the output combined first and mask pass images. The suffixes "_fp" and "_mp" are appended to the root name to distinguish the two images. .le .ls expmap = ".exp" The root name of the output first and mask pass xposure map images or the string appended to the output image name \fIoutput\fR to create the first and mask pass output exposure map image names. The suffixes "_fp" and "_mp" are appended to the root name to distinguish the two images. .le .ls fp_xslm = yes Perform the first pass sky subtraction step ? The input images must be sky subtracted before the bad pixel correction, cosmic ray removal, and image combining steps can be performed. .le .ls fp_maskfix = yes Fix bad pixels in the sky subtracted images during the first pass using the bad pixel mask \fIbpmask\fR ? .le .ls fp_xzap = yes Remove cosmic rays from the sky subtracted images during the first pass using the xnzap task if \fInewxzap\fR = yes or xzap if \fInewxzap\fR = no ? .le .ls fp_badpixupdate = yes Update the bad pixel mask \fIbpmask\fR during the first pass ? The bad pixel updating task adds pixels detected in 3 or more sky subtracted images to the bad pixel mask using the current cosmic ray masks. Bad pixel mask updating is only done if \fIfp_xzap\fR is yes. .le .ls fp_mkshifts = no Interactively determine the offsets required to combine the corrected images during the first and mask passes ? .le .ls fp_xnregistar = yes Compute the first pass combined output image and exposure map image using offsets and exposure time scaling defined in \fIshiftlist\fR ? .le .ls mp_mkmask = yes Create the combined image object mask and inverse object core mask task ? If fp_mkmask is no and the object mask or inverse object mask do not exist the task will terminate. .le .ls mp_maskdereg = yes Create object masks and inverse object masks for the individual input images by extracting the appropriate sections of the combined image masks ? .le .ls mp_xslm = yes Perform the mask pass sky subtraction step using object masking ? The input images must be sky subtracted before the bad pixel correction, cosmic ray removal, and image combining steps can be performed. .le .ls mp_maskfix = yes Fix bad pixels in the sky subtracted images during the mask pass using the bad pixel mask \fIbpmask\fR ? .le .ls mp_xzap = yes Remove cosmic rays from the sky subtracted images during the mask pass using the xnzap task if \fInewxzap\fR = yes or xzap if \fInewxzap\fR = no ? .le .ls mp_badpixupdate = yes Update the bad pixel mask \fIbpmask\fR during the mask pass ? The bad pixel updating task adds bad pixels detected in 3 or more sky subtracted images to the bad pixel mask using the current cosmic ray masks. Bad pixel updating is only done if \fImp_xzap\fR is yes. .le .ls mp_xnregistar = yes Compute the mask pass combined output image and exposure map image using the positional offsets and exposure time scaling factors in \fIshiftlist\fR? .le .ls statsec = "" The input image section used to compute the sky statistics for each input image in the first and mask pass sky subtraction and cosmic ray removal tasks. By default the entire input image is used. .le .ls nsigrej = 3.0 The rejection limits used to compute the sky statistics in number of sigma by the first and mask pass sky subtraction and cosmic ray removal tasks. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the sky statistics by the first and mask pass sky subtraction and cosmic ray removal tasks. .le .ls sslist = ".sub" The output first pass and mask pass sky subtracted image list or the string appended to the input image names in \fIinlist\fR to create the output sky subtracted images names. .le .ls hmasks = ".hom" The output mask pass holes mask list or the string appended to the sky subtracted image names to create the holes mask names. .le .ls newxslm = no Use the new xnslm task rather than the original xslm task in the first and mask passes ? .le .ls forcescale = yes Force recalculation of the input image sky statistics during the first and mask pass sky subtraction step even though they have been previously computed and stored in the keyword "SKYMED". .le .ls nmean = 6 The number of neighboring images used by first and mask pass sky subtraction task to compute the sky image for each input image. .le .ls nskymin = 3 The minimum number of input images used by the first and mask pass sky subtraction task to compute the sky image. .le .ls nreject = 1 The number of high and low side pixels to reject when the sky image is computed by the first and mask pass sky subtraction task. .le .ls cache = yes Enable image caching for improved efficiency in the new xnslm task ? .le .ls mp_useomask = yes Use object masks to recompute the sky statistics during the mask pass sky subtraction step. The object masks are used to create the sky images images regardless of the value of mp_useomask. .le .ls bpmask The name of the input bad pixel mask used to fix bad pixels in the sky subtracted images in the first and mask passes. Bpmask is assumed to be the same for all the input images and to consist of 0's in the bad pixel regions and 1's elsewhere. .le .ls forcefix = yes Force bad pixel fixing during the first and mask passes even though the image have been previously fixed as indicated by the presense of the keyword "MASKFIX". .le .ls crmasks = ".crm" The output first or mask pass cosmic ray mask list or the string appended to the sky subtracted image names to create the output cosmic ray masks names. Cosmic ray masks consist of 1's in the cosmic ray regions and 0's elsewhere. .le .ls newxzap = yes Use the new xnzap task rather than the original xzap task in the first and mask passes ? .le .ls nrepeats = 3 If a pixel is detected as a cosmic ray in \fInrepeats\fR or more images and \fIbadpixupdate\fR is yes then the pixel is set to bad in the bad pixel mask \fIbpmask\fR. .le .ls fp_chkshifts = no Check and edit the list of input image reference stars, the list of registration stars, and the final offsets computed by the interactive offset computing task if \fIfp_mkshifts\fR is yes ? .le .ls fp_cradius = 5.0 The centroiding radius in pixels used by the interactive offset computing task if \fIfp_mkshifts\fR is yes. .le .ls fp_maxshift = 5.0 The maximum permitted difference in pixels between the final computed offset and the offset predicted by the interactive offset computing task if \fIfp_mkshifts\fR is yes. .le .ls mp_mag = 4.0 The block replication factor for the mask pass combined image and exposure map. .le .ls mp_blkrep = yes Use block replication rather than bilinear interpolation to magnify the image if \fImag\fR > 1.0. .le .ls shiftlist = "" The input shifts file used to combine the corrected images during the first and mask passes. Shiftlist contains the corrected image name, the x and y offsets in user units (usually pixels), and the exposure time used to scale the image. If \fIfp_mkshifts\fR is yes shiftlist is the output of the interactive offset computing task. Otherwise shiftlist must be created by the user. .le .ls sections ".corners" The output first pass sections file name or the string appended to the output first pass image name \fIoutput\fR to create the output first pass sections file name. The sections file contains the input image name from \fIinlist\fR, the coordinates of the lower left corner of the input image in the output combined image, and the coordinates of the upper right corner of the input image in the output combined image in columns 1 through 5 respectively. .le .ls rmasks = ".rjm" The output mask pass rejection mask list or the string appended to the sky subtracted image names to create the output rejection mask names. Rejection masks consist of 1's in the good regions and 0's elsewhere. .le .ls mp_nprev_omask = 0 The number of previous individual object masks that are combined to create the final individual object mask. .le .ls fractional = no Use the fractional as well as integer part of the corrected image offsets if mag = 1. Bilinear interpolation is used to do the fractional part of the shift. .le .ls pixin = yes If pixin is yes the input offsets called a and b are assumed to be defined in the reference image pixel coordinate system x and y, and ab_sense, xscale, yscale, and a2x_angle default to yes, -1.0, -1.0, and 0.0 respectively. .le .ls ab_sense = yes Is the rotation of the a to b axis counter-clockwise ? The x and b axes are the axes along which the input offsets are measured. Ab_sense defaults to yes if pixin is yes. .le .ls xscale = 1.0, yscale = 1.0 The number of pixel coordinates x and y per input coordinates a and b. For example if the input offsets are measured in arcseconds and the pixel scale is 0.25 arcseconds per pixel then xscale and yscale should be set to 4.0. Xscale and yscale default to -1.0 and -1.0 if pixin is yes. .le .ls a2x_angle = 0 The angle in degrees of the a offset axis measured counter-clockwise to the image x axis. A2x_angle defaults to 0.0 if pixin is yes. .le .ls ncoavg = 1 The number of co-averages per input image. The total exposure time for an image is ncoavg * exptime * secpexp where exptime is read from inlist. .le .ls secpexp = 1.0 The number of seconds per unit exposure time. Secpexp is required by the image combining task xnregistar. .le .ls y2n_angle = 0.0 The angle in degrees from the image y axis to the north axis measured from north through east. Y2n_angle can be used to orient the output image to within 45 degrees of N up and E left if set correctly. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? .le .ls omask = ".msk" The output combined image object mask name or the string appended to the first pass output image name \fIoutput_fp\fR to create the output combined object mask name. An additional "i" is added to the combined object mask name to create the inverse object core mask name. Object masks consist of 1's in object regions and 0's elsewhere. Inverse object masks are the reverse. .le .ls chkmasks = no Check the displayed mask and optionally enter a new threshold value ? .le .ls kpchking = yes Repeatedly check the mask until satisfied ? .le .ls mp_statsec = "" The combined image section used to compute the sky statistics in the mask creation step. By default the entire combined image is used. .le .ls mp_nsigcrmsk = 1.5 The factor times the recommended threshold used by the mask creation task to compute the combined image inverse object core mask for cosmic ray unzapping. .le .ls mp_nsigobjmsk = 1.1 The factor times the recommended threshold used by the mask creation task to compute the combined input image object mask used for improving the sky subtraction. .le .ls mp_negthresh = no Use negative as well as positive thresholds to create the combined input image object mask ? .le .ls ngrow = 0 The object growing box half-width in pixels ? .le .ls ocrmasks = ".ocm" The list of output individual inverse core object masks or the string appended to the individual sky subtracted image names to create the individual output inverse core object mask names. The inverse object masks consist of 0's in the object regions and 1's elsewhere and are used for unzapping cosmic rays detected in object regions. .le .ls objmasks = ".objm" The list of output individual image object masks or the string appended to the individual sky subtracted image names to create the individual output object mask names. The object masks consist of 1's in the object regions and 0's elsewhere and are used for improving the sky subtraction. .le .ls del_bigmasks = no Delete \fIomask\fR and its related inverse mask on task termination ? .le .ls del_smallmasks = no Delete \fIocrmasks\fR and \fIobjmasks\fR and their related inverse on task termination ? .le .ih DESCRIPTION XMOSAIC sky subtracts, bad pixel corrects, and cosmic ray corrects the input images in \fIinlist\fR and combines them into a single combined output image \fIoutput\fR and accompanying exposure map image \fIexpmap\fR. The image combining is done in two steps. The first step produces a first guess combined image which is used to construct the combined image object mask \fIomask\fR. The combined object mask is split into the corresponding individual image object masks which are used improve the sky subtraction and cosmic ray cleaning procedures in the final mask pass step. The output sky subtracted, bad pixel corrected, and cosmic ray corrected individual images are stored in \fIsslist\fR, and the output cosmic ray masks are stored in \fIcrmasks\fR. The bad pixel mask is assumed to be the same for all the input images and consists of 0's in bad pixel regions and 1's elsewhere. Cosmic ray masks consist of 1's in the cosmic ray regions and 0's elsewhere. The locations of the input images in the output combined image are stored in \fIsections\fR. The combined object mask and inverse object core mask for the first pass combined image are stored in \fIomask\fR and its associated inverse mask. The individual image object masks and inverse object core masks are stored in \fIobjmasks\fR and \fIocrmasks\fR respectively. Object masks consist of 1's in the object regions and 0's elsewhere. Inverse object masks consist of 0's in the object regions and 1's elsewhere. The output holes masks are stored in \fIhmasks\fR. Holes mask consist of 0's in regions where the sky subtraction is undefined and 1's elsewhere. If \fIfp_xslm\fR is yes XMOSAIC sky subtracts the input images using the XNSLM task if \fInewxslm\fR is yes or XSLM task f it is no, and writes the results to the output images \fIsslist\fR. For each input image XSLM/XNSLM computes the running mean of the \fInmean\fR neighboring images, after scaling them by the median pixel values and rejecting the \fInreject\fR highest scaled pixels. There must be at least \fInskymin\fR neighboring images for a sky image to be computed and subtracted. The input image medians are computed using pixels in the region defined by \fIstatsec\fR and iterative rejection with rejection parameters \fInsigrej\fR and \fImaxiter\fR. The reciprocal of the computed median is stored in the image header keyword "SKYMED". If \fIforcescale\fR is no and the "SKYMED" keyword is already defined in the image header, then the image medians are not recomputed. When sky subtraction is complete the keyword SKYSUB is written to the sky subtracted image header. More information about the XSLM/XNSLM task can be found in the XSLM/XNSLM help pages. If \fIfp_maskfix\fR is yes XMOSAIC removes known bad pixels from sky subtracted images \fIsslist\fR using the MASKFIX task and the bad pixel mask \fIbpmask\fR. The bad pixel mask consists of 0's in bad pixel regions and 1's elsewhere and must be the same size as the input sky subtracted images. The bad pixels are removed by linearly interpolating across bad columns in each image line. When bad pixel removal is complete the keyword "MASKFIX" is written to the header of the sky subtracted image. If \fIforcefix\fR is no and "MASKFIX" exists in the image header then the bad pixel removal step is skipped. More information on the MASKFIX task can be found in the MASKFIX help page. If \fIfp_xzap\fR is yes XMOSAIC removes cosmic rays from the sky subtracted images \fIsslist\fR using the XNZAP task if \fInewxzap\fR is yes or the XZAP task if it is no, and writes the cosmic ray masks to \fIcrmasks\fR. The output cosmic ray masks contain 1's in the cosmic ray regions and 0's elsewhere. Both XZAP and XNZAP write the keyword CRMASK which contains the name of the output cosmic ray MASK to the cosmic ray corrected image. If the CRMASK keyword is present in the sky subtracted image headers cosmic ray cleaning is skipped. XZAP is the tried and true XDIMSUM cosmic ray removal task. XNZAP is experimental but promises to be a faster technique. XZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the median of the surrounding box of 5 by 5 pixels, and which are not part of an object where an object is any pixel more than 2.0 sky sigma above the median of the surrounding 15 by 15 box of pixels. XZAP uses a sky subsampling factor of 2 and cosmic ray and region growing box widths of 0.0 and 0.0 respectively. The sky sigma is computed using the region of the input sky subtracted images specified by \fIstatsec\fR and iterative rejection with rejection parameters \fInsigrej\fR and fImaxiter\fR. The cosmic rays in the input sky subtracted images are replaced with the local median value. More information on the XZAP task can be found in the XZAP help page. XNZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the mean of the surrounding box of 5 by 5 pixels with the central pixel and the highest pixel removed, and which are not part of an object where an object is more than 5.0 sky sigma above the local background. The local background is defined as the median of the pixels in an annulus 5.0 pixels wide around the averaging box. The local sky sigma is estimated by computing the percentile points of pixels in 25 by 25 pixel subsections evenly distributed over the image. The cosmic ray and object growing radii are set to 0.0 and 0.0 respectively. The cosmic rays in the input sky subtracted images are replaced with the local average value. More information on the XNZAP task can be found in the XNZAP and CRAVERAGE help pages. If \fIfp_xzap\fR is yes and \fIfp_badpixupdate\fR is yes then XMOSAIC updates the bad pixel mask \fIbpmask\fRa using the BADPIXUPDATE task. BADPIXUPDATE examines the list of cosmic rays image produced by XZAP or XNZAP, searches for pixels that are bad in 3 or more images, and sets those pixels in \fIbpmask\fR t0 0. More information about BADPIXUPDATE can be found in the BADPIXUPDATE help page. If \fIfp_mkshifts\fR = yes then XMOSAIC calls the XDSHIFTS task to determine the x and y shifts required to accurately combine the sky subtracted images. XDSHIFTS displays the sky subtracted images and requests the user to identify a reference object common to all of them, then displays the reference image \fIreference\fR and requests the user to identify a set of registration objects. The reference objects are used to compute initial offset with respect to the reference image. The positions of the registration objects in each image are computed using a centroiding algorithm and a centering radius of \fIfp_cradius\fR pixels. Objects with offsets that are more than \fIfp_maxshifts\fR pixels larger than the initial offsets are rejected from the registration list and the shifts of the remaining objects are averaged to compute the final shift for each image. If \fIfp_chkshifts\fR is yes the user is permitted to edit the reference object list, the registration list, and the list of final shifts. Currently XDSHIFTS sets the exposure times of the input sky subtracted images to 1.0. More about the XDSHIFTS can be found in the XDSHIFTS help page. If \fIfp_mkshifts\fR = no then the name of the sky subtracted image, its x and y shifts relative to the reference image and its exposure time are read from the file \fIshiftlist\fR. Shiftlist may have been written by the XDSHIFTS, XMSHIFTS, XFSHIFTS, or XRSHIFTS tasks. If \fIfp_xnregistar\fR is yes then xmosaic combines the sky subtracted images into the first guess output combined image \fIoutput\fR and output exposure map image \fIexpmap\fR using the bad pixel mask \fIbpmask\fR, and offsets and scaling factors in \fIshiftlist\fR if \fIfp_mkshifts\fR is no, or computed by XDSHIFTS if the \fIfp_mkshifts\fR is yes. If \fIfractional\fR is no only the integer part of the shifts is used. XMOSAIC calls the XNREGISTAR task to do the actual image combining. The parameters \fIpixin\fR, \fIab_sense\fR, \fIxscale\fR, \fIyscale\fR, and \fIa2x_angle\fR are used to convert shifts from user units, e.g. arcseconds to units of pixels in the reference image. The parameters \fIncoavg\fR and \fIsecpexp\fR are used to normalize the input exposure times. The parameters \fIy2n_angle\fR and \fIrotation\fR are used to orient the final combined image and exposure map to within 45 degrees of north up and east to the left. The pixel positions of the input images in the output combined image are stored stored in the file \fIsections\fR for later use in the mask deregistration step. If \fImp_mkmask\fR is yes the first pass combined image object mask \fIomask\fR and its associated inverse object core mask are created by the MKMASK task using thresholding factors \fImp_nsigobjmask\fR and \fImp_nsigcrmask\fR times the recommended thresholding factor respectively. If \fImp_negthresh\fR is "yes" then both negative and positive masking thresholds are used to create the combined image object mask. The recommended threshold is computed using pixels in the section specified by \fImp_statsec\fR and iterative rejection with rejection parameters \fInsigrej\fR and \fImaxiter\fR. If \fIchkmasks\fR is yes the user is permitted to examine the combined image and set the threshold level. MKMASK uses default values of 2, 15, and 3 for the MKMASK image subsampling factor, median filter size, and smoothing size respectively. More about the MKMASK task can be found in the task help page. If \fImp_maskdereg\fR is yes then individual object masks and inverse object core masks \fIobjmasks\fR and \fIocrmasks\fR are created from the combined image object masks using information in the \fIsections\fR file. If \fImp_nprev_omask\fR > 0 then the object mask for each individual image is the sum of its own mask and those of its nprev_omask neighbors. The inverse object core masks are used to unzap cosmic rays in object regions where the cosmic ray positions are identified in \fIcrmasks\fR. The object mask and inverse object core mask names are stored in the image header keywords "OBJMASK" and "CROBJMAS" respectively. If \fImp_maskdereg\fR is no then the object masks are assumed to already exist. If \fImp_xslm\fR is yes XMOSAIC sky subtracts the input images using the XNSLM task if \fInewxslm\fR is yes or XSLM task if it is no and the object masks \fIobjmasks\fR, and writes the results to the output images \fIsslist\fR. Existing sky subtracted images are overwritten. The object masks are assumed to have been created by the MASKDEREG task and their names tored in the keyword OBJMASK in the input images. XSLM/XNSLM computes the running mean of the \fInmean\fR neighboring images, after scaling by their median pixel values and rejecting the \fInreject\fR highest scaled pixels. There must be at least \fInskymin\fR neighboring images for a sky image to be computed and subtracted. The input image medians are computed using pixels in the region defined by \fIstatsec\fR, the object mask \fIobjmask\fR if \fImp_useomask\fR is yes, and iterative rejection with rejection parameters \fInsigrej\fR and \fImaxiter\fR. The reciprocal of the computed median is stored in the image header keyword "SKYMED". If \fIforcescale\fR is no and the "SKYMED" keyword already exists in the image header then the image medians are not recomputed. If use of the object masks results in sky image pixels which are undefined then the holes mask \fIhmasks\fR is written. Holes masks consist of 0's in undefined regions and 1's elsewhere. If a holes mask was created then the keyword "HOLES" containing the name of the holes mask is written to the output image. More information about the XSLM/XNSLM task can be found in the XSLM/XNSLM help pages. If \fImp_maskfix\fR is yes XMOSAIC removes known bad pixels from sky subtracted images \fIsslist\fR using the MASKFIX task and the bad pixel mask \fIbpmask\fR exactly as it does in the first pass with the exception that the bad pixel mask may have been updated during the first pass. If \fImp_xzap\fR is yes XMOSAIC removes cosmic rays from the sky subtracted images \fIsslist\fR using the XNZAP task if \fInewxzap\fR is yes or the XZAP task if it is no, and writes the cosmic ray masks to \fIcrmasks\fR. Existing cosmic ray masks are overwritten. XZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the median of the surrounding box of 5 by 5 pixels and are not part of an object where an object is any pixel located in an object region defined by the inverse object masks \fIocrmasks\fR stored in the header keyword "CROBJMAS". More information about XZAP can be found in the corresponding description for the first pass cosmic ray cleaning step and in the XZAP help page. XNZAP detects and removes cosmic rays by finding pixels which are more than 5.0 sky sigma above the mean of the surrounding box of 5 by 5 pixels with the central pixel and the highest pixel removed and which are not part of an object where an object is defined by the inverse object mask \fIocrmasks\fR stored in the image header keyword "CROBJMAS". More information about XNZAP can be found in the corresponding description for the first pass cosmic ray cleaning step and in the XNZAP and CRAVERAGE help pages. If \fImp_xzap\fR is yes and \fImp_badpixupdate\fR is yes then XMOSAIC updates the bad pixel mask \fIbpmask\fR with the BADPIXUPDATE task in exactly the same way as it is done in the first pass. In preparation for final image combining the name of the sky subtracted image, its x and y shifts relative to the reference image and its exposure time are read from the file \fIshiftlist\fR. Shiftlist be a preexisting file written by one of the XDSHIFTS, XMSHIFTS, XFSHIFTS, or XRSHIFTS tasks or have been created interactively in the first pass with the XDSHIFTS task. If \fImp_xnregistar\fR is yes then XMOSAIC combines the sky subtracted images into the output combined image \fIoutput\fR and output exposure map image \fIexpmap\fR using the rejection masks \fIrmasks\fR. Rejection masks consist of 1's and 0's with 1's defining the good regions. Rejection masks are created by the XMSKCOMBINE task which combines the bad pixel mask \fIbpmask\fR, the cosmic ray masks \fIcrmasks\fR, the holes masks \fIhmasks\fR, and the \fInprev_omask\fR object masks in \fIobjmasks\fR and offsets and scaling factors read from \fIshiftlist\fR. XMOSAIC calls the XNREGISTAR task to do the actual image combining. The parameters \fIpixin\fR, \fIab_sense\fR, \fIxscale\fR, \fIyscale\fR, and \fIa2x_angle\fR are used to convert shifts from user units, e.g. arcseconds to units of pixels in the reference image. The magnification factor \fImp_mag\fR determines the magnification of the final combined image with respect the the initial combined image. If mag = 1 and \fIfractional\fR is no only the integer part of the shifts is used. If mag > 1 and \fImp_blkrep\fR is yes then block replication is used to do the magnification, otherwise bilinear interpolation is used. The parameters \fIncoavg\fR and \fIsecpexp\fR are used to normalize the input exposure times. The parameters \fIy2n_angle\fR and \fIrotation\fR are used to orient the final combined image and exposure map to within 45 degrees of north up and east to the left. .ih EXAMPLES 1. Perform a first and mask pass image combining operation on the demo images using the default shiftlist demo.slist. .nf cl> demos mkxdimsum cl> xmosaic @demo.list demo13 mosaic ".exp" shiftlist=demo.slist nsigrej=5.0 \ maxiter=10 bpmask=demo.pl secpexp=60.0 .fi 2. Repeat the first pass image combining operation on the demo images but determine the shifts interactively. cl> xmosaic @demo.list demo13 mosaic ".exp" fp_mkshifts=yes \ shiftlist=myshiftlist nsigrej=5.0 maxiter=10 bpmask=demo.pl secpexp=60.0 .nf ... do first pass sky subtraction with xslm ... do first pass bad pixel correction with maskfix ... do first pass cosmic ray cleaning with xzap ... do first pass bad pixel mask updating with badpixupdate ... enter the interactive xdshifts task ... the first sky subtracted image is displayed and imexamine starts ... use the n and p keystrokes to step though the image list ... select a reference object common to all image ... type q to quit imexamine ... the first sky subtracted image is displayed and imexamine starts ... move cursor to reference object and type a ... type n to display next image ... repeat previous 2 steps until first image is redisplayed ... type q to quit imexamine ... the reference sky subtracted image is displayed ... move cursor to registration objects and type a ... type q to quit xdisplay ... do first pass image combining with xnregistar ... create master object and inverse object masks with mkmask ... create individual object and inverse object masks with maskdereg ... do mask pass sky subtraction with xslm ... do mask pass bad pixel correction with maskfix ... do mask pass cosmic ray cleaning with xzap ... do mask pass bad pixel mask updating with badpixupdate ... do mask pass image combining with xnregistar .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xfirstpass, xmaskpass, xslm, xnslm, maskfix, xzap, xnzap, badpixupdate, xdshifts xnregistar .endhelp iraf-xdimsum-main/doc/xmshifts.hlp000066400000000000000000000137701455666516400175560ustar00rootroot00000000000000.help xmshifts Sep00 xdimsum .ih NAME xmshifts -- compute total offsets for an ordered sequence of images using object detection and list matching techniques .ih USAGE xmshifts inlist output shifts hwhmpsf threshold xlag ylag tolerance .ih PARAMETERS .ls inlist The list of input sky subtracted images. The input image list must be in order with each image offset from the previous one by approximately \fIxlag\fR pixels in x and \fIylag\fR pixels in y. .le .ls output The output total offsets file suitable for input to the xnregistar task. Output contains the input image name, the total x offset, the total y offset, and the default exposure time in columns 1 through 4 respectively. The total x and y offsets of image N are defined as the shifts x(N) - x(1) and y(N) - y(1) required to place image N in the same coordinate system as image 1. The default exposure time is 1 time unit. .le .ls shifts = "" The optional relative offsets file. Shifts contains the input image name, the relative x offset and the relative y offset in columns 1 through 3 respectively. The relative offsets of image N are defined as the shifts x(N-1) - x(N) and y(N-1) - y(N) required to register image N to image N-1. .le .ls hwhmpsf = 1.25 The approximate half-width at half-maximum of the image PSF in pixels. If the PSF width varies significantly over the sequence hwhmpsf should be set to the average value for the sequence. .le .ls threshold = 50.0 The object detection threshold above local background in ADU. Threshold should be set no lower than 4 * sigma where sigma is the standard deviation of the background pixels in ADU. .le .ls xlag = 0.0, ylag = 0.0 The approximate relative offsets x(N) - x(N-1) and y(N) - y(N-1) between adjacent images in the input image list. .le .ls tolerance = 5.0 The object matching tolerance in pixels used in the list matching step. .le .ls fradius = 2.5 (hwhmpsf) The fitting radius in units of hwhmpsf. Fradius defines the size of the Gaussian kernel used to compute the density enhancement image and the size of the image region used to do the moment analysis in the object detection step. .le .ls sepmin = 5.0 (hwhmpsf) The minimum separation for detected objects in units of hwhmpsf. .le .ls datamin = INDEF, datamax = INDEF The minimum and maximum good data values in ADU. Datamin and datamax default to the constants -MAX_REAL and MAX_REAL respectively. .le .ls roundlo = 0.0, roundhi = 0.5 The minimum and maximum ellipticity values for detected objects, where ellipticity is defined as 1 - b / a, and a and b are the semi-major and semi-minor object axis lengths respectively. .le .ls sharplo = 0.5, sharphi = 2.0 The minimum and maximum sharpness values of the detected objects, where sharpness is defined to be the ratio of the object size determined by moments analysis to the hwhmpsf parameter value. .le .ls nxblock = INDEF, nyblock = INDEF The working block size. If undefined nxblock and nyblock default to the number of columns and rows in the input image respectively. .le .ih DESCRIPTION XMSHIFTS computes total offsets for the images in the input image list \fIinlist\fR and writes the results in a form suitable for input to the xnregistar task to \fIoutput\fR. If the \fIshifts\fR parameter is defined the relative offsets for adjacent images are written to the file \fIshifts\fR. XMSHIFTS requires the input image list to be ordered and also requires that the relative offsets between adjacent images are approximately equal to \fIxlag\fR and \fIylag\fR pixels. XMSHIFTS computes the relative offsets between adjacent images by first detecting objects in each input image using the STARFIND task, and then by matching the resulting detected object lists in adjacent images using the XYXYMATCH task. STARFIND searches the input images for local density maxima with half-widths at half-maxima of ~ \fIhwhmpsf\fR and peak amplitudes greater than \fIthreshold\fR counts above the local background, which are brighter than all surrounding objects within a radius of \fIsepmin\fR * \fIhwhmpsf\fR pixels. Data within \fIfradius\fR * \fIhwhmpsf\fR pixels of the detected density maximum and within the good data range defined by the \fIdatamin\fR and \fIdatamax\fR parameters are used to estimate the object position, shape, and size relative to the PSF. Objects outside the shape and size limits specified by the \fIroundlo\fR, \fIroundhi\fR, \fIsharplo\fR, and \fIsharphi\fR parameters are eliminated from the final object list. By default STARFIND reads the entire input image into memory. If the input images become too large or memory is limited the \fInyblock\fR parameter can be set. For the sake of efficiency \fInxblock\fR should be left set to INDEF so that XMSHIFTS always operates on an integral number of image lines. More information on the STARFIND algorithms can be found in the STARFIND task help page. XYXYMATCH matches objects in adjacent images using the tolerance matching algorithm, a radial tolerance of \fItolerance\fR pixels, and initial guesses for the relative x and y offsets of \fIxlag\fR and \fIylag\fR. More information on the XYXYMATCH algorithms can be found in the XYXYMATCH task help page. The relative offsets between adjacent images are estimated by computing the average shift of all the detected matched objects. If adjacent frames contain no objects in common the relative offsets are set to \fIxlag\fR and \fIylag\fR. Total offsets are computed by summing the relative offsets. .ih EXAMPLES 1. Compute the total offsets for a series of 250 ONIS sky subtracted images which are offset by approximately 50 pixels in x and 0.5 pixels in y. Output both the total and relative offsets. Since the noise in the sky background for these images is around 12 ADU use a detection threshold of 50 ADU. .nf cl> type simlist ss_kk07_001 ss_kk07_002 ss_kk07_003 ... ... ss_kk07_249 ss_kk07_250 cl> xmshifts @simlist offsets shifts 1.5 50.0 50.0 0.5 tolerance=2.5 cl> xnregistar offsets "" "" "" kk07.mosaic kk07.corners .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xfshifts,xdshifts,starfind,xyxymatch .endhelp iraf-xdimsum-main/doc/xmskcombine.hlp000066400000000000000000000112341455666516400202210ustar00rootroot00000000000000.help xmskcombine Sep00 xdimsum .ih NAME xmkscombine -- combine the bad pixel, cosmic ray, holes, and previous object masks .ih USAGE xmkscombine inlist bpmask crmasks hmasks omasks rmasks .ih PARAMETERS .ls inlist The input sky subtracted image list. .le .ls bpmask The input bad pixel mask common to all the input sky subtracted images. The bad pixel mask is assumed to consist of 1's and 0's where 0 defines a bad pixel. If no bad pixel mask is defined a virtual bad pixel mask consisting entirely of 1's is assumed. .le .ls crmasks The list of input cosmic ray masks normally produced by the xzap or xnzap tasks. The cosmic ray mask is assumed to consist of 1's and 0's where 1 defines a cosmic ray. Crmasks may define a list masks which has the same length as inlist, or an image keyword containing the name of the cosmic ray mask. The default keyword name written by xzap and xnzap is "CRMASK". If no cosmic ray mask is defined a virtual cosmic ray mask consisting entirely of 0's is defined. .le .ls hmasks The list of input holes masks normally produced by the xslm task. The holes mask is assumed to consist of 1's and 0's where 0 defines a hole or undefined pixel in the input image sky subtracted image which contains no good data. Hmasks may define a list of masks which has the same length as inlist or an image keyword containing the name of the holes mask. The default keyword name written by xslm is "HOLES". If no holes mask is defined a virtual holes mask consisting entirely of 1's is defined. .le .ls omasks The list of input object masks normally produced by the mkmask / maskdereg tasks. The objects mask is assumed to consist of 1's and 0's where 1 defines and object and 0 defines the sky. Omasks may define a list of masks which has the same length as inlist or an image keyword containing the name of the object mask. The default keyword name written by maskdereg is "OBJMASK". If no objects mask is defined a virtual objects mask consisting entirely of 0's is defined. Object masks are only used if \fInprev_omask\fR > 0. .le .ls rmasks The list of output rejection masks or the string appended to the input sky subtracted image name to create the output rejection mask name. New rejection masks are not created if only the bad pixel mask \fIbpmask\fR is defined. Rejection masks consist entirely of 0's and 1's with 0's defining the bad pixels and are suitable for input to the XNREGISTAR task. The name of the rejection mask is written to the REJMASK keyword in the input image. .le .ls nprev_omask = 0 The number of previous object masks to combine to create an objects mask. By default no object masks are defined. If nprev_omask is 1 then the object mask of the previous image is used to mask the current image, if \fInprev_omask\fR = 2 then the 2 previous object masks are used, etc. .le .ih DESCRIPTION XMSKCOMBINE combines the bad pixel mask \fIbpmask\fR, the cosmic ray masks \fIcrmasks\fR (normally written by the XZAP or XNZAP tasks), the holes masks \fIhmasks\fR (normally written by the XSLM task), and the previous object masks \fIomasks\fR (normally written by the MKMASK and MASKDEREG tasks) into combined rejection masks \fIrmasks\fR corresponding to the sky subtracted images in \fIinlist\fR. The final combined mask which is suitable for input to the XNREGISTAR tasks consists entirely of 0's and 1's where 0's define the bad pixels. Users may befine their own \fIcrmasks\fR, \fIhmasks\fR, and \fIomasks\fR lists or set these parameters to the appropriate input image header keyword, normally CRMASK, HMASK, and OBJMASK respectively. .ih EXAMPLES 1. Combine the first pass bad pixel mask. Note that in this no new masks are written because the rejection mask is equal to the bad pixel mask. The bad pixel mask name is written to the REJMASK keyword. .nf cl> type simlist demo01.sub.im demo02.sub.imh demo03.sub.imh ... ... demo24.sub.imh demo25.sub.imh cl> xmskcombine @simlist demo.pl "" "" "" ".rjm" .fi 2. Combine the first pass bad pixel mask and the cosmic ray masks. The rejection mask name is written to the REJMASK keyword. .nf cl> type simlist demo01.sub.im demo02.sub.imh demo03.sub.imh ... ... demo24.sub.imh demo25.sub.imh cl> xmskcombine @simlist demo.pl CRMASK "" "" ".rjm" .fi 3. Combine the bad pixel, cosmic ray, holes, and previous object masks. The rejection mask name is written to the REJMASK keyword. .nf cl> type simlist demo01.sub.im demo02.sub.imh demo03.sub.imh ... ... demo24.sub.imh demo25.sub.imh cl> xmskcombine @simlist demo.pl CRMASK HOLES OBJMASK ".rjm" .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xslm,xzap,xnzap,mkmask,mkdereg,xnregistar .endhelp iraf-xdimsum-main/doc/xnregistar.hlp000066400000000000000000000211701455666516400200700ustar00rootroot00000000000000.help xnregistar Sep00 xdimsum .ih NAME xnregistar -- combine a list of sky subtracted images using precomputed offsets exposure times and masks .ih USAGE xnregistar inlist rmasks output expmap sections .ih PARAMETERS .ls inlist The input shiftlist normally produced by the xmshifts, xfshifts, xrshifts, or xdshifts tasks. Inlist contains the name of the input sky subtracted image, the x offset, the y offset, and the exposure time in columns 1 through 4. .le .ls rmasks The list of input rejection masks normally produced by the xmskcombine task. The rjection mask is assumed to consist of 1's and 0's where 1's define the good values. Rrmasks may define a list masks which has the same length as inlist, or an image keyword containing the name of the rejection mask. The default keyword name written by xmskcombine is "REJMASK". If no rejection mask is defined a virtual cosmic ray mask consisting entirely of 1's is defined. .le .ls output The name of the output combined image. .le .ls expmap The name of the output exposure map image. .le .ls sections The optional output sections or corners file suitable for input to the maskdereg task. If defined sections contains the name of the input images in \fIsinlist\fR if it is defined or \fIinlist\fR, the x and y coordinates of the lower left corner of the input image in the combined output image, and the x and y coordinates of the upper right corner of the input image in the output image in columns 1 through 5 respectively. .le .ls sinlist = "" The list of image names that will be written to the sections file. If sinlist is undefined then the input image names in \fIinlist\fR are used. .le .ls nprev_omask = 0 The number of previous object masks to combine to create an objects mask. By default no object masks are defined. If nprev_omask is 1 then the object mask of the previous image is used to mask the current image, if \fInprev_omask\fR = 2 then the 2 previous object masks are used, etc. .le .ls blkrep = yes Use block replication to magnify the image if \fImag\fR > 1 rather than bilinear interpolation ? .le .ls mag = 1 The default magnification factor. If mag = 1 the scale of the output image is the same as the scale of the input images. If mag > 1 then the input images are block replicated by a factor of mag before being combined to create the output images. .le .ls fractional = no If fractional is yes then the input images are shifted by the fractional part of the total offset in inlist before being combined. If fractional is no then the fractional part of the pixel shift is lost. .le .ls pixin = yes If pixin is yes the input offsets called a and b are assumed to be defined in the reference image pixel coordinate system x and y and ab_sense, xscale, yscale, and a2x_angle default to yes, -1.0, -1.0, and 0.0 respectively. .le .ls ab_sense = yes Is the rotation of the a to b axis counter-clockwise ? The x and b axes are the axes along which the input offsets are measured. Ab_sense defaults to yes if pixin is yes. .le .ls xscale = 1.0, yscale = 1.0 The number of pixel coordinates x and y per input coordinates a and b. For example if the input offsets are measured in arcseconds and the pixel scale is 0.25 arcseconds per pixel then xscale and yscale should be set to 4.0. Xscale and yscale default to -1.0 and -1.0 if pixin is yes. .le .ls a2x_angle = 0 The angle in degrees of the a offset axis measured counter-clockwise to the image x axis. A2x_angle defaults to 0.0 is pixin is yes. .le .ls ncoavg = 1 The number of co-averages per input image. The total exposure time for an image is ncoavg * exptime * secpexp where exptime is read from inlist. .le .ls secpexp = 1.0 The number of seconds per unit exposure time. .le .ls y2n_angle = 0.0 The angle in degrees from the image y axis to the north axis measured from north through east. Y2n_angle can be used to orient the output image to within 45 degrees of N up and E left if set correctly. .le .ls rotation = yes Is the rotation of the input image north axis to the east axis counter-clockwise ? .le .ih DESCRIPTION XNREGISTAR uses the image names, positional offsets, and exposure time data in \fIinlist\fR to create a combined output image \fIoutput\fR and associated exposure map image \fIexpmap\fR. Bad data in each input image is excluded from the output image and exposure map image using the rejection masks \fIrmasks\fR. Rejection masks consist entirely of 1's and 0's with 1's defining the good pixels. Rejection masks are normally created by the XMSKCOMBINE task which combines information in the global bad pixel mask, the cosmic ray masks (normally written by the XZAP or XNZAP tasks), the input image holes mask (normally written by the XSLM task), and the object masks (normally written by the MKMASK and MASKDEREG tasks), to create a single rejection mask for each input image. If the sections file \fIsections\fR is defined an output file describing the location of each input image in the output image is also written. The sections file is suitable for input to the MASKDEREG task. The input image names in column 1 of \fIinlist\fR are the names of the sky subtracted images normally written by the XSLM task. If \fIsinlist\fR is "" these names are written to the sections file \fIsections\fR. Otherwise the names in sinlist are used. The number of images in sinlist must be 0 or the same as the number of input images. The offsets in columns 2 and 3 of \fIinlist\fR are assumed to be defined in the ab coordinate system. If \fIpixin\fR = yes then the ab coordinate system is assumed to be the same as the xy coordinate system of the reference image used to compute the offsets. If pixin = no then the \fIab_sense\fR, \fIxscale\fR, \fIyscale\fR, and \fIa2x_angle\fR are used to determine the transformation from the ab to the xy coordinate system. If \fImag\fR is > 1 then the input images are block replicated by a factor of mag before being combined into the output image and output exposure map image. The integer pixel offsets for each input image are computed as shown below. These offsets are passed directly to the IMCOMBINE task which does the actual image combining. The quantities a and b are the coordinates as read directly from \fIinlist\fR. .nf tmag = mag if (pixin == yes) { ab_sense = yes txscale = -1.0 tyscale = -1.0 ta2x = 0.0 sign = 1 } else if (ab_sense == yes) { txscale = xscale tyscale = yscale ta2x = a2x_angle sign = 1 } else { txscale = xscale tyscale = yscale ta2x = a2x_angle sign = -1 } x = tmag * (txscale * a * cos (ta2x) + tyscale * b * sign * sin (ta2x)) y = tmag * (tyscale * b * sign * cos (ta2x) - txscale * a * sin (ta2x)) if (x == 0.0) ix = 0 else ix = int (x + 0.5 * (x / abs (x))) if (y == 0.0) iy = 0 else iy = int (y + 0.5 * (y / abs (y))) .fi If \fIfractional\fR = yes then the input images are shifted by the fractional part of the pixel offsets using the IMSHIFTS task before being combined with the IMCOMBINE task. If fractional = no the fractional part of the shift is ignored. The fractional shifts are defined as follows. .nf xfrac = newx - ix yfrac = newy - iy .fi The input images are multiplied by a factor equal to \fIncoavg / (mag * mag)\fR before being summed into the combined output image \fIoutput\fR. The summed output image is divided by the exposure map image to compute the final output image. Each input image contributes a factor equal to \fItexp * ncoavg * secpexp\fR to the exposure map image, where texp is the exposure time read from \fIinlist\fR. The bad data masks \fIbpmask\fR, \fIcrmasks\fR, \fIholes\fR, and \fIomasks\fR are used to exclude bad pixels, known cosmic ray pixels, and undefined pixels from the combined output image and output exposure map image. Finally if \fIy2n_angle\fR and \fIrotation\fR are set correctly the output image and the output exposure map image will be oriented to within 45 degrees of north pointing up and east pointing left. .ih EXAMPLES 1. Compute the total offsets for the series of 25 demo sky subtracted images whose total offsets were computed with the xdshifts task. Combine the images with xnregister using the bad pixel mask demo.pl. The output image and exposure map image will be written to demo.mosaic and exp_demo.mosaic respectively. .nf cl> type simlist demo01.sub.im demo02.sub.imh demo03.sub.imh ... ... demo24.sub.imh demo25.sub.imh cl> xdshifts @simlist "" offsets cradius=5.0 cl> xmskcombine @simlist badpix.pl "" "" "" ".rjm" cl> xnregistar offsets REJMASK demo.mosaic demo.mosaic.exp "" .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xmshifts,xfshifts,xrshifts,xdshifts,xslm,xzap,xnzap,imshift,blkrep,imcombine .endhelp iraf-xdimsum-main/doc/xnslm.hlp000066400000000000000000000131131455666516400170410ustar00rootroot00000000000000.help xnslm Sep01 xdimsum .ih NAME xnslm -- sky subtract a list of images using a running mean .ih USAGE xnslm inlist omasks nmean outlist .ih PARAMETERS .ls inlist The list of input images to be sky subtracted. The input image list is assumed to be in order. .le .ls omasks The list of object masks associated with each input image or the input image keyword containing the name of the object mask normally OBJMASK. Object masks contain 1's in object regions and 0's elsewhere. .le .ls nmean The number of neighboring images used to computed the sky image for each input image. .le .ls outlist The list of output sky subtracted images. .le .ls hmasks = ".hom" The list of output holes masks or the string appended to the output image name to create the holes mask name. The holes masks are only created if the input object masks are defined, and there is at least one undefined sky image pixel. Holes masks contain 0's in undefined sky regions and 1's elsewhere. The holes mask is required by later processing steps and is normally not deleted on task termination. .le .ls forcescale = no Force recalculation of the input image statistics even though they have been previously computed and stored in the keyword "SKYMED". .le .ls useomask = yes Use the input object masks if any to compute the sky statistics as well as create the sky images ? .le .ls statsec = "" The input image section used to compute the sky statistics for each input image. By default the entire input image is used. .le .ls nsigrej = 3.0 The rejection limits used to compute the image statistics in number of sigma. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the image statistics. .le .ls nskymin = 3 The minimum number of input images used to compute the sky image. .le .ls nreject = 1 The number of high and low side pixels to reject when computing the sky image. .le .ls cache = yes Enable the caching the input image data in memory ? .le .ls del_hmasks = no Delete the holes masks at task termination ? .le .ih DESCRIPTION XNSLM computes the average sky image for each image in the input image list \fIinlist\fR and subtracts it from the input image to create the output list of sky subtracted images \fIoutlist\fR. The input image list is assumed to be ordered by time of observation. If the input object masks list \fIomasks\fR is defined then input image pixels in object regions are removed from the sky image computation. XSLM also creates a list of holes masks \fIhmasks\fR. XNSLM estimates the median for each input image using iterative rejection around the mean, pixels in the region defined by \fIstatsec\fR, and the bad pixel rejection parameters \fInsigrej\fR and \fImaxiter\fR. If \fIuseomask\fR = yes and an object mask is defined for the input image, then pixels in object regions are also rejected from the sky statistics computation. The reciprocal of the median value is stored in the keyword "SKYMED". New sky statistics are computed if \fIforcescale\fR is yes or if the SKYMED keyword is undefined. The XRSKYSUB task is used to compute the image statistics. XNSLM computes the sky image for each input image by multiplying each input image by the value of the SKYMED keyword, and then computing the mean of the \fInmean\fR neighbor images after rejecting the \fInreject\fR high and low pixels. For example if the number of input images is 25 and nmean is 6 then images 2-4 are used to compute the sky image for image 1, images 10-12 and 14-16 are used to compute the sky for image 13, and images 22-24 are used to compute the sky image for image 25. There must be a minimum of \fInskymin\fR neighbor images or the sky image will not be computed. If the input object masks are defined then pixels in object regions are also rejected from the sky image computation. The XRSKYSUUB task is used to compute and subtract the sky images. After the sky image is computed XNSLM divides it into the input image and computes the median of the ratio image. The final sky subtracted image is computing by multiplying the sky image by the median of the ratio image and subtracting it from the input image. The XRSKYSUB task does this as well. More about XRSKYSUB can be found in the appropriate help page. If input image masking is enabled then it is possible for pixels in the sky image and the output sky subtracted image to be undefined. If at least one such pixel is undefined in the output image then XNSLM creates a holes mask \fIhmasks\fR. The holes masks are used by the XMSKCOMBINE task tp create a combined mask for the XNREGISTAR tas. If \fIcache\fR is yes then XNSLM will attempt to cache image in memory as needed. This can significantly speed up the statisticis computation and the image combining step. If \fIdel_hmasks\fR is enabled then the holes masks are deleted at task termination. .ih EXAMPLES 1. Sky subtract the demo images with object masking. .nf cl> type demo.list demo01 demo01 ... demo25 cl> xnslm @demo.list "" 6 ".sub" nsigrej=5.0 maxiter=10 cl> dir *.sub.imh demo01.sub.imh demo01.sub.imh ... demo25.sub.imh .fi 2. Repeat the previous example but specify an output image list. .nf cl> xnslm @demo.list "" 6 @outlist nsigrej=5.0 maxiter=10 .fi 3. Repeat example 1 with object masking assuming that the object mask names are stored in the keyword "OBJMASK" .nf cl> xnslm @demo.list "OBJMASK" 6 ".sub" nsigrej=5.0 maxiter=10 .fi 4. Repeat example 2 with object masking assuming that the object mask names are stored in the image list objmasks. .nf cl> xnslm @demo.list @objmasks 6 @outlist nsigrej=5.0 maxiter=10 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xslm .endhelp iraf-xdimsum-main/doc/xnzap.hlp000066400000000000000000000126371455666516400170520ustar00rootroot00000000000000.help xnzap Sep00 xdimsum .ih NAME xnzap -- remove cosmic rays using a moving average filter .ih USAGE xnzap inlist omasks outlist crmasks .ih PARAMETERS .ls inlist The list of input sky subtracted images to be cosmic ray corrected. .le .ls omasks The list of input object masks used to unzap cosmic rays detected in object regions or the input image keyword containing the name of the object mask, normally "CROBJMAS". Object masks contain 0's in object regions and 1's elsewhere. Note that this is the inverse of the usual definition of an XDIMSUM object mask. .le .ls outlist The list of output cosmic ray corrected images. The output image list can be the same as the input image list. .le .ls crmasks = ".crm" The name of the output cosmic ray masks or the string appended to the output image name to create the output cosmic ray mask name. Cosmic ray masks contain 1's in cosmic ray regions and 0's elsewhere. The name of the output cosmic ray mask is stored in the input and output image header keyword CRMASK. .le .ls zboxsz = 5 The size in pixels of the moving average filter. The central pixel plus \fInrejzap\fR pixels are rejected from the average. .le .ls skyfiltsize = 15 The sky filter size in pixels. For each point the median of the pixels in an annulus of width (\fIskyfiltsize\fR - \fIzboxsz\fR) / 2 pixels is used to estimate the local background. .le .ls sigfiltsize = 25 Size of box used for local background sigma estimates. The sigma filter is not a moving filter. Sigmas are estimated using percentile points of of the pixels in the box. .le .ls nsigzap = 5.0 The cosmic ray detection threshold in units of sky sigma. .le .ls nsigneg = 0.0 The negative deviant pixel detection threshold in units of sky sigma. If nsigneg <= 0.0 negative feature detection is not enabled. .le .ls nrings = 0 The cosmic ray growing region half-width in pixels. .le .ls nsigobj = 2.0 The object detection threshold in units of sky sigma. If nsigobj <= 0.0 only cosmic ray detection is performed. .le .ls ngrowobj = 0 The number of pixels to flag as a buffer around objects detected in the object detection step. .le .ls del_crmask = no Delete the cosmic ray mask at task termination ? By default the cosmic ray masks are stored and used in later processing steps. .le .ls verbose = no Print messages about actions taken by the task ? .le .ih DESCRIPTION XNZAP detects detects and removes cosmics rays from the input images \fIinlist\fR and writes the corrected images to \fIoutlist\fR. The output image list may be the same as the input image list. If input object masks \fIomasks\fR are defined then only cosmic rays in sky regions are detected and removed. These object mask consist of 0's and 1's with 0's defining the object regions in contrast to the usual XDIMSUM convention. The output cosmic rays mask are written to \fIcrmasks\fR. Cosmic ray masks consist of 1's and 0's with 1's defining the detected cosmic rays. At each pixel position XNZAP computes a running average filter of size \fIzboxsz\fR excluding the central pixel and the \fInrejzap\fR highest pixels from the average, and a running median in an annulus (\fIskyfiltsize\fR - \fIzboxsz\fR) / 2 pixels wide. The local sky sigmas are estimated by dividing the image into square blocks which are \fIsigfiltsize\fR pixels wide and estimating the percentile points of pixels in the box. A pixel is considered part of an object if the difference between the average value and the median background > \fInsigobj\fR times the background sigma. If nsigobj <= 0 then no object detection is performed. If the pixel is NOT considered to be part of an object and if the difference between the pixel value and the average value exceeds \fInsigzap\fR times the background sigma it is identified as a cosmic ray. If \fInsigneg\fR > 0.0 then pixels more than nsigneg times the background sigma are also considered to be cosmic rays and are added to the cosmic ray mask. If \fInrings\fR > 0 then XNZAP grows the detected cosmic rays to include pixels within a radius of nrings pixels of the detected cosmic ray. If \fInobjgrow\fR is > 0 then the detected object regions are grown to include pixels with a radius of nobjgrow pixels of the target object. The output cosmic ray mask is not affected by the region growing parameters however. XNZAP is a new cosmic ray detection program which can be used as an alternative to XZAP. It uses the CRAVERAGE task to detect and remove cosmic rays. Normally CRAVERAGE is part of the addon CRUTIL package but a private copy has been installed in XDIMSUM. Users can find out more about CRAVERAGE by consulting the CRAVERAGE help page. If \fIdel_crmask\fR = yes the output cosmic ray mask is deleted on task termination If \fIverbose\fR = yes then XNZAP prints messages on the terminal about the progress of the task. .ih EXAMPLES 1. Detect cosmic rays in the demo sky subtracted images. .nf cl> type sdemo.list demo01.sub.imh demo02.sub.imh ... demo25.sub.imh cl> xnzap @sdemo.list "" @sdemo.list ".crm" .fi 2. Repeat example 1 but specify an output cosmic ray mask list. .nf cl> xnzap @sdemo.list "" @sdemo.list @crmlist .fi 3. Repeat example 1 but specify an input inverse object core mask using the keyword "CROBJMAS". .nf cl> xnzap @sdemo.list "CROBJMAS" @sdemo.list ".crm" .fi 4. Repeat example 2 but specify the input inverse object core mask list. .nf cl> xnzap @sdemo.list @ocrmlist @sdemo.list @crmlist .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xzap, craverage .endhelp iraf-xdimsum-main/doc/xrshifts.hlp000066400000000000000000000156431455666516400175640ustar00rootroot00000000000000.help xrshifts Sep00 xdimsum .ih NAME xrshifts -- compute total offsets for an ordered sequence of images using cross-correlation techniques .ih USAGE xrshifts inlist output shifts regions xlag ylag window cbox .ih PARAMETERS .ls inlist The list of input sky subtracted images. The input image list must be in order with each image offset from the previous one by approximately \fIxlag\fR pixels in x and \fIylag\fR pixels in y. .le .ls output The output total offsets file suitable for input to the xnregistar task. Output contains the input image name, the total x offset, the total y offset, and the default exposure time in columns 1 through 4 respectively. The total x and y offsets of image N are defined as the shifts x(N) - x(1) and y(N) - y(1) required to place image N in the same coordinate system as image 1. The default exposure time is 1 time unit. .le .ls shifts = "" The optional relative offsets file. Shifts contains the input image name, the relative x offset and the relative y offset in columns 1 through 3 respectively. The relative offsets of image N are defined as the shifts x(N-1) - x(N) and y(N-1) - y(N) required to register image N to image N-1. .le .ls regions The input image region used to compute the cross-correlation function. Regions should be defined so as to exclude areas of obviously bad data. By default the entire image is used. .le .ls xlag, ylag The approximate relative offsets x(N) - x(N-1) and y(N) - y(N-1) between adjacent images in the input image list. .le .ls window The width of the cross-correlation function region to be computed and searched for peaks. The search window corresponds to shifts of - window / 2 <= shift <= window /2. \fIWindow\fR is automatically rounded up to the next nearest odd number. .le .ls cbox The width of the box centered on the peak of the cross-correlation function used to compute the fractional pixel x and y center. .le .ls background = "none" The default background function to be subtracted from the input and reference image data in the correlation region before the cross-correlation function is computed. The options are: .ls none no background subtraction is done. .le .ls mean the mean of the reference and input image region is computed and subtracted from the image data. .le .ls median the median of the reference and input image region is computed and subtracted from the data. .le .ls plane a plane is fit to the reference and input image region and subtracted from the data. .le By default the cross-correlation function is computed in a manner which removes the mean intensity in the reference and input image regions from the data. For many data sets this "correction" is sufficient to remove first order background level effects from the computed cross-correlation function and no additional background subtraction is required. .le .ls correlation = "discrete" The algorithm used to compute the cross-correlation function. The options are: .ls discrete The cross-correlation function is calculated by computing the discrete convolution of the reference and imput image regions over the x and y window of interest. This technique is most efficient method for small cross-correlation function x and y search windows. .le .ls fourier The cross-correlation function is calculated by computing the convolution of the reference and input image regions using Fourier techniques. This technique is the most efficient method for computing the cross-correlation function for small x and y search windows. .le .le .function = "centroid" The algorithm used to compute the x and y position of the cross-correlation function peak. The options are: .ls none the position of the cross-correlation function peak is set to x and y position of the maximum pixel. .le .ls centroid the position of the cross-correlation function peak is calculated by computing the intensity-weighted mean of the marginal profiles of the cross-correlation function in x and y. .le .ls sawtooth the position of the cross-correlation function peak is calculated by convolving 1D slices in x and y through the cross-correlation function with a 1D sawtooth function and using the point at which the peak is bisected to determine the x and y position of the cross-correlation peak. .le .ls parabolic a 1D parabola is fit to 1D slices in x and y through the cross-correlation function and the fitted coefficients are used to compute the peak of the cross-correlation function. .le .ls mark mark the peak of the cross-correlation function with the graphics cursor. This option will only work if \fIinteractive\fR = "yes". .le .le .ls tolerance = 5.0 The maximum permitted difference between the computed relative offsets and the initial values of \fIxlag\R and \fIylag\fR. .le .ls interactive = no Compute the cross-correlation function and relative offsets interactively ? .le .ih DESCRIPTION XRSHIFTS computes total offsets for the images in the input image list \fIinlist\fR and writes the results in a form suitable for input to the xnregistar task to \fIoutput\fR. If the \fIshifts\fR parameter is defined the relative offsets for adjacent images are written to the file \fIshifts\fR. XRSHIFTS requires the input image list to be ordered and also requires that the relative offsets between adjacent images are approximately equal to \fIxlag\fR and \fIylag\fR pixels. XRSHIFTS computes the relative offsets between adjacent images by computing the peak of the cross-correlation function for each pair of adjacent images using the XREGISTER task. XREGISTER computes the cross-correlation function of pairs of adjacent images using data in \fIregions\fR and a correlation window of width \fIwindow\fR pixels. The maximum detectable shifts is +/- window / 2 pixels. Window should be set large enough to detect the likely range of shifts. If \fIbackground\fR is set then the background is estimated and subtracted from the input image data before the cross-correlation function is computed. If \fIcorrelation\fR is "fourier" the cross-correlation function is computed using fourier transform techniques, otherwise it is computed directly. The position of the peak of the cross-correlation function is computed using \fIcbox\fR pixels centered around the correlation peak and the algorithm specified by \fIfunction\fR. If adjacent frames contain no objects in common or the computed shift is greater than \fItolerance\fR the relative offsets are set to \fIxlag\fR and \fIylag\fR. Total offsets are computed by summing the relative offsets. .ih EXAMPLES 1. Compute the total offsets for a series of 250 ONIS sky subtracted images which are offset by approximately 50 pixels in x and 0.5 pixels in y. Output both the total and relative offsets. .nf cl> type simlist ss_kk07_001 ss_kk07_002 ss_kk07_003 ... ... ss_kk07_249 ss_kk07_250 cl> xrshifts @simlist offsets shifts [*,*] 50.0 0.5 31 9 tolerance=2.5 cl> xnregistar offsets "" "" "" kk07.mosaic kk07.corners .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xmshifts,xfshifts,xdshifts,xregister .endhelp iraf-xdimsum-main/doc/xslm.hlp000066400000000000000000000147161455666516400166750ustar00rootroot00000000000000.help xslm Sep00 xdimsum .ih NAME xslm -- sky subtract a list of images using a running mean .ih USAGE xslm inlist omasks nmean outlist .ih PARAMETERS .ls inlist The list of input images to be sky subtracted. The input image list is assumed to be in order. .le .ls omasks The list of object masks associated with each input image or the input image keyword containing the name of the object mask normally OBJMASK. Object masks contain 1's in object regions and 0's elsewhere. .le .ls nmean The number of neighboring images used to computed the sky image for each input image. .le .ls outlist The list of output sky subtracted images. .le .ls ssmasks = ".ssm" The list of output sky subtraction masks or the string appended to the output image name to create the output sky subtraction mask name. The sky subtraction masks are only created if the input object masks are defined, and contain the total number of input sky image pixels minus the number of sky image pixels actually used to compute the sky image. The sky subtraction masks are normally deleted on task termination. .le .ls hmasks = ".hom" The list of output holes masks or the string appended to the output image name to create the holes mask name. The holes masks are only created if the input object masks are defined, and there is at least one undefined sky image pixel. Holes masks contain 0's in undefined sky regions and 1's elsewhere. The holes mask is required by later processing steps and is normally not deleted on task termination. .le .ls forcescale = no Force recalculation of the input image statistics even though they have been previously computed and stored in the keyword "SKYMED". .le .ls useomask = yes Use the input object masks if any to compute the sky statistics as well as create the sky images ? .le .ls statsec = "" The input image section used to compute the sky statistics for each input image. By default the entire input image is used. .le .ls nsigrej = 3.0 The rejection limits used to compute the image statistics in number of sigma. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the image statistics. .le .ls nskymin = 3 The minimum number of input images used to compute the sky image. .le .ls nreject = 1 The number of high and low side pixels to reject when computing the sky image. .le .ls del_ssmasks = yes Delete the sky subtraction masks at task termination ? .le .ls del_hmasks = no Delete the holes masks at task termination ? .le .ih DESCRIPTION XSLM computes the average sky image for each image in the input image list \fIinlist\fR and subtracts it from the input image to create the output list of sky subtracted images \fIoutlist\fR. The input image list is assumed to be ordered by time of observation. If the input object masks list \fIomasks\fR is defined then input image pixels in object regions are removed from the sky image computation. XSLM also creates a list of rejected input image pixel masks \fIssmasks\fR and a list of holes masks \fIhmasks\fR. XSLM estimates the median for each input image using iterative rejection around the mean, pixels in the region defined by \fIstatsec\fR, and the bad pixel rejection parameters \fInsigrej\fR and \fImaxiter\fR. If \fIuseomask\fR = yes and an object mask is defined for the input image, then pixels in object regions are also rejected from the sky statistics computation. The reciprocal of the median value is stored in the keyword "SKYMED". New sky statistics are computed if \fIforcescale\fR is yes or if the SKYMED keyword is undefined. XSLM uses the ITERSTAT task to compute the image statistics if the input object masks are undefined, otherwise it uses the MASKSTAT task. More information on ITERSTAT and MASKSTAT can be found in the appropriate help pages. XSLM computes the sky image for each input image by multiplying each input image by the value of the SKYMED keyword, and then computing the mean of the \fInmean\fR neighbor images after rejecting the \fInreject\fR high and low pixels. For example if the number of input images is 25 and nmean is 6 then images 2-4 are used to compute the sky image for image 1, images 10-12 and 14-16 are used to compute the sky for image 13, and images 22-24 are used to compute the sky image for image 25. There must be a minimum of \fInskymin\fR neighbor images or the sky image will not be computed. If the input object masks are defined then pixels in object regions are also rejected from the sky image computation. The IMCOMBINE task is used to compute the sky images. More about IMCOMBINE can be found in the IMCOMBINE help page. After the sky image is computed XSLM divides it into the input image and computes the median of the ratio image using the ITERSTAT or MASKSTAT tasks described above. The final sky subtracted image is computing by multiplying the sky image by the median of the ratio image and subtracting it from the input image. The IMEXPR task is used to do the scaling and subtraction. More about IMEXPR can be found in the appropriate help pages. If the input object masks are defined then XSLM also creates the sky subtraction masks \fIssmasks\fR. Each pixel of the sky subtraction pixel is equal to the total number of input images used to compute the sky image minus the number of input image pixels actually used. If at least one pixel in the sky subtraction mask is equal to the number of input images used to compute the sky frame then at least one sky pixel was undefined and a holes mask \fIhmasks\fR is created. The holes masks are used by the XNREGISTAR task to create the combined final image. If \fIdel_ssmasks\fR and \fIdel_hmasks\fR then the sky subtraction and holes masks are deleted at task termination. .ih EXAMPLES 1. Sky subtract the demo images with object masking. .nf cl> type demo.list demo01 demo01 ... demo25 cl> xslm @demo.list "" 6 ".sub" nsigrej=5.0 maxiter=10 cl> dir *.sub.imh demo01.sub.imh demo01.sub.imh ... demo25.sub.imh .fi 2. Repeat the previous example but specify an output image list. .nf cl> xslm @demo.list "" 6 @outlist nsigrej=5.0 maxiter=10 .fi 3. Repeat example 1 with object masking assuming that the object mask names are stored in the keyword "OBJMASK" .nf cl> xslm @demo.list "OBJMASK" 6 ".sub" nsigrej=5.0 maxiter=10 .fi 4. Repeat example 2 with object masking assuming that the object mask names are stored in the image list objmasks. .nf cl> xslm @demo.list @objmasks 6 @outlist nsigrej=5.0 maxiter=10 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO iterstat,maskstat,imcombine,imexpr .endhelp iraf-xdimsum-main/doc/xzap.hlp000066400000000000000000000153441455666516400166720ustar00rootroot00000000000000.help xzap Sep00 xdimsum .ih NAME xzap -- remove cosmic rays using median filtering .ih USAGE xzap inlist omasks outlist crmasks .ih PARAMETERS .ls inlist The list of input sky subtracted images to be cosmic ray corrected. .le .ls omasks The list of input inverse object core masks used to unzap cosmic rays detected in object regions or the input image keyword containing the name of the inverse object mask normally CROBJMAS. Inverse object core masks contain 0's in object regions and 1's elsewhere. Note that this is the inverse of the usual definition of an object mask. .le .ls outlist The list of output cosmic ray corrected images. The output image list can be the same as the input image list. .le .ls crmasks = ".crm" The list of output cosmic ray masks or the suffix appended to the output image name to create the output cosmic ray mask name. Cosmic ray masks contain 1's in cosmic ray regions and 0's elsewhere. The name of the output cosmic ray mask is stored in the input and output image header keyword CRMASK. .le .ls statsec = "" The input image section used to compute the image statistics for each input image. By default the entire input image is used. .le .ls nsigrej = 3.0 The rejection limits used to compute the image statistics in number of sigma. .le .ls maxiter = 20 The maximum number of rejection cycles used to compute the image statistics. .le .ls checklimits = yes Check the input image data limits for the fast median filter ? If checklimits is yes then the lower and upper data limits are set to max (\fIzmin\fR, image_min) and min (\fIzmax\fR, image_max) respectively. If checklimits is no no image data limits checking is done. .le .ls zmin = -32768.0, zmax = 32767.0 The default data limits supplied to the fast median filter if \fIchecklimits\fR is yes. .le .ls zboxsz = 5 The size in pixels of the fast median filtering box. .le .ls nsigzap = 5.0 The cosmic ray detection threshold in units of sky sigma. .le .ls nsigobj = 2.0 The object detection threshold in units of sky sigma. If nsigobj <= 0.0 only cosmic ray detection is performed. .le .ls subsample = 1 The input image subsampling factor used in the object detection step. .le .ls skyfiltsize = 15 The sky filter size used in the object detection step. .le .ls ngrowobj = 0 The number of pixels to flag as a buffer around objects detected in the object detection step. .le .ls nrings = 0 The cosmic ray growing region half-width in pixels. .le .ls nsigneg = 0.0 The negative deviant pixel detection threshold in units of sky sigma. If nsigneg <= 0.0 negative feature detection is not performed. .le .ls del_crmask = no Delete the cosmic ray mask at task termination ? By default the cosmic ray masks are stored and used in later processing steps. .le .ls del_wimages = yes, del_wmasks = yes Delete the working images and masks ? By default the working median filtered image, the cosmic ray image, and the cosmic ray only image are deleted as well as the object detection and negative bad pixel detection masks if any. .le .ih DESCRIPTION XZAP detects detects and removes cosmics rays from the input images \fIinlist\fR and writes the corrected images to \fIoutlist\fR. The output image list may be the same as the input image list. If input object masks \fIomasks\fR is defined then only cosmic rays in sky regions are detected and removed. These object mask consist of 0's and 1's with 0's defining the object regions in contrast to the usual XDIMSUM convention. The output cosmic ray mask are written to \fIcrmasks\fR. Cosmic ray masks consist of 1's and 0's with 1's defining the detected cosmic rays. XZAP computes the input image sigma using iterative rejection, pixels in the region defined by \fIstatsec\fR, and the rejection parameters \fInsigrej\fR and \fImaxiter\fR. The XDIMSUM task ITERSTAT is used to compute the sky sigma. More about the ITERSTAT algorithms can be found in the ITERSTAT help page. XZAP detects cosmic rays by median filtering the input image using a filter size of \fIzboxsz\fR and data limits determined by the minimum and maximum image pixel values, and subtracting it from the input image. Objects more than \fInsigzap\fR sky sigma above the background are assumed to be cosmic rays. The median filter can be protected against deviant values by setting \fIchecklimits\fR to yes and \fIzmin\fR and \fIzmax\fR to reasonable values. If \fInsigobj\fR is > 0.0 then the median filtered image is searched for objects with pixel values > \fInsigobj\fR * sky sigma above the background. The object detection code uses a smoothing value of 0, an input image subsampling factor of \fIsubsample\fR, a sky filter size of \fIskyfiltsize\fR pixels which applies to the subsampled image not the original image, and an object growing size of \fIngrowobj\fR. Cosmic rays detected in the object regions are removed from the cosmic rays masks. The object region mask is created with the XDIMSUM task MAKEMASK. More details about MAKEMASK can be found in the task help page. If \fInrings\fR > 0 then XZAP grows the detected cosmic rays to include a box 2 * nrings + 1 pixels wide centered on the detected cosmic ray. If \fInsigneg\fR > 0.0 then pixels more than nsigneg * sky sigma below background are considered to be cosmic rays and added to the cosmic ray mask. Finally if the input object masks defined by \fIomasks\fR exist cosmic rays detected in the input object regions are removed from the cosmic ray masks. Finally XSLM multiplies the final cosmic ray mask by the input image minus the median filtered image to produce a cosmic rays only image and subtracts this image from the input image to produce the cosmic ray corrected image. If \fIdel_crmask\fR = yes the output cosmic ray mask is deleted on task termination. If \fIdel_wimages\fR = no then the working median filtered, cosmic ray ,and cosmic ray only images are saved for later examination. If \fIdel_wmasks\fR the working object detection and negative bad pixel detection masks are also saved. .ih EXAMPLES 1. Detect cosmic rays in the demo sky subtracted images. .nf cl> type sdemo.list demo01.sub.imh demo02.sub.imh ... demo25.sub.imh cl> xzap @sdemo.list "" @sdemo.list ".crm" nsigrej=5.0 maxiter=10 \ subsample=2 .fi 2. Repeat example 1 but specify an output cosmic ray mask list. .nf cl> xzap @sdemo.list "" @sdemo.list @crmlist nsigrej=5.0 maxiter=10 \ subsample=2 .fi 3. Repeat example 1 but set the input object mask list to the image header keyword "CROBJMAS". .nf cl> xzap @sdemo.list "CROBJMAS" @sdemo.list @crmlist nsigrej=5.0 \ maxiter=10 subsample=2 .fi 4. Repeat example 2 but specify an input inverse object core mask list. .nf cl> xzap @sdemo.list @ocrmlist @sdemo.list @crmlist nsigrej=5.0 \ maxiter=10 subsample=2 .fi .ih TIME REQUIREMENTS .ih BUGS .ih SEE ALSO xnzap, iterstat, fmedian, makemask .endhelp iraf-xdimsum-main/lib/000077500000000000000000000000001455666516400151755ustar00rootroot00000000000000iraf-xdimsum-main/lib/helpdb.mip000066400000000000000000000111521455666516400171420ustar00rootroot00000000000000D'yß ¦ˆõþ-B>B#rootdefdir=xdimsum$lib/_xdimsumxdimsum$lib/rootxdimsum.hdþyB‹ B!=Qxe)rootxdimsumdefdir=xdimsum$lib/xdimsumxdimsum$xdimsum.menxdimsum$xdimsum.menxdimsum$xdimsum.hlpxdimsum$xdimsum.hdxdimsum$xdimsum.clÿÞ Þ*;Pm†¡ÐÝò ¼Â)2CS\m}‡™ª²ÂÑÚëû&5jt†—¢µÍÖç÷'0AQ]q„¢´ºÈÕßñCK[ ,7J\bp}†—§¬¹ÅÏáøý xdimsumdefdir=xdimsum$doc=xdimsum$doc/src=xdimsum$src/demos=xdimsum$demos/ximcentroid=src$ximcentroid/xstarfind=src$xstarfind/xcraverage=src$xcraverage/ximcombine=src$ximcombine/guidedoc$guide.hlpbadpixupdatedoc$badpixupdate.hlpsrc$badpixupdate.cldemosdoc$demos.hlpdemos$demos.cliterstatdoc$iterstat.hlpsrc$iterstat.clmakemaskdoc$makemask.hlpsrc$makemask.clmaskderegdoc$maskdereg.hlpsrc$maskdereg.clmaskfixdoc$maskfix.hlpsrc$maskfix.clmaskstatdoc$maskstat.hlpsrc$maskstat.clmkmaskdoc$mkmask.hlpsrc$mkmask.clorientdoc$orient.hlpsrc$orient.clxmosaicdoc$xmosaic.hlpsrc$xmosaic.clsigmanormdoc$sigmanorm.hlpsrc$sigmanorm.clxcraveragedoc$xcraverage.hlpcraverage$t_craverage.xxdshiftsdoc$xdshifts.hlpsrc$xdshifts.clxfirstpassdoc$xfirstpass.hlpsrc$xfirstpass.clxfshiftsdoc$xfshifts.hlpsrc$xfshifts.clximcentroiddoc$ximcentroid.hlpsrc$t_imcentroid.xximcombinedoc$ximcombine.hlpsrc$t_imcombine.xxlistdoc$xlist.hlpsrc$xlist.clxmaskpassdoc$xmaskpass.hlpsrc$xmaskpass.clxmshiftsdoc$xmshifts.hlpsrc$xmshifts.clxnregistardoc$xnregistar.hlpsrc$xnregistar.clxnzapdoc$xnzap.hlpsrc$xnzap.clxrshiftsdoc$xrshifts.hlpsrc$xrshifts.clxslmdoc$xslm.hlpsrc$xslm.clxstarfinddoc$xstarfind.hlpxstarfind$t_starfind.xxzapdoc$xzap.hlpsrc$xzap.cl"UN©N$?G[o‚•_rootxdimsum$lib/root.hd_xdimsumxdimsum$lib/rootxdimsum.hdxdimsumxdimsum$xdimsum.menxdimsum$xdimsum.hlpxdimsum$xdimsum.clxdimsum$xdimsum.hdxdimsum$xdimsum.men_indexR'yßxdimsum$lib/root.hd'_`vxdimsum$lib/rootxdimsum.hda'_`»xdimsum$xdimsum.hdé'yÜdiraf-xdimsum-main/lib/mkpkg.inc000066400000000000000000000014731455666516400170060ustar00rootroot00000000000000# Global MKPKG definitions for the XDIMSUM package. $set XFLAGS = "$(XFLAGS) -p xdimsum" $set XVFLAGS = "$(XVFLAGS) -p xdimsum" $set LFLAGS = "$(LFLAGS) -p xdimsum" #$ifeq (MACH, sparc) then # $include "xdimsum$lib/mkpkg.sf.SUN4" #$else $ifeq (MACH, i386) then # $include "xdimsum$lib/mkpkg.sf.I386" #$else $ifeq (MACH, f68881) then # $include "xdimsum$lib/mkpkg.sf.SUN3" #$else $ifeq (MACH, ffpa) then # $include "xdimsum$lib/mkpkg.sf.SUN3" #$else $ifeq (MACH, vms) then # $include "xdimsum$lib/mkpkg.sf.VMS" #$else $ifeq (MACH, ddec) then # $include "xdimsum$lib/mkpkg.sf.DDEC" #$else $ifeq (MACH, dmip) then # $include "xdimsum$lib/mkpkg.sf.DMIP" #$else $ifeq (MACH, rs6000) then # $include "xdimsum$lib/mkpkg.sf.AIX3" #$else $ifeq (MACH, mips) then # $include "xdimsum$lib/mkpkg.sf.MIPS" #$end iraf-xdimsum-main/lib/mkpkg.sf.AIX3000066400000000000000000000003431455666516400173430ustar00rootroot00000000000000# Mkpkg special file list for AIX/IRAF on the IBM RS/6000. # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- $set XNO = '& "$xc $(XFLAGS) -cq &"' iraf-xdimsum-main/lib/mkpkg.sf.DDEC000066400000000000000000000007171455666516400173430ustar00rootroot00000000000000# Mkpkg special file list for DECstation/Ultrix DEC Fortran. # All files needing special processing for the local host operating system, # e.g., to permit host dependent optimization or to work around compiler bugs, # should be listed here. # Files optimized for the local host system. # ----------------------------------------- # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- iraf-xdimsum-main/lib/mkpkg.sf.DMIP000066400000000000000000000007201455666516400173670ustar00rootroot00000000000000# Mkpkg special file list for DECstation/Ultrix MIPS Fortran. # All files needing special processing for the local host operating system, # e.g., to permit host dependent optimization or to work around compiler bugs, # should be listed here. # Files optimized for the local host system. # ----------------------------------------- # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- iraf-xdimsum-main/lib/mkpkg.sf.I386000066400000000000000000000004561455666516400172750ustar00rootroot00000000000000# Mkpkg special file list for SUN/IRAF, SUN 386i. # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- $set XNO = '& "$xc -cq -/$(MACH) &"' $set XO1 = '& "$xc -cq -/O1 -/$(MACH) &"' $set XO2 = '& "$xc -cq -/O2 -/$(MACH) &"' iraf-xdimsum-main/lib/mkpkg.sf.MIPS000066400000000000000000000006731455666516400174150ustar00rootroot00000000000000# Mkpkg special file list for MIPS/IRAF. # All files needing special processing for the local host operating system, # e.g., to permit host dependent optimization or to work around compiler bugs, # should be listed here. # Files optimized for the local host system. # ----------------------------------------- # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- iraf-xdimsum-main/lib/mkpkg.sf.SSUN000066400000000000000000000002571455666516400174330ustar00rootroot00000000000000# Mkpkg special file list for SUN/IRAF, Solaris $set XNO = '& "$xc -cq -/libmil -p immatchx &"' $special "$(immatchx)src/geometry/": geotran.x $(XNO) ; iraf-xdimsum-main/lib/mkpkg.sf.SUN3000066400000000000000000000003261455666516400173700ustar00rootroot00000000000000# Mkpkg special file list for SUN/IRAF, Sun-3/OS-4. $set XNO = '& "$xc -cq -/$(MACH) &"' $set XO1 = '& "$xc -cq -/O1 -/$(MACH) &"' $set XO2 = '& "$xc -cq -/O2 -/$(MACH) &"' $set XP = '& "$xc -cq -/P -/$(MACH) &"' iraf-xdimsum-main/lib/mkpkg.sf.SUN4000066400000000000000000000000571455666516400173720ustar00rootroot00000000000000# Mkpkg special file list for Sun/IRAF, Sun-4. iraf-xdimsum-main/lib/mkpkg.sf.VMS000066400000000000000000000007711455666516400173110ustar00rootroot00000000000000# Mkpkg special file list for VMS/IRAF. # All files needing special processing for the local host operating system, # e.g., to permit host dependent optimization or to work around compiler bugs, # should be listed here. # Files optimized for the local host system. # ----------------------------------------- # Files requiring special compilation due to host compiler bugs. # ------------------------------------------------------------- # (no such files at present for the VMS VAX/Fortran compiler). iraf-xdimsum-main/lib/root.hd000066400000000000000000000004131455666516400164730ustar00rootroot00000000000000# Root help directory for the XDIMSUM package. This dummy package is # necessary in order to have `package' appear as a module in some package, # so that the user can type "help " (with `package' given as a task). _xdimsum pkg = xdimsum$lib/rootxdimsum.hd iraf-xdimsum-main/lib/rootxdimsum.hd000066400000000000000000000004321455666516400201030ustar00rootroot00000000000000# Root task entry for the XDIMSUM package help tree. Defines `' # as both a task and a package in the help database. xdimsum men = xdimsum$xdimsum.men, hlp = xdimsum$xdimsum.men, sys = xdimsum$xdimsum.hlp, pkg = xdimsum$xdimsum.hd, src = xdimsum$xdimsum.cl iraf-xdimsum-main/lib/strip.xdimsum000066400000000000000000000005211455666516400177440ustar00rootroot00000000000000# STRIP.XDIMSUM -- Rmfiles command script, used to strip the XDIMSUM # directories of all files not required for ordinary runtime use. src -allbut .hlp .hd .men .cl .par .key .dat .mip .fits # Sun/IRAF only. # --------------- -file bin.f68881/OBJS.arc.Z -file bin.ffpa/OBJS.arc.Z -file bin.sparc/OBJS.arc.Z -file bin.i386/OBJS.arc.Z iraf-xdimsum-main/lib/zzsetenv.def000066400000000000000000000003011455666516400175370ustar00rootroot00000000000000# Global environment definitions for the XDIMSUM package. reset pkglibs = "xdimsum$bin(arch)/,xdimsum$lib/" reset xdimsumbin = "xdimsum$bin(arch)/" reset xdimsumlib = "xdimsum$lib/" keep iraf-xdimsum-main/mkpkg000066400000000000000000000063021455666516400154640ustar00rootroot00000000000000# Make the XDIMSUM package. $call update@src $exit update: $call update@src ; # STRIP -- Strip the package directories of all sources and other files # not required to run the system, or for user programming. strip: !rmfiles -f lib/strip ; # SUMMARY -- [UNIX] mkpkg summary: output a summary of the spooled mkpkg # output, omitting most of the mundane chatter. Used to scan large spool # files for errors. summary: $ifeq (HOSTID, unix) $ifndef (spool) $set spool = spool $endif ! grep -v ':$$' spool | grep -v '^xc' | grep -v '^ar'\ | grep -v '^check file' $else $echo "mkpkg summary only available on a UNIX system" $endif ; # IRAF multiple architecture support. # ---------------------------------------- arch: # show current float option showfloat: $verbose off !$(hlib)/mkfloat.csh ; generic: # generic installation (no bin) $ifnfile (bin.generic) !mkdir bin.generic $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh generic -d $(DIRS) ; freebsd: # install FreeBSD binaries $ifnfile (bin.freebsd) !mkdir bin.freebsd $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh freebsd -d $(DIRS) ; linux: # install Slackwkare Linux binaries $ifnfile (bin.linux) !mkdir bin.linux $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh linux -d $(DIRS) ; linux64: # install x86_64 binaries $ifnfile (bin.linux64) !mkdir bin.linux64 $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh linux64 -d $(DIRS) ; macosx: # install Mac OS X (PPC) binaries $ifnfile (bin.macosx) !mkdir bin.macosx $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh macosx -d $(DIRS) ; macintel: # install Mac OS X (Intel) binaries $ifnfile (bin.macintel) !mkdir bin.macintel $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh macintel -d $(DIRS) ; cygwin: # install Cygwin binaries $ifnfile (bin.cygwin) !mkdir bin.cygwin $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh cygwin -d $(DIRS) ; redhat: # install Redhat Linux binaries $ifnfile (bin.redhat) !mkdir bin.redhat $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh redhat -d $(DIRS) ; sparc: # install sparc binaries $ifnfile (bin.sparc) !mkdir bin.sparc $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh sparc -d $(DIRS) ; ssun: # install Sun/Solaris binaries $ifnfile (bin.ssun) !mkdir bin.ssun $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh ssun -d $(DIRS) ; sunos: # install SunOS (Solaris x86) binaries $ifnfile (bin.sunos) !mkdir bin.sunos $endif $verbose off $set DIRS = "lib src" !$(hlib)/mkfloat.csh sunos -d $(DIRS) ; iraf-xdimsum-main/src/000077500000000000000000000000001455666516400152165ustar00rootroot00000000000000iraf-xdimsum-main/src/Revisions000066400000000000000000000054431455666516400171300ustar00rootroot00000000000000.help revisions Dec00 xdimsum xdimsum$src/xdshifts.cl Added a hidden parameter to control the number of frames to use with IMEXAM. The default value works with both DS9 and XIMTOOL. A larger number could then be used with XIMTOOL. (1/2/24, Valdes) ============== August 6, 2002 ============== xdimsum$src/xnregistar.cl IMCOMBINE normalizes the input scales to the first image rather than using them in an absolute sense. A correction needed to be applied to produce output images per unit exposure time and exposure masks in unit exposure times. (8/6/02, Valdes) xdimsum$src/xnregistar.cl xdimsum$src/xnregistar.hlp xdimsum$src/xfirstpass.cl xdimsum$src/xmaskpass.cl xdimsum$src/xmaskpass.hlp xdimsum$src/xmosaic.cl xdimsum$src/xmosaic.hlp Added the omasks and nprev_omask to the xregistar task and add support for previous object masking. Made the necessary modficiations to xfirstpass, xmaskpass, and xmosaic and their help pages. (Davis, 26/01/01) xdimsum$src/maskdereg.cl xdimsum$src/maskpass.cl xdimsum$src/maskdereg.hlp Removed the nprev_omask parameter from the maskdereg task and the maskdereg calls in xmaskpass. (Davis, 25/01/01) xdimsum$src/xmaskpass.cl xdimsum$src/xmosaic.cl Added the mask region growing parameter ngrow to the xmaskpass and xmosaic scripts. Rearranged the xmosaic parameters. (Davis 25/01/01) xdimsum$src/xmshifts.cl Fixed an error in the code which computes the average shifts, that was introduced when xdimsum was recently modified. (Davis 24/01/01) xdimsum$src/xmosaic.cl Added switch checks to the xfirstpass and xmaskpass calls so that the routines are not called if no switchs are set. (Davis 23/01/01) xdimsum$src/xmaskpass.cl Added checks for the existence of the input combined image, input exposure map, and input sections file. (Davis 23/01/01) xdimsum$src/xfirstpass.cl xdimsum$src/xmaskpass.cl xdimsum$src/xmosaic.cl xdimsum$doc/xfirstpass.hlp xdimsum$doc/xmaskpass.hlp xdimsum$doc/xmosaic.hlp Added the parameter nrepeats to the xfirstpass, xmaskpass, and xmosaic script tasks. If the same pixel is bad in nrepeats or more images then it is set to bad in the bad pixel mask. (Davis 01/17/01) xdimsum$src/makemask.cl xdimsum$src/xzap.cl xdimsum$src/makemask.hlp Added the parameter negthresh to the makemask task. If negthresh is yes both positive and negative masking threshold are used otherwise only positive masking threshold are used. Negthresh was set to no in the xzap makemask call. (Davis 01/17/01) xdimsum$src/xfirstpass.cl xdimsum$src/xmaskpass.cl xdimsum$src/xmosaic.cl xdimsum$src/xfirstpass.hlp xdimsum$src/xmaskpass.hlp xdimsum$src/xmosaic.hlp Added the parameter negthresh to the xfirstpass, xmaskpass, and xmosaic tasks. (Davis 01/17/01) .endhelp iraf-xdimsum-main/src/addcomment.cl000066400000000000000000000031141455666516400176500ustar00rootroot00000000000000# ADDCOMMENT appends 'COMMENT' cards to the image header. All existing 'COMMENT' # cards are collated and moved to the end of the header, and the new card is # added afterward. procedure addcomment (inlist, comment) # Addcomment uses the sections, hfix and delete tasks and the CL builtin task # match. string inlist {prompt="Image(s) to which to append comment card"} string comment {prompt="Comment"} bool verify {no, prompt="Verify header ?"} bool answer {yes, prompt="Update this header ?", mode="q"} struct *inimglist begin string tinlist, tcomment, imlist, headfile, img bool setheader # Get query parameters. tinlist = inlist tcomment = comment if (! verify) setheader = yes # Create input image list. imlist = mktemp ("tmp$addc") sections (tinlist, option="fullname", > imlist) inimglist = imlist # Loop over the input images. while (fscan (inimglist, img) != EOF) { headfile = mktemp ("_headerjj") hfix (img, command="!grep -v 'COMMENT =' $fname > " // headfile, update-) hfix (img, command="!grep 'COMMENT =' $fname >> " // headfile, update-) print("COMMENT = '", tcomment, "'", >> headfile) if (verify) { print ("Comment cards currently read:") match ("COMMENT =", headfile, stop-, print+) if (answer) { setheader = yes } else { setheader = no print ("Header will be left unchanged") } } if (setheader) { hfix (img, command="delete $fname ver- ; copy "//headfile//" $fname", update+) } delete (headfile,ve-) } # Cleanup inimglist = "" delete (imlist, ver-) end iraf-xdimsum-main/src/avshift.par000066400000000000000000000000301455666516400173570ustar00rootroot00000000000000input,s,a,,,,Input file iraf-xdimsum-main/src/badpixupdate.cl000066400000000000000000000046321455666516400202150ustar00rootroot00000000000000# BADPIXUPDATE finds ixels corrected more than nrepeats times by XNZAP or XZAP # and adds them to the bad pixel mask file. procedure badpixupdate (inlist, nrepeats, bpmask) # Badpixupdate uses the files and imaccess CL biltins. It also uses the # imcombine, imarith, minmax, imexpr, imstatistics, and imdelete tasks. string inlist {prompt="List of mask images"} int nrepeats {3, min=1, prompt="Threshold for repeated zaps"} string bpmask {prompt="Bad pixel mask file"} begin int nrep, nthresh, nim, nzap string ilist, badp # Get query parameters ilist = inlist nrep = nrepeats badp = bpmask # Initialize. nthresh = nrep - 1 # Sum mask images from xzap to get list of zapped pixels. if (imaccess ("_cr_sum")) imdelete ("_cr_sum", ver-) files (ilist, sort-) | count | scan (nim) imcombine (ilist, "_cr_sum", headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", comb="average", reject="none", project-, outtype="real", outlimits="", offsets="none", masktype="none", maskvalue=0.0 ,blank=0., scale="none", zero="none", weight="none", statsec="", expname="", lthresh=INDEF, hthresh=INDEF, nlow=1, nhi=1, nkeep=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0) # Normalize the image since imcombine does not sum and imsum cannot deal # with the number of files. imarith ("" // nim, "*", "_cr_sum","_cr_sum", title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) # If maximum greater than threshold, update bad pixel mask. minmax ("_cr_sum", force+, update-, ver-) if (minmax.maxval > nthresh) { print ("Updating bad pixel map ", badp) if (imaccess ("_jbadpix.pl")) imdelete ("_jbadpix.pl", ver-) imexpr ("nint(a) > b ? 0 : 1", "_jbadpix.pl", "_cr_sum", "" // nthresh, dims="auto", intype="auto", outtype="int", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") imstat ("_jbadpix.pl", fields="npix", lower=0, upper=0, nclip=0, lsigma=3.0, usigma=3.0, format-, cache-) | scan (nzap) print (" Adding ", nzap, " pixels to mask ", badp) imarith ("_jbadpix.pl", "*", badp, badp, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) imdelete ("_jbadpix.pl", ver-) } imdelete ("_cr_sum", ver-) end iraf-xdimsum-main/src/fileroot.cl000066400000000000000000000053721455666516400173700ustar00rootroot00000000000000# FILEROOT parses a file name into root name and extension fields. procedure fileroot(filename) # The extension is assumed to be the portion of the file name which follows the # last period in the input string supplied by the user. The root is everything # which preceeds that period. # # Included parameter validim to force a check to see if the extension # represents a valid IRAF image datatype, and if not, to negate the parsing. # This would be a common usage; often the user only wants to strip off the # portion of the filename after the last period if that substring represents # a valid IRAF image type such as .imh or .pl. Without the validim parameter, # if the file included another period somewhere in its name, then the portion # of the filename after that period would be erroneously returned as an image # extension. At present, the routine only checks for a few datatypes; this # should be expanded in the future. # # Fileroot uses the strlen, substr, stridx, and envget CL builtins. string filename {prompt="File name"} bool validim {no,prompt="Parse only if extension represents valid image datatype?"} string root {"",prompt="Returned filename root"} string extension {"",prompt="Returned filename extension"} string defextn {"",prompt="Returned default filename extension"} begin # Declare local variables. string imtype = "imh", "fits", "fit", "pl", "hhh", "qpoe", "" string fname, revname int ilen, ipos, ic, ii # Get query parameter. fname = filename # Reverse filename string character by character and store in revname. ilen = strlen (fname) revname = "" for (ic = ilen; ic >= 1; ic-=1) { revname = revname // substr (fname, ic, ic) } # Look for the first period in the reversed name. ipos = stridx (".", revname) # If period exists, break filename into root and extension. Otherwise, # return null values for the extension, and the whole file name for the root. if (ipos != 0) { root = substr (fname, 1, ilen-ipos) extension = substr (fname, ilen - ipos + 2, ilen) } else { root = fname extension = "" } # If validim = yes and extension != "", check to see if the parsed extension # is a string indicating a valid image data type, e.g. "imh", "pl", etc. # If not, then undo the parsing, replacing the root with the complete input # string 'filename' and setting the extension to null. if (validim && extension != "") { ii = 1 while (imtype[ii] != "") { if (extension == imtype[ii]) break ii += 1 } if (imtype[ii] == "") { root = fname extension = "" } } # Set default extension from "imtype" environment variable. defextn = "." // envget ("imtype") ipos = stridx (",", defextn) if (ipos > 0) defextn = substr (defextn, 1, ipos-1) end iraf-xdimsum-main/src/iterstat.cl000066400000000000000000000044371455666516400174050ustar00rootroot00000000000000# ITERSTAT iteratively compute image statistics using the new IMSTATISTICS # task. procedure iterstat (inlist) # Iterstat also uses the mktemp, sections, and delete tasks. file inlist {prompt="The input image list"} string statsec {"", prompt="The image section for computing statistics"} real lower {INDEF,prompt="The initial lower data limit"} real upper {INDEF,prompt="The initial upper data limit"} real nsigrej {3.0, min=0.0, prompt="The n-sigma rejection limit"} int maxiter {20, min=1, prompt="The maximum number of iterations"} bool show {yes, prompt="Print final results ?"} real imean {prompt="The returned image mean"} real isigma {prompt="The returned image sigma"} real imedian {prompt="The returned image median"} real imode {prompt="The returned image mode"} struct *imglist struct *seclist begin # Declare local variables. real mn, sig, med, mod int npx string imginlist, infile, secfile, img, sec, usec # Get query parameter. imginlist = inlist # Expand image template into a list of root image names. infile = mktemp ("tmp$iterstat") sections (imginlist, option="root", > infile) # Expand image template into a list of image sections. secfile = mktemp ("tmp$iterstat") sections (imginlist, option="section", > secfile) # Loop through images img = "" sec = "" usec = "" imglist = infile seclist = secfile while (fscan (imglist, img) != EOF && fscan (seclist, sec) != EOF) { # Compute the initial image statistics. if (sec == "") { usec = statsec } else { usec = sec } imstatistics (img // usec, fields="mean,stddev,npix,midpt,mode", lower=lower, upper=upper, nclip=maxiter, lsigma=nsigrej, usigma=nsigrej, binwidth=0.1, format-, cache-) | scan (mn, sig, npx, med, mod) # Optionally print the final results. if (show) print (img, usec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) # Save the results in parameter values. imean = mn isigma = sig imedian = med imode = mod } # Delete the temporary root image and image section lists. delete (infile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") delete (secfile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") imglist = "" seclist = "" end iraf-xdimsum-main/src/makemask.cl000066400000000000000000000275041455666516400173370ustar00rootroot00000000000000# MAKEMASK creatas object masks for input images using median filtering # techniques. procedure makemask (inlist, outlist) # Image is sky subtracted, either using a constant value, or optionally by # median filtering the image on a specified spatial scale and subtracting # filtered image. If the desired filtering scale is large, the user may want # to first subsample the image to a smaller size before filtering in order # to speed up the calculation -- the resulting sky frame is then block # replicated back up to the original image size before subtracting. # # After sky subtraction, a threshold is applied to the image after optional # boxcar smoothing. The threshold may be specified in terms of a number of # sky sigma above the median sky level as measured using iterative sigma # rejection, or as a specified constant number of ADU above the sky level. The # resulting thresholded image is turned into a mask with "sky" set to 0 and # "objects" set to 1. The user may "grow" additional rings of pixels around # masked regions to increase their area. # # Finally, the resulting mask may optionally be recorded in the input image # header using the keyword BPM. The user may in fact create a mask from one # input image and add it into the header of another by specifying different # lists for inlist and hinlist. # # Calls the xdimsum ITERSTAT task. # # Also calls the sections, blkavg, minmax, fmedian, blkrep, imgets, imcopy, # imarith, boxcar, imreplace, hedit, imdelete, and delete tasks. # # Creates temporary images of the form _ftemp, fwtemp, _blktemp, and _mtemp string inlist {prompt="The input images used to compute the masks"} string outlist {prompt="The output masks"} string hinlist {"",prompt="The list of images to add BPM keywords to"} int subsample {1,min=0,prompt="Block averaging factor before median filtering"} bool checklimits {yes,prompt="Check data limits before filtering?"} real zmin {-32767.,prompt="Minimum data value for fmedian"} real zmax {32767.,prompt="Maximum data value for fmedian"} int filtsize {15,min=0,prompt="Median filter size for local sky evaluation"} int nsmooth {3,min=0,prompt="Boxcar smoothing size before thresholding"} string statsec {"",prompt="Image region for computing sky statistics"} real nsigrej {3.0, prompt="The nsigma sky statistics rejection limit"} int maxiter {20, prompt="The maximum number of sky statistics iterations"} string threshtype {"nsigma",enum="nsigma|constant", prompt="Thresholding type: nsigma or constant"} real nsigthresh {2.,prompt="Threshold for masking in sky sigma"} real constthresh {0.,prompt="Constant threshold above sky for masking"} bool negthresh {no,prompt="Set negative as well as positive thresholds ?"} int ngrow {0,min=0,prompt="Half-width of box to grow around masked objects"} bool verbose {no,prompt="Verbose output?"} struct *imglist struct *outimglist struct *hdrimglist begin real thresh, nthresh, dmin, dmax, realsize int nin, nout, nbox, narea, ix,iy string inl, onl, infile, infile2, outfile, img, img2, outimg, workimg string cutsec, ext # Get query parameters. inl = inlist onl = outlist # Expand input and output file list. infile = mktemp ("tmp$makemask") sections (inl, option="fullname", >infile) nin = sections.nimages outfile = mktemp ("tmp$makemask") sections (onl, option="fullname", >outfile) nout = sections.nimages if (nin != nout) { print ("The input and output image lists are not the same size") delete (infile, ver-) delete (outfile, ver-) return } # If parameter hinlist != "", update the image headers with bad pixel list. if (hinlist != "") { infile2 = mktemp ("tmp$makemask") sections (hinlist, option="fullname", >infile2) hdrimglist = infile2 } # The boxcar smoothing scale must be an odd number. if (nsmooth > 0) { if (2 * int (nsmooth / 2) == nsmooth) { print ("Error: the parameter nsmooth must be an odd number") delete (infile, ver-) delete (outfile, ver-) if (hinlist != "") delete (infile2, verify-) return } } # Notify user of effective median filter scale. if (subsample > 1 && filtsize > 0) { realsize = subsample * filtsize if (verbose) { print ("The effective median filter scale is ", realsize) } } # Size for boxcar smoothing in growing stage. nbox = (2 * ngrow + 1) narea = nbox * nbox # Loop through input files. imglist = infile outimglist = outfile while (fscan (imglist, img) != EOF && fscan (outimglist, outimg) != EOF) { if (! imaccess (img)) { print ("The input image ", img, " does not exist") next } # Strip extension off filename if present. fileroot (img, validim+) img = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext fileroot (outimg, validim+) outimg = fileroot.root // ".pl" if (imaccess (outimg)) { print ("The output mask ", outimg, " already exists") next } if (verbose) print ("Working on image ", img) if (verbose) print (" Subtracting local sky") # If filtsize > 0, median filter image to produce local sky, then subtract # that from the image. if (imaccess ("_mtemp")) imdelete ("_mtemp", verify-) if (filtsize > 0) { # If subsample > 1, block average input image to smaller size. if (subsample > 1) { if (verbose) print (" Block averaging") if (imaccess ("_blktemp")) imdelete ("_blktemp", verify-) blkavg (img // ext, "_blktemp", subsample, subsample, option="average") workimg = "_blktemp" } else { workimg = img } # First, check limits of data range. Wildly large (positive or negative) # data values will screw up fmedian calculation unless checklimits = yes and # zmin and zmax are set to appropriate values, e.g. zmin=-32768, zmax=32767. # Note that the old fmedian bug which occurred if zmin=hmin and zmax=hmax has # been fixed in IRAF version 2.10.1. if (verbose) print (" Median filtering sky") if (checklimits) { minmax (workimg, force+, update+, ve-) if (verbose) print(" Data minimum = ", minmax.minval, " maximum = ", minmax.maxval) if (minmax.minval < zmin || minmax.maxval > zmax) { if (minmax.minval < zmin) { dmin = zmin } else { dmin = minmax.minval } if (minmax.maxval > zmax) { dmax = zmax } else { dmax = minmax.maxval } if (verbose) { print (" Truncating data range ", dmin," to ",dmax) } if (imaccess ("_fwtemp")) imdelete ("_fwtemp", verify-) fmedian (workimg, "_fwtemp", filtsize, filtsize, hmin=-32768, hmax=32767, zmin=dmin, zmax=dmax, zloreject=INDEF, zloreject=INDEF, unmap+, boundary="nearest", constant=0.0, verbose-) } else { fmedian (workimg, "_fwtemp", filtsize, filtsize, hmin=-32768, hmax=32767, zmin=INDEF, zmax=INDEF, zloreject=INDEF, zhireject=INDEF, unmap+, boundary="nearest", constant=0.0, verbose-) } } else { fmedian (workimg, "_fwtemp", filtsize, filtsize, hmin=-32768, hmax=32767, zmin=INDEF, zmax=INDEF, zloreject=INDEF, zhireject=INDEF, unmap+, boundary="nearest", constant=0.0, verbose-) } # If we have block averaged, block replicate median filtered image back to # original size. if (subsample > 1) { if (verbose) print (" Block reproducing") if (imaccess ("_ftemp")) imdelete ("_ftemp", verify-) blkrep ("_fwtemp", "_ftemp", subsample, subsample) imgets (img // ext, "i_naxis1") ix = int (imgets.value) imgets (img // ext, "i_naxis2") iy = int (imgets.value) cutsec = "[1:" // ix // ",1:" // iy // "]" imcopy ("_ftemp" // cutsec, "_ftemp", ver-) imarith (img // ext, "-", "_ftemp", "_mtemp", title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) } else { imarith (img // ext, "-", "_fwtemp", "_mtemp", title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) } } else { # ...or, just copy the image to a working mask frame. imcopy (img // ext, "_mtemp", verbose-) } # Calculate image statistics to determine median sky level and RMS noise. if (verbose) print (" Computing sky statistics") iterstat ("_mtemp", statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show-) if (verbose) { print (" Mean=", iterstat.imean, " Rms=", iterstat.isigma, " Med=", iterstat.imedian, " Mode=", iterstat.imode) } # Smoothing image before thresholding. if (nsmooth > 0) { if (verbose) { print (" Smoothing image before thresholding") } boxcar ("_mtemp", "_mtemp", nsmooth, nsmooth, boundary="nearest", constant=0.0) } # Calculate threshold. if (threshtype == "constant") { thresh = iterstat.imedian + constthresh if (negthresh) nthresh = iterstat.imedian - constthresh else nthresh = -1.0e37 } else { if (nsmooth > 0) { thresh = iterstat.imedian + nsigthresh * iterstat.isigma / nsmooth if (negthresh) nthresh = iterstat.imedian - nsigthresh * iterstat.isigma / nsmooth else nthresh = -1.0e37 } else { thresh = iterstat.imedian + nsigthresh * iterstat.isigma if (negthresh) nthresh = iterstat.imedian - nsigthresh * iterstat.isigma else nthresh = -1.0e37 } } if (verbose) print (" Thresholding image at level ",thresh) # Apply threshold to image, setting "objects" to 1 and "sky" to 0. The order # of the imreplace statments must be different if threshold is greater than # or less than 1. if (verbose) { print (" Saving mask as ", outimg) } # If desired, grow rings around masked objects. Rings are only grown around # positive objects. if (ngrow > 0) { imexpr ("a > b ? 1 : 0", outimg, "_mtemp", "" // thresh, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) if (verbose) print (" Growing rings around masked objects") imarith (outimg, "*", narea, outimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) boxcar (outimg, outimg, nbox, nbox, boundary="nearest", constant=0.0) imreplace (outimg, 1, lower=1, upper=INDEF, radius=0.0) if (negthresh) { imexpr ("a < b ? 1 : 0", "_mmtemp", "_mtemp", "" // nthresh, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) imarith (outimg, "+", "_mmtemp", outimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) imreplace (outimg, 1, lower=1, upper=INDEF, radius=0.0) imdelete ("_mmtemp", verify-) } } else { imexpr ("a > b || a < c ? 1 : 0", outimg, "_mtemp", "" // thresh, "" // nthresh, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) } # Record mask name into BPM keyword in image header of files specified # by hdrimglist. if (hinlist != "") { if (fscan(hdrimglist, img2) != EOF) { if (verbose) { print (" Recording pixel mask in image ", img2) } hedit (img2, "BPM", outimg, add+, ver-, update+) } } # Clean up. if (filtsize > 0) { imdelete ("_fwtemp", verify-) if (subsample > 1 ) { imdelete ("_blktemp", verify-) imdelete ("_ftemp", verify-) } } imdelete ("_mtemp", verify-) } delete (infile, ver-) delete (outfile, ver-) if (hinlist != "") delete (infile2, ver-) imglist = "" outimglist = "" hdrimglist = "" end iraf-xdimsum-main/src/maskdereg.cl000066400000000000000000000114251455666516400175030ustar00rootroot00000000000000# MASKDEREG creates individual object masks using the combined image object # mask created by MKMASK and the sections file created by XNREGISTAR which # defines the location of the each input image in the combined image. procedure maskdereg (omask, sections, outlist) # Maskdereg uses the imcopy, orient, fileroot, imdelete, xlist, fields, imsum, # and delete tasks and the CL builtin imaccess and mktemp tasks. string omask {prompt="Input combined image object mask"} string sections {prompt="The input sections file written by xnregistar"} string outlist {".obm", prompt="The list of output individual object masks or suffix"} real y2n_angle {0.0, prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes, prompt="Is N thru E CCW ?"} bool mkcrmask {no, prompt="Cosmic ray or sky subtraction mask?"} bool update {yes, prompt="Add object mask name to image headers?"} struct *imglist struct *outimglist begin int ix, iy, fx, fy, nim string tobjmask, tsections, toutlist, omsk, outimlist string img, fieldstring, msect, objlist # int imno, start, finish, ndiff # string cobjlist, tmpim # Get query parameters tobjmask = omask tsections = sections toutlist = outlist # Verify that the object mask exists. if (! imaccess (tobjmask)) { print ("Error: Object mask ", tobjmask," does not exist") return } # Verify that the sections file exists. if (! access (tsections)) { print ("Error: Sections file ", tsections," does not exist") return } count (tsections) | scan (nim) # Generate the output image list outimlist = mktemp ("tmp$maskdereg") if (substr (toutlist, 1, 1) == ".") { imglist = tsections while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // toutlist print (img, >> outimlist) } } else { sections (toutlist, option="fullname", > outimlist) if (nim != sections.nimages) { print ("Error: Input and out object mask lists do not match") delete (outimlist, ver-) return } } # Re-orient mask image which was erected by xnregistar to match input images. if (imaccess ("_maskimage.pl")) imdelete ("_maskimage.pl", ver-) imcopy (tobjmask, "_maskimage.pl", ver-) orient ("_maskimage.pl", y2n_angle, rotation=rotation, invert+) # Make working mask images, one for each input image, by cutting out appropriate # subsection of the input mosaic object mask image. If update=yes insert mask # name into input image headers with OBJMASK card. # If mkcrmask=yes mask name is OBJmask* and field is CROBJMASK, # if mkcrmask=no mask name is objmask* and header field is OBJMASK if (mkcrmask) { fieldstring="CROBJMASK" } else { fieldstring="OBJMASK" } # Loop over the input images. objlist = mktemp ("tmp$maskdereg") imglist = tsections outimglist = outimlist while (fscan (imglist, img, ix, iy, fx, fy) != EOF && fscan (outimglist, omsk) != EOF) { print ("Making object masks for image: ", img) fileroot (img, validim+) img = fileroot.root fileroot (omsk, validim+) omsk = fileroot.root // ".pl" msect = "["//ix//":"//fx//","//iy//":"//fy//"]" if (imaccess (omsk)) { imdelete (omsk, verify-) } imcopy ("_maskimage.pl" // msect, omsk, ver-) print (omsk, >> objlist) if (update) hedit (img, fieldstring, omsk, add+, ver-, up+, sho-) } # Combine the object masks. # if (nprev_omask > 0) { # count (objlist) | scan (nim) # for (imno = nim; imno >= 1; imno = imno - 1) { # start = max (1, imno - nprev_omask) # finish = imno # cobjlist = mktemp ("tmp$maskdereg") # xlist (objlist, cobjlist, start, finish, 0, suffix="") # ndiff = finish - start # if (ndiff > 0) { # fields (tsections, 1, lines="" // imno, quit_if_missing=no, # print_file_name=no) | scan (img) # print ("Combining object mask for image: ", img, # " with ", ndiff, " previous masks") # if (imaccess ("_junk.pl")) imdelete ("_junk.pl", verify-) # tmpim = "_junk.pl" # imsum ("@" // cobjlist, tmpim, title="", hparams="", # pixtype="", calctype="", option="sum", low_reject=0.0, # high_reject=0.0, verbose-) # fields (objlist, 1, lines=""//imno, quit_if_missing=no, # print_file_name=no) | scan (img) # imdelete (img, verify-) # imexpr ("a > 0 ? 1 : 0", img, tmpim, dims="auto", # intype="auto", outtype="auto", refim="auto", # bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, # verbose-, exprdb="none") # imdelete (tmpim, verify-) # } # delete (cobjlist, verify-) # } # } # Clean up. imdelete ("_maskimage.pl", ver-) delete (outimlist, verify-) delete (objlist, verify-) imglist = "" outimglist = "" end iraf-xdimsum-main/src/maskfix.cl000066400000000000000000000076071455666516400172120ustar00rootroot00000000000000# MASKFIX replaces the bad pixels in the input image using a bad pixel mask, # a bad pixel mask value, and linear interpolation. procedure maskfix (inlist, bpmasks, badvalue) # Maskfix uses the sections, fileroot, delete, imcopy, hselect, chpixtype # imgets, hedit, and maskinterp tasks as well as the CL builtins access, # mktemp, and imaccess. string inlist {prompt="The input image list"} string bpmasks {prompt="The bad pixel mask list"} int badvalue {prompt="The bad pixel value in the mask"} bool forcefix {no, prompt="Force the bad pixel fixing ?"} string *imglist string *bplist begin int badv, ipixtype, nimgs, nbp, junk string inlst,img, bad, badimh, badl, infile, bpfile bool firstim, badtoimh, copied # Get query parameters inlst = inlist badl = bpmasks badv = badvalue # Expand input lists infile = mktemp ("tmp$maskfix") sections (inlst, option="fullname", > infile) nimgs = sections.nimages bpfile = mktemp ("tmp$maskfix") sections (badl, option="fullname", > bpfile) nbp = sections.nimages # Check validity of image lists if (nbp == 0) { print ("Error: The bad pixel list is undefined") delete (infile, ver-) delete (bpfile, ver-) return } else if (nbp == 1) { ; } else if (nbp != nimgs) { print ("Error: Image and bad pixel lists don't match") delete (infile, ver-) delete (bpfile, ver-) return } badtoimh = no copied = no # Main interpolation loop imglist = infile bplist = bpfile firstim = yes while (fscan (imglist, img) != EOF) { # Get name of bad pixel file if nbp > 1 if (nbp == 1) { if (firstim) junk = fscan (bplist, bad) } else { junk = fscan( bplist, bad) } fileroot (bad, validim+) bad = fileroot.root // ".pl" firstim = no # If specified bad pixel file is a .pl mask, make default extension version; # otherwise, check for existence of default extension version. Not sure why # this is necesary at present. if (nbp != 1 || ! badtoimh) { fileroot (bad, validim+) badimh = fileroot.root // fileroot.defextn if (fileroot.extension == "pl") { if (! access (badimh)) { badimh = "_badtemp" // fileroot.defextn imcopy (bad, badimh, verbose-) copied = yes } } # Check for existence of default extension version of bad pixel mask. if (! access (badimh)) { print ("Bad pixel file ", badimh, " does not exist") delete (bpfile, ver-) delete (infile, ver-) return } # Make sure that default extension version of bad pixel file is of data type # short. hselect (badimh, "i_pixtype", "yes") | scan (ipixtype) if (ipixtype != 3) { chpixtype (badimh, badimh, "short", verbose-) } badtoimh = yes } # Do the interpolation. imgets (img, "MASKFIX", >& "dev$null") if (forcefix) { print ("Fixing bad pixels in file ", img, " using mask ", bad) maskinterp (img, badimh, badv) hedit (img, "MASKFIX", bad, add+, del-, ver-, show-, update+) } else if (imgets.value == "0") { print ("Fixing bad pixels in file ", img, " using mask ", bad) maskinterp (img, badimh, badv) hedit (img, "MASKFIX", bad, add+, del-, ver-, show-, update+) } else if (imgets.value != bad) { print ("Fixing bad pixels in file ", img, " using mask ", bad) maskinterp (img, badimh, badv) hedit (img, "MASKFIX", bad, add+, ver-, del-, show-, update+) } else { print ("Bad pixels in ", img, " already fixed using mask ", bad) } # Delete temporary default extension copy of bad pixel mask if nbp > 1. if (nbp != 1 && copied) imdelete (badimh, ver-) } # Delete temporary default extension copy of bad pixel mask if nbp = 1. if (nbp == 1 && copied) imdelete (badimh,ver-) delete (bpfile, ver-) delete (infile, ver-) imglist = "" bplist = "" end iraf-xdimsum-main/src/maskinterp.par000066400000000000000000000001471455666516400201010ustar00rootroot00000000000000image,s,a,,,,Image to correct bpimage,s,a,,,,Bad pixel mask file badvalue,i,a,0,,,Value for bad pixels iraf-xdimsum-main/src/maskstat.cl000066400000000000000000000101141455666516400173620ustar00rootroot00000000000000# Calculate images statistics from unmasked regions of an input frame. procedure maskstat (inlist, masks, goodvalue) # The mask file must have only values of 0 and 1. No error checking is # presently done for this. # # Parameter iterstat gives the option of calling iterative statistics # routine iterstat instead of imstat. # # Mask stat checks to see if stsdas.tools is loaded. If so, it uses # imcalc to do the calculation; otherwise, it uses a slower combination of # imarith statements. # # Maskstat uses the dimsum tasks iterstat.cl, minv.cl, and fileroot.cl. # # Maskstat also uses sections, imarith, imdelete, and delete. string inlist {prompt="The input image list"} string masks {prompt="The input mask list"} int goodvalue {0,min=0,max=1,prompt="Good pixel value in mask"} string statsec {"", prompt="The section for computing statistics"} real lower {INDEF,prompt="Initial lower limit for data range"} real upper {INDEF,prompt="Initial upper limit for data range"} bool iterstat {no,prompt="Use iterstat instead of imstat ?"} real nsigrej {3.0, prompt="The n-sigma rejection limit"} int maxiter {20, prompt="The maximum number of iterations"} bool show {yes,prompt="Print results of final iteration ?"} real mean {prompt="The returned masked mean value"} real msigma {prompt="The returned masked sigma value"} real median {prompt="The returned masked median value"} real mmode {prompt="The returned masked mode value"} struct *imglist struct *mlist begin # Declare local variables. real mn, sig, med, mod int nimgs, nmask, goodv, npx string imginlist, img, msk, infile, mfile, mlistf # Get query parameter. imginlist = inlist msk = masks goodv = goodvalue # Expand input image list. infile = mktemp ("tmp$maskstat") sections (imginlist, option="fullname", > infile) nimgs = sections.nimages imglist = infile # Expand mask image list. sections (msk, option="nolist") nmask = sections.nimages if (nmask == 1) { mfile = msk } else { if (nmask != nimgs) { print ("ERROR: Numbers of image files and mask files differ.") delete (infile, ver-) return } mlistf = mktemp ("tmp$maskstat") sections (msk, option="fullname", >> mlistf) mlist = mlistf } # Loop through input image list. while (fscan (imglist, img) != EOF) { # Get name of mask file if nmask > 1. If nmask == 1 it was defined above. if (nmask != 1) { if (fscan (mlist, mfile) == EOF) { delete (infile, ver-) delete (mlistf, ver-) print ("ERROR: Prematurely reached end of mask list.") return } } # Calculate statistics for the mask file. if (show) { print ("Calculating statistics for ", img, " using mask ", mfile) } if (iterstat) { if (goodv == 0) miterstat (img, inmsklist=mfile, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=iNDEF, show=show) else { miterstat (img, inmsklist="^"//mfile, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=iNDEF, show=show) } maskstat.mean = miterstat.imean maskstat.msigma = miterstat.isigma maskstat.median = miterstat.imedian maskstat.mmode = miterstat.imode } else { if (goodv == 0) mimstatistics (img // statsec, imasks=mfile, omasks="", fields="mean,stddev,npix,midpt,mode", lower=INDEF, upper=INDEF, binwidth=0.10, nclip=0, lsigma=3.0, usigma=3.0, format-, cache-) | scan (mn, sig, npx, med, mod) else { mimstatistics (img // statsec, imasks="^"//mfile, omasks="", fields="mean,stddev,npix,midpt,mode", lower=INDEF, upper=INDEF, binwidth=0.10, nclip=0, lsigma=3.0, usigma=3.0, format-, cache-) | scan (mn, sig, npx, med, mod) } if (show) print (img, statsec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) maskstat.mean = mn maskstat.msigma = sig maskstat.median = med maskstat.mmode = mod } } # Cleanup. if (nmask > 1) delete (mlistf, ver-) delete (infile, ver-) imglist = "" mlist = "" end iraf-xdimsum-main/src/minv.cl000066400000000000000000000015221455666516400165070ustar00rootroot00000000000000# Routine to invert mask of zeros and ones, i.e. to make 0 --> 1 and 1 --> 0. procedure minv (infile, outfile) string infile {prompt = "Input mask image"} string outfile {prompt = "Output (inverted) mask image"} begin string inf,outf # Get query parameters: inf = infile fileroot (inf, validim+) inf = fileroot.root // ".pl" outf = outfile fileroot (outf, validim+) outf = fileroot.root // ".pl" if (inf != outf) { #imcopy (inf, outf, ve-) imexpr ("a == 1 ? 0 : 1", outf, inf, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) } else { imreplace (outf, 2, imaginary=0.0, lower=0, upper=0, radius=0.0) imarith (outf, "-", 1, outf, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) } end iraf-xdimsum-main/src/miterstat.cl000066400000000000000000000054251455666516400175600ustar00rootroot00000000000000# MITERSTAT iteratively compute image statistics through a mask using the new # MIMSTATISTICS task. procedure miterstat (inlist) # Iterstat also uses the mktemp, sections, and delete tasks. file inlist {prompt="The input image list"} file inmsklist {prompt="The input mask list"} string statsec {"", prompt="The image section for computing statistics"} real lower {INDEF,prompt="The initial lower data limit"} real upper {INDEF,prompt="The initial upper data limit"} real nsigrej {3.0, min=0.0, prompt="The n-sigma rejection limit"} int maxiter {20, min=1, prompt="The maximum number of iterations"} bool show {yes, prompt="Print final results ?"} real imean {prompt="The returned image mean"} real isigma {prompt="The returned image sigma"} real imedian {prompt="The returned image median"} real imode {prompt="The returned image mode"} struct *imglist struct *msklist struct *seclist begin # Declare local variables. real mn, sig, med, mod int npx string imginlist, mskinlist, infile, mskfile, secfile, img, msk, sec, usec string inmask # Get query parameter. imginlist = inlist mskinlist = inmsklist # Expand image template into a list of root image names. infile = mktemp ("tmp$iterstat") sections (imginlist, option="root", > infile) # Expand mask template into a list of root mask names. mskfile = mktemp ("tmp$iterstat") sections (mskinlist, option="root", > mskfile) # Expand image template into a list of image sections. secfile = mktemp ("tmp$iterstat") sections (imginlist, option="section", > secfile) # Loop through images img = "" msk = "" sec = "" usec = "" imglist = infile msklist = mskfile seclist = secfile while (fscan (imglist, img) != EOF && fscan (seclist, sec) != EOF && fscan (msklist, msk) != EOF) { # Compute the initial image statistics. if (sec == "") { usec = statsec } else { usec = sec } mimstatistics (img // usec, imasks=msk, omasks="", fields="mean,stddev,npix,midpt,mode", lower=lower, upper=upper, nclip=maxiter, lsigma=nsigrej, usigma=nsigrej, binwidth=0.1, format-, cache-) | scan (mn, sig, npx, med, mod) # Optionally print the final results. if (show) print (img, usec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) # Save the results in parameter values. imean = mn isigma = sig imedian = med imode = mod } # Delete the temporary root image and image section lists. delete (infile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") delete (mskfile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") delete (secfile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") imglist = "" seclist = "" msklist = "" end iraf-xdimsum-main/src/mkmask.cl000066400000000000000000000111571455666516400170260ustar00rootroot00000000000000# Create the master image masks used by xslm. procedure mkmask (input, expmap, output, nthreshold) # # Also calls the display, imexamine, minmax, imcopy, imreplace, imarith, and # imdelete tasks. # # Creates temporary images called _zerotemp, _inormtemp, and _normtemp. string input {prompt="The input image used to make the mask"} string expmap {prompt="The input exposure map image"} string output {prompt="The name of the output object mask"} real nthreshold {prompt="Number of recommended thresholds for object detection"} bool negthresh {no, prompt="Set negative as well as positive thresholds ?"} string statsec {"", prompt="Image region for computing sky statistics"} real nsigrej {3.0, prompt="The nsigma sky statistics rejection limit"} int maxiter {20, prompt="The maximum number of sky statistics iterations"} int nsmooth {3,min=0,prompt="Boxcar smoothing size before thresholding"} int subsample {1,min=1,prompt="Block averaging factor before median filtering"} int filtsize {15,min=1,prompt="Median filter size for local sky evaluation"} int ngrow {0,min=0,prompt="Half-width of box to grow around masked objects"} bool interactive {yes,prompt="Interactively examine normalized image?"} real threshold {prompt="Cutoff threshold ",mode="q"} begin real th, recthresh, minval, maxval, maxexp, flagval string img, texpmap, oimg, ext # Get query parameter. img = input texpmap = expmap oimg = output # Strip extension off file name. fileroot (img, validim+) img = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext fileroot (oimg, validim+) oimg = fileroot.root // ".pl" # Normalize image to uniform pixel-to-pixel rms using square root of exposure # map. Resulting frame is called _inormtemp. If the exposure map does not # exist then no normalization is necessary and the statistics cab be computed # directly. if (texpmap == "") { iterstat (img // ext, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show-) } else { sigmanorm (img // ext, texpmap, "_inormtemp") # Set flag value at 1 DN below minimum pixel value in normalized image. minmax ("_inormtemp", update-, ver-) minval = minmax.minval maxval = minmax.maxval flagval = 2 * minval - maxval # Identify regions with zero exposure time and exclude from sigma calculation # by flagging them to the flagval and excluding them from the iterstat # calculation. imexpr ("a <= 0.0 ? b : 0.0", "_zerotemp", texpmap, "" // flagval, dims="auto", intype="real", outtype="real", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) imarith ("_inormtemp", "+", "_zerotemp", "_normtemp", divzero=0.0, hparams="", pixtype="real", calctype="real", ver-, noact-) iterstat ("_normtemp", statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=minval, upper=INDEF, show-) imdelete ("_zerotemp", ver-) imdelete ("_normtemp", ver-) } # Calculate rms of masked, normalized image with iterative sigma rejection. # Recommended threshold (to be applied to boxcar smoothed data) is approx. # 4.5/nsmooth x unsmoothed rms. recthresh = 4.5 / nsmooth * iterstat.isigma # Optionally allow user to interactively examine the unsmoothed normalized # image to set threshold for masking. if (interactive) { print ("Recommended threshold level for mask is ", recthresh) if (texpmap == "") { imexamine (img // ext, display="display(image='$1',frame=$2,zs+)") } else { imexamine ("_inormtemp", display="display(image='$1',frame=$2,zs+)") } th = threshold } else { print ("Setting threshold level for mask to ", nthreshold, " * ", "the recommended threshold ", recthresh) th = nthreshold * recthresh } # Create the mask. if (texpmap == "") { makemask (img // ext, oimg, hinlist="", subsample=subsample, filtsize=filtsize, nsmooth=nsmooth, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, threshtype="constant", nsigthresh=2.0, constthresh=th, negthresh=negthresh, ngrow=ngrow, checklimits+, zmin=-32767.0, zmax=32767.0, ver-) } else { makemask ("_inormtemp", oimg, hinlist="", subsample=subsample, filtsize=filtsize, nsmooth=nsmooth, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, threshtype="constant", nsigthresh=2.0, constthresh=th, negthresh=negthresh, ngrow=ngrow, checklimits+, zmin=-32767.0, zmax=32767.0, ver-) imdelete ("_inormtemp", ver-) } # Display original image and the mask. if (interactive) { display (img // ext, 1) display (oimg, 2, z1=0, z2=1, zsca-, zra-) } end iraf-xdimsum-main/src/mkpkg000066400000000000000000000006001455666516400162460ustar00rootroot00000000000000# Make the XDIMSUM Package $call relink $exit update: $call relink $call install ; relink: $set LIBS = "-lxtools" $update libpkg.a $omake x_xdimsum.x $link x_xdimsum.o libpkg.a $(LIBS) -o xx_xdimsum.e ; install: $move xx_xdimsum.e xdimsumbin$x_xdimsum.e ; libpkg.a: @xdsrc ; iraf-xdimsum-main/src/obsolete/000077500000000000000000000000001455666516400170325ustar00rootroot00000000000000iraf-xdimsum-main/src/obsolete/addring.cl.old000066400000000000000000000014271455666516400215430ustar00rootroot00000000000000procedure addring(mask) # Slight change of display levels 2/28/93 MD # Script addring.cl adds a ring around all objects in a mask image. # 11 July 1992 by John S. Ward # Mod. 19 May 1993 by Mark Dickinson to make it compatable # with .pl masks, to add mask as query parameter, to make number # of added rings a variable, and to eliminate autodisplay. # # NOTE: This routine assumes that "objects" are masked with 1s # while blank sky is represented by 0s. string mask {prompt="Name of mask image"} int ngrow {1,min=0,prompt="Number of pixel rings to grow around mask"} begin string mi # equals maskim int nbox int nbox2 mi = mask nbox = 2 * ngrow + 1 nbox2 = nbox * nbox imarith (mi,"*",nbox2,mi,ver-) boxcar (mi,mi,nbox,nbox) imreplace (mi,1,lower=1,upper=INDEF) end iraf-xdimsum-main/src/obsolete/bundle.cl.old000066400000000000000000000055601455666516400214060ustar00rootroot00000000000000procedure bundle(image_list,nbundle) # Procedure to coaverage sets of individual exposures taken at a given # sky position. Takes as input a list of files (which must be in the proper # sequence for grouping, i.e. presumably ther order in which they were taken) # and the number of files to average to form each "bundle". Output files # are named after the first file of the bundle with the an added suffix # 'bn', where n is the number of files in the bundle. # # 22 Sept 90. Magnificently written by Mark Dickinson, # nouveau IRAF script demi-pundit extraordinaire # # Edited 10 May 91 to add test for nbundle=2 then average in first pass # by Peter Eisenhardt # # Upgraded 8 July 92 to work with IRAF version 2.10 by John Ward # Further revisions 13 July to support v2.10 combine # Changed 21 Jul 93 from combine --> imcombine # # Minor changes 4 Aug 1993 -- MD string image_list {prompt="List of images in sequence for bundling"} int nbundle {min=1, prompt="Number of images to bundle at a time"} string *imglist begin string img, outimg, img1, tlist int i, ibundle, navg # Get query parameters. imglist = image_list navg = nbundle ibundle=0 tlist = mktemp("tmp$bundle") while (fscan(imglist,img) != EOF) { files(img, >> tlist) ibundle+=1 if (ibundle==1) { fileroot (img,validim+) img1 = fileroot.root } else if (ibundle==navg) { outimg = img1 // "b" // navg print ("Making bundled frame ",outimg) if (ibundle >= 3) { imcombine ("@"//tlist,outimg,combine="average",reject="none", proj-,outtype="real",off="none",maskty="none",scal="none",zero="none", weight="none",lthr=INDEF,hthr=INDEF,nkeep=1,mclip+,lsig=3.,hsig=3., sigscale=0.,grow=0,plfile="",sigma="") } else imcombine ("@"//tlist,outimg,combine="average",reject="none", proj-,outtype="real",off="none",maskty="none",scal="none",zero="none", weight="none",lthr=INDEF,hthr=INDEF,mclip+,lsig=3.,hsig=3., sigscale=0.,grow=0,plfile="",sigma="") delete (tlist,ver-) ibundle = 0 } } # This extra pass is to handle the last few files in the list, # and is only triggered when an odd number (i.e. not=nbundle) is left. if (ibundle!=0) { outimg = img1 // "b" // ibundle print ("Making bundled frame ",outimg) if (ibundle >= 3) imcombine ("@"//tlist,outimg,combine="average",reject="none", proj-,outtype="real",off="none",maskty="none",scal="none",zero="none", weight="none",lthr=INDEF,hthr=INDEF,nkeep=1,mclip+,lsig=3.,hsig=3., sigscale=0.,grow=0,plfile="",sigma="") else imcombine ("@"//tlist,outimg,combine="average",reject="none", proj-,outtype="real",off="none",maskty="none",scal="none",zero="none", weight="none",lthr=INDEF,hthr=INDEF,mclip+,lsig=3.,hsig=3., sigscale=0.,grow=0,plfile="",sigma="") delete (tlist,ver-) print ("Bundle ",outimg," averages only ",ibundle, " frames.") } imglist = "" end iraf-xdimsum-main/src/obsolete/finalpass.cl.old000066400000000000000000000127751455666516400221230ustar00rootroot00000000000000procedure finalpass(sfimg,outimg,mask) # Modified 19 August 1992 to use pre-mask version of slm. Assumes # input images have been previously flatfielded. Calls xzap. # Pixels corrected by xzap more than 2 times added to badpix. # # Script combining slm, flat fielding, fixpix, zap, and magshiftfix for # for the second pass of reduction of HZRG's. Maskpass must be given # the name of the image from newshiftfix, the number of images to use # in the sky frame, the path of the flat for flat fielding, the path of # the bad pixel list, the name of the final shifted image, and all # relevent parameters for calling magshiftfix. # A threshold value of 5 times the average of the standard deviation # of the fixpixed images is used in calling zap, and the file for logging # bad pixels is called zaplog. The output images are prefixed with "ss_". # All existing images "ss_*" are deleted when finalpass called. # The mask image must be named "mask". # # 11 July 1992 by John S. Ward string sfimg {prompt="Name of image produced by shiftfix"} string outimg {prompt="Name for final magshifted image"} string mask {prompt="Name of object mask file"} bool maskdereg {yes,prompt="Deregister mask sections from main mask?"} bool xslm {yes,prompt="Do xslm stage?"} bool fixpix {yes,prompt="Do fixpix stage?"} bool xzap {yes,prompt="Do xzap stage?"} bool badpixupdate {yes,prompt="Do bad pixel file update?"} bool register {yes,prompt="Do register stage?"} string shiftlist {"Shiftlist",prompt="Shift list file (names, a shifts, b shifts, weights)"} int nmed {4,min=1,prompt="Number of images to use in sky frame"} int mfac {4,min=1,prompt="Magnification factor for magshift"} string bpimage {"",prompt="Bad pixel mask image"} string prefix {"ss_",prompt="Prefix for sky subtracted images"} real secpexp {60.,prompt="Seconds per unit exposure time"} int ncoavg {1,prompt="Number of internal coaverages per frame"} int rjct {1,prompt="Number of pixels for xslm minmax reject"} int nskymin {0,prompt="Minimum number of frames to use for sky"} bool premask {yes,prompt="Mask working sky images to make sky frame?"} bool forcescale {yes,prompt="Force recalculation of image medians in sky scaling?"} bool pixin {no,prompt="Are input coords measured pixels of ref object?"} real scale_x {1.,prompt="x pixels per ab coord unit"} real scale_y {1.,prompt="y pixels per ab coord unit"} real ang_a2x {180.,prompt="Angle in degrees from a CCW to x"} bool senseab {no,prompt="Is a through b counterclockwise?"} real ang_y2N {0.,prompt="Angle in degrees from y to N dir N through E"} bool rotation {yes,prompt="Is N through E counterclockwise?"} bool answer {yes,prompt="OK to delete old sky subtracted files?",mode="q"} struct *ilist begin string ext # Default extension string sfim # equals sfimg string outim # equals outimg string msk # equals mask int nprefix string img # image filename string tlist1 # temporary file list string tlist2 # temporary file list string simgimh # name of sky subtracted image for first image on list sfim = sfimg outim = outimg msk = mask # Create temporary lists of filenames for unskysubtracted and sky subtracted # output files. # Determine filename of first sky subtracted file and save in variable # imgimh for later use. fileroot (sfim,validim+) sfim = fileroot.root ext = fileroot.defextn if (maskdereg || xslm || fixpix || xzap) { tlist1 = mktemp("tmp$firstpass") tlist2 = mktemp("tmp$firstpass") ilist = sfim // "._shift" while (fscan(ilist,img) != EOF) { fileroot (img,validim+) if (fileroot.extension == "") { simgimh = prefix // fileroot.root // ext } else { simgimh = prefix // img } print (img,>>tlist1) print (prefix//img,>>tlist2) } } # Call maskdereg, xslm, fixpix, xzap, badpixupdate, and register. if (maskdereg) { print("------ Deregistering mask subsections with maskdereg ------") imdelete ("objmask_*.pl",ver-) maskdereg (sfim,msk,angle=ang_y2N,rotation=rotation,update+) print("") } if (xslm) { print("----------- Sky subtracting images with xslm. -------------") if (access(simgimh)) { if (answer) imdel(simgimh,ver-) } imdelete ("csky_"//prefix//"*.pl",ver-) imdelete ("holes_"//prefix//"*.pl",ver-) xslm(tlist1,nmed,mask=yes,prefix=prefix,nrej=rjct,nskymin=nskymin, premask=premask,force=forcescale,csky_del=no) print("") } if (fixpix) { print("----------Correcting bad pixels with maskfix.-------------") maskfix ("@"//tlist2,bp,0) print("") } if (xzap) { print("---------- Zapping cosmic rays using xzap. -------------") imdel ("_cr*"//ext//",_mask*"//ext//",_fmed*"//ext,ver-) xzap("@"//tlist2,"@"//tlist2,deletemask=no, cleanpl=yes,cleanimh=yes,verbose=no) print("") } if (badpixupdate) { print("------- Updating bad pixel file with badpixupdate. -------") badpixupdate (3,bp) print("") } if (register) { print("------Shifting and coadding images with register.------") nprefix = strlen(prefix) register(shiftlist,outim,bpimage,xscale=scale_x,yscale=scale_y, axangle=ang_a2x,absense=senseab,pixin=pixin,angle=ang_y2N, rotation=rotation,secpexp=secpexp,ncoavg=ncoavg,mag=mfac, nprefix=nprefix) } # Clean up. if (maskdereg || xslm || fixpix || xzap) { delete (tlist1,ver-) delete (tlist2,ver-) } ilist = "" end iraf-xdimsum-main/src/obsolete/initpass.cl.old000066400000000000000000000100301455666516400217530ustar00rootroot00000000000000procedure initpass(imlist,outim) # Various changes up to 7/20/93 to make structure more generic, including # making sky subtracted file prefix a parameter. -- MD # Modified 2/27/93 to delete masks from xzap after they are imsummed. -- MD # Script combining xslm, fixpix, xzap, and register for # for the first pass of reduction of HZRG's. Firstpass must be given # the name of the image list, the number of images to use # in the sky frame, the path of # the bad pixel list, the name of the final shifted image, and all # relevent parameters for calling register. # # 11 July 1992 by John S. Ward string imlist {prompt="List of images"} string outim {prompt="Name for final shifted image"} bool xslm {yes,prompt="Do xslm stage?"} bool fixpix {yes,prompt="Do fixpix stage?"} bool xzap {yes,prompt="Do xzap stage?"} bool badpixupdate {yes,prompt="Do bad pixel file update?"} bool register {yes,prompt="Do register stage?"} string shiftlist {"Shiftlist",prompt="Shift list file (names, a shifts, b shifts, weights)"} int nmed {4,min=1,prompt="Number of images to use in sky frame"} string bpimage {"",prompt="Bad pixel mask image"} string prefix {"s_",prompt="Prefix for sky subtracted images"} real secper {60.,prompt="Seconds per unit exposure time"} int ncoavg {1,min=1,prompt="Number of internal coaverages per frame"} int rjct {1,min=0,prompt="Number of pixels for xslm minmax reject"} int nskymin {0,min=0,prompt="Minimum number of frames to use for sky"} bool forcescale {yes,prompt="Force recalculation of image medians in sky scaling?"} bool pixin {yes,prompt="Are input coords measured pixels of ref object?"} real scale_x {1.,prompt="x pixels per ab coord unit"} real scale_y {1.,prompt="y pixels per ab coord unit"} real ang_ax {0.,prompt="Angle in degrees from a CCW to x"} bool senseab {yes,prompt="Is a through b counterclockwise?"} real ang_y2N {90.,prompt="Angle in degrees from y to N dir N through E"} bool rotation {no,prompt="Is N through E counterclockwise?"} bool answer {yes,prompt="OK to delete old sky subtracted files?",mode="q"} struct *ilist begin string ext # default extension string lst # equals imlist string oi # equals outim string img # image filename string tlist # temporary output file list string simgimh int nprefix int ifile # Get query parameters. lst = imlist oi = outim # Create temporary list of filenames for sky subtracted output files. # Determine filename of first sky subtracted file and save in variable # imgimh for later use. fileroot ("") ext = fileroot.defextn tlist = mktemp("tmp$initpass") ilist = lst ifile = 0 while (fscan(ilist,img) != EOF) { ifile += 1 if (ifile == 1) { fileroot (img,validim+) if (fileroot.extension == "") simgimh = prefix // fileroot.root // ext else simgimh = prefix // img } print (prefix//img,>>tlist) } # Call xslm, fixpix, xzap, badpixupdate, and register. if (xslm) { print("----------Sky subtracting images with xslm.-------------") if (access(simgimh)) { if (answer) imdel("@"//tlist,ver-) } xslm(lst,nmed,mask-,prefix=prefix,nreject=rjct,nskymin=nskymin, premask-,force=forcescale) print("") } if (fixpix) { print("----------Correcting bad pixels with maskfix.-------------") maskfix ("@"//tlist,bpimage,0) print("") } if (xzap) { print("---------- Zapping cosmic rays using xzap. -------------") imdel ("_cr*"//ext//",_mask*"//ext//",_fmed*"//ext,ver-) xzap("@"//tlist,"@"//tlist,deletemask=no, cleanpl=yes,cleanimh=yes,verbose=no) print("") } if (badpixupdate) { print("------- Updating bad pixel file with badpixupdate. -------") badpixupdate (3,bpimage) print("") } if (register) { print("-------Shifting and coadding images with register.--------") imdelete ("bigshift*"//ext//",bigscale*"//ext,ver-) nprefix = strlen(prefix) register(shiftlist,oi,bpimage,xscale=scale_x,yscale=scale_y, axangle=ang_ax,absense=senseab,pixin=pixin,angle=ang_y2N, rotation=rotation,secpexp=secper,ncoavg=ncoavg,mag=1, nprefix=nprefix) print("") } delete (tlist,ver-) ilist = "" end iraf-xdimsum-main/src/obsolete/iterstat.cl000066400000000000000000000064221455666516400212150ustar00rootroot00000000000000# ITERSTAT iteratively compute image statistics using the IMSTATISTICS task. procedure iterstat (inlist) # Iterstat also uses the mktemp, sections, and delete tasks. file inlist {prompt="The input image list"} string statsec {"", prompt="The image section for computing statistics"} real lower {INDEF,prompt="The initial lower data limit"} real upper {INDEF,prompt="The initial upper data limit"} real nsigrej {3.0, min=0.0, prompt="The n-sigma rejection limit"} int maxiter {20, min=1, prompt="The maximum number of iterations"} bool show {yes, prompt="Print final results ?"} bool verbose {yes, prompt="Print results of each iteration ?"} real imean {prompt="The returned image mean"} real isigma {prompt="The returned image sigma"} real imedian {prompt="The returned image median"} real imode {prompt="The returned image mode"} struct *imglist struct *seclist begin # Declare local variables. real mn, sig, med, mod, ll, ul int npx, m, nx string imginlist, infile, secfile, img, sec, usec # Get query parameter. imginlist = inlist # Expand image template into a list of root image names. infile = mktemp ("tmp$iterstat") sections (imginlist, option="root", > infile) # Expand image template into a list of image sections. secfile = mktemp ("tmp$iterstat") sections (imginlist, option="section", > secfile) # Loop through images img = "" sec = "" usec = "" imglist = infile seclist = secfile while (fscan (imglist, img) != EOF && fscan (seclist, sec) != EOF) { # Compute the initial image statistics. if (sec == "") { usec = statsec } else { usec = sec } #ximstat (img // usec, fields="mean,stddev,npix,midpt,mode", #lower=lower, upper=upper, nclip=maxiter, lsigma=nsigrej, #usigma=nsigrej, binwidth=0.1, format-) | scan (mn, sig, npx, #med, mod) imstatistics (img // usec, fields="mean,stddev,npix,midpt,mode", lower=lower, upper=upper, binwidth=0.1, format-) | scan (mn, sig, npx, med, mod) # Perform the rejection cycle. for (m = 1; m <= maxiter; m = m + 1) { # Print the current results. if (verbose) print (img, usec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) # Compute the new rejection limits. ll = mn - (nsigrej * sig) ul = mn + (nsigrej * sig) if (lower != INDEF && ll < lower) ll = lower if (upper != INDEF && ul > upper) ul = upper # Compute new statistics. imstatistics (img // usec, fields="mean,stddev,npix,midpt,mode", lower=ll, upper=ul, binwidth=0.1, format-) | scan (mn, sig, nx, med, mod) # Quit if no new pixels are rejected. if (nx == npx) break npx = nx } # Optionally print the final results. if (show && ! verbose) print (img, usec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) # Save the results in parameter values. imean = mn isigma = sig imedian = med imode = mod } # Delete the temporary root image and image section lists. delete (infile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") delete (secfile, go_ahead+, verify-, default_action+, allversions+, subfiles+, > "dev$null") imglist = "" seclist = "" end iraf-xdimsum-main/src/obsolete/magshiftfix.cl.old000066400000000000000000000347701455666516400224530ustar00rootroot00000000000000procedure magshiftfix(image_list, outimg, badpixfile) # Replaced MKIMAGE with MKPATTERN -- 3/31/97 FV # # WARNING !! Recent adjustment made to the use of the 'exp' column in # the shiftlist file -- magshiftfix no longer multiplies the image by # that factor before adding it into the mosaic! It DOES multiply the # appropriate "_one" scaling image by that factor before adding it # into the exposure map, however. This is meant to be appropriate for # using the 'exp' column to adjust for non-photometric scalings or # differing relative exposure times. It no longer serves as a weighting # factor, however, unless exp=0, in which case magshiftfix just skips # that image in the summation, as before. This may not be a desirable # change and must be considered further. In the meanwhile, be forewarned! # -- 10/17/93 MD # # Modified check for holes mask to use "HOLES" keyword in # image header. 9/19/93 MD # Check for zero weight in Shiftlist file, and if so, skip that # image rather than going through all the trouble just to end # up multiplying by zero... 9/19/93 MD # Modified call to orientimg --> to call new routine orient. 7/22/93 MD # Added parameter ncoavg to properly account for data take in # mode where multiple individual exposures are internally coaveraged # before readout. -- MD 7/15/93 # Debugging problem where pixin+ doesn't work 7 Dec # Addtl. mod 16 Dec 1991 at KPNO 50" to reduce space needed, by # deleting magnified images as soon as possible # Modification of task newshiftfix to do all integer shifts rather # than imshift interpolation, by scaling input images up with # block replication factor "mag" which is input. # 5 Aug. 1991 Peter Eisenhardt # Procedure to combine images taken at different locations # into one big image, with no loss of spatial coverage or signal # Assumes all input images have same dimensions # Peter Eisenhardt 3 April 1989 # Modified 13 June 1989 to have scale and angle - unlike shiftpix, # this version takes coordinate offsets as input. # Further modified 21 Sept 1990 to allow masking of bad pixels specified # in file bpixfile (uses fixpix format) # Minor change 22 Oct/90 to add secpexp - seconds per exposure unit - # Output is then in units of flux per second. # Mofified 13 May 1991 to add parameter rotation which gives # sense of North thru E. Rotation is "true" if N thru E is CCW, # which means "sign" is negative (and vice versa). Rotation and # angle are use in task orient, which does the transformation to # put N near top and E near left. # more mods 15 July 1991 -- changing way integers vs. fractions are handled # so that always do "proper" integer shift # also doing auto weighting assuming bundle format name # and allowing different x and y scales # Yet more mods 22 July 1991 to support sublocalmask -- # now generates addtl output file outimg//"._shift" # Still even more additional mods 24 July -- separate dependence of # NE, from input coords AB # Don't need orientshiftlist call -- just want shifts in raw # input coords, but do need to deshift mask pixel coords from final output coords # Corrected error in newx , newy formulae for differing x and y scales, # now in accordance with geomap string image_list {prompt="List of images, Nshifts, Eshifts, and expos. times"} string outimg {prompt="Output combined image name"} string badpixfile {prompt="Bad pixel file"} bool pixin {no, prompt="Are input coords measured pixels of ref object?"} real xscale {1.,prompt="x pixels per ab coord unit"} real yscale {1.,prompt="y pixels per ab coord unit"} real axangle {180., prompt="angle in degrees from a CCW to x"} bool absense {no, prompt="Is a thru b counterclockwise?"} real angle {0., prompt="angle in degrees from y to N dir N thru E"} bool rotation {yes, prompt="Is N thru E counterclockwise?"} real secpexp {60., prompt="Seconds per unit exposure time"} int ncoavg {1, min=1, prompt="Number of internal coaverages per frame"} int mag {4, min=1, prompt="Block replication factor(for sub pixel accuracy)"} struct *imglist begin string ext # default extension real axrad # ax angle in radians real a,b # fscan'ed values for coords a and b of input frame real newx,newy # values for x and y shift real exp # fscan'ed relative exposure time real mexp # mexp=exp/(mag*mag) to conserve counts real seconds # exposure time in seconds real xmin,xmax,ymin,ymax # extreme values for x and y shifts int ixmin,ixmax,iymin,iymax # Integer values of extreme shifts int ix,iy # Start and finish column,row int fx,fy # for integer shift using copy int ixdim,iydim # x and y dimensions of input images int oxdim,oydim # x and y dimensions of output image int sign # -1 if absense is CW, +1 if CCW int ilen # character length string strtemp # used to get number bundled real navg # number bundled string img,oimg # input and output image names string bpfile # equals badixfile string rewind # used to rewind imglist string sect # image section used for integer shift string which_one # name of individual scaling image string headfile1, headfile2 # files for temporary storage of header struct theadline # temporary struct for header data string holesmask # name of HOLES mask file, if any string crmask # name of cosmic ray mask, if any xmin=9E+32 # initial values -- set large so that ymin=9E+32 # they will get reset xmax=-2E+9 ymax=-2E+9 # Get the query parameters rewind=image_list oimg=outimg bpfile=badpixfile axrad=axangle*3.1415926535/180. sign=-1 if (absense) sign=1 # If input coords are measured pixels of ref object, scale is 1, but # shifts are opposite sign of measured pixels. if(pixin) { xscale=-1. yscale=-1. # Adding set axangle = 0. and absense=yes if pixin+ axrad=0. sign=1 } # Load necessary packages # images # need imgets # imdebug # need mkimage # Check for existence of output files and query about deletion. fileroot ("") ext = fileroot.defextn if (access(oimg//ext)) { print ("Output image already exists.") imdelete (oimg,ve+) } if (access("exp"//oimg//ext)) { print ("Output image already exists.") imdelete ("exp"//oimg,ve+) } if (access("_one"//ext)) imdelete ("_one"//ext,ver-) if (access("_this_one"//ext)) imdelete ("_this_one"//ext,ver-) # Scan header of first image to get image dimensions. We will # assume that all images have the same size... imglist=rewind # rewind imglist if (fscan (imglist,img,a,b) != EOF) { imgets(img,"i_naxis1") ixdim = int(imgets.value) imgets(img,"i_naxis2") iydim = int(imgets.value) } # Find maximum and minimum x and y shift values imglist=rewind # rewind imglist while (fscan (imglist,img,a,b) != EOF) { newx=mag*(xscale*a*cos(axrad) + yscale*b*sign*sin(axrad)) newy=mag*(yscale*b*sign*cos(axrad) - xscale*a*sin(axrad)) if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } if (newx > xmax) { xmax = newx } if (newy > ymax) { ymax = newy } } ixmax=0 ixmin=0 iymax=0 iymin=0 if(xmax!=0.)ixmax=int(xmax+0.5*(xmax/abs(xmax))) if(ymax!=0.)iymax=int(ymax+0.5*(ymax/abs(ymax))) if(xmin!=0.)ixmin=int(xmin+0.5*(xmin/abs(xmin))) if(ymin!=0.)iymin=int(ymin+0.5*(ymin/abs(ymin))) # Make a flat image for scaling position dependent exposure time # This has size of original input image so that bad pixel masking can be done #mkimage("_one",ixdim,iydim,"r",1.,"Scaling image") mkpattern ("_one", pattern="constant", option="replace", v1=1., title="Scaling image", pixtype="r", ndim=2, ncols=ixdim, nlines=iydim) # Set bad pixels to zero in the flat image imarith("_one","*",bpfile,"_one",ver-) # Now rescale up to mag size for output image ixdim=ixdim*mag iydim=iydim*mag oxdim = ixdim + ixmax - ixmin oydim = iydim + iymax - iymin # Create magnified output images here #mkimage(oimg,oxdim,oydim,"r",0.,"shifted") #mkimage("exp"//oimg,oxdim,oydim,"r",0.,"Exposure map") mkpattern (oimg, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) mkpattern ("exp"//oimg, pattern="constant", option="replace", v1=0., title="Exposure map", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Now do the shift imglist=rewind # rewind imglist while (fscan (imglist,img,a,b,exp) != EOF) { print("Shifting ",img) # Check to see if weight is exactly zero, and if so skip this image. if (exp == 0.0) { print (" Image weight is zero in the sum. Moving on...") next } # Strip off extension if present. fileroot (img,validim+) img = fileroot.root # Check for cosmic ray mask, and if it exists, combine it with bad pixel file. # First, we look for a file called "crm_"//ext//".pl". If that is not # present, check the image header for the keyword CRMASK, and if present, look # for the file named there. This allows the user some flexibility in not always # having to rename the crmask file if different sky subtracted versions of # the same image are used at various times. crmask = "" if (access("crm_"//img//".pl")) { crmask = "crm_"//img//".pl" print ("Using prefixed cosmic ray mask file: ",crmask) } else { imgets (img,"CRMASK",>& "dev$null") if (imgets.value != "0") { crmask = imgets.value print ("Using cosmic ray mask file from header: ",crmask) } } if (crmask != "") { imarith ("_one","-",crmask,"_this_one"//ext) imreplace ("_this_one",0.,lower=INDEF,upper=0.) which_one = "_this_one"//ext } else { which_one = "_one"//ext } # Check for "holes" mask, and if it exists, combine it into weighting mask. holesmask = "" hselect (img,"HOLES","yes") | scan (holesmask) if (holesmask != "" && access(holesmask)){ print ("Using 'holes' mask file ",holesmask) imarith (which_one,"*",holesmask,"_this_one"//ext) which_one = "_this_one"//ext } # Set bad pixels, CR pixels, and holes to zero in copy of image named _img. imarith (img,"*",which_one,"_"//img,ver-) # Calculate integer shifts newx=mag*(xscale*a*cos(axrad) + yscale*b*sign*sin(axrad)) newy=mag*(yscale*b*sign*cos(axrad) - xscale*a*sin(axrad)) ix=0 if(newx!=0.) ix=int(newx+0.5*(newx/abs(newx))) ix = 1 + ix - ixmin # For zero shift of 50 x 100, fx = ix + ixdim - 1 # imcopy shift big[1:50,1:100] iy=0 if(newy!=0.) iy=int(newy+0.5*(newy/abs(newy))) iy = 1 + iy - iymin fy = iy + iydim - 1 # Construct the image section string sect = "["//ix//":"//fx//","//iy//":"//fy//"]" # Make big empty image #mkimage("bigshift"//img,oxdim,oydim,"r",0.,"shifted") mkpattern ("bigshift"//img, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # The routine 'bundle.cl' averaged all size bundles to a single unit of # exposure time, regardless of how many units went into the bundle. # To weight the cumulative exposure properly, we need to multiply # each bundle by the number of units (navg) that went into it. # This will be read from the file name, since the suffix '-bN' was # attached for this purpose. Note that N (=navg) must be less than 10 # (i.e. a single digit) for the following to work. # # This should really be replaced with a call to the image header, and # bundle should record the number of frames bundled in that header keyword... ilen=strlen(img) if(substr(img,ilen-1,ilen-1)=="b") { strtemp=substr(img,ilen,ilen) navg=real(strtemp) } else { navg = 1 } exp = exp * navg # Multiply exposure by the number of internally coaveraged exposures per frame. exp = exp * ncoavg # Now do the magnification and delete the temporary copy _img. blkrep("_"//img,"shift"//img,mag,mag) imdelete ("_"//img,ver-) # Divide by mag squared because want to conserve total number of counts # in input image. # Previous version had: mexp= exp/(mag*mag) mexp= (navg*ncoavg)/(mag*mag) imarith("shift"//img,"*",mexp,"shift"//img,pixt="real", calc="real",ver-) # and copy into the big image imcopy("shift"//img,"bigshift"//img//sect,ver-) imdel("shift"//img,verify=no) # and finally sum into output image. imarith("bigshift"//img,"+",oimg,oimg,pixt="real",calc="real") imdel("bigshift"//img,verify=no) # Now make the image to scale for position dependent exposure time #mkimage("bigscale"//img,oxdim,oydim,"r",0.,"scaling") mkpattern ("bigscale"//img, pattern="constant", option="replace", v1=0., title="scaling", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) seconds=secpexp*exp print (" Total effective exposure time for this frame is ",seconds) blkrep(which_one,"scale"//img,mag,mag) imarith("scale"//img,"*",seconds,"scale"//img,pixt="real", calc="real",ver-) imcopy("scale"//img,"bigscale"//img//sect,ver-) imdel("scale"//img,verify=no) imarith("bigscale"//img,"+","exp"//oimg,"exp"//oimg,pixt="real", calc="real",ver-) imdel("bigscale"//img,verify=no) if (access("_this_one"//ext)) imdelete ("_this_one"//ext,ver-) } imdel("_one",verify=no) # Divide output image sum by exposure map. imarith(oimg,"/","exp"//oimg,oimg,divzero=0.,pixt="real", calc="real",ver-) # Orient these to N at top, E at left for iraf default orient(oimg,angle,rotation=rotation,invert-) orient("exp"//oimg,angle,rotation=rotation,invert-) # Copy header information from 1st input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. print ("Updating header information.") imglist=rewind # rewind imglist if (fscan (imglist,img,a,b) != EOF) { headfile1 = mktemp("_header") headfile2 = mktemp("_header") hfix (img,command="copy $fname "//headfile1) match ("dimsum.slm",headfile1,stop+,print+,>headfile2) hfix (oimg,command="delete $fname ve- ; copy "//headfile2//" $fname") hselect (img,"title",yes) | scan(theadline) hedit (oimg,field="exptime",value="1",add+,ver-,show+,update+) hedit (oimg,field="title",value="Magshiftfix mosaic sum: "//theadline, ver-,show+,update+) hedit ("exp"//oimg,field="title", value="Exposure time map: "//theadline,ver-,show+,update+) hedit (oimg,fields="BPM,HOLES,SKYMED",delete+,ver-,show+,update+) time | scan (theadline) addcomment ("exp"//oimg,"dimsum.magshiftfix: "//theadline,ver-) addcomment (oimg,"dimsum.magshiftfix: "//theadline,ver-) addcomment (oimg,"dimsum.magshiftfix: Header data copied from file "//img,ver-) delete (headfile1,ve-) delete (headfile2,ve-) } imglist = "" end iraf-xdimsum-main/src/obsolete/maskinterp.x.old000066400000000000000000000031611455666516400221560ustar00rootroot00000000000000include procedure t_maskinterp () char image[SZ_FNAME] # Image to correct char bpimage[SZ_FNAME] # Bad pixel mask image int ibadvalue # Value for bad pixels int i, ii, j, nc, nl, ilastgood, clgeti() real val, lastgood, delta bool gooddata pointer im, bp, imin, imout, bpin, immap(), imgl2r(), impl2r(), imgl2s() begin call clgstr ("image", image, SZ_FNAME) call clgstr ("bpimage", bpimage, SZ_FNAME) ibadvalue = clgeti ("badvalue") im = immap (image, READ_WRITE, 0) bp = immap (bpimage, READ_ONLY, 0) nc = IM_LEN(im,1) nl = IM_LEN(im,2) if (IM_LEN(bp,1) != nc || IM_LEN(bp,2) != nl) call error (1, "Image and mask files have mismatched dimensions.") do j = 1, nl { imin = imgl2r (im, j) imout = impl2r (im, j) bpin = imgl2s (bp, j) # Assume that we start off with good data. gooddata = true lastgood = 0. ilastgood = 0 do i = 1, nc { val = Memr[imin+i-1] if (Mems[bpin+i-1] == ibadvalue) { # Bad pixel... if (gooddata) gooddata = false if (i == nc && ilastgood != 0) { do ii = ilastgood+1, nc # ...at end of row... Memr[imin+ii-1] = lastgood } } else { if (!gooddata) { if (ilastgood == 0) { do ii = 1, i-1 # ...at start of row... Memr[imin+ii-1] = val } else { # ...interpolate... delta = (val - lastgood) / (i - ilastgood) do ii = ilastgood+1, i-1 Memr[imin+ii-1] = lastgood + (ii - ilastgood) * delta } gooddata = true } lastgood = val ilastgood = i } } call amovr (Memr[imin], Memr[imout], nc) } call imunmap (bp) call imunmap (im) end iraf-xdimsum-main/src/obsolete/maskstat.cl000066400000000000000000000113411455666516400212010ustar00rootroot00000000000000# Calculate images statistics from unmasked regions of an input frame. procedure maskstat (inlist, masks, goodvalue) # The mask file must have only values of 0 and 1. No error checking is # presently done for this. # # Parameter iterstat gives the option of calling iterative statistics # routine iterstat instead of imstat. # # Mask stat checks to see if stsdas.tools is loaded. If so, it uses # imcalc to do the calculation; otherwise, it uses a slower combination of # imarith statements. # # Maskstat uses the dimsum tasks iterstat.cl, minv.cl, and fileroot.cl. # # maks stat also uses sections, imarith, imdelete, and delete. string inlist {prompt="The input image list"} string masks {prompt="The input mask list"} int goodvalue {0,min=0,max=1,prompt="Good pixel value in mask"} string statsec {"", prompt="The section for computing statistics"} real lower {INDEF,prompt="Initial lower limit for data range"} real upper {INDEF,prompt="Initial upper limit for data range"} bool iterstat {no,prompt="Use iterstat instead of imstat ?"} real nsigrej {3.0, prompt="The n-sigma rejection limit"} int maxiter {20, prompt="The maximum number of iterations"} bool show {yes,prompt="Print results of final iteration ?"} bool verbose {yes,prompt="Print results of each iteration ?"} real mean {prompt="The returned masked mean value"} real msigma {prompt="The returned masked sigma value"} real median {prompt="The returned masked median value"} real mmode {prompt="The returned masked mode value"} struct *imglist struct *mlist begin # Declare local variables. real minval, maxval, flagval, mn, sig, med, mod int nimgs, nmask, goodv, npx string imginlist, img, msk, infile, mfile, minvfile, mlistf # Get query parameter. imginlist = inlist msk = masks goodv = goodvalue # Expand input image list. infile = mktemp ("tmp$maskstat") sections (imginlist, option="fullname", > infile) nimgs = sections.nimages imglist = infile # Expand mask image list. sections (msk, option="nolist") nmask = sections.nimages if (nmask == 1) { mfile = msk #sections (mfile, option="root") | scan (minvfile) #minvfile = "_"//minvfile minvfile = "_msktemp.pl" minv (mfile, minvfile) } else { if (nmask != nimgs) { print ("ERROR: Numbers of image files and mask files differ.") delete (infile, ver-) return } mlistf = mktemp ("tmp$maskstat") sections (msk, option="fullname", >> mlistf) mlist = mlistf } # Loop through input image list. while (fscan (imglist, img) != EOF) { # Get name of mask file if nmask > 1. if (nmask != 1) { if (fscan (mlist, mfile) != EOF) { #sections (mfile, option="root") | scan (minvfile) #minvfile = "_" // minvfile minvfile = "_msktemp.pl" minv (mfile, minvfile) } else { delete (infile, ver-) delete (mlistf, ver-) print ("ERROR: Prematurely reached end of mask list.") return } } # Calculate statistics for the mask file. if (show) { print ("Calculating statistics for ", img, " using mask ", mfile) } minmax (img, force+, update-, ver-) minval = minmax.minval maxval = minmax.maxval if (lower == INDEF) { flagval = 2 * minval - maxval } else { minval = lower flagval = 2 * lower - maxval } if (goodv == 0) { imexpr ("a*b+c*d", "_temp", img, minvfile, flagval, mfile, dims="auto", intype="real", outtype="real", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) } else { imexpr ("a*b+c*d", "_temp", img, mfile, flagval, minvfile, dims="auto", intype="real", outtype="real", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) } if (iterstat) { iterstat ("_temp", statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=minval, upper=upper, show=show) maskstat.mean = iterstat.imean maskstat.msigma = iterstat.isigma maskstat.median = iterstat.imedian maskstat.mmode = iterstat.imode } else { imstat ("_temp"//statsec, fields="mean,stddev,npix,midpt,mode", lower=minval, upper=upper, binwidth=0.10, nclip=0, lsigma=3.0, usigma=3.0, format-, cache-) | scan (mn, sig, npx, med, mod) if (show) print ("_temp", statsec, ": mn=", mn, " rms=", sig, " npix=", npx, " med=", med, " mode=", mod) maskstat.mean = mn maskstat.msigma = sig maskstat.median = med maskstat.mmode = mod } imdelete ("_temp", ver-) if (nmask != 1) { imdelete (minvfile, ver-) } } # Cleanup. if (nmask == 1) imdelete (minvfile, ver-) else delete (mlistf, ver-) delete (infile, ver-) imglist = "" mlist = "" end iraf-xdimsum-main/src/obsolete/maskxzap.cl.old000066400000000000000000000205541455666516400217730ustar00rootroot00000000000000procedure maskxzap(inlist,outlist) # Variant of xzap which is called in maskpass and therefore assumes the # presence of objmask files from a combined image mask. # Cosmic ray cleaning routine using median filtering. # Latest revision: 8 Oct 1993 # Mark Dickinson # # Calls scripts fileroot.cl, iterstat.cl, makemask.cl, minv.cl string inlist {prompt="Image(s) for cosmic ray cleaning"} string outlist {prompt="Output image(s)"} int zboxsz {5,min=3,prompt="Box size for zapping"} real nsigma {5.,min=0.,prompt="Number of sky sigma for zapping threshold"} real nnegsigma {0.,min=0.,prompt="Number of sky sigma for negative zapping"} int nrings {0,min=0,prompt="Number of pixels to flag as buffer around CRs"} real nobjsigma {2.,min=0.,prompt="Number of sky sigma for object identification"} int skyfiltsize {15,min=0,prompt=" Median filter size for local sky evaluation"} int skysubsample{1,min=0,prompt=" Block averaging factor before median filtering"} int ngrowobj {0,min=0,prompt=" Number of pixels to flag as buffer around objects"} string statsec {"",prompt="Image section to use for computing sky sigma"} bool deletemask {no, prompt="Delete CR mask after execution?"} bool cleanpl {yes,prompt="Delete other working .pl masks after execution?"} bool cleanimh {yes,prompt="Delete working images after execution?"} bool verbose {yes,prompt="Verbose output?"} bool checklimits {yes,prompt="Check min and max pix values before filtering?"} bool unzap {no,prompt="Unzap using objects from objmask files?"} real zmin {-32768.,prompt="Minimum data value for fmedian"} real zmax {32767.,prompt="Minimum data value for fmedian"} struct *inimglist struct *outimglist struct *statlist begin real skysig,skymode real crthresh,objthresh,negthresh real dmin,dmax int nbox,nbox2 int nin string ext, infile, outfile, img, outimg, statfile bool maskobj, maskneg # Check input parameters. if (nnegsigma > 0.) maskneg = yes else maskneg = no if (nobjsigma == 0.) { print ("No object masking will be used during zapping.") maskobj = no } else { maskobj = yes } # Expand file lists into temporary files. infile = mktemp("tmp$zap") outfile = mktemp("tmp$zap") sections (inlist,option="fullname",>infile) nin = sections.nimages sections (outlist,option="fullname",>outfile) if (nin != sections.nimages) { print ("ERROR: Numbers of input and output images do not match.") return } inimglist = infile outimglist = outfile fileroot ("") ext = fileroot.defextn # Loop through input files: while (fscan(inimglist,img) != EOF) { # Strip extension off input file name. fileroot (img,validim+) img = fileroot.root # Read name of output file. if (fscan(outimglist,outimg) == EOF) { print ("ERROR: Problem scanning output file name in xzap.") return } fileroot (outimg,validim+) outimg = fileroot.root print ("Working on ",img," ---ZAP!--> ",outimg) # Calulate sky mean and RMS noise using iterative sigma rejection. if (verbose) print (" Computing statistics.") iterstat (img//statsec, statsec="", nsigrej=5.0, maxiter=10, lower=INDEF, upper=INDEF, verbose=verbose, show=verbose) skymode = iterstat.imean skysig = iterstat.isigma # Median filter image to produce file _fmed_//img if (verbose) print (" Median filtering.") # First, check limits of data range. Wildly large (positive or negative) data values # will screw up fmedian calculation unless checklimits = yes and zmin and zmax are set # to appropriate values, e.g. zmin=-32768, zmax=32767. Note that the old fmedian # bug which occurred if zmin=hmin and zmax=hmax has been fixed in IRAF version 2.10.1. # The pipe to dev$null, however, is included because V2.10.1 and .2 have debugging # print statements accidentally left in the fmedian code. if (checklimits) { minmax (img,force+,update+,ve-) if (verbose) print(" Data minimum = ",minmax.minval, " maximum = ",minmax.maxval) } if (checklimits && (minmax.minval < zmin || minmax.maxval > zmax)) { if (minmax.minval < zmin) { dmin = zmin } else { dmin = minmax.minval } if (minmax.maxval > zmax) { dmax = zmax } else { dmax = minmax.maxval } if (verbose) print (" Truncating data range ",dmin," to ",dmax) fmedian (img,"_fmed_"//img,xw=zboxsz,yw=zboxsz, boundary="reflect",hmin=-32768,hmax=32767, zmin=dmin,zmax=dmax,>&"dev$null") } else { fmedian (img,"_fmed_"//img,xw=zboxsz,yw=zboxsz,boundary="reflect", hmin=-32768,hmax=32767,zmin=INDEF,zmax=INDEF,>&"dev$null") } # Take difference to produce "unsharp masked" image _cr_//img imarith (img,"-","_fmed_"//img,"_cr_"//img) # Threshold _cr_//img at nsigma*skysig to make CR mask _peaks_//img. # Potential CRs --> 1 # "Blank sky" --> 0 # Note that crthresh will be positive by definition. if (verbose) print (" Masking potential CR events.") imcopy ("_cr_"//img,"_peaks_"//img//ext,ve-) crthresh = nsigma*skysig imreplace ("_peaks_"//img//ext,0.,upper=crthresh,lower=INDEF) imreplace ("_peaks_"//img//ext,1.,lower=crthresh,upper=INDEF) # Make PL format version of _peaks_//img and delete IMH format version. imcopy ("_peaks_"//img//ext,"_peaks_"//img//".pl",ve-) imdelete ("_peaks_"//img//ext,ve-) # Object masking: create mask identifying where objects might be. if (maskobj) { if (verbose) print (" Creating object mask.") objthresh = nobjsigma*skysig makemask ("_fmed_"//img,pre="_obj",headlist="",subs=skysubsample, filts=skyfiltsize,nsmoo=0,threshty="constant",constth=objthresh, ngrow=ngrowobj,statsec=statsec,checklimits=checklimits,verbose=verbose) # Invert mask to make "objects" --> 0 and "sky" --> 1. minv ("_obj_fmed_"//img//".pl","_obj_fmed_"//img//".pl") } # If not masking objects, final CR mask is just _peaks_//img. If we are # masking objects, take product of object and CR masks to make crmask_//img if (maskobj) { imarith ("_peaks_"//img//".pl","*","_obj_fmed_"//img//".pl", "crmask_"//img//".pl") } else { imcopy ("_peaks_"//img//".pl","crmask_"//img//".pl",ve-) } # Grow additional buffer region around identified CRs. if (nrings > 0) { if (verbose) print (" Growing mask rings around CR hits.") nbox = 2 * nrings + 1 nbox2 = nbox * nbox imarith ("crmask_"//img//".pl","*",nbox2,"crmask_"//img//".pl") boxcar ("crmask_"//img//".pl","crmask_"//img//".pl", xw=nbox,yw=nbox) imreplace ("crmask_"//img//".pl",1,lower=1,upper=INDEF) } # Identify negative pixels if desired. No "rings" are grown around negative if (maskneg) { if (verbose) print (" Masking deviant negative pixels.") imcopy ("_cr_"//img,"_neg_"//img,ve-) negthresh = -1.*nnegsigma*skysig imreplace ("_neg_"//img,0., lower=negthresh,upper=INDEF) imreplace ("_neg_"//img,1., upper=negthresh,lower=INDEF) imcopy ("_neg_"//img//ext,"_neg_"//img//".pl",ve-) imdelete ("_neg_"//img//ext,ve-) imarith ("crmask_"//img//".pl","+","_neg_"//img//".pl", "crmask_"//img//".pl") imreplace ("crmask_"//img//".pl",1,lower=1,upper=INDEF) } # unzap pixels which are where objects are as defined by objmask files if (unzap) { imarith("objmask_"//img//".pl","*","crmask_"//img//".pl", "crmask_"//img//".pl",ver-) } if (verbose) print (" Replacing CR hits with local median.") # Multiply CR mask by crmask_//img to make "comic rays only" image _cronly_//img imarith ("_cr_"//img//ext,"*","crmask_"//img//".pl", "_cronly_"//img//ext) # Subtract _cronly_//img from data to produce clean image "outimg". # Note that this effectively replaces the masked regions with the local # median, since _cronly_//img = img - _fmed_//img. imarith (img,"-","_cronly_"//img,outimg) # Record CR mask name in headers of input and output images hedit (img//","//outimg,"CRMASK","crmask_"//img//".pl", add+,ver-,update-,>&"dev$null") # Clean up. if (deletemask) delete ("crmask_"//img//".pl",ve-) if (cleanpl) { delete ("_peaks_"//img//".pl",ve-) if (maskobj) delete ("_obj_fmed_"//img//".pl",ve-) if (maskneg) delete ("_neg_"//img//".pl",ve-) } if (cleanimh) { imdelete ("_fmed_"//img,ve-) imdelete ("_cr_"//img,ve-) imdelete ("_cronly_"//img,ve-) } if (verbose) print (" Done.") } inimglist = ""; delete (infile, verify-) outimglist = ""; delete (outfile, verify-) statlist = "" end iraf-xdimsum-main/src/obsolete/medmkmask.cl.old000066400000000000000000000070601455666516400221030ustar00rootroot00000000000000procedure mkmask(image) # Modified 9 June 2000 by L. Davis to use new version of iterstat. # Modified 26 July 1993 by MD to call sigmanorm. # Modified July 1993 by MD to use makemask.cl; various structural changes. # Modified 2/28/93 by MD to exclude zero exposure regions from computation # of pixel sigma. # Script mkmask creates the image mask used by slm. # 11 July 1992 by John S. Ward # Calls scripts makemask, sigmanorm, iterstat string image {prompt="Name of image for making mask"} real nthresh {prompt="Number of x suggested threshold"} int nsmooth {3,min=0,prompt="Size of filter for boxcar smoothing."} int subsample {1,min=1,prompt="Block averaging factor before median filtering"} int filtsize {15,min=1,prompt="Median filter size for local sky evaluation"} int ngrow {0,min=0,prompt="Width of rings to grow around masked objects"} bool interact {yes,prompt="Interactively examine normalized image?"} real threshold {prompt="Cutoff point for replacement",mode="q"} begin string img # equals image string ext # default extension real th # equals threshold real recthresh # recommended thresholding value real minval # minimum value in mask image real maxexp # peak exposure time real flagval # flag value # Get query parameter. img = image # Strip extension off file name. fileroot (img,validim+) img = fileroot.root ext = fileroot.defextn # Normalize image to uniform pixel-to-pixel rms using square root of exposure map. # Resulting frame is called norm//img sigmanorm (img,normimage="",prefix="norm") # Set flag value at 1 DN below minimum pixel value in normalized image. minmax("norm"//img,update-,ver-) minval = minmax.minval flagval = minval - 1. # Identify regions with zero exposure time and exclude from sigma calculation # by flagging them to the flagval and excluding them from the iterstat calculation. imcopy("exp"//img,"_zeroflag",ver-) imreplace("_zeroflag",-1.,lower=INDEF,upper=0.) imreplace("_zeroflag",0.,lower=0.,upper=INDEF) imreplace("_zeroflag",flagval,lower=-1.,upper=-1.) imarith("norm"//img,"+","_zeroflag","_norm"//img) # Calculate rms of masked, normalized image with iterative sigma rejection. # Recommended threshold (to be applied to boxcar smoothed data) is approx. # 4.5/nsmooth x unsmoothed rms. iterstat ("_norm" // img, statsec="", nsigrej=5.0, maxiter=10., lower=minval, upper=INDEF, verbose-, show-) recthresh = 4.5 / nsmooth * iterstat.isigma print ("Recommended thresholding level for mask is ",recthresh) # Allow user to interactively examine (unsmoothed) normalized image to set threshold # for masking. if (interact) imexamine("norm"//img,display="display(image='$1',frame=$2,zs+)") # If interactive, query for final threshold to adopt. # If not interactive, either use the value specified by the user on the command # line, or if that is set to zero, then use the default recommended threshold. if (interact) { threshold = recthresh th = threshold } else if (threshold != 0) { th = nthresh * threshold } else { th = recthresh } # Apply thresholding to image using makemask. makemask ("norm"//img,prefix="Mask_",headlist="",subsample=subsample, filtsize=filtsize,nsmooth=nsmooth,threshtype="constant",constthresh=th, ngrow=ngrow,statsec="",checklimits+,ver-) imrename ("Mask_norm"//img//".pl","Mask_"//img//".pl",ver-) # Display original image and mask if interact=yes. if (interact) { display(img,1) display("Mask_"//img//".pl",2,z1=0,z2=1,zsca-,zra-) } # Clean up. imdelete ("_norm"//img,ver-) imdelete ("norm"//img,ver-) imdelete ("_zeroflag",ver-) end iraf-xdimsum-main/src/obsolete/mkpkg.old000066400000000000000000000003201455666516400206360ustar00rootroot00000000000000# Make the DIMSUM package $call relink $exit update: $call relink $call install ; relink: $omake maskinterp.x $link maskinterp.o -o xx_dimsum.e ; install: $move xx_dimsum.e dimsumbin$x_dimsum.e ; iraf-xdimsum-main/src/obsolete/mosaic.cl.old000066400000000000000000000223331455666516400214050ustar00rootroot00000000000000procedure mosaic(imlist, outimage) # Replaced MKIMAGE with MKPATTERN -- 3/31/97 FV # # Modified February 1995 by SAS to handle optical images all with the # same exposure time so using just one exposure map image expccd # to save on disk space. Also does sky-subtraction. # Modified 18 Oct 1993 by MD to strip extensions off filenames in order to # allow for the possibility that .pl masks may be used for exposure maps. # For the time being, however, all newly created exposure maps have default # extension format and real data values. In fact, we force this by # specifying a default extension for those images. # # Also put in check for zero fraction shift (i.e. integer pixel offset only) # to speed this step up in certain cases. # Other minor changes made too. -- MD 10/18/93 # # Procedure to combine images outputs of different sets on the same object # -- uses exp maps # based on script shift.cl # Peter Eisenhardt # 16 May 1991 # Note shifts are input AS MEASURED, e.g. for two images, I and II with # the same object located at I[50,50] and II[53,57.2] the input list # would read: # # I 0. 0. # II 3. 7.2 # This is opposite of sense in shift.cl and shiftpix.cl # slightly modified oxdim, oydim calc 22 May # # Modified integer portion calculation 15 July 1991 to do correct rounding. # # 19 Oct 1992. Update to allow for loss of "sum" option in combine # Replace either with imsum or imarith accumulator # # Requires dimsum tasks fileroot.cl, iterstat.cl, and addcomment.cl # # Uses imgets, mkpattern, imarith, imrename, imdelete, imshift, imcopy, hfix, # hselect, hedit, and delete. string imlist {prompt="List of images and pixel shifts"} string outimage {prompt = "Output combined image name"} string statsec {"", prompt="Image section for sky subtraction statistics"} real nsigrej {3.0, prompt="The n-sigma rejection limit for sky subtraction"} int maxiter {20, prompt="The max number of sky subtraction iterations"} struct *imglist begin real newx,newy # fscan'ed values for x and y shift real xfrac,yfrac # fractional (subpixel) x and y shifts real xmin,xmax,ymin,ymax # extreme values for x and y shifts int ixmin,ixmax,iymin,iymax # Integer values of extreme shifts int ix,iy # Start and finish column,row int fx,fy # for integer shift using copy int ixdim,iydim # x and y dimensions of input images int oxdim,oydim # x and y dimensions of output image string img,oimg # input and output image names string ext # default extension string rewind # used to rewind imglist string sect # image section used for integer shift string headfile struct theadline xmin=9E+32 # initial values -- set large so that ymin=9E+32 # they will get reset xmax=-2E+9 ymax=-2E+9 # Get the query parameters rewind=imlist oimg=outimage # Strip extension off output image name if present. fileroot (oimg,validim+) oimg = fileroot.root ext = fileroot.defextn # Load necessary packages # images # need imgets # imdebug # need mkimage # Find minimum x and y shift values and maximum (shift + dimension) values # to determine output image size imglist=rewind # rewind imglist while (fscan (imglist,img,newx,newy) != EOF) { imgets(img,"i_naxis1") ixdim = int(imgets.value) imgets(img,"i_naxis2") iydim = int(imgets.value) # Correct for sign reversal between the measured difference II - I # and the required shift to superimpose II on I newx=-1.*newx newy=-1.*newy if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } if ((newx + ixdim) > xmax) { xmax = newx + ixdim } if ((newy + iydim) > ymax) { ymax = newy + iydim } print("xmax=",xmax,"xmin=",xmin,"ymax=",ymax,"ymin=",ymin) } ixmax=0 iymax=0 ixmin=0 iymin=0 if (xmax != 0.) ixmax=int(xmax+0.5*(xmax/abs(xmax))) if (xmin != 0.) ixmin=int(xmin+0.5*(xmin/abs(xmin))) if (ymax != 0.) iymax=int(ymax+0.5*(ymax/abs(ymax))) if (ymin != 0.) iymin=int(ymin+0.5*(ymin/abs(ymin))) print("ixmax=",ixmax,"ixmin=",ixmin,"iymax=",iymax,"iymin=",iymin) # Set dimensions for output image based on input image dimensions and the # extreme values Ensure that the output image is actually big enough by # adding small amount (0.001) to avoid subtraction errors. oxdim = int(0.501+xmax-xmin) oydim = int(0.501+ymax-ymin) # Create output images here 19 Oct 1992 #mkimage("exp"//oimg//ext,oxdim,oydim,"r",0.,"Exposure Map") #mkimage(oimg,oxdim,oydim,"r",0.,"shifted") mkpattern ("exp"//oimg//ext, pattern="constant", option="replace", v1=0., title="Exposure Map", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) mkpattern (oimg, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) print("Output image dimensions: ",oxdim,oydim) # Now do the shift imglist=rewind # rewind imglist while (fscan(imglist,img,newx,newy)!= EOF) { # Strip extension off image name. fileroot (img,validim+) img = fileroot.root # Sky-subtract then scale the image up by its exposure time image iterstat (img, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show=no, verbose=no) imarith(img,"-",iterstat.imode,"_sub"//img) imarith("_sub"//img,"*","expccd","_T"//img) # Calculate integer shifts imgets(img,"i_naxis1") ixdim = int(imgets.value) imgets(img,"i_naxis2") iydim = int(imgets.value) newx=-1.*newx newy=-1.*newy ix=0 if (newx != 0.) ix=int(newx+0.5*(newx/abs(newx))) xfrac=newx-ix ix = 1 + ix - ixmin fx = ix + ixdim - 1 print("ix=",ix,"fx=",fx) # For zero shift of 50 x 100,imcopy shift big[1:50,1:100] iy=0 if (newy != 0.) iy=int(newy+0.5*(newy/abs(newy))) yfrac=newy-iy iy = 1 + iy - iymin fy = iy + iydim - 1 # Construct the image section string sect = "["//ix//":"//fx//","//iy//":"//fy//"]" print("Section = ",sect) # Make big empty image #mkimage("bigshift"//img,oxdim,oydim,"r",0.,"shifted") mkpattern ("bigshift"//img, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Do fractional pixel shifts if (xfrac == 0.0 && yfrac == 0.0) { print("Fractional shift is zero for ", img) imrename ("_T"//img,"shift"//img,ver-) } else { imshift("_T"//img,"shift"//img,xsh=xfrac,ysh=yfrac, shifts_file="",interp="spline3",bound="constant",const=0.) imdel("_T"//img,verify=no) print("Fractional shift done for ", img) } # and copy into the big image imcopy("shift"//img,"bigshift"//img//sect) imdel("shift"//img,verify=no) # Accumulator image inserted here 19 Oct 1992 imarith("bigshift"//img,"+",oimg,oimg,pixt="real",calc="real") imdel("bigshift"//img,ver-) print("integer shift done for "//img) # Now make the image to scale for position dependent exposure time #mkimage("bigscale"//img,oxdim,oydim,"r",0.,"scaling") mkpattern ("bigscale"//img, pattern="constant", option="replace", v1=0., title="scaling", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Do fractional shift for exposure image if (xfrac == 0.0 && yfrac == 0.0) { imcopy ("expccd","bigscale"//img//sect,ver-) } else { imshift("expccd","_Texpccd"//ext,xsh=xfrac,ysh=yfrac, shifts_file="",interp="linear",bound="constant",const=0.) imcopy("_Texpccd"//ext,"bigscale"//img//sect) imdel("_Texpccd",verify=no) imdel("_sub"//img,verify=no) } # Accumulator image inserted here 19 Oct 1992 imarith("bigscale"//img,"+","exp"//oimg,"exp"//oimg,pixt="real", calc="real") imdel("bigscale"//img,ver-) print("scale image done for "//img) } # Now combine the big images and divide by the scale imarith(oimg,"/","exp"//oimg,oimg,divzero=0.) # Copy header information from 1st input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. print ("Updating header information.") imglist=rewind # rewind imglist if (fscan (imglist,img, newx, newy) != EOF) { fileroot (img,validim+) img = fileroot.root headfile = mktemp("_header") hfix (img,command="copy $fname "//headfile) hfix (oimg,command="delete $fname ve- ; copy "//headfile//" $fname") hselect (img,"title",yes) | scan(theadline) hedit (oimg,field="exptime",value="1",add+,ver-,show+,update+) hedit (oimg,field="title",value=theadline,ver-,show+,update+) hedit (oimg,fields="OBJMASK,CRMASK,BPM,HOLES,SKYMED",delete+, ver-,show+,update+) delete (headfile,ve-) headfile = mktemp("_header") hfix ("expccd",command="copy $fname "//headfile) hfix ("exp"//oimg, command="delete $fname ve- ; copy "//headfile//" $fname") hselect ("expccd","title",yes) | scan(theadline) hedit ("exp"//oimg,field="title",value=theadline,ver-,show+,update+) time | scan (theadline) addcomment ("exp"//oimg,"dimsum.shiftset: "//theadline,ver-) addcomment (oimg,"dimsum.shiftset: "//theadline,ver-) addcomment (oimg, "dimsum.shiftset: Header data copied from file "//img,ver-) delete (headfile,ve-) } imglist = "" end iraf-xdimsum-main/src/obsolete/mtv.cl.old000066400000000000000000000004361455666516400207400ustar00rootroot00000000000000procedure mtv(image, frame) # Display a mask image with display range forced to # z1=0, z2=1. A convenience... string image {prompt="Mask image to be displayed"} int frame {min=1,max=4,prompt="Frame buffer for image display"} begin display (image,frame,zsc-,zra-,z1=0,z2=1) end iraf-xdimsum-main/src/obsolete/photcheck.cl.old000066400000000000000000000212211455666516400220750ustar00rootroot00000000000000procedure photcheck(image,starcoords,output) # Procedure for monitoring photometric stability of a data set. # The user first identifies several suitable objects in the mosaic # image produced by shiftfix or magshiftfix, and records their X and Y # coordinates in a file. It is recommended that these objects mostly be # located on a portion of the mosaic with nearly maximum exposure time, # so that they will appear in most or all of the individual input frames. # This script then takes that input position list, transforms it back to # the coordinate systems of the individual, sky subtracted images which # were summed to make the mosaic, and uses digiphot.apphot.phot to # compute accurate positions and measure magnitudes for the reference # objects in each sky subtracted input frame. If the user sets badcheck=yes, # then the bad pixel mask, plus cosmic ray and "holes" masks, if present, are # used to set all bad pixels in each frame to a flag value recognized by phot. # If any bad pixels are within the photometric aperture, phot will # return an INDEF value for the magnitude. Finally, the output files from # phot are compiled into a convenient format by use of an awk script. # # This routine requires the script minv.cl, and also that awk be defined # in the user package as a foreign task, i.e. task $awk = $foreign. # # 2-3 Aug 1993 by Mark Dickinson string image {prompt="Maskpass mosaic image"} string starcoords {prompt="File containing reference star coordinates"} string output {prompt="File for formatted output photometry"} bool badcheck {yes, prompt="Check for bad pixels and return INDEF values?"} string badpix {prompt="Bad pixel mask"} real angle {0., prompt="angle in deg. from y to N dir N thru E"} bool rotation {yes, prompt="Is N thru E counterclockwise?"} real secpexp {prompt="Seconds per unit exposure time"} bool verbose {yes, prompt="Verbose output?"} struct *imglist struct *starlist begin string mimg,starc,outp # Equal query parameters int ixdim,iydim,oxdim,oydim # Dimensions of original and mosaiced images int ix, iy # Coordinate offsets of input images string img # Fscanned name of image bool flipx,flipy,trans # Orientation switches string starfile # File for reoriented star coordinates string starshift # File for translated star coordinates string workimage # Copy of image for use with phot. real xstar, ystar # Star coordinates real temp # swap variable string photlist # temporary dump file string dimsumdir # pathname of DIMSUM source code directory string crmask, holesmask, ext real flagval # large flag value -- set to 1.e10 flagval = 1.e10 # Check to make sure digiphot.apphot is loaded. if (!defpac("apphot")) { print ("Please load package digiphot.apphot and set parameters for") print (" the task 'phot' before using this routine.") return } else { print ("") print ("Be sure to edit parameter sets for task 'phot' before using this routine.") print ("") } # Get query parameters. mimg = image starc = starcoords outp = output # Check for presence of the photcheck.format.awk script in the DIMSUM source # code directory. If that file is not present, return error message. dimsumdir = osfn("dimsumsrc$") if (!access(dimsumdir//"photcheck.format.awk")) { print ("ERROR: Cannot access ",dimsumdir//"photcheck.format.awk") return } # Get dimensions of mosaic image. imgets(mimg,"i_naxis1") oxdim=int(imgets.value) imgets(mimg,"i_naxis2") oydim=int(imgets.value) # Get dimensions of first input image. It is assumed that all the # input images have the same dimension -- no checking is done for this. imglist=mimg//"._shifts" if (fscan(imglist,img) != EOF) { imgets(img,"i_naxis1") ixdim=int(imgets.value) imgets(img,"i_naxis2") iydim=int(imgets.value) } else { error (0,"ERROR: problem reading shift list.") } # Set angle to a value from -45 to 315 degrees while (angle < -45.) {angle+=360.} while (angle >= 315.) {angle-=360.} # Determine transformation of mosaic image back to original coordinate system. if (angle < 45) { if (rotation) { flipx = no ; flipy = no ; trans = no } else { flipx = yes ; flipy = no ; trans = no } } else if (angle < 135) { if (rotation) { flipx = no ; flipy = yes ; trans = yes } else { flipx = no ; flipy = no ; trans = yes } } else if (angle < 225) { if (rotation) { flipx = yes ; flipy = yes ; trans = no } else { flipx = no ; flipy = yes ; trans = no } } else if (angle < 315) { if (rotation) { flipx = yes ; flipy = no ; trans = yes } else { flipx = yes ; flipy = yes ; trans = yes } } # Read star coordinates and transform to original image orientation. starfile = mktemp("tmp$photcheck") starlist = starc while (fscan(starlist,xstar,ystar) != EOF) { if (flipx) xstar = oxdim - xstar + 1 if (flipy) ystar = oydim - ystar + 1 if (trans) { temp = xstar xstar = ystar ystar = temp } print (xstar, ystar, >> starfile) } starlist = "" # If bad pixel checking is turned on, delete temporary files if present. fileroot ("") ext = fileroot.defextn if (badcheck) { if (access("_tempcrmask.pl")) imdelete ("_tempcrmask.pl",ver-) if (access("_badpix"//ext)) imdelete ("_badpix"//ext,ver-) # Parameter datapars.datamin is set to trigger 'INDEF' results for any object which # has a bad pixel within the aperture. If badcheck=no, then leave datamin = INDEF. datapars.datamin = -0.95 * flagval } else { datapars.datamin = INDEF } # Rewind image list and create temporary file for recording phot output filenames. imglist=mimg//"._shifts" photlist = mktemp ("tmp$photcheck") # First, do photometry on stars in the mosaic image to act as reference values. # Here we retain the original coordinate scheme, and set the exposure time to # one second (which it should be after dimsum reduction). if (verbose) print ("Measuring reference magnitudes from ",mimg) datapars.itime = 1. phot (mimg,skyfile="",centerpars="",fitskypars="",coords=starc, output=mimg//".mag.X",inter-,verify-,verbose-) # Record photometry output file name in temporary file photlist. print (mimg//".mag.X", >photlist) # Reset datapars.itime to the individual exposure times of the sky subtracted # frames for proper magnitude normalization. datapars.itime = secpexp # Next, loop through the individual images. while (fscan(imglist,img,ix,iy) != EOF) { if (verbose) print ("Working on image ",img) # Combine bad pixel mask with cosmic ray mask and "holes" mask, if present. # We rename the new mask to _badpix, giving it datatype real to accept # the large flag values used later. if (badcheck) { imcopy (badpix,"_badpix"//ext,ver-) imgets (img,"CRMASK") if (imgets.value != "0") { crmask = imgets.value if (access(crmask)) { if (verbose) print (" Using CRMASK file ",crmask) minv (crmask,"_tempcrmask.pl") imarith ("_badpix"//ext,"*","_tempcrmask.pl","_badpix"//ext,ver-) imdelete ("_tempcrmask.pl",ver-) } } imgets (img,"HOLES") if (imgets.value != "0") { holesmask = imgets.value if (access(holesmask)) { if (verbose) print (" Using HOLES file ",holesmask) imarith ("_badpix"//ext,"*",holesmask,"_badpix"//ext,ver-) } } # Copy image and set bad pixels to a large, negative flag value. imcopy (img,"_"//img,ver-) imarith ("_"//img,"*","_badpix"//ext,"_"//img,ver-) minv ("_badpix"//ext,"_badpix"//ext) imarith ("_badpix"//ext,"*",flagval,"_badpix"//ext,ver-) imarith ("_"//img,"-","_badpix"//ext,"_"//img,ver-) workimage = "_"//img } else { workimage = img } # Apply translation to star coordinate file. starshift = mktemp("tmp$photcheck") lintran (starfile,xf=1,yf=2,x1=ix,y1=iy,x2=0.,y2=0., xsc=1.,ysc=1.,angle=0,min_sig=4,>>starshift) # Do photometry on star list. Output goes to file named workimage//.mag.X phot (workimage,skyfile="",centerpars="",fitskypars="",coords=starshift, output=workimage//".mag.X",inter-,verify-,verbose-) # Record photometry output file name in temporary file photlist. print (workimage//".mag.X",>>photlist) # Clean up. delete (starshift,ver-) if (badcheck) { imdelete ("_badpix"//ext,ver-) imdelete ("_"//img,ver-) } } # Dump photometric records to output photometry file and format using awk script. txdump ("@"//photlist,"image,otime,mag,merr","yes",headers-) | awk ("-f",dimsumdir//"photcheck.format.awk",> outp) if (verbose) { print ("") print ("Output data written to file ",outp) print ("Use this as input to task photdiff to compute") print ("and plot photometric offsets between frames.") print ("") } # Clean up. delete ("@"//photlist,ver-) delete (photlist,ver-) delete (starfile,ver-) imglist = "" end iraf-xdimsum-main/src/obsolete/photcheck.diff.awk000066400000000000000000000041571455666516400224240ustar00rootroot00000000000000# An awk script used by IRAF/DIMSUM routine photdiff to look for photometric # variations from frame to frame over an observing sequence. This routine uses # the formatted output from DIMSUM routine photcheck + awk script photcheck.format.awk # as its input. The first line of that input file is considered to be the photometry # for the "reference frame." Magnitudes of stars in each subsequent line are compared # to it, and the average and rms of the magnitude differences is output along with # the individual stellar magnitude differences. Magnitude records that are INDEF # are ignored in this computation. # # 3 August 1993, Mark Dickinson # { # # Record magnitudes from first line as reference values. # if (NR==1) { ii=0 nn=0 for (i=3;i<=NF;i+=2) { ii+=1 if ($i == "INDEF") { m[ii] = -99.99 v[ii] = -99.99 } else { nn+=1 m[ii] = $i v[ii] = $(i+1)*$(i+1) } } printf ("%15s %7s %7s %6s %2g ",$1," UT ","delta m"," err ",nn) ii=0 for (i=3;i<=NF;i+=2) { ii+=1 if ($i == "INDEF") { printf (" %6s", " INDEF") } else { printf (" %6.3f", m[ii]) } } printf ("\n") # # For all other lines, calculate differences between the star magnitudes and # the reference values, print these out, and calculate the mean and rms of # those differences, then print those out at the end of the line. Stars with # magnitude values = INDEF are excluded from the mean and rms calculation. # } else { printf ("%15s %7.4f ",$1,$2) dsum = 0. wsum = 0. nn = 0 ii=0 for (i=3;i<=NF;i+=2) { ii+=1 if ($i != "INDEF" && m[ii] != -99.99) { d[ii] = m[ii] - $i vd[ii] = $(i+1)*$(i+1) + v[ii] dsum += d[ii]/vd[ii] wsum += 1./vd[ii] nn += 1 } else { d[ii] = -99.99 } } if (nn > 0) { dmean = dsum / wsum derr = sqrt(1./wsum) printf ("%7.3f %6.3f %2g ", dmean, derr, nn) } else { printf ("%7s %6s %2g "," INDEF"," INDEF", 0) } ii=0 for (i=3;i<=NF;i+=2) { ii+=1 if ($i != "INDEF" && m[ii] != -99.99) { printf (" %6.3f", d[ii]) } else { printf (" %6s"," INDEF") } } printf ("\n") } } iraf-xdimsum-main/src/obsolete/photcheck.format.awk000066400000000000000000000031701455666516400227760ustar00rootroot00000000000000# An awk script used by the IRAF/DIMSUM routine photcheck for formatting # output data files. The input data is taken from txdump, and consists # of a series of N lines for each apphot.phot photometry file, where # column 1 of each line has the name of the image from which the photometry # was measured, column 2 records the time of observation, column 3 contains # the magnitude measurement for the star, and column 4 contains the associated # error estimate in that magnitude. There will be a blank line between each # set of N input data lines, indicating a break before the next photometry file. # # Mark Dickinson, 3 Aug 1993. # Format slightly revised 16 Oct 1993. # # Set new file switch. # BEGIN {newfile = 1} # { # # If input line is blank, print carriage return and set newfile=1. # if ($0=="") { printf ("\n") newfile = 1 # # Otherwise, if new file, print image name in column 1, the obstime (converted to decimal) # in column 2, and set newfile=0. # } else { if (newfile) { uth = substr($2,1,2) utm = substr($2,4,2) uts = substr($2,7,2) ut = uth + utm/60. + uts/3600. printf ("%15s %7.4f ",$1,ut) newfile = 0 } # # If magnitude record = INDEF, print "INDEF" on end of current output record. # if ($3=="INDEF") { printf (" %6s"," INDEF") # # Otherwise, print magnitude on end of current output record. # } else { printf (" %6.3f",$3) } # # If error record = INDEF, print "INDEF" on end of current output record. # if ($4=="INDEF") { printf (" %5s","INDEF") # # Otherwise, print error on end of current output record. # } else { printf (" %5.3f",$4) } } } iraf-xdimsum-main/src/obsolete/photdiff.cl000066400000000000000000000063071455666516400211630ustar00rootroot00000000000000procedure photdiff (photfile,output) string photfile {prompt="Photometry data file from photcheck"} string output {prompt="Output file"} bool display {yes, prompt="Automatically display lightcurve (requires STSDAS)?"} struct *outdat begin string pfile,outp # equal query parameters string dimsumdir # directory containing DIMSUM scripts string igicommands string filename real ut, delta, err real xmin, xmax, ymin, ymax real xplotmin, xplotmax, yplotmin, yplotmax, ynumber # If display==yes, check to see if stsdas.graphics.stplot is loaded, # and if not, load it. if (display) { if (!defpac("stsdas")) stsdas if (!defpac("stplot")) stplot } # Get query parameters. pfile = photfile outp = output # Check for presence of the photcheck.diff.awk script in the DIMSUM source # code directory. If that file is not present, return error message. dimsumdir = osfn("dimsumsrc$") if (!access(dimsumdir//"photcheck.diff.awk")) { print ("ERROR: Cannot access ",dimsumdir//"photcheck.diff.awk") return } # Use awk script to calculate photometric scalings between frames. awk ("-f",dimsumdir//"photcheck.diff.awk",pfile,>outp) # If display==yes, call stsdas.graphics.stplot.igi to display light curve. if (display) { # First, scan data values to determine plot limits. # Skip first line. xmin = 1.E20 xmax = -1.E20 ymin = 1.E20 ymax = -1.E20 outdat = outp if (fscan(outdat,filename) == EOF) error (0,"No lines in file ",outdat) while (fscan(outdat,filename,ut,delta,err) != EOF) { xmin = min(xmin,ut) xmax = max(xmax,ut) ymin = min(ymin,delta-err) ymax = max(ymax,delta+err) } xplotmin = xmin - 0.1 * (xmax-xmin) xplotmax = xmax + 0.1 * (xmax-xmin) yplotmin = ymin - 0.2 * (ymax-ymin) yplotmax = ymax + 0.2 * (ymax-ymin) ynumber = ymax + 0.1 * (ymax-ymin) # Now open temporary file and create igi command macro. igicommands = mktemp("tmp$plotdiff") print ("limits ",xplotmin,xplotmax,yplotmin,yplotmax, >igicommands) print ("box", >>igicommands) print ("xlabel UT", >>igicommands) print ("ylabel \gDm", >>igicommands) print ("title Relative photometric scalings: ", outp, >>igicommands) print ("ltype 1", >>igicommands) print ("relocate ",xplotmin," 0.0 ", >>igicommands) print ("draw ",xplotmax," 0.0 ", >>igicommands) print ("ltype 0", >>igicommands) print ("data ",outp, >>igicommands) # print ("lines 1 1", >>igicommands) # print ("xcolumn 2", >>igicommands) # print ("ycolumn 3", >>igicommands) # print ("ptype 10 3", >>igicommands) # print ("points", >>igicommands) print ("lines 2 10000 ", >>igicommands) print ("xcolumn 2", >>igicommands) print ("ycolumn 3", >>igicommands) print ("ecol 4", >>igicommands) print ("ptype 4 0", >>igicommands) print ("points", >>igicommands) print ("error 2", >>igicommands) print ("error 4", >>igicommands) print ("yevaluate ",ynumber, >>igicommands) print ("angle 90", >>igicommands) print ("expand 0.5", >>igicommands) print ("number", >>igicommands) # Execute igi with command macro, exit, then bring up graphics cursor to # allow user to snapshot if desired. igi (initcmd="input "//igicommands//" ; end", >"dev$null") =gcur } # Clean up. delete (igicommands,ver-) outdat = "" end iraf-xdimsum-main/src/obsolete/reduce.cl000066400000000000000000000570711455666516400206330ustar00rootroot00000000000000 # Combine the input images into a single mosaic after sky subtraction, bad pixel # corrections, and cosmic ray cleaning. Object masks are not used in the first # pass but are created from the combined image produced in the first pass step # and used in the mask pass to create better sky images and do unzap cosmic # rays that are part of object regions. The output is a list of sky subtracted, # bad pixel cleaned, and cosmic ray cleaned images, a list of cosmic ray masks, # a list of holes masks defining blank regions in the sky images, and the final # combined image and associated exposure map image. A file describing the # position of the input images in the output image is also produced. # The combined image object masks and the individual object masks are also # saved. procedure reduce (inlist, reference, sslist, crmasks, hmasks, output, expmap, sections) # Xmosaic calls the xdimsum tasks mkmask, maskdereg, xslm, maskfix, xzap, # xnzap, badpixupdate, xdshifts, xnregistar, and fileroot. # # Xmosaic also calls the IRAF tasks sections, imdelete and delete as well # as the CL builtins mktemp and time. string inlist {prompt="The list of input images"} string reference {prompt="The reference image in input image list"} string sslist {".sub",prompt="The output sky-subtracted images or suffix"} string crmasks {".crm",prompt="The output cosmic ray masks or suffix"} string hmasks {".hom",prompt="The output holes masks or suffix"} string output {prompt="Root name for output combined images"} string expmap {".exp",prompt="Root name for output exposure map image or suffix"} string sections {".corners",prompt="The for output sections list file or suffix"} string omask {".msk",prompt="The output first pass combined image mask or suffix"} string ocrmasks {".ocm",prompt="The output cosmic ray unzapping masks or suffix"} string objmasks {".obm",prompt="The output object masks or suffix"} bool fp_xslm {yes,prompt="Do firstpass xslm ?"} bool fp_maskfix {yes,prompt="Do firstpass maskfix ?"} bool fp_xzap {yes,prompt="Do firstpass xzap ?"} bool fp_badpixupdate {yes,prompt="Do firstpass bad pixel file update ?"} bool fp_mkshifts {no,prompt="Determine shifts interactively ?"} bool fp_chkshifts {no,prompt="Check new shifts interactively ?"} string shiftlist {"",prompt="Input shifts file if fp_mkshifts is off"} real fp_cradius {5.0,prompt="Centroiding radius in pixels for mkshifts"} real fp_maxshift {5.0,prompt="Maximum centroiding shift in pixels for mkshifts"} bool fp_xnregistar {yes,prompt="Do firstpass xnregistar ?"} bool mp_mkmask {yes,prompt="Make masks ?"} bool mp_chkmasks {no,prompt="Check masks ?"} bool mp_kpchking {yes,prompt="Keep checking masks ?",mode="q"} string mp_statsec {"",prompt="The combined image section for computing mask stats"} real mp_nsigcrmsk {1.5,prompt="factor x suggested threshold for cr masking"} real mp_nsigobjmsk {1.1,prompt="factor x suggested threshold for object masking"} bool mp_maskdereg {yes,prompt="Deregister masks ?"} int mp_nprev_omask {0, prompt="Number of previous object masks to combine"} bool mp_xslm {yes,prompt="Do maskpass xslm ?"} bool mp_useomask {yes,prompt="Use object mask to compute sky statistics in maskpass ?"} bool mp_maskfix {yes,prompt="Do maskpass fixpix ?"} bool mp_xzap {yes,prompt="Do maskpass xzap ?"} bool mp_badpixupdate {yes,prompt="Do maskpass bad pixel file update ?"} bool mp_xnregistar {yes,prompt="Do maskpass xnregistar ?"} int mp_mag {4,min=1,prompt="Mag factor for maskpass image"} string statsec {"",prompt="The image section for computing sky stats"} real nsigrej {3.0,prompt="The nsigma rejection for computing sky stats"} int maxiter {20, prompt="The maximum number of iterations for sky stats"} bool forcescale {yes,prompt="Force recalculation of image medians in sky scaling ?"} int nmean {6,min=1,prompt="Number of images to use in sky frame"} int nreject {1,min=0,prompt="Number of pixels for xslm minmax reject"} int nskymin {3,min=0,prompt="Minimum number of frames to use for sky"} bool forcefix {yes,prompt="Force bad pixel fixing ?"} string bpmask {"",prompt="Bad pixel mask image"} bool newxzap {yes,prompt="Use new version of xzap ?"} bool fractional {no,prompt="Use fractional pixel shifts if mag = 1 ?"} bool pixin {yes,prompt="Are input coords in ref object pixels ?"} bool ab_sense {yes,prompt="Is A through B counterclockwise ?"} real xscale {1.,prompt="X pixels per A coordinate unit"} real yscale {1.,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.,prompt="Angle in degrees from A CCW to X"} int ncoavg {1,min=1,prompt="Number of internal coaverages per frame"} real secpexp {1.0,prompt="Seconds per unit exposure time"} real y2n_angle {0.,prompt="Angle in degrees from Y to N N through E"} bool rotation {yes,prompt="Is N through E counterclockwise?"} bool del_bigmasks {no,prompt="Delete combined image masks at task termination ?"} bool del_smallmasks {no,prompt="Delete the individual object masks at task termination ?"} struct *imglist struct *shlist begin int nin, nref, ifile string itlist, stlist, ctlist, htlist, ssmtlist, ocrtlist, objtlist string ushiftlist, toutput1, toutput2 string trefim, toutput, tsslist, tcrmasks, ext, texpmap1, texpmap2 string tsections, texpmap, thmasks, tomask, tocrmasks, tobjmasks string msk, imsk, img, j1, j2, j3, j4 print ("start") time ("") itlist = mktemp ("tmp$reduce") stlist = mktemp ("tmp$reduce") ctlist = mktemp ("tmp$reduce") htlist = mktemp ("tmp$reduce") ssmtlist = mktemp ("tmp$reduce") ocrtlist = mktemp ("tmp$reduce") objtlist = mktemp ("tmp$reduce") ushiftlist = mktemp ("tmp$reduce") # Expand the list of input images and get query parameters. sections (inlist, option="fullname", > itlist) nin = sections.nimages trefim = reference tsslist = sslist tcrmasks = crmasks thmasks = hmasks # Get the output image, output exposure map, and output sections file names. toutput = output fileroot (toutput, validim+) toutput = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext toutput1 = toutput // "_fp" // ext toutput2 = toutput // "_mp" // ext texpmap = expmap if (substr (texpmap, 1, 1) == ".") { texpmap1 = toutput // "_fp" // texpmap // ext texpmap2 = toutput // "_mp" // texpmap // ext } else { fileroot (texpmap, validim+) ext = fileroot.extension if (ext != "") ext = "." // ext texpmap1 = fileroot.root // "_fp" // ext texpmap2 = fileroot.root // "_mp" // ext } tsections = sections if (substr (tsections, 1, 1) == ".") { tsections = toutput // tsections } tomask = omask tocrmasks = ocrmasks tobjmasks = objmasks # Create list of filenames for sky subtracted output files and determine the # name of the reference image in the output sky subtracted image list. if (substr (tsslist, 1, 1) == ".") { if (trefim != "") { fileroot (trefim, validim+) trefim = fileroot.root // tsslist } imglist = itlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tsslist print (img, >> stlist) } } else { sections (tsslist, option="fullname", > stlist) if (nin != sections.nimages) { print ("Error: Input and sky subtracted image lists do not match") delete (itlist, ver-) delete (stlist, ver-) return } if (trefim != "") { fileroot (trefim, validim+) trefim = fileroot.root ifile = 0 imglist = itlist while (fscan (imglist, img) != EOF) { ifile += 1 fileroot (img, validim+) img = fileroot.root if (img == trefim) break } nref = ifile if (nref == 0) { trefim = "" } else { ifile = 0 imglist = stlist while (fscan (imglist, img) != EOF) { ifile += 1 if (ifile != nref) next fileroot (img, validim+) trefim = fileroot.root break } } } } # Create temporary list of filenames for the cosmic ray masks. if (substr (tcrmasks, 1, 1) == ".") { imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tcrmasks // ".pl" print (img, >> ctlist) } } else { sections (tcrmasks, option="fullname", > ctlist) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } } # Create the holes mask list. if (substr (thmasks, 1, 1) == ".") { imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // thmasks // ".pl" print (img, >> htlist) img = fileroot.root // ".ssm.pl" print (img, >> ssmtlist) } } else { sections (thmasks, option="fullname", > htlist) if (fileno != sections.nimages) { print ("Error: Input and holes image lists do not match") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) delete (htlist, ver-) delete (ssmtlist, ver-) return } imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // ".ssm.pl" print (img, >> ssmtlist) } } # Get the combined image mask name. The output mask directory will default to # the combined image directory. Get the individual object and cosmic ray # unzapping masks. The output individual mask directory defaults to the sky # subtracted image directory. if (substr (tomask, 1, 1) == ".") { #fileroot (outim, validim+) msk = toutput // tomask // ".pl" imsk = toutput // tomask // "i" // ".pl" } else { fileroot (tomask, validim+) msk = fileroot.root // ".pl" imsk = fileroot.root // "i" // ".pl" } if (substr (tocrmasks, 1, 1) == ".") { imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tocrmasks // ".pl" print (img, >> ocrtlist) } } else { sections (tocrmasks, option="fullname", > ocrtlist) if (fileno != sections.nimages) { print ("Error: Input image and cosmic ray unzapping mask lists do not match") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) delete (ssmtlist, ver-) delete (htlist, ver-) delete (ocrtlist, ver-) return } } if (substr (tobjmasks, 1, 1) == ".") { imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tobjmasks // ".pl" print (img, >> objtlist) } } else { sections (tobjmasks, option="fullname", > objtlist) if (fileno != sections.nimages) { print ("Error: Input image and object mask lists do not match") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) delete (ssmtlist, ver-) delete (htlist, ver-) delete (ocrtlist, ver-) delete (objtlist, ver-) return } } # Call xslm, fixpix, and xzap to produce firstpass sky-subtracted frames if (fp_xslm) { print ("begin first pass xslm") time ("") print ("-------Sky Subtracting------------------------------------") xslm ("@" // itlist, "", nmean, "@" // stlist, ssmasks=".ssm", hmasks=".hom", statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, forcescale=forcescale, useomask=no, del_ssmasks=yes, del_hmasks=no) print ("") } if (fp_maskfix) { print ("begin first pass maskfix") time ("") print ("-------Fixing bad pixels----------------------------------") if (bpmask == "") { print (" The Bad pixel mask is undefined") delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) return } maskfix ("@" // stlist, bpmask, 0, forcefix=forcefix) print ("") } if (fp_xzap) { print ("begin first pass xzap") time ("") if (newxzap) { print("--------Zapping cosmic rays with xnzap----------------") xnzap ("@" // stlist, "", "@" // stlist, "@" // ctlist, zboxsz=5, skyfiltsize=15, sigfiltsize=25, nsigzap=5.0, nsigneg=0.0, nrejzap=1, nrings=0, nsigobj=5.0, ngrowobj=0, del_crmask=no, verbose=no) } else { print("--------Zapping cosmic rays with xzap-----------------") xzap ("@" // stlist, "", "@" // stlist, "@" // ctlist, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, checklimits+, zboxsz=5, zmin=-32768.0, zmax=32767.0, nsigzap=5, nsigobj=2.0, subsample=2, skyfiltsize=15, ngrowobj=0, nrings=0, nsigneg=0.0, del_crmask=no, del_wmasks=yes, del_wimages=yes, verbose=no) } print ("") if (fp_badpixupdate) { print ("badpix update") time ("") print ("-------Updating bad pixel file with badpixupdate-----") badpixupdate ("@" // ctlist, 3, bpmask) print("") } } # Now make the shifts list if (fp_mkshifts) { print("-------Making the shiftlist--------------------------------") print(" ") if (access (shiftlist)) { print (" The shifts file ", shiftlist, " already exists") delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) return } else { xdshifts ("@" // stlist, trefim, shiftlist, fp_cradius, datamin=INDEF, datamax=INDEF, background=INDEF, niterate=3, maxshift=fp_maxshift, chkshifts=fp_chkshifts) print ("") copy (shiftlist, ushiftlist, verbose-) } } else if (! access (shiftlist)) { print (" The shifts file ", shiftlist, " is undefined") delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) return } else { print ("------- Checking the shiftlist---------------------------") imglist = stlist shlist = shiftlist while (fscan (imglist, img) != EOF && fscan (shlist, j1, j2, j3, j4) != EOF) { print (img, " ", j2, " ", j3, " ", j4, >> ushiftlist) } } if (fp_xnregistar) { print ("begin first pass xregistar") time ("") print("-------Shifting and coadding images -----------------------") xnregistar (ushiftlist, bpmask, "", "", toutput1, texpmap1, tsections, sinlist="@" // itlist, mag=1, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation) print ("") } # On to the maskpass if (mp_mkmask) { print ("begin mask pass mkmask") time ("") print("-------Making masks for unzapping object cores-------------") if (imaccess (msk)) imdelete (msk, ver-) mkmask (toutput1, texpmap1, msk, mp_nsigcrmsk, statsec=mp_statsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=mp_chkmasks) if (mp_chkmasks) { mp_kpchking = yes while (mp_kpchking) { if (imaccess (msk)) imdelete (msk, ver-) mkmask (toutput1, texpmap1, msk, mp_nsigcrmsk, statsec=mp_statsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=mp_chkmasks) } } print ("") # Invert the mask for unzapping print ("-------Inverting mask for unzapping ----------------------") if (imaccess (imsk )) imdelete (imsk, ver-) minv (msk, imsk) print ("") } else if (! access (msk)) { print ("The mask required by maskdereg ", imsk, "does not exist") delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) delete (ocrtlist, verify=no) delete (objtlist, verify=no) if (access (ushiftlist)) delete (ushiftlist, verify-) return } else { print ("-------Using existing object mask ", imsk, "---------------") } # and deregister to make objmask for each frame. Note the cr+ in the maskdereg # call. This will unzap first pass crmasks even if mp_xzap is off. if (mp_maskdereg) { print ("begin mask pass maskdereg") time ("") print("------Deregistering unzap mask subsections ----------------") imdelete ("@" // ocrtlist, ver-, >& "dev$null") maskdereg (imsk, tsections, "@" // ocrtlist, y2n_angle=y2n_angle, rotation=rotation, update+, mkcrmask+, nprev_omask=0) print ("") } if (mp_mkmask) { print ("begin mask pass mkmask") time ("") print("-------Making masks for sky subtraction-------------------") if (imaccess (msk)) imdelete (msk, ver-) mkmask (toutput1, texpmap1, msk, mp_nsigobjmsk, statsec=mp_statsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=mp_chkmasks) if (mp_chkmasks) { mp_kpchking = yes while (mp_kpchking) { if (imaccess (msk)) imdelete (msk, ver-) mkmask (toutput1, texpmap1, msk, mp_nsigobjmsk, statsec=mp_statsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=mp_chkmasks) } } print ("") } else if (! access (msk)) { print ("The mask required by maskdereg ", msk, "does not exist") delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) delete (ocrtlist, verify=no) delete (objtlist, verify=no) if (access (ushiftlist)) delete (ushiftlist, verify-) return } else { print ("-------Using existing object mask ", msk, "---------------") } if (mp_maskdereg) { print ("begin mask pass maskdereg") time ("") print("-------Deregistering skysub mask subsections --------------") imdelete ("@" // objtlist, ver-, >& "dev$null") maskdereg (msk, tsections, "@" // objtlist, y2n_angle=y2n_angle, rotation=rotation, update+, mkcrmask-, nprev_omask=mp_nprev_omask) print("") } # Call xslm, fixpix, xzap, badpixupdate, and xregistar. if (mp_xslm) { print ("begin mask pass xslm") time ("") print("-------Sky subtracting images -----------------------------") imdelete ("@" // stlist, ver-, >& "dev$null") imdelete ("@" // ssmtlist, ver-, >& "dev$null") imdelete ("@" // htlist, ver-, >& "dev$null") #xslm ("@" // itlist, "OBJMASK", nmean, "@" // stlist, xslm ("@" // itlist, "@" // objtlist, nmean, "@" // stlist, ssmasks="@" // ssmtlist, hmasks="@" // htlist, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, forcescale=forcescale, useomask=mp_useomask, del_ssmasks=yes, del_hmasks=no) print("") } if (mp_maskfix) { print ("begin mask pass maskfix") time ("") print("-------Correcting bad pixels ------------------------------") if (bpmask == "") { delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) delete (ocrtlist, verify=no) delete (objtlist, verify=no) if (access (ushiftlist)) delete (ushiftlist, verify-) return } maskfix ("@" // stlist, bpmask, 0, forcefix=forcefix) print("") } # The mp xzap call has nobjsigma=0 and unzap=yes on the assumption that object # masking is better done using the ocrmmask files from the combined image mask. if (mp_xzap) { print ("begin mask pass xzap") time ("") if (newxzap) { print("-------Zapping cosmic rays with xnzap ----------------") #xnzap ("@" // stlist, "CROBJMAS", "@" // stlist, "@" // ctlist, xnzap ("@" // stlist, "@" // ocrtlist, "@" // stlist, "@" // ctlist, zboxsz=5, skyfiltsize=15, sigfiltsize=25, nsigzap=5.0, nsigneg=0.0, nrejzap=1, nrings=0, nsigobj=0.0, ngrowobj=0, del_crmask=no, verbose=no) } else { print("-------Zapping cosmic rays with xzap -----------------") #xzap ("@" // stlist, "CROBJMAS", "@" // stlist, "@" // ctlist, xzap ("@" // stlist, "@" // ocrtlist, "@" // stlist, "@" // ctlist, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, checklimits+, zboxsz=5, zmin=-32768.0, zmax=32767.0, nsigzap=5, nsigobj=0.0, subsample=2, skyfiltsize=15, ngrowobj=0, nrings=0, nsigneg=0.0, del_crmask=no, del_wmasks=yes, del_wimages=yes, verb=no) } print("") if (mp_badpixupdate) { print("-------Updating bad pixel file -----------------------") badpixupdate ("@" // ctlist, 3, bpmask) print("") } } else { print("-------Unaapping existing cosmic rays ----------------") imarith ("@" // ocrtlist, "*", "@" // ctlist, "@" // ctlist, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) } if (mp_xnregistar) { print ("begin mask pass xregister") time ("") print("------Magnifying and coadding images ---------------------") #xnregistar (ushiftlist, bpmask, "CRMASK", "HOLES", xnregistar (ushiftlist, bpmask, "@" // ctlist, "@" // htlist, toutput2, texpmap2, "", sinlist="", mag=mp_mag, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation) } # Cleanup. if (del_bigmasks) { if (imaccess (msk)) imdelete (msk, verify-, >& "dev$null") if (imaccess (imsk)) imdelete (imsk, verify-, >& "dev$null") } if (del_smallmasks) { imdelete ("@" // ocrtlist, verify-, >& "dev$null") imdelete ("@" // objlist, verify-, >& "dev$null") } delete (itlist, verify=no) delete (stlist, verify=no) delete (ctlist, verify=no) delete (htlist, verify=no) delete (ssmtlist, verify=no) delete (ocrtlist, verify=no) delete (objtlist, verify=no) if (access (ushiftlist)) delete (ushiftlist, verify=no) imglist = "" shlist = "" print ("finish") time ("") end iraf-xdimsum-main/src/obsolete/setup1.awk000066400000000000000000000000461455666516400207570ustar00rootroot00000000000000{print "imarith ",$1," * ",$2," ",$2} iraf-xdimsum-main/src/obsolete/setup2.awk000066400000000000000000000000311455666516400207520ustar00rootroot00000000000000'{print "s"$1,$2,$3,$4}' iraf-xdimsum-main/src/obsolete/shiftfix.cl.old000066400000000000000000000336401455666516400217610ustar00rootroot00000000000000procedure shiftfix(image_list, outimg, badpixfile) # Replaced MKIMAGE with MKPATTERN -- 3/31/97 FV # # WARNING !! Recent adjustment made to the use of the 'exp' column in # the shiftlist file -- shiftfix no longer multiplies the image by # that factor before adding it into the mosaic! It DOES multiply the # appropriate "_one" scaling image by that factor before adding it # into the exposure map, however. This is meant to be appropriate for # using the 'exp' column to adjust for non-photometric scalings or # differing relative exposure times. It no longer serves as a weighting # factor, however, unless exp=0, in which case shiftfix just skips # that image in the summation, as before. This may not be a desirable # change and must be considered further. In the meanwhile, be forewarned! # -- 10/17/93 MD # # Check for zero weight in Shiftlist file, and if so, skip that # image rather than going through all the trouble just to end # up multiplying by zero... 9/19/93 MD # 26 June 1993 -- rewritten to add shifted images into final summed # image one at a time, rather than with en masse call to imsum. # This follows previous change made to magshiftfix. -- MD # Modified calls to orientimg --> calls new routine orient. 7/22/93 MD # Added code to copy header information from first input file to # the final mosaic image, and to set other header parameters. 7/19/93 # Added parameter ncoavg to properly account for data take in # mode where multiple individual exposures are internally coaveraged # before readout. -- MD 7/15/93 # Changed handling of outimg string to deal with optional presence # of extension. -- MD 2/28/93 # Slight modification in definition of list directed parameter bpixfile # --- MD 2/28/93 # Added check for existence of output files and queried deletion if # they are there. Also deletes other working files (e.g. "one") at start. # --- MD 2/27/93 # Debugging problem where pixin+ doesn't work 7 Dec # Added spec shifts="" in imshift calls 19Oct 1992 in response # to bug noted by Brian McLeod. # minor param prompt mod 14 Sept 1992 # Procedure to combine images taken at different locations # into one big image, with no loss of spatial coverage or signal # Assumes all input images have same dimensions # Peter Eisenhardt 3 April 1989 # Modified 13 June 1989 to have scale and angle - unlike shiftpix, # this version takes coordinate offsets as input. # Further modified 21 Sept 1990 to allow masking of bad pixels specified # in file bpixfile (uses fixpix format) # Minor change 22 Oct/90 to add secpexp - seconds per exposure unit - # Output is then in units of flux per second. # Mofified 13 May 1991 to add parameter rotation which gives # sense of North thru E. Rotation is "true" if N thru E is CCW, # which means "sign" is negative (and vice versa). Rotation and # angle are use in task orient, which does the transformation to # put N near top and E near left. # more mods 15 July 1991 -- changing way integers vs. fractions are handled # so that always do "proper" integer shift # also doing auto weighting assuming bundle format name # and allowing different x and y scales # Yet more mods 22 July 1991 to support sublocalmask -- # now generates addtl output file outimg//"._shift" # Still even more additional mods 24 July -- separate dependence of # NE, from input coords AB # Don't need orientshiftlist call -- just want shifts in raw # input coords, but do need to deshift mask pixel coords from final output coords # Corrected formulat for newx, newy to match geopmap and handle different # x and y scale values correctly. # # 9 Dec 91 removed prefix character of img for record in oshifti # # Upgraded 8 July 92 to work with IRAF version 2.10 by John Ward string image_list {prompt="List of images, ashifts, bshifts, and weights"} string outimg {prompt="Output combined image name"} string badpixfile {prompt="Bad pixel file"} bool pixin {no, prompt="Are input coords measured pixels of ref object?"} real xscale {1., prompt="x pixels per ab coord unit"} real yscale {1., prompt="y pixels per ab coord unit"} real axangle {180., prompt="angle in degrees from a CCW to x"} bool absense {no, prompt="Is a thru b counterclockwise?"} real angle {0., prompt="angle in degrees from y to N dir N thru E"} bool rotation {yes, prompt="Is N thru E counterclockwise?"} string interp {"linear", enum="nearest|linear|poly3|poly5|spline3", prompt="Interpolation algorithm"} int nprefix {1, min=0, prompt="Number of letters in input image prefix"} real secpexp {60., prompt="Seconds per unit exposure time"} int ncoavg {1, min=1, prompt="Number of internal coaverages per frame"} struct *imglist begin real axrad # ax angle in radians real a,b # fscan'ed values for coords a and b of input frame real newx,newy # values for x and y shift real exp # fscan'ed relative exposure time real mexp real seconds # exposure time in seconds real xfrac,yfrac # fractional (subpixel) x and y shifts real xmin,xmax,ymin,ymax # extreme values for x and y shifts int ixmin,ixmax,iymin,iymax # Integer values of extreme shifts int ix,iy # Start and finish column,row int fx,fy # for integer shift using copy int ixdim,iydim # x and y dimensions of input images int oxdim,oydim # x and y dimensions of output image int sign # -1 if absense is CW, +1 if CCW int ilen # used to get string lengths int numsub # for removing prefixs in ._shift string strtemp # used to get number bundled real navg # number bundled string bpfile # equals bad pixel file string img,oimg # input and output image names string ext # default extension string shimg # shorter img name without 1st char. string rewind # used to rewind imglist string sect # image section used for integer shift string oshifti # list of images and pixel shifts used string headfile1, headfile2 # files for temporary storage of header struct theadline # temporary struct for header information xmin=9E+32 # initial values -- set large so that ymin=9E+32 # they will get reset xmax=-2E+9 ymax=-2E+9 # Load necessary packages # images # need imgets # imdebug # need mkimage # Get the query parameters. rewind = image_list oimg = outimg bpfile = badpixfile # Strip extension off output image name if present. fileroot (oimg,validim+) oimg = fileroot.root ext = fileroot.defextn axrad=axangle*3.1415926535/180. sign=-1 if (absense) sign=1 # If input coords are measured pixels of ref object, scale is 1, but # shifts are opposite sign of measured pixels. if(pixin) { xscale=-1. yscale=-1. # Adding set axangle = 0. and absense=yes if pixin+ axrad=0. sign=1 } oshifti=oimg//"._shift" numsub=nprefix + 1 # Check for existence of output files and query about deletion. if (access(oimg//ext)) { print ("Output image already exists.") imdelete (oimg,ve+) } if (access("exp"//oimg//ext)) { print ("Output image already exists.") imdelete ("exp"//oimg,ve+) } if (access("_one"//ext)) imdelete ("_one"//ext,ver-) if (access(oshifti)) { delete (oshifti,ver-) } # Find maximum and minimum x and y shift values imglist=rewind # rewind imglist while (fscan (imglist,img,a,b) != EOF) { newx=xscale*a*cos(axrad) + yscale*b*sign*sin(axrad) newy=yscale*b*sign*cos(axrad) - xscale*a*sin(axrad) if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } if (newx > xmax) { xmax = newx } if (newy > ymax) { ymax = newy } imarith (img,"*",bpfile,img,ver-) } ixmax=0 ixmin=0 iymax=0 iymin=0 if(xmax!=0.)ixmax=int(xmax+0.5*(xmax/abs(xmax))) if(ymax!=0.)iymax=int(ymax+0.5*(ymax/abs(ymax))) if(xmin!=0.)ixmin=int(xmin+0.5*(xmin/abs(xmin))) if(ymin!=0.)iymin=int(ymin+0.5*(ymin/abs(ymin))) # Set dimensions for output image based on input image dimensions # and the extreme values imgets(img,"i_naxis1") ixdim = int(imgets.value) oxdim = ixdim + ixmax - ixmin imgets(img,"i_naxis2") iydim = int(imgets.value) oydim = iydim + iymax - iymin # Make a flat image for scaling position dependent exposure time. Copy # header of first input image into this file. #mkimage("_one",ixdim,iydim,"r",1.,"Scaling image") mkpattern ("_one", pattern="constant", option="replace", v1=1., title="Scaling image", pixtype="r", ndim=2, ncols=ixdim, nlines=iydim) # Set bad pixels to zero in the flat image. imarith ("_one","*",bpfile,"_one",ver-) # Create output images here. #mkimage(oimg,oxdim,oydim,"r",0.,"shifted") #mkimage("exp"//oimg,oxdim,oydim,"r",0.,"Exposure map") mkpattern (oimg, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) mkpattern ("exp"//oimg, pattern="constant", option="replace", v1=0., title="Exposure map", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Now do the shift imglist=rewind # rewind imglist while (fscan (imglist,img,a,b,exp) != EOF) { print("Shifting image "//img) # Strip off extension if present. fileroot (img,validim+) img = fileroot.root # Calculate integer shifts newx=xscale*a*cos(axrad) + yscale*b*sign*sin(axrad) newy=yscale*b*sign*cos(axrad) - xscale*a*sin(axrad) ix=0 if(newx!=0.) ix=int(newx+0.5*(newx/abs(newx))) xfrac=newx-ix ix = 1 + ix - ixmin # For zero shift of 50 x 100, fx = ix + ixdim - 1 # imcopy shift big[1:50,1:100] iy=0 if(newy!=0.) iy=int(newy+0.5*(newy/abs(newy))) yfrac=newy-iy iy = 1 + iy - iymin fy = iy + iydim - 1 # Record shifts in oshifti shimg=substr(img,numsub,strlen(img)) print(shimg," ",ix,iy, >> oshifti) # Check to see if weight is exactly zero, and if so skip the rest of the loop # for this image. if (exp == 0.0) { print (" Image weight is zero in the sum. Moving on...") next } # Construct the image section string sect = "["//ix//":"//fx//","//iy//":"//fy//"]" # Do fractional pixel shifts imshift(img,"shift"//img,xsh=xfrac,ysh=yfrac, shifts="",int=interp,bo="constant",con=0.) # Make big empty image #mkimage("bigshift"//img,oxdim,oydim,"r",0.,"shifted") mkpattern ("bigshift"//img, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # The routine 'bundle.cl' averaged all size bundles to a single unit of # exposure time, regardless of how many units went into the bundle. # To weight the cumulative exposure properly, we need to multiply # each bundle by the number of units (navg) that went into it. # This will be read from the file name, since the suffix '-bN' was # attached for this purpose. Note that N (=navg) must be less than 10 # (i.e. a single digit) for the following to work. # # This should really be replaced with a call to the image header, and # bundle should record the number of frames bundled in that header keyword... ilen=strlen(img) if(substr(img,ilen-1,ilen-1)=="b") { strtemp=substr(img,ilen,ilen) navg=real(strtemp) exp=exp*navg } else { navg = 1 } # Multiply exposure by the number of internally coaveraged exposures per frame, # then multiply into shifted frame. exp = exp * ncoavg mexp = ncoavg * navg imarith("shift"//img,"*",mexp,"shift"//img,pixt="real", calc="real",ver-) # Do shift for exposure map too. Use linear interpolation unless interp="nearest". if (interp=="nearest") imshift("_one","scale"//img,xsh=xfrac,ysh=yfrac, shifts="",int="nearest",bo="constant",con=0.) else imshift("_one","scale"//img,xsh=xfrac,ysh=yfrac, shifts="",int="linear",bo="constant",con=0.) # and copy into the big image imcopy("shift"//img,"bigshift"//img//sect,ver-) imdel("shift"//img,verify=no) # and finally sum into output image. imarith("bigshift"//img,"+",oimg,oimg,pixt="real",calc="real") imdel("bigshift"//img,verify=no) # Now make the image to scale for position dependent exposure time #mkimage("bigscale"//img,oxdim,oydim,"r",0.,"scaling") mkpattern ("bigscale"//img, pattern="constant", option="replace", v1=0., title="scaling", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) seconds=secpexp*exp imarith("scale"//img,"*",seconds,"scale"//img,pixt="real", calc="real",ver-) imcopy("scale"//img,"bigscale"//img//sect,ver-) imdel("scale"//img,verify=no) imarith("bigscale"//img,"+","exp"//oimg,"exp"//oimg,pixt="real", calc="real",ver-) imdel("bigscale"//img,verify=no) } imdel("_one",verify=no) # Divide output image sum by exposure map. imarith(oimg,"/","exp"//oimg,oimg,divzero=0.,pixt="real", calc="real",ver-) # Orient these to N at top, E at left for iraf default orient(oimg,angle,rotation=rotation,invert-) orient("exp"//oimg,angle,rotation=rotation,invert-) # Copy header information from 1st input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. print ("Updating header information.") imglist=rewind # rewind imglist if (fscan (imglist,img,a,b) != EOF) { headfile1 = mktemp("_header") headfile2 = mktemp("_header") hfix (img,command="copy $fname "//headfile1) match ("dimsum.shiftfix",headfile1,stop+,print+,>headfile2) hfix (oimg,command="delete $fname ve- ; copy "//headfile2//" $fname") hselect (img,"title",yes) | scan(theadline) hedit (oimg,field="exptime",value="1",add+,ver-,show+,update+) hedit (oimg,field="title",value="Shiftfix mosaic sum: "//theadline, ver-,show+,update+) hedit (oimg,fields="BPM,HOLES,SKYMED",delete+,ver-,show+,update+) hedit ("exp"//oimg,field="title", value="Exposure time map: "//theadline,ver-,show+,update+) time | scan (theadline) addcomment ("exp"//oimg,"dimsum.shiftfix: "//theadline,ver-) addcomment (oimg,"dimsum.shiftfix: "//theadline,ver-) addcomment (oimg,"dimsum.shiftfix: Header data copied from file "//img,ver-) delete (headfile1,ve-) delete (headfile2,ve-) } imglist = "" end iraf-xdimsum-main/src/obsolete/shiftset.cl.old000066400000000000000000000203731455666516400217650ustar00rootroot00000000000000procedure shiftset(image_list, outimg) # Replaced MKIMAGE with MKPATTERN -- 3/31/97 FV # # Modified 18 Oct 1993 by MD to strip extensions off filenames in order to # allow for the possibility that .pl masks may be used for exposure maps. # For the time being, however, all newly created exposure maps have default # extension format and real data values. In fact, we force this by # specifying an extension for those images. # # Also put in check for zero fraction shift (i.e. integer pixel offset only) # to speed this step up in certain cases. # Other minor changes made too. -- MD 10/18/93 # # Procedure to combine images outputs of different sets on the same object # -- uses exp maps # based on script shift.cl # Peter Eisenhardt # 16 May 1991 # Note shifts are input AS MEASURED, e.g. for two images, I and II with # the same object located at I[50,50] and II[53,57.2] the input list # would read: # # I 0. 0. # II 3. 7.2 # This is opposite of sense in shift.cl and shiftpix.cl # slightly modified oxdim, oydim calc 22 May # Modified integer portion calculation 15 July 1991 to do # correct rounding # 19 Oct 1992 Update to allow for loss of "sum" option in combine # Replace either with imsum or imarith accumulator # # Requires fileroot.cl string image_list {prompt="List of images, xshifts, yshifts (in pixels)"} string outimg {prompt = "Output combined image name"} struct *imglist begin real newx,newy # fscan'ed values for x and y shift real xfrac,yfrac # fractional (subpixel) x and y shifts real xmin,xmax,ymin,ymax # extreme values for x and y shifts int ixmin,ixmax,iymin,iymax # Integer values of extreme shifts int ix,iy # Start and finish column,row int fx,fy # for integer shift using copy int ixdim,iydim # x and y dimensions of input images int oxdim,oydim # x and y dimensions of output image string img,oimg # input and output image names string ext # default extension string rewind # used to rewind imglist string sect # image section used for integer shift string headfile struct theadline xmin=9E+32 # initial values -- set large so that ymin=9E+32 # they will get reset xmax=-2E+9 ymax=-2E+9 # Get the query parameters rewind=image_list oimg=outimg # Strip extension off output image name if present. fileroot (oimg,validim+) oimg = fileroot.root ext = fileroot.defextn # Load necessary packages # images # need imgets # imdebug # need mkimage # Find minimum x and y shift values # and maximum (shift + dimension) values to determine output image size imglist=rewind # rewind imglist while (fscan (imglist,img,newx,newy) != EOF) { imgets(img,"i_naxis1") ixdim = int(imgets.value) imgets(img,"i_naxis2") iydim = int(imgets.value) # Correct for sign reversal between the measured difference II - I # and the required shift to superimpose II on I newx=-1.*newx newy=-1.*newy if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } if ((newx + ixdim) > xmax) { xmax = newx + ixdim } if ((newy + iydim) > ymax) { ymax = newy + iydim } print("xmax=",xmax,"xmin=",xmin,"ymax=",ymax,"ymin=",ymin) } ixmax=0 iymax=0 ixmin=0 iymin=0 if (xmax != 0.) ixmax=int(xmax+0.5*(xmax/abs(xmax))) if (xmin != 0.) ixmin=int(xmin+0.5*(xmin/abs(xmin))) if (ymax != 0.) iymax=int(ymax+0.5*(ymax/abs(ymax))) if (ymin != 0.) iymin=int(ymin+0.5*(ymin/abs(ymin))) print("ixmax=",ixmax,"ixmin=",ixmin,"iymax=",iymax,"iymin=",iymin) # Set dimensions for output image based on input image dimensions # and the extreme values # Ensure that the output image is actually big enough by adding small amount # (0.001) to avoid subtraction errors. oxdim = int(0.501+xmax-xmin) oydim = int(0.501+ymax-ymin) # Create output images here 19 Oct 1992 #mkimage("exp"//oimg//ext,oxdim,oydim,"r",0.,"Exposure Map") #mkimage(oimg,oxdim,oydim,"r",0.,"shifted") mkpattern ("exp"//oimg//ext, pattern="constant", option="replace", v1=0., title="Exposure map", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) mkpattern (oimg, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) print("Output image dimensions: ",oxdim,oydim) # Now do the shift imglist=rewind # rewind imglist while (fscan(imglist,img,newx,newy)!= EOF) { # Strip extension off image name. fileroot (img,validim+) img = fileroot.root # Scale the image up by its exposure time image imarith(img,"*","exp"//img,"_T"//img) # Calculate integer shifts imgets(img,"i_naxis1") ixdim = int(imgets.value) imgets(img,"i_naxis2") iydim = int(imgets.value) newx=-1.*newx newy=-1.*newy ix=0 if (newx != 0.) ix=int(newx+0.5*(newx/abs(newx))) xfrac=newx-ix ix = 1 + ix - ixmin fx = ix + ixdim - 1 print("ix=",ix,"fx=",fx) # For zero shift of 50 x 100,imcopy shift big[1:50,1:100] iy=0 if (newy != 0.) iy=int(newy+0.5*(newy/abs(newy))) yfrac=newy-iy iy = 1 + iy - iymin fy = iy + iydim - 1 # Construct the image section string sect = "["//ix//":"//fx//","//iy//":"//fy//"]" print("Section = ",sect) # Make big empty image #mkimage("bigshift"//img,oxdim,oydim,"r",0.,"shifted") mkpattern ("bigshift"//img, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Do fractional pixel shifts if (xfrac == 0.0 && yfrac == 0.0) { print("Fractional shift is zero for ", img) imrename ("_T"//img,"shift"//img,ver-) } else { imshift("_T"//img,"shift"//img,xsh=xfrac,ysh=yfrac, shifts_file="",interp="spline3",bound="constant",const=0.) imdel("_T"//img,verify=no) print("Fractional shift done for ", img) } # and copy into the big image imcopy("shift"//img,"bigshift"//img//sect) imdel("shift"//img,verify=no) # Accumulator image inserted here 19 Oct 1992 imarith("bigshift"//img,"+",oimg,oimg,pixt="real",calc="real") imdel("bigshift"//img,ver-) print("integer shift done for "//img) # Now make the image to scale for position dependent exposure time #mkimage("bigscale"//img,oxdim,oydim,"r",0.,"scaling") mkpattern ("bigscale"//img, pattern="constant", option="replace", v1=0., title="scaling", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim) # Do fractional shift for exposure image if (xfrac == 0.0 && yfrac == 0.0) { imcopy ("exp"//img,"bigscale"//img//sect,ver-) } else { imshift("exp"//img,"_Texp"//img//ext,xsh=xfrac,ysh=yfrac, shifts_file="",interp="linear",bound="constant",const=0.) imcopy("_Texp"//img//ext,"bigscale"//img//sect) imdel("_Texp"//img,verify=no) } # Accumulator image inserted here 19 Oct 1992 imarith("bigscale"//img,"+","exp"//oimg,"exp"//oimg,pixt="real",calc="real") imdel("bigscale"//img,ver-) print("scale image done for "//img) } # Now combine the big images and divide by the scale imarith(oimg,"/","exp"//oimg,oimg,divzero=0.) # Copy header information from 1st input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. print ("Updating header information.") imglist=rewind # rewind imglist if (fscan (imglist,img, newx, newy) != EOF) { fileroot (img,validim+) img = fileroot.root headfile = mktemp("_header") hfix (img,command="copy $fname "//headfile) hfix (oimg,command="delete $fname ve- ; copy "//headfile//" $fname") hselect (img,"title",yes) | scan(theadline) hedit (oimg,field="exptime",value="1",add+,ver-,show+,update+) hedit (oimg,field="title",value=theadline,ver-,show+,update+) hedit (oimg,fields="OBJMASK,CRMASK,BPM,HOLES,SKYMED",delete+,ver-,show+,update+) delete (headfile,ve-) headfile = mktemp("_header") hfix ("exp"//img,command="copy $fname "//headfile) hfix ("exp"//oimg,command="delete $fname ve- ; copy "//headfile//" $fname") hselect ("exp"//img,"title",yes) | scan(theadline) hedit ("exp"//oimg,field="title",value=theadline,ver-,show+,update+) time | scan (theadline) addcomment ("exp"//oimg,"dimsum.shiftset: "//theadline,ver-) addcomment (oimg,"dimsum.shiftset: "//theadline,ver-) addcomment (oimg,"dimsum.shiftset: Header data copied from file "//img,ver-) delete (headfile,ve-) } imglist = "" end iraf-xdimsum-main/src/obsolete/xregistar.cl000066400000000000000000000435751455666516400214000ustar00rootroot00000000000000procedure xregistar (image_list, badpixfile, outimg) # Replaced MKIMAGE with MKPATTERN -- 3/31/97 FV # # WARNING !! Recent adjustment made to the use of the 'exp' column in # the shiftlist file -- magshiftfix no longer multiplies the image by # that factor before adding it into the mosaic! It DOES multiply the # appropriate "_one" scaling image by that factor before adding it # into the exposure map, however. This is meant to be appropriate for # using the 'exp' column to adjust for non-photometric scalings or # differing relative exposure times. It no longer serves as a weighting # factor, however, unless exp=0, in which case magshiftfix just skips # that image in the summation, as before. This may not be a desirable # change and must be considered further. In the meanwhile, be forewarned! # -- 10/17/93 MD # # Modified check for holes mask to use "HOLES" keyword in # image header. 9/19/93 MD # Check for zero weight in Shiftlist file, and if so, skip that # image rather than going through all the trouble just to end # up multiplying by zero... 9/19/93 MD # Modified call to orientimg --> to call new routine orient. 7/22/93 MD # Added parameter ncoavg to properly account for data take in # mode where multiple individual exposures are internally coaveraged # before readout. -- MD 7/15/93 # Debugging problem where pixin+ doesn't work 7 Dec # Addtl. mod 16 Dec 1991 at KPNO 50" to reduce space needed, by # deleting magnified images as soon as possible # Modification of task newshiftfix to do all integer shifts rather # than imshift interpolation, by scaling input images up with # block replication factor "mag" which is input. # 5 Aug. 1991 Peter Eisenhardt # Procedure to combine images taken at different locations # into one big image, with no loss of spatial coverage or signal # Assumes all input images have same dimensions # Peter Eisenhardt 3 April 1989 # Modified 13 June 1989 to have scale and angle - unlike shiftpix, # this version takes coordinate offsets as input. # Further modified 21 Sept 1990 to allow masking of bad pixels specified # in file bpixfile (uses fixpix format) # Minor change 22 Oct/90 to add secpexp - seconds per exposure unit - # Output is then in units of flux per second. # Mofified 13 May 1991 to add parameter rotation which gives # sense of North thru E. Rotation is "true" if N thru E is CCW, # which means "sign" is negative (and vice versa). Rotation and # angle are use in task orient, which does the transformation to # put N near top and E near left. # more mods 15 July 1991 -- changing way integers vs. fractions are handled # so that always do "proper" integer shift # also doing auto weighting assuming bundle format name # and allowing different x and y scales # Yet more mods 22 July 1991 to support sublocalmask -- # now generates addtl output file outimg//"._shift" # Still even more additional mods 24 July -- separate dependence of # NE, from input coords AB # Don't need orientshiftlist call -- just want shifts in raw # input coords, but do need to deshift mask pixel coords from final output coords # Corrected error in newx , newy formulae for differing x and y scales, # now in accordance with geomap string image_list {prompt="List of images, N and E shifts, and exposures"} string badpixfile {prompt="The input bad pixel file"} string outimg {prompt="The output combined image name"} string exp_prefix {"exp_", prompt="The output exposure map prefix"} string crmasks {"", prompt="Optional input CR mask list for mask pass"} string hmasks {"", prompt="Optional input holes mask list for mask pass"} string in_prefix {"", prompt="The optional first pass input image name prefix"} string oshift_suffix {".shifts", prompt="The first pass output shifts file suffix"} int mag {4, min=1, prompt="Block replication factor"} bool pixin {yes, prompt="Are input shifts in ref object pixels?"} bool ab_sense {yes, prompt="Is A thru B counterclockwise?"} real xscale {1.0,prompt="X pixels per A coordinate unit"} real yscale {1.0,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.0, prompt="Angle in degrees from A CCW to X"} int ncoavg {1, min=1, prompt="Number of internal coaverages per frame"} real secpexp {60., prompt="Seconds per unit exposure time"} real y2n_angle {0.0, prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes, prompt="Is N thru E CCW?"} struct *imglist struct *crimglist struct *himglist begin real axrad, a, b, newx, newy, xmin, xmax, ymin, ymax, xfrac, yfrac real navg, texp, mexp, seconds int sign, numsub, ixdim, iydim, ixmin, ixmax, iymin, iymax, oxdim, oydim int ix, iy, fx, fy, ilen string rewind, oimg, bpfile, clist, hlist, oshifti, ext, img string crmaskfile, holesmask, which_one, strtemp string shimg # shorter img name without 1st char string sect # image section used for integer shift string headfile1, headfile2 # files for temporary storage of header struct theadline # temporary struct for header data # Initialize x and y min and max values so that they will be reset. xmin=9.0E+32 ymin=9.0E+32 xmax=-2.0E+9 ymax=-2.0E+9 # Get the query parameters rewind = image_list oimg = outimg bpfile = badpixfile # Get cosmic ray image list clist = mktemp ("tmp$registar") sections (crmasks, option="fullname", > clist) # Get holes image list hlist = mktemp ("tmp$registar") sections (hmasks, option="fullname", > hlist) # Initialize geoemtry parameters. axrad = a2x_angle * 3.1415926535 / 180.0 if (ab_sense) { sign=1 } else { sign=-1 } # If input coords are measured in pixels with respect to reference object # the scale is 1 but shifts are opposite sign of measured pixels. In this # case a2x_angle is set to zero abd abs_ense is yes. if(pixin) { xscale=-1.0 yscale=-1.0 axrad=0.0 sign=1 } # Determine the name of the output shifts file created by the first pass # registration step. if (mag == 1) { oshifti = oimg // oshift_suffix numsub = strlen (in_prefix) + 1 if (access (oshifti)) delete (oshifti, ver-) } # Check for existence of output files. fileroot ("") ext = fileroot.defextn if (access (oimg // ext)) { print ("Deleting existing output image", oimg // ext) imdelete (oimg, ve+) } if (access (exp_prefix // oimg // ext)) { print ("Deleting existing exposure image", exp_prefix // oimg // ext) imdelete (exp_prefix // oimg, ve+) } # Delete existing temporary files. if (access ("_one" // ext)) imdelete ("_one" // ext, ver-) if (access("_this_one" // ext)) imdelete ("_this_one" // ext, ver-) # Scan header of first image to get image dimensions. We will assume for now # that all images have the same size... imglist=rewind if (fscan (imglist, img, a, b) != EOF) { imgets(img, "i_naxis1") ixdim = int(imgets.value) imgets(img, "i_naxis2") iydim = int(imgets.value) } # Find maximum and minimum x and y shift values and apply badpixel mask. imglist=rewind while (fscan (imglist, img, a, b) != EOF) { newx = mag * (xscale * a * cos(axrad) + yscale * b * sign * sin(axrad)) newy = mag * (yscale * b * sign * cos(axrad) - xscale * a * sin(axrad)) if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } if (newx > xmax) { xmax = newx } if (newy > ymax) { ymax = newy } if (mag == 1) { imarith (img, "*", bpfile, img, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) } } # Transform the shifts to integer values. ixmax=0 ixmin=0 iymax=0 iymin=0 if (xmax != 0.0) ixmax =int (xmax + 0.5 * (xmax / abs(xmax))) if (ymax != 0.0) iymax =int (ymax + 0.5 * (ymax / abs(ymax))) if (xmin != 0.0) ixmin =int (xmin + 0.5 * (xmin / abs(xmin))) if (ymin != 0.0) iymin =int (ymin + 0.5 * (ymin / abs(ymin))) # Make a flat image for scaling position dependent exposure time. This has size # of original input image so that bad pixel masking can be done. #mkimage("_one",ixdim,iydim,"r",1.,"Scaling image") mkpattern ("_one", pattern="constant", option="replace", v1=1., title="Scaling image", pixtype="r", ndim=2, ncols=ixdim, nlines=iydim, header="") # Set bad pixels to zero in the flat image imarith ("_one", "*", bpfile, "_one", title="", divzero=0.0, hparams="", calctype="", pixtype="", ver-) # Now rescale up to mag size for output image ixdim = ixdim * mag iydim = iydim * mag oxdim = ixdim + ixmax - ixmin oydim = iydim + iymax - iymin # Create magnified output images here. #mkimage(oimg,oxdim,oydim,"r",0.,"shifted") #mkimage("exp"//oimg,oxdim,oydim,"r",0.,"Exposure map") mkpattern (oimg, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim, header="") mkpattern (exp_prefix // oimg, pattern="constant", option="replace", v1=0., title="Exposure map", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim, header="") # Now do the shifts. imglist=rewind crimglist = clist himglist = hlist while (fscan (imglist, img, a, b, texp) != EOF) { print ("Shifting image ", img) # Strip off extension if present. fileroot (img, validim+) img = fileroot.root # Calculate integer shifts. newx = mag * (xscale * a * cos(axrad) + yscale * b *sign * sin(axrad)) newy = mag *(yscale * b * sign * cos(axrad) - xscale * a * sin(axrad)) ix = 0 if (newx != 0.0) ix = int(newx + 0.5 * (newx / abs(newx))) xfrac = newx - ix ix = 1 + ix - ixmin fx = ix + ixdim - 1 iy = 0 if (newy != 0.0) iy = int(newy + 0.5 * (newy / abs(newy))) yfrac = newy - iy iy = 1 + iy - iymin fy = iy + iydim - 1 # Record shifts in oshifti if firstpass if (mag==1) { shimg = substr(img, numsub, strlen(img)) print (shimg, " ", ix, iy, >> oshifti) } # Check to see if weight is exactly zero, and if so skip this image. if (texp == 0.0) { print (" Image weight is zero in the sum. Moving on...") next } # Construct the image section string sect = "["//ix//":"//fx//","//iy//":"//fy//"]" # If firstpass do fractional pixel shifts of both the img and the flat. # Otherwise check for cosmic ray mask, and if it exists, combine it with the # bad pixel file. # First, we look for a file called "crm_"//img//".pl". If that is not # present, check the image header for the keyword CRMASK, and if present, look # for the file named there. This allows the user some flexibility in not always # having to rename the crmask file if different sky subtracted versions of # the same image are used at various times. if (imaccess ("_" // img)) imdelete ("_" // img, ver-) if (mag == 1) { imshift (img, "_" // img, xsh = xfrac, ysh=yfrac, shifts="", int="linear",bo="constant",con=0.) imshift ("_one", "_this_one", xsh = xfrac, ysh=yfrac, shifts="", int="linear", bo="constant",con=0.) which_one = "_this_one" // ext } else { crmaskfile = "" if (fscan (crimglist, crmaskfile) != EOF) { if (access (crmaskfile)) { print (" Using prefixed cosmic ray mask file: ", crmaskfile) } else { print (" Cannot find cosmic ray mask file: ", crmaskfile) crmaskfile = "" } } else { hselect (img, "CRMASK", yes) | scan (crmaskfile) if (crmaskfile != "") { if (access (crmaskfile)) { print ("Using header cosmic ray mask file: ", crmaskfile) } else { print (" Cannot find cosmic ray mask file: ", crmaskfile) crmaskfile = "" } } else { print (" Cannot find cosmic ray mask file: ", crmaskfile) } } if (crmaskfile != "") { imarith ("_one", "-", crmaskfile, "_this_one" // ext, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) imreplace ("_this_one", 0., lower=INDEF, upper=0., radius=0.0) which_one = "_this_one" // ext } else { which_one = "_one" // ext } # Check for "holes" mask, and if it exists, combine it into weighting mask. holesmask = "" if (fscan (himglist, holesmask) != EOF) { if (access (holesmask)) { print (" Using prefixed holes mask file: ", crmaskfile) } else { print (" Cannot find holes mask file: ", holesmask) holesmask = "" } } else { hselect (img, "HOLES", yes) | scan (holesmask) if (holesmask != "") { if (access (holesmask)) { print ("Using header holes mask file: ", holesmask) } else { print (" Cannot find holes mask file: ", crmaskfile) holesmask = "" } } else { print (" Cannot find holes mask file: ", holesmask) } } if (holesmask != "") { imarith (which_one, "*", holesmask, "_this_one" // ext, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) which_one = "_this_one"//ext } # Set bad pixels, CR pixels, and holes to zero in copy of image named _img. imarith (img, "*", which_one, "_" // img, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) } # The routine 'bundle.cl' averags all size bundles to a single unit of # exposure time regardless of how many units went into the bundle. To weight # the cumulative exposure properly, we need to multiply each bundle by the # number of units navg that went into it. Currently this is read from the # file name since the suffix 'bN' was attached for this purpose. Note that # navg must be less than 10 i.e. a single digit for the following to work. # Bundling is currently disabled. #ilen = strlen (img) #if(substr (img, ilen-1, ilen-1) == "b") { #strtemp=substr(img,ilen,ilen) #navg=real(strtemp) #} else { navg = 1 #} texp = texp * navg # Multiply exposure by the number of internally coaveraged exposures per frame. texp = texp * ncoavg # Now do the magnification and delete the temporary copy _img. if (imaccess ("shift" // img)) imdelete ("shift" // img, ver-) blkrep ("_" // img, "shift" // img, mag, mag) imdelete ("_" // img, ver-) # Divide by mag squared because want to conserve total number of counts # in input image. mexp = (navg * ncoavg) / (mag * mag) imarith ("shift" // img, "*", mexp, "shift" // img, title="", divzero=0.0, hparams="", pixtype="real", calctype="real", ver-, noact-) # Make big empty image #mkimage("bigshift"//img,oxdim,oydim,"r",0.,"shifted") mkpattern ("bigshift" // img, pattern="constant", option="replace", v1=0., title="shifted", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim, header="") # and copy into the big image. imcopy ("shift" // img, "bigshift" // img // sect, ver-) imdelete ("shift" // img, verify=no) # and finally sum into output image. imarith("bigshift" // img, "+" ,oimg, oimg, title="", divzero=0.0, hparams="", pixtype="real", calctype="real", ver-, noact-) imdelete ("bigshift" // img, verify=no) # Now make the image to scale for position dependent exposure time. #mkimage("bigscale"//img,oxdim,oydim,"r",0.,"scaling") mkpattern ("bigscale" // img, pattern="constant", option="replace", v1=0., title="scaling", pixtype="r", ndim=2, ncols=oxdim, nlines=oydim, header="", header="") seconds = secpexp * texp print (" Total effective exposure time for this frame is ", seconds) if (imaccess ("scale" // img)) imdelete ("scale" // img, ver-) blkrep (which_one, "scale" // img, mag, mag) imarith ("scale" // img, "*", seconds, "scale"//img, title="", divzero=0.0, hparams="", pixtype="real", calctype="real", ver-, noact-) imcopy ("scale" // img, "bigscale" // img //sect, ver-) imdelete ("scale" // img, verify=no) imarith ("bigscale" // img, "+", exp_prefix // oimg, exp_prefix // oimg, title="", divzero=0.0, hparams="", pixtype="real", calctype="real", ver-, noact-) imdelete ("bigscale" // img, verify=no) if (access ("_this_one" // ext)) { imdelete ("_this_one" // ext, ver-) } } imdelete ("_one", verify=no) # Divide output image sum by exposure map. imarith (oimg, "/", exp_prefix // oimg, oimg, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) # Orient these to N at top, E at left for iraf default orient(oimg, y2n_angle, rotation=rotation, invert-) orient (exp_prefix // oimg, y2n_angle, rotation=rotation, invert-) # Copy header information from first input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. print (" Updating header information.") imglist=rewind # rewind imglist if (fscan (imglist, img, a, b) != EOF) { headfile1 = mktemp("registar") headfile2 = mktemp("registar") hfix (img, command="copy $fname " // headfile1) match ("dimsum.slm", headfile1, stop+, print+, > headfile2) hfix (oimg, command="delete $fname ve- ; copy " // headfile2 //" $fname") hselect (img, "title", yes) | scan (theadline) hedit (oimg, "exptime", "1", add+, ver-, show-, update+) hedit (oimg, "title", "Register mosaic sum: " // theadline, ver-, show-, update+) hedit (exp_prefix // oimg, "title", "Exposure time map: " // theadline, ver-, show-, update+) hedit (oimg, "BPM,HOLES,SKYMED", delete+, ver-, show-, update+) time | scan (theadline) addcomment (exp_prefix // oimg, "dimsum.registar: " //theadline, ver-) addcomment (oimg, "dimsum.registar: " // theadline, ver-) addcomment (oimg, "dimsum.registar: Header data copied from file "//img, ver-) delete (headfile1, ve-) delete (headfile2, ve-) } # Cleanup. delete (clist, ver-) delete (hlist, ver-) imglist = "" crimglist = "" himglist = "" end iraf-xdimsum-main/src/orient.cl000066400000000000000000000027021455666516400170370ustar00rootroot00000000000000# Orient the image to within 45 degrees of north pointing up and east pointing # pointing left. procedure orient (input, y2n_angle) # Orient requires the imcopy and imtranpose tasks. string input {prompt="The name of the image to reorient"} real y2n_angle {0.,prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes,prompt="Is N thru E counterclockwise ?"} bool invert {no,prompt="Inverse operation used for reorienting masks ?"} begin real angle string image # Get query parameters image = input angle = y2n_angle # Set angle to a value from -45 to 315 degrees while (angle < -45.0) { angle += 360. } while (angle >= 315.0) { angle -= 360. } if (angle < 45.0) { if (rotation) return else imcopy (image // "[-*,*]", image, verbose-) } else if (angle < 135.0) { if (rotation) { if (invert) imtranspose (image // "[*,-*]", image, len_blk=1024) else imtranspose (image // "[-*,*]", image, len_blk=1024) } else { imtranspose (image, image, len_blk=1024) } } else if (angle < 225.0) { if (rotation) imcopy (image // "[-*,-*]", image, verbose-) else imcopy(image // "[*,-*]", image, verbose-) } else if (angle < 315.0) { if (rotation) { if (invert) imtranspose (image // "[-*,*]", image, len_blk=1024) else imtranspose (image // "[*,-*]", image, len_blk=1024) } else { imtranspose (image // "[-*,-*]", image, len_blk=1024) } } end iraf-xdimsum-main/src/sigmanorm.cl000066400000000000000000000016461455666516400175410ustar00rootroot00000000000000# Sigmanorm renormalizes the input image by the square root of the exposure map # to produce an image which should have uniform rms pixel-to-pixel noise across # the entire area. procedure sigmanorm (input, expmap, output) # Sigmanorm call the minmax and imexpr tasks. string input {prompt="The name of the input image"} string expmap {prompt="The name of input exposure map image"} string output {prompt="The output normalized image"} begin real maxexp string img, expimg, oimg # Get query parameter. img = input expimg = expmap oimg = output # Calculate sqrt of exposure map and multiply into image with appropriate # normalization. minmax (expimg, force-, update-, verbose-) maxexp = minmax.maxval imexpr ("a * sqrt (b / c)", oimg, img, expimg, maxexp, dims="auto", intype="real", outtype="real", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) end iraf-xdimsum-main/src/x_xdimsum.x000066400000000000000000000000721455666516400174230ustar00rootroot00000000000000task maskinterp = t_maskinterp, avshift = t_avshift iraf-xdimsum-main/src/xaddmask.cl000066400000000000000000000065501455666516400173400ustar00rootroot00000000000000# Add the previous object masks together. The input list is either the # list of input object masks (keyword = "") or the list of parent images # containing the object mask keyword. The current mimage is defined by # the integer current and the nprev masks to that are summed to produce # the output mask. procedure xaddmasks (inmasks, current, nprev, keyword, outmask) string inmasks {prompt="List of input images or object masks"} int current {prompt="The current mask number"} int nprev {prompt="The number of previous masks to use"} string keyword {prompt="The object mask keyword name"} string outmask {prompt="The name of the output mask"} string outarg {prompt="The return output argument"} struct *imglist begin int tcurrent, tnprev, nim, start, finish, ndiff string tinmasks, tkeyword, toutmask, cobjlist, imlist, tmpname, img # Get query parameters. tinmasks = inmasks if (tinmasks == "") { outarg = "1" return } # Return if the current mask is less than or equal to one. tcurrent = current if (tcurrent <= 1) { outarg = "1" return } # Return if the number of previous masks is less than or equal to # zero. tnprev = nprev if (tnprev <= 0) { outarg = "1" return } tkeyword = keyword toutmask = outmask # Count the number of input masks / images count (tinmasks) | scan (nim) # Compute the mask range to be used and create the temporary list. start = max (1, tcurrent - tnprev) finish = min (nim, tcurrent - 1) ndiff = finish - start + 1 # Sum the masks. if (ndiff > 0) { # Create a file to contain the image sublist. cobjlist = mktemp ("tmp$xaddmask") # In this case the input list is the list of object masks which # are extracted and summed. nim = 0 if (tkeyword == "") { xlist (tinmasks, cobjlist, start, finish, 0, suffix="") count (cobjlist) | scan (nim) # In this case the input list is the list of parent images which # contain the object mask keyword. } else { imlist = mktemp ("tmp$xaddmask") xlist (tinmasks, imlist, start, finish, 0, suffix="") count (imlist) | scan (nim) if (nim > 0) { imglist = imlist while (fscan (imglist, img) != EOF) { tmpname = "" hselect (img, tkeyword, yes) | scan (tmpname) if (access(tmpname)) { print (tmpname, >> cobjlist) } else { break } } } delete (imlist, verify-) } # Extract and sum the masks. if (nim != ndiff) { outarg = "1" } else if (ndiff == 1) { fileroot (toutmask, validim+) tmpname = fileroot.root // ".pl" imcopy ("@" // cobjlist, tmpname, verbose-) outarg = tmpname } else { if (imaccess ("_junk.pl")) imdelete ("_junk.pl", verify-) imsum ("@" // cobjlist, "_junk.pl", title="", hparams="", pixtype="", calctype="", option="sum", low_reject=0.0, high_reject=0.0, verbose-) fileroot (toutmask, validim+) tmpname = fileroot.root // ".pl" imexpr ("a > 0 ? 1 : 0", tmpname, "_junk.pl", dims="auto", intype="auto", outtype="auto", refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose-, exprdb="none") imdelete ("_junk.pl", verify-) outarg = tmpname } if (access (cobjlist)) delete (cobjlist, verify-) } else { outarg = "1" } imglist = "" end iraf-xdimsum-main/src/xcraverage/000077500000000000000000000000001455666516400173455ustar00rootroot00000000000000iraf-xdimsum-main/src/xcraverage/mkpkg000066400000000000000000000002751455666516400204050ustar00rootroot00000000000000# Make the CRUTIL task $checkout libpkg.a ../../ $update libpkg.a $checkin libpkg.a ../../ $exit libpkg.a: t_craverage.x t_crgrow.x ; iraf-xdimsum-main/src/xcraverage/t_craverage.x000066400000000000000000000524041455666516400220250ustar00rootroot00000000000000include include include define MAXBUF 500000 # Maximum pixel buffer define PLSIG 15.87 # Low percentile define PHSIG 84.13 # High percentile # T_CRAVERAGE -- Detect, fix, and flag cosmic rays. Also detect objects. # Deviant pixels relative to a local average with the candidate pixel # excluded and sigma are detected and replaced by the average value # and/or written to a cosmic ray mask. Average values above a the median # of a background annulus are detected as objects and cosmic rays are # excluded. The object positions may be output in the mask. procedure t_craverage () int inlist # Input image list int outlist # Output image list int crlist # Output mask list int avglist # Output average list int siglist # Output sigma list int crval # Output cosmic ray mask value int objval # Output object mask value int navg # Averaging box size int nrej # Number of high pixels to reject from average int nbkg # Background width int nsig # Sigma box size real lobjsig, hobjsig # Object threshold sigmas real lcrsig, hcrsig # CR threshold sigmas outside of object real var0 # Variance coefficient for DN^0 term real var1 # Variance coefficient for DN^1 term real var2 # Variance coefficient for DN^2 term real crgrw # Cosmic ray grow radius real objgrw # Object grow radius int i, nc, nl, nlstep, nbox, l1, l2, l3, l4, nl1, pmmode pointer sp, input, output, crmask, average, sigma pointer in, out, pm, aim, sim pointer inbuf, pinbuf, outbuf, pbuf, abuf, sbuf real clgetr() int clgeti(), imtopenp(), imtgetim(), strmatch() pointer immap(), imgs2s(), imgs2r(), imps2r(), imps2s() errchk immap, imgs2s, imgs2r, imps2r, imps2s, craverage, crgrow begin call smark (sp) call salloc (input, SZ_FNAME, TY_CHAR) call salloc (output, SZ_FNAME, TY_CHAR) call salloc (crmask, SZ_FNAME, TY_CHAR) call salloc (average, SZ_FNAME, TY_CHAR) call salloc (sigma, SZ_FNAME, TY_CHAR) # Get parameters. inlist = imtopenp ("input") outlist = imtopenp ("output") crlist = imtopenp ("crmask") avglist = imtopenp ("average") siglist = imtopenp ("sigma") crval = clgeti ("crval") objval = clgeti ("objval") navg = max (1, clgeti ("navg") / 2) nrej = min (clgeti ("nrej"), navg-1) nbkg = clgeti ("nbkg") nsig = clgeti ("nsig") lobjsig = clgetr ("lobjsig") hobjsig = clgetr ("hobjsig") lcrsig = clgetr ("lcrsig") hcrsig = clgetr ("hcrsig") nbox = 2 * (navg + nbkg) + 1 var0 = clgetr ("var0") var1 = clgetr ("var1") var2 = clgetr ("var2") crgrw = clgetr ("crgrow") objgrw = clgetr ("objgrow") # Do the input images. while (imtgetim (inlist, Memc[input], SZ_FNAME) != EOF) { if (imtgetim (outlist, Memc[output], SZ_FNAME) == EOF) Memc[output] = EOS if (imtgetim (crlist, Memc[crmask], SZ_FNAME) == EOF) Memc[crmask] = EOS if (imtgetim (avglist, Memc[average], SZ_FNAME) == EOF) Memc[average] = EOS if (imtgetim (siglist, Memc[sigma], SZ_FNAME) == EOF) Memc[sigma] = EOS # Map the input and output images. iferr { in = NULL; out = NULL; pm = NULL; aim = NULL; sim = NULL inbuf = NULL; pinbuf = NULL; outbuf = NULL; pbuf = NULL; abuf = NULL; sbuf=NULL in = immap (Memc[input], READ_ONLY, 0) if (Memc[output] != EOS) out = immap (Memc[output], NEW_COPY, in) if (Memc[crmask] != EOS) { if (strmatch (Memc[crmask], ".pl$") == 0) call strcat (".pl", Memc[crmask], SZ_FNAME) pmmode = READ_WRITE iferr (pm = immap (Memc[crmask], pmmode, 0)) { pmmode = NEW_COPY pm = immap (Memc[crmask], pmmode, in) } } if (Memc[average] != EOS) aim = immap (Memc[average], NEW_COPY, in) if (Memc[sigma] != EOS) sim = immap (Memc[sigma], NEW_COPY, in) # Go through the input in large blocks of lines. If the # block is smaller than the whole image overlap the blocks # so the average only has boundaries at the ends of the image. # However, the output is done in non-overlapping blocks with # the pointers are adjusted so that addresses can be in the # space of the input block. CRAVERAGE does not address # outside of the output data block. Set the mask values # based on the distances to the nearest good pixels. nc = IM_LEN(in,1) nl = IM_LEN(in,2) nlstep = max (1, MAXBUF / nc - nbox) do i = 1, nl, nlstep { l1 = i l2 = min (nl, i + nlstep - 1) l3 = max (1, l1 - nbox / 2) l4 = min (nl, l2 + nbox / 2) nl1 = l4 - l3 + 1 inbuf = imgs2r (in, 1, nc, l3, l4) if (out != NULL) outbuf = imps2r (out, 1, nc, l1, l2) - (l1 - l3) * nc if (pm != NULL) { if (pmmode == READ_WRITE) { pinbuf = imgs2s (pm, 1, nc, l1, l2) pbuf = imps2s (pm, 1, nc, l1, l2) call amovs (Mems[pinbuf], Mems[pbuf], nc*(l2-l1+1)) pinbuf = pinbuf - (l1 - l3) * nc pbuf = pbuf - (l1 - l3) * nc } else { pinbuf = NULL pbuf = imps2s (pm, 1, nc, l1, l2) call aclrs (Mems[pbuf], nc*(l2-l1+1)) pbuf = pbuf - (l1 - l3) * nc } } if (aim != NULL) abuf = imps2r (aim, 1, nc, l1, l2) - (l1 - l3) * nc if (sim != NULL) sbuf = imps2r (sim, 1, nc, l1, l2) - (l1 - l3) * nc if (pinbuf == NULL) call craverage (inbuf, outbuf, pbuf, abuf, sbuf, nc, nl1, l1-l3+1, l2-l3+1, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig, crval, objval) else call craverage1 (inbuf, pinbuf, outbuf, pbuf, abuf, sbuf, nc, nl1, l1-l3+1, l2-l3+1, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig, crval, objval) } # Grow regions if desired. The routines are nops if the # grow is zero. if (pm != NULL) { if (crval == objval) call crgrow (pm, max (crgrw, objgrw), crval, crval) else { call crgrow (pm, crgrw, crval, crval) call crgrow (pm, objgrw, objval, objval) } } } then call erract (EA_WARN) if (sim != NULL) call imunmap (sim) if (aim != NULL) call imunmap (aim) if (pm != NULL) call imunmap (pm) if (out != NULL) call imunmap (out) call imunmap (in) } call imtclose (inlist) call imtclose (outlist) call imtclose (crlist) call imtclose (avglist) call imtclose (siglist) call sfree (sp) end # CRAVERAGE -- Detect, replace, and flag cosmic rays. # A local background is computed using moving box averages to avoid # contaminating bad pixels. If variance model is given then that is # used otherwise a local sigma is computed in blocks (it is not a moving box # for efficiency) by using a percentile point of the sorted pixel values to # estimate the width of the distribution uncontaminated by bad pixels). Once # the background and sigma are known deviant pixels are found by using sigma # threshold factors. procedure craverage (in, out, pout, aout, sout, nc, nl, nl1, nl2, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig crval, objval) pointer in #I Input data pointer out #O Output data pointer pout #O Output mask (0=good, 1=bad) pointer aout #O Output averages pointer sout #O Output sigmas int nc, nl #I Number of columns and lines int nl1, nl2 #I Lines to compute int navg #I Averaging box half-size int nrej #I Number of high pixels to reject from average int nbkg #I Median background width real var0 #I Variance coefficient for DN^0 term real var1 #I Variance coefficient for DN^1 term real var2 #I Variance coefficient for DN^2 term int nsig #I Sigma box size real lcrsig, hcrsig #I Threshold sigmas outside of object real lobjsig, hobjsig #I Object threshold sigmas int crval #I CR mask value int objval #I Object mask value int i, j, c, c1, c2, c3, c4, l, l1, l2, l3, l4, n1, n2 int navg2, nbkg2, nsig2, plsig, phsig real data, avg, bkg, sigma, losig, hosig real low, high, cravg(), amedr() pointer stack, avgs, bkgs, sigs, work1, work2 pointer ptr1, ptr2, ip, op, pp, ap, sp begin navg2 = (2 * navg + 1) ** 2 nbkg2 = (2 * (navg + nbkg) + 1) ** 2 - navg2 nsig2 = nsig * nsig call smark (stack) call salloc (avgs, nc, TY_REAL) call salloc (bkgs, nc, TY_REAL) call salloc (sigs, nc, TY_REAL) call salloc (work1, navg2, TY_REAL) call salloc (work2, max (nsig2, nbkg2), TY_REAL) if (var0 != 0. && var1 == 0. && var2 ==0.) call amovkr (sqrt(var0), Memr[sigs], nc) avgs = avgs - 1 sigs = sigs - 1 bkgs = bkgs - 1 plsig = nint (PLSIG*nsig2/100.-1) phsig = nint (PHSIG*nsig2/100.-1) losig = lobjsig / sqrt (real(navg2-1)) hosig = hobjsig / sqrt (real(navg2-1)) do l = nl1, nl2 { # Compute statistics. l1 = max (1, l-navg-nbkg) l2 = max (1, l-navg) l3 = min (nl, l+navg) l4 = min (nl, l+navg+nbkg) ap = aout + (l - 1) * nc do c = 1, nc { c1 = max (1, c-navg-nbkg) c2 = max (1, c-navg) c3 = min (nc, c+navg) c4 = min (nc, c+navg+nbkg) ptr1 = work1 ptr2 = work2 n1 = 0 n2 = 0 do j = l1, l2-1 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } do j = l2, l3 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c2-1 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } do i = c2, c3 { if (j != l || i != c) { Memr[ptr1] = Memr[ip] n1 = n1 + 1 ptr1 = ptr1 + 1 } ip = ip + 1 } do i = c3+1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } do j = l3+1, l4 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } avg = cravg (Memr[work1], n1, nrej) bkg = amedr (Memr[work2], n2) Memr[bkgs+c] = bkg Memr[avgs+c] = avg if (aout != NULL) { Memr[ap] = avg - bkg ap = ap + 1 } } # Compute sigmas and output if desired. if (var0 != 0. || var1 != 0. || var2 != 0.) { if (var1 != 0.) { if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0+var1*data+var2*data**2) } } else { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var1 * data) } } } else if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var2 * data**2) } } } else { # Compute sigmas from percentiles. This is done in blocks. if (mod (l-nl1, nsig) == 0 && l high) { Memr[op] = data } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Memr[op] = avg else Memr[op] = data } ip = ip + 1 op = op + 1 } } else if (out == NULL) { ip = in + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) Mems[pp] = objval else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Mems[pp] = crval } ip = ip + 1 pp = pp + 1 } } else { ip = in + (l - 1) * nc op = out + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data Mems[pp] = objval } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) { Memr[op] = avg Mems[pp] = crval } else Memr[op] = data } ip = ip + 1 op = op + 1 pp = pp + 1 } } } call sfree (stack) end # CRAVERAGE1 -- Detect, replace, and flag cosmic rays checking input mask. # A local background is computed using moving box averages to avoid # contaminating bad pixels. If variance model is given then that is # used otherwise a local sigma is computed in blocks (it is not a moving box # for efficiency) by using a percentile point of the sorted pixel values to # estimate the width of the distribution uncontaminated by bad pixels). Once # the background and sigma are known deviant pixels are found by using sigma # threshold factors. procedure craverage1 (in, pin, out, pout, aout, sout, nc, nl, nl1, nl2, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig crval, objval) pointer in #I Input data pointer pin #I Pixel mask data pointer out #O Output data pointer pout #O Output mask (0=good, 1=bad) pointer aout #O Output averages pointer sout #O Output sigmas int nc, nl #I Number of columns and lines int nl1, nl2 #I Lines to compute int navg #I Averaging box half-size int nrej #I Number of high pixels to reject from average int nbkg #I Median background width real var0 #I Variance coefficient for DN^0 term real var1 #I Variance coefficient for DN^1 term real var2 #I Variance coefficient for DN^2 term int nsig #I Sigma box size real lcrsig, hcrsig #I Threshold sigmas outside of object real lobjsig, hobjsig #I Object threshold sigmas int crval #I CR mask value int objval #I Object mask value int i, j, c, c1, c2, c3, c4, l, l1, l2, l3, l4, n1, n2 int navg2, nbkg2, nsig2, plsig, phsig real data, avg, bkg, sigma, losig, hosig real low, high, cravg(), amedr() pointer stack, avgs, bkgs, sigs, work1, work2 pointer ptr1, ptr2, ip, mp, op, pp, ap, sp begin navg2 = (2 * navg + 1) ** 2 nbkg2 = (2 * (navg + nbkg) + 1) ** 2 - navg2 nsig2 = nsig * nsig call smark (stack) call salloc (avgs, nc, TY_REAL) call salloc (bkgs, nc, TY_REAL) call salloc (sigs, nc, TY_REAL) call salloc (work1, navg2, TY_REAL) call salloc (work2, max (nsig2, nbkg2), TY_REAL) if (var0 != 0. && var1 == 0. && var2 ==0.) call amovkr (sqrt(var0), Memr[sigs], nc) avgs = avgs - 1 sigs = sigs - 1 bkgs = bkgs - 1 losig = lobjsig / sqrt (real(navg2-1)) hosig = hobjsig / sqrt (real(navg2-1)) do l = nl1, nl2 { # Compute statistics. l1 = max (1, l-navg-nbkg) l2 = max (1, l-navg) l3 = min (nl, l+navg) l4 = min (nl, l+navg+nbkg) ap = aout + (l - 1) * nc do c = 1, nc { c1 = max (1, c-navg-nbkg) c2 = max (1, c-navg) c3 = min (nc, c+navg) c4 = min (nc, c+navg+nbkg) ptr1 = work1 ptr2 = work2 n1 = 0 n2 = 0 do j = l1, l2-1 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } } do j = l2, l3 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c2-1 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } do i = c2, c3 { if ((j != l || i != c) && Mems[mp] == 0) { Memr[ptr1] = Memr[ip] n1 = n1 + 1 ptr1 = ptr1 + 1 } ip = ip + 1 mp = mp + 1 } do i = c3+1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } } do j = l3+1, l4 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 } } if (n1 > 0) avg = cravg (Memr[work1], n1, nrej) else avg = INDEFR if (n2 > 0) bkg = amedr (Memr[work2], n2) else bkg = INDEFR Memr[bkgs+c] = bkg Memr[avgs+c] = avg if (aout != NULL) { if (IS_INDEFR(avg) || IS_INDEFR(bkg)) Memr[ap] = 0. else Memr[ap] = avg - bkg ap = ap + 1 } } # Compute sigmas and output if desired. if (var0 != 0. || var1 != 0. || var2 != 0.) { if (var1 != 0.) { if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0+var1*data+var2*data**2) } } else { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var1 * data) } } } else if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var2 * data**2) } } } else { # Compute sigmas from percentiles. This is done in blocks. if (mod (l-nl1, nsig) == 0 && l 10) { call asrtr (Memr[work2], Memr[work2], n2) plsig = nint (PLSIG*n2/100.-1) phsig = nint (PHSIG*n2/100.-1) sigma = (Memr[work2+phsig]-Memr[work2+plsig])/2. } else sigma = INDEFR call amovkr (sigma, Memr[sigs+c], nsig) } call amovkr (sigma, Memr[sigs+c], nc-c+1) } } if (sout != NULL) { sp = sout + (l - 1) * nc do c = 1, nc { sigma = Memr[sigs+c] if (IS_INDEFR(sigma)) Memr[sp] = 0. else Memr[sp] = sigma sp = sp + 1 } } # Detect, fix, and flag cosmic rays. if (pout == NULL && out == NULL) ; if (pout == NULL) { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc op = out + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Memr[op] = avg else Memr[op] = data } } else Memr[op] = data ip = ip + 1 mp = mp + 1 op = op + 1 } } else if (out == NULL) { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) Mems[pp] = objval else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Mems[pp] = crval } } ip = ip + 1 mp = mp + 1 pp = pp + 1 } } else { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc op = out + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data Mems[pp] = objval } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) { Memr[op] = avg Mems[pp] = crval } else Memr[op] = data } } else Memr[op] = data ip = ip + 1 mp = mp + 1 op = op + 1 pp = pp + 1 } } } call sfree (stack) end # CRAVG -- Compute average with the highest nrej points excluded. # When nrej is greater than 2 the data array will be returned sorted. real procedure cravg (data, npts, nrej) real data[npts] #I Input data (will be sorted if nrej>2) int npts #I Number of data points int nrej #I Number of data points to reject int i real sum, max1, max2, val begin if (npts <= nrej) return (INDEFR) switch (nrej) { case 0: sum = 0. do i = 1, npts sum = sum + data[i] case 1: sum = 0. max1 = data[1] do i = 2, npts { val = data[i] if (val > max1) { sum = sum + max1 max1 = val } else sum = sum + val } case 2: sum = 0. max1 = min (data[1], data[2]) max2 = max (data[1], data[2]) do i = 3, npts { val = data[i] if (val > max1) { sum = sum + max1 if (val > max2) { max1 = max2 max2 = val } else max1 = val } else sum = sum + val } default: call asrtr (data, data, npts) sum = 0. do i = 1, npts-nrej sum = sum + data[i] } return (sum / (npts - nrej)) end iraf-xdimsum-main/src/xcraverage/t_craverage.x.old000066400000000000000000000522651455666516400226070ustar00rootroot00000000000000include include include define MAXBUF 500000 # Maximum pixel buffer define PLSIG 15.87 # Low percentile define PHSIG 84.13 # High percentile # T_CRAVERAGE -- Detect, fix, and flag cosmic rays. Also detect objects. # Deviant pixels relative to a local average with the candidate pixel # excluded and sigma are detected and replaced by the average value # and/or written to a cosmic ray mask. Average values above a the median # of a background annulus are detected as objects and cosmic rays are # excluded. The object positions may be output in the mask. procedure t_craverage () int inlist # Input image list int outlist # Output image list int crlist # Output mask list int avglist # Output average list int siglist # Output sigma list int crval # Output cosmic ray mask value int objval # Output object mask value int navg # Averaging box size int nrej # Number of high pixels to reject from average int nbkg # Background width int nsig # Sigma box size real lobjsig, hobjsig # Object threshold sigmas real lcrsig, hcrsig # CR threshold sigmas outside of object real var0 # Variance coefficient for DN^0 term real var1 # Variance coefficient for DN^1 term real var2 # Variance coefficient for DN^2 term real crgrw # Cosmic ray grow radius real objgrw # Object grow radius int i, nc, nl, nlstep, nbox, l1, l2, l3, l4, nl1, pmmode pointer sp, input, output, crmask, average, sigma pointer in, out, pm, aim, sim pointer inbuf, pinbuf, outbuf, pbuf, abuf, sbuf real clgetr() int clgeti(), imtopenp(), imtgetim(), strmatch() pointer immap(), imgs2s(), imgs2r(), imps2r(), imps2s() errchk immap, imgs2s, imgs2r, imps2r, imps2s, craverage, crgrow begin call smark (sp) call salloc (input, SZ_FNAME, TY_CHAR) call salloc (output, SZ_FNAME, TY_CHAR) call salloc (crmask, SZ_FNAME, TY_CHAR) call salloc (average, SZ_FNAME, TY_CHAR) call salloc (sigma, SZ_FNAME, TY_CHAR) # Get parameters. inlist = imtopenp ("input") outlist = imtopenp ("output") crlist = imtopenp ("crmask") avglist = imtopenp ("average") siglist = imtopenp ("sigma") crval = clgeti ("crval") objval = clgeti ("objval") navg = max (1, clgeti ("navg") / 2) nrej = min (clgeti ("nrej"), navg-1) nbkg = clgeti ("nbkg") nsig = clgeti ("nsig") lobjsig = clgetr ("lobjsig") hobjsig = clgetr ("hobjsig") lcrsig = clgetr ("lcrsig") hcrsig = clgetr ("hcrsig") nbox = 2 * (navg + nbkg) + 1 var0 = clgetr ("var0") var1 = clgetr ("var1") var2 = clgetr ("var2") crgrw = clgetr ("crgrow") objgrw = clgetr ("objgrow") # Do the input images. while (imtgetim (inlist, Memc[input], SZ_FNAME) != EOF) { if (imtgetim (outlist, Memc[output], SZ_FNAME) == EOF) Memc[output] = EOS if (imtgetim (crlist, Memc[crmask], SZ_FNAME) == EOF) Memc[crmask] = EOS if (imtgetim (avglist, Memc[average], SZ_FNAME) == EOF) Memc[average] = EOS if (imtgetim (siglist, Memc[sigma], SZ_FNAME) == EOF) Memc[sigma] = EOS # Map the input and output images. iferr { in = NULL; out = NULL; pm = NULL; aim = NULL; sim = NULL inbuf = NULL; pinbuf = NULL; outbuf = NULL; pbuf = NULL; abuf = NULL; sbuf=NULL in = immap (Memc[input], READ_ONLY, 0) if (Memc[output] != EOS) out = immap (Memc[output], NEW_COPY, in) if (Memc[crmask] != EOS) { if (strmatch (Memc[crmask], ".pl$") == 0) call strcat (".pl", Memc[crmask], SZ_FNAME) pmmode = READ_WRITE iferr (pm = immap (Memc[crmask], pmmode, 0)) { pmmode = NEW_COPY pm = immap (Memc[crmask], pmmode, in) } } if (Memc[average] != EOS) aim = immap (Memc[average], NEW_COPY, in) if (Memc[sigma] != EOS) sim = immap (Memc[sigma], NEW_COPY, in) # Go through the input in large blocks of lines. If the # block is smaller than the whole image overlap the blocks # so the average only has boundaries at the ends of the image. # However, the output is done in non-overlapping blocks with # the pointers are adjusted so that addresses can be in the space # of the input block. CRMEDIAN does not address outside of # the output data block. Set the mask values based on the # distances to the nearest good pixels. nc = IM_LEN(in,1) nl = IM_LEN(in,2) nlstep = max (1, MAXBUF / nc - nbox) do i = 1, nl, nlstep { l1 = i l2 = min (nl, i + nlstep - 1) l3 = max (1, l1 - nbox / 2) l4 = min (nl, l2 + nbox / 2) nl1 = l4 - l3 + 1 inbuf = imgs2r (in, 1, nc, l3, l4) if (out != NULL) outbuf = imps2r (out, 1, nc, l1, l2) - (l1 - l3) * nc if (pm != NULL) { if (pmmode == READ_WRITE) { pinbuf = imgs2s (pm, 1, nc, l1, l2) - (l1 - l3) * nc pbuf = imps2s (pm, 1, nc, l1, l2) - (l1 - l3) * nc call amovs (Mems[pinbuf+(l1-l3)*nc], Mems[pbuf+(l1-l3)*nc], nc*(l2-l1+1)) } else { pinbuf = NULL pbuf = imps2s (pm, 1, nc, l1, l2) - (l1 - l3) * nc call aclrs (Mems[pbuf+(l1-l3)*nc], nc*(l2-l1+1)) } } if (aim != NULL) abuf = imps2r (aim, 1, nc, l1, l2) - (l1 - l3) * nc if (sim != NULL) sbuf = imps2r (sim, 1, nc, l1, l2) - (l1 - l3) * nc if (pinbuf == NULL) { call craverage (inbuf, outbuf, pbuf, abuf, sbuf, nc, nl1, l1-l3+1, l2-l3+1, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig, crval, objval) } else { call craverage1 (inbuf, pinbuf, outbuf, pbuf, abuf, sbuf, nc, nl1, l1-l3+1, l2-l3+1, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig, crval, objval) } } if (pm != NULL) { if (crval == objval) { call crgrow (pm, max (crgrw, objgrw), crval, crval) } else { call crgrow (pm, crgrw, crval, crval) call crgrow (pm, objgrw, objval, objval) } } } then call erract (EA_WARN) if (sim != NULL) call imunmap (sim) if (aim != NULL) call imunmap (aim) if (pm != NULL) call imunmap (pm) if (out != NULL) call imunmap (out) call imunmap (in) } call imtclose (siglist) call imtclose (avglist) call imtclose (crlist) call imtclose (outlist) call imtclose (inlist) call sfree (sp) end # CRAVERAGE -- Detect, replace, and flag cosmic rays. # A local background is computed using moving box averages to avoid # contaminating bad pixels. If variance model is given then that is # used otherwise a local sigma is computed in blocks (it is not a moving box # for efficiency) by using a percentile point of the sorted pixel values to # estimate the width of the distribution uncontaminated by bad pixels). Once # the background and sigma are known deviant pixels are found by using sigma # threshold factors. procedure craverage (in, out, pout, aout, sout, nc, nl, nl1, nl2, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig crval, objval) pointer in #I Input data pointer out #O Output data pointer pout #O Output mask (0=good, 1=bad) pointer aout #O Output averages pointer sout #O Output sigmas int nc, nl #I Number of columns and lines int nl1, nl2 #I Lines to compute int navg #I Averaging box half-size int nrej #I Number of high pixels to reject from average int nbkg #I Median background width real var0 #I Variance coefficient for DN^0 term real var1 #I Variance coefficient for DN^1 term real var2 #I Variance coefficient for DN^2 term int nsig #I Sigma box size real lcrsig, hcrsig #I Threshold sigmas outside of object real lobjsig, hobjsig #I Object threshold sigmas int crval #I CR mask value int objval #I Object mask value int i, j, c, c1, c2, c3, c4, l, l1, l2, l3, l4, n1, n2 int navg2, nbkg2, nsig2, plsig, phsig real data, avg, bkg, sigma, losig, hosig real low, high, cravg(), amedr() pointer stack, avgs, bkgs, sigs, work1, work2 pointer ptr1, ptr2, ip, op, pp, ap, sp begin navg2 = (2 * navg + 1) ** 2 nbkg2 = (2 * (navg + nbkg) + 1) ** 2 - navg2 nsig2 = nsig * nsig call smark (stack) call salloc (avgs, nc, TY_REAL) call salloc (bkgs, nc, TY_REAL) call salloc (sigs, nc, TY_REAL) call salloc (work1, navg2, TY_REAL) call salloc (work2, max (nsig2, nbkg2), TY_REAL) if (var0 != 0. && var1 == 0. && var2 ==0.) call amovkr (sqrt(var0), Memr[sigs], nc) avgs = avgs - 1 sigs = sigs - 1 bkgs = bkgs - 1 plsig = nint (PLSIG*nsig2/100.-1) phsig = nint (PHSIG*nsig2/100.-1) losig = lobjsig / sqrt (real(navg2-1)) hosig = hobjsig / sqrt (real(navg2-1)) do l = nl1, nl2 { # Compute statistics. l1 = max (1, l-navg-nbkg) l2 = max (1, l-navg) l3 = min (nl, l+navg) l4 = min (nl, l+navg+nbkg) ap = aout + (l - 1) * nc do c = 1, nc { c1 = max (1, c-navg-nbkg) c2 = max (1, c-navg) c3 = min (nc, c+navg) c4 = min (nc, c+navg+nbkg) ptr1 = work1 ptr2 = work2 n1 = 0 n2 = 0 do j = l1, l2-1 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } do j = l2, l3 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c2-1 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } do i = c2, c3 { if (j != l || i != c) { Memr[ptr1] = Memr[ip] n1 = n1 + 1 ptr1 = ptr1 + 1 } ip = ip + 1 } do i = c3+1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } do j = l3+1, l4 { ip = in + (j - 1) * nc + c1 - 1 do i = c1, c4 { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 ip = ip + 1 } } avg = cravg (Memr[work1], n1, nrej) bkg = amedr (Memr[work2], n2) Memr[bkgs+c] = bkg Memr[avgs+c] = avg if (aout != NULL) { Memr[ap] = avg - bkg ap = ap + 1 } } # Compute sigmas and output if desired. if (var0 != 0. || var1 != 0. || var2 != 0.) { if (var1 != 0.) { if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0+var1*data+var2*data**2) } } else { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var1 * data) } } } else if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var2 * data**2) } } } else { # Compute sigmas from percentiles. This is done in blocks. if (mod (l-nl1, nsig) == 0 && l high) { Memr[op] = data } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Memr[op] = avg else Memr[op] = data } ip = ip + 1 op = op + 1 } } else if (out == NULL) { ip = in + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) Mems[pp] = objval else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Mems[pp] = crval } ip = ip + 1 pp = pp + 1 } } else { ip = in + (l - 1) * nc op = out + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data Mems[pp] = objval } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) { Memr[op] = avg Mems[pp] = crval } else Memr[op] = data } ip = ip + 1 op = op + 1 pp = pp + 1 } } } call sfree (stack) end # CRAVERAGE1 -- Detect, replace, and flag cosmic rays checking input mask. # A local background is computed using moving box averages to avoid # contaminating bad pixels. If variance model is given then that is # used otherwise a local sigma is computed in blocks (it is not a moving box # for efficiency) by using a percentile point of the sorted pixel values to # estimate the width of the distribution uncontaminated by bad pixels). Once # the background and sigma are known deviant pixels are found by using sigma # threshold factors. procedure craverage1 (in, pin, out, pout, aout, sout, nc, nl, nl1, nl2, navg, nrej, nbkg, var0, var1, var2, nsig, lcrsig, hcrsig, lobjsig, hobjsig crval, objval) pointer in #I Input data pointer pin #I Pixel mask data pointer out #O Output data pointer pout #O Output mask (0=good, 1=bad) pointer aout #O Output averages pointer sout #O Output sigmas int nc, nl #I Number of columns and lines int nl1, nl2 #I Lines to compute int navg #I Averaging box half-size int nrej #I Number of high pixels to reject from average int nbkg #I Median background width real var0 #I Variance coefficient for DN^0 term real var1 #I Variance coefficient for DN^1 term real var2 #I Variance coefficient for DN^2 term int nsig #I Sigma box size real lcrsig, hcrsig #I Threshold sigmas outside of object real lobjsig, hobjsig #I Object threshold sigmas int crval #I CR mask value int objval #I Object mask value int i, j, c, c1, c2, c3, c4, l, l1, l2, l3, l4, n1, n2 int navg2, nbkg2, nsig2, plsig, phsig real data, avg, bkg, sigma, losig, hosig real low, high, cravg(), amedr() pointer stack, avgs, bkgs, sigs, work1, work2 pointer ptr1, ptr2, ip, mp, op, pp, ap, sp begin navg2 = (2 * navg + 1) ** 2 nbkg2 = (2 * (navg + nbkg) + 1) ** 2 - navg2 nsig2 = nsig * nsig call smark (stack) call salloc (avgs, nc, TY_REAL) call salloc (bkgs, nc, TY_REAL) call salloc (sigs, nc, TY_REAL) call salloc (work1, navg2, TY_REAL) call salloc (work2, max (nsig2, nbkg2), TY_REAL) if (var0 != 0. && var1 == 0. && var2 ==0.) call amovkr (sqrt(var0), Memr[sigs], nc) avgs = avgs - 1 sigs = sigs - 1 bkgs = bkgs - 1 losig = lobjsig / sqrt (real(navg2-1)) hosig = hobjsig / sqrt (real(navg2-1)) do l = nl1, nl2 { # Compute statistics. l1 = max (1, l-navg-nbkg) l2 = max (1, l-navg) l3 = min (nl, l+navg) l4 = min (nl, l+navg+nbkg) ap = aout + (l - 1) * nc do c = 1, nc { c1 = max (1, c-navg-nbkg) c2 = max (1, c-navg) c3 = min (nc, c+navg) c4 = min (nc, c+navg+nbkg) ptr1 = work1 ptr2 = work2 n1 = 0 n2 = 0 do j = l1, l2-1 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } } do j = l2, l3 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c2-1 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } do i = c2, c3 { if ((j != l || i != c) && Mems[mp] == 0) { Memr[ptr1] = Memr[ip] n1 = n1 + 1 ptr1 = ptr1 + 1 } ip = ip + 1 mp = mp + 1 } do i = c3+1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 mp = mp + 1 } } do j = l3+1, l4 { ip = in + (j - 1) * nc + c1 - 1 mp = pin + (j - 1) * nc + c1 - 1 do i = c1, c4 { if (Mems[mp] == 0) { Memr[ptr2] = Memr[ip] n2 = n2 + 1 ptr2 = ptr2 + 1 } ip = ip + 1 } } if (n1 > 0) avg = cravg (Memr[work1], n1, nrej) else avg = INDEFR if (n2 > 0) bkg = amedr (Memr[work2], n2) else bkg = INDEFR Memr[bkgs+c] = bkg Memr[avgs+c] = avg if (aout != NULL) { if (IS_INDEFR(avg) || IS_INDEFR(bkg)) Memr[ap] = 0. else Memr[ap] = avg - bkg ap = ap + 1 } } # Compute sigmas and output if desired. if (var0 != 0. || var1 != 0. || var2 != 0.) { if (var1 != 0.) { if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0+var1*data+var2*data**2) } } else { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var1 * data) } } } else if (var2 != 0.) { do c = 1, nc { data = max (0., Memr[avgs+c]) Memr[sigs+c] = sqrt (var0 + var2 * data**2) } } } else { # Compute sigmas from percentiles. This is done in blocks. if (mod (l-nl1, nsig) == 0 && l 10) { call asrtr (Memr[work2], Memr[work2], n2) plsig = nint (PLSIG*n2/100.-1) phsig = nint (PHSIG*n2/100.-1) sigma = (Memr[work2+phsig]-Memr[work2+plsig])/2. } else sigma = INDEFR call amovkr (sigma, Memr[sigs+c], nsig) } call amovkr (sigma, Memr[sigs+c], nc-c+1) } } if (sout != NULL) { sp = sout + (l - 1) * nc do c = 1, nc { sigma = Memr[sigs+c] if (IS_INDEFR(sigma)) Memr[sp] = 0. else Memr[sp] = sigma sp = sp + 1 } } # Detect, fix, and flag cosmic rays. if (pout == NULL && out == NULL) ; if (pout == NULL) { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc op = out + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Memr[op] = avg else Memr[op] = data } } else Memr[op] = data ip = ip + 1 mp = mp + 1 op = op + 1 } } else if (out == NULL) { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) Mems[pp] = objval else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) Mems[pp] = crval } } ip = ip + 1 mp = mp + 1 pp = pp + 1 } } else { ip = in + (l - 1) * nc mp = pin + (l - 1) * nc op = out + (l - 1) * nc pp = pout + (l - 1) * nc do c = 1, nc { data = Memr[ip] avg = Memr[avgs+c] bkg = Memr[bkgs+c] sigma = Memr[sigs+c] if (!(Mems[mp] != 0 || IS_INDEFR(avg) || IS_INDEFR(bkg) || IS_INDEFR(sigma))) { low = bkg - losig * sigma high = bkg + hosig * sigma if (avg < low || avg > high) { Memr[op] = data Mems[pp] = objval } else { low = avg - lcrsig * sigma high = avg + hcrsig * sigma if (data < low || data > high) { Memr[op] = avg Mems[pp] = crval } else Memr[op] = data } } else Memr[op] = data ip = ip + 1 mp = mp + 1 op = op + 1 pp = pp + 1 } } } call sfree (stack) end # CRAVG -- Compute average with the highest nrej points excluded. # When nrej is greater than 2 the data array will be returned sorted. real procedure cravg (data, npts, nrej) real data[npts] #I Input data (will be sorted if nrej>2) int npts #I Number of data points int nrej #I Number of data points to reject int i real sum, max1, max2, val begin if (npts <= nrej) return (INDEFR) switch (nrej) { case 0: sum = 0. do i = 1, npts sum = sum + data[i] case 1: sum = 0. max1 = data[1] do i = 2, npts { val = data[i] if (val > max1) { sum = sum + max1 max1 = val } else sum = sum + val } case 2: sum = 0. max1 = min (data[1], data[2]) max2 = max (data[1], data[2]) do i = 3, npts { val = data[i] if (val > max1) { sum = sum + max1 if (val > max2) { max1 = max2 max2 = val } else max1 = val } else sum = sum + val } default: call asrtr (data, data, npts) sum = 0. do i = 1, npts-nrej sum = sum + data[i] } return (sum / (npts - nrej)) end iraf-xdimsum-main/src/xcraverage/t_crgrow.x000066400000000000000000000072031455666516400213660ustar00rootroot00000000000000include include # T_CRGROW -- Grow cosmic ray mask identifications. procedure t_crgrow () int input # Input masks int output # Output masks real radius # Radius int inval # Input mask value to grow int outval # Output grown mask value char inmask[SZ_FNAME], outmask[SZ_FNAME] pointer envp, im, ptr int imtopenp(), imtlen(), imtgetim() int envputs(), envfree() bool strne() int clgeti() real clgetr() pointer immap() errchk immap, crgrow begin # Task parameters. input = imtopenp ("input") output = imtopenp ("output") radius = max (0., clgetr ("radius")) inval = clgeti ("inval") outval = clgeti ("outval") if (imtlen (output) != imtlen (input)) call error (1, "Input and output lists do not match") # Set output type to be masks. call envmark (envp) if (envputs ("imtype", "pl") == 0) ; # Grow the cosmic ray masks. while (imtgetim (input, inmask, SZ_FNAME) != EOF) { call strcpy (inmask, outmask, SZ_FNAME) if (imtgetim (output, outmask, SZ_FNAME) == EOF) call error (1, "Output list ended prematurely") if (strne (inmask, outmask)) { iferr (call imcopy (inmask, outmask)) { call erract (EA_WARN) next } } if (radius < 1.) next iferr { im = NULL ptr = immap (outmask, READ_WRITE, 0); im = ptr call crgrow (im, radius, inval, outval) } then { call erract (EA_WARN) if (strne (inmask, outmask)) { if (im != NULL) { call imunmap (im) iferr (call imdelete (outmask)) call erract (EA_WARN) } } } if (im != NULL) call imunmap (im) } if (envfree (envp, 0) == 0) ; call imtclose (output) call imtclose (input) end # CRGROW -- Grow cosmic rays. procedure crgrow (im, grow, inval, outval) pointer im # Mask pointer (Read/Write) real grow # Radius (pixels) int inval # Input mask value for pixels to grow int outval # Output mask value for grown pixels int i, j, k, l, nc, nl, ngrow, nbufs, val1, val2 long v1[2], v2[2] real grow2, y2 pointer , buf, buf1, buf2, ptr int imgnli(), impnli() errchk calloc, imgnli, impnli begin if (grow < 1. || inval == 0) return grow2 = grow * grow ngrow = int (grow) buf = NULL iferr { if (IM_NDIM(im) > 2) call error (1, "Only one or two dimensional masks are allowed") nc = IM_LEN(im, 1) if (IM_NDIM(im) > 1) nl = IM_LEN(im,2) else nl = 1 # Initialize buffering. nbufs = min (1 + 2 * ngrow, nl) call calloc (buf, nc*nbufs, TY_INT) call amovkl (long(1), v1, IM_NDIM(im)) call amovkl (long(1), v2, IM_NDIM(im)) while (imgnli (im, buf1, v1) != EOF) { j = v1[2] - 1 buf2 = buf + mod (j, nbufs) * nc do i = 1, nc { val1 = Memi[buf1] val2 = Memi[buf2] if ((IS_INDEFI(inval) && val1 != 0) || val1 == inval) { do k = max(1,j-ngrow), min (nl,j+ngrow) { ptr = buf + mod (k, nbufs) * nc - 1 y2 = (k - j) ** 2 do l = max(1,i-ngrow), min (nc,i+ngrow) { if ((l-i)**2 + y2 > grow2) next Memi[ptr+l] = -val1 } } } else { if (val2 >= 0) Memi[buf2] = val1 } buf1 = buf1 + 1 buf2 = buf2 + 1 } if (j > ngrow) { while (impnli (im, buf2, v2) != EOF) { k = v2[2] - 1 buf1 = buf + mod (k, nbufs) * nc do i = 1, nc { val1 = Memi[buf1] if (val1 < 0) { if (IS_INDEFI(outval)) Memi[buf2] = -val1 else Memi[buf2] = outval } else Memi[buf2] = val1 Memi[buf1] = 0. buf1 = buf1 + 1 buf2 = buf2 + 1 } if (j != nl) break } } } } then call erract (EA_ERROR) if (buf != NULL) call mfree (buf, TY_INT) end iraf-xdimsum-main/src/xdshifts.cl000066400000000000000000000156711455666516400174040ustar00rootroot00000000000000# Compute the relative shifts by marking common objects on the image display. procedure xdshifts (inlist, refim, shiftlist, cradius) string inlist {prompt="List of input sky subtracted images"} string refim {prompt="Reference image in image list"} string shiftlist {prompt="The output shifts list"} real cradius {5.0, prompt="The centering radius in pixels"} real datamin {INDEF, prompt="Lower good data limit"} real datamax {INDEF, prompt="Upper good data limit"} real background {INDEF, prompt="Mean background level for centroiding"} int niterate {3, prompt="The maximum number of centering iterations"} real maxshift {5.0, prompt="The maximum X and Y shift in pixels"} bool chkshifts {no,prompt="Check new shifts interactively ?"} int nframes {4, prompt="Number of frames for imexamine"} struct *imglist begin # Declare local variables. real tcradius, xx, yy, x0, y0 int nimages, i, tboxsize, nshifts string trefim, tshiftlist string im_lst, exam_lst, align_lst, stars_lst, temp1, temp2 im_lst = mktemp ("tmp$xdshifts") temp1 = mktemp ("tmp$xdshifts") temp2 = mktemp ("tmp$xdshifts") # Create the input image list and get the reference image name shiflist name. sections (inlist, option="fullname", > im_lst) count (im_lst) | scan (nimages) trefim = refim if (trefim == "") { imglist = im_lst if (fscan (imglist, trefim) == EOF) { trefim = "" } } if (! imaccess (trefim)) { print ("Reference image ", trefim, " does not exist") delete (im_lst, verify-) return } tshiftlist = shiftlist if (access (tshiftlist)) { print ("Output shifts file ", tshiftlist, " already exist") delete (im_lst, verify-) return } tcradius = cradius # Create some temporary files. exam_lst = tshiftlist // ".exam" align_lst = tshiftlist // ".align" stars_lst = tshiftlist // ".stars" # Initialize display and imexamine tasks. Don't like having to do this but # there is not an easy way around it except to save set and restore all the # parameters. unlearn ("rimexam") rimexam.fittype="gaussian" rimexam.radius = tcradius rimexam.rplot = 2.0 * tcradius unlearn ("display") # Now make the shifts list interactively. #print ("------Making the shiftlist--------------------------------") # Examine the images a choose a registration star. print (" ") print ("Examine images ...") print (" Select reference star which is present in all images") print (" Type n key to display next image") print (" Type p key to display previous image") print (" Type q key to quit") print (" ") imexamine ("@" // im_lst, 1, "", logfile="", keeplog-, defkey="a", autoredraw+, allframes+, nframes=nframes, ncstat=5, nlstat=5, graphcur="", imagecur="", wcs="logical", xformat="", yformat="", graphics="stdgraph", use_display+, display="display(image='$1',frame=$2, fill=yes, >& 'dev$null')") # Measure the position of the reference star in each image. print (" ") print ("Determine relative shifts using above reference star ...") print (" Move cursor to the selected star") print (" Type a key to measure the selected star") print (" Type n key to move to the next image") print (" Type q key to quit") print (" ") if (access (exam_lst)) delete (exam_lst, verify-) imexamine ("@" // im_lst, 1, "", logfile=exam_lst, keeplog+, defkey="a", autoredraw+, allframes+, nframes=nframes, ncstat=5, nlstat=5, graphcur="", imagecur="", wcs="logical", xformat="", yformat="", graphics="stdgraph", use_display+, display="display(image='$1',frame=$2,fill=yes, >& 'dev$null')") if (chkshifts) edit (exam_lst) # Select a set of reference image registration stars but make sure the # first star measured is the registration star. print (" ") print ("Select reference image registration stars ...") print (" Move to reference star measured previously") print (" Type a to measure reference star") print (" Move to other promising looking stars") print (" Type a to measure other registration stars") print (" Type q key to quit") print (" ") if (access (stars_lst)) delete (stars_lst, verify-) imexamine (trefim, 1, "", logfile=stars_lst, keeplog+, defkey="a", autoredraw+, allframes+, nframes=nframes, ncstat=5, nlstat=5, graphcur="", imagecur="", wcs="logical", xformat="", yformat="", graphics="stdgraph", use_display+, display="display(image='$1',frame=$2,fill=yes, >& 'dev$null')") if (chkshifts) edit (stars_lst) # Format the reference star list so that it is suitable for input to # imcentroid. Save the coordinates of the registration star in the reference # image in x0 and y0. i = 0; xx = 0; yy = 0 imglist = stars_lst while (fscan (imglist, xx, yy) != EOF) { if (nscan() == 2) { if (i == 0) { x0 = xx y0 = yy i = i + 1 } print (xx, yy, >> temp2) } } imglist = "" # Compute an initial shifts list suitable for input to the imcentroid task. # The shifts file can only be created if the reference star coordinates # were determined in the previous step. if (i != 0) { imglist = exam_lst while (fscan (imglist, xx, yy) != EOF) { if (nscan() == 2) { xx = x0 - xx yy = y0 - yy print (xx, yy, >> temp1) } } imglist = "" } # Compute the shifts using the imcentroid task. if (! access (temp1)) { print ("The shifts file for centroiding is missing") } else if (! access (temp2)) { print ("The reference coordinates file for centroiding is missing") } else { tboxsize = 2 * int (tcradius) + 1 if (access (align_lst)) delete (align_lst, verify-) imcentroid ("@" // im_lst, trefim, temp2, shifts=temp1, boxsize=tboxsize, bigbox=13, negative=no, background=background, lower=datamin, upper=datamax, niterate=niterate, tolerance=0, maxshift=maxshift, verbose-, >& align_lst) delete (temp1, verify=no) delete (temp2, verify=no) # Reverse the sense of the shifts to those expected by the xdimsum xnregistar # task. imglist = align_lst nshifts = 0 while (fscan (imglist, temp1) != EOF) { temp2 = substr (temp1, 1, 7) if (temp2 == "#Shifts") { while (fscan (imglist, temp1, xx, temp2, yy) != EOF) { if (nshifts >= nimages) break if (temp1 == "" || temp1 == "#Trim_Section") break printf ("%s %0.3f %0.3f 1.0\n", temp1, -xx, -yy, >> tshiftlist) nshifts = nshifts + 1 } } } if (chkshifts) { edit (tshiftlist) count (tshiftlist) | scan (nshifts) if (nimages != nshifts) print ("Warning: The number of shifts != to number of images") } else if (nimages != nshifts) { print ("Warning: The number of shifts != to number of images") } } imglist = "" delete (exam_lst, verify=no) delete (align_lst, verify=no) delete (stars_lst, verify=no) delete (im_lst, verify=no) end iraf-xdimsum-main/src/xdsrc/000077500000000000000000000000001455666516400163415ustar00rootroot00000000000000iraf-xdimsum-main/src/xdsrc/maskinterp.x000066400000000000000000000031611455666516400207100ustar00rootroot00000000000000include procedure t_maskinterp () char image[SZ_FNAME] # Image to correct char bpimage[SZ_FNAME] # Bad pixel mask image int ibadvalue # Value for bad pixels int i, ii, j, nc, nl, ilastgood, clgeti() real val, lastgood, delta bool gooddata pointer im, bp, imin, imout, bpin, immap(), imgl2r(), impl2r(), imgl2s() begin call clgstr ("image", image, SZ_FNAME) call clgstr ("bpimage", bpimage, SZ_FNAME) ibadvalue = clgeti ("badvalue") im = immap (image, READ_WRITE, 0) bp = immap (bpimage, READ_ONLY, 0) nc = IM_LEN(im,1) nl = IM_LEN(im,2) if (IM_LEN(bp,1) != nc || IM_LEN(bp,2) != nl) call error (1, "Image and mask files have mismatched dimensions.") do j = 1, nl { imin = imgl2r (im, j) imout = impl2r (im, j) bpin = imgl2s (bp, j) # Assume that we start off with good data. gooddata = true lastgood = 0. ilastgood = 0 do i = 1, nc { val = Memr[imin+i-1] if (Mems[bpin+i-1] == ibadvalue) { # Bad pixel... if (gooddata) gooddata = false if (i == nc && ilastgood != 0) { do ii = ilastgood+1, nc # ...at end of row... Memr[imin+ii-1] = lastgood } } else { if (!gooddata) { if (ilastgood == 0) { do ii = 1, i-1 # ...at start of row... Memr[imin+ii-1] = val } else { # ...interpolate... delta = (val - lastgood) / (i - ilastgood) do ii = ilastgood+1, i-1 Memr[imin+ii-1] = lastgood + (ii - ilastgood) * delta } gooddata = true } lastgood = val ilastgood = i } } call amovr (Memr[imin], Memr[imout], nc) } call imunmap (bp) call imunmap (im) end iraf-xdimsum-main/src/xdsrc/mkpkg000066400000000000000000000003361455666516400173770ustar00rootroot00000000000000# Make the XDIMSUM Package $checkout libpkg.a ../.. $update libpkg.a $checkin libpkg.a ../.. $exit libpkg.a: maskinterp.x t_avshift.x mptools.x ; iraf-xdimsum-main/src/xdsrc/mptools.x000066400000000000000000000303271455666516400202340ustar00rootroot00000000000000include include include include include # MP_OPEN -- Open the specified mask for image i/o # # Open the specified pixel mask. The input pixel mask specification may be # # "" The mask is undefined # # "EMPTY" The mask is undefined # # "!KEYWORD" The mask is the pixel mask pointed to by the reference # image header keyword KEYWORD # "!^KEYWORD" The mask is inverse of the pixel mask pointed to by the # reference image header keyword KEYWORD # "MASK" The mask is a pixel mask or image # # "^MASK" The mask is inverse of the pixel mask or image # # "EXPR" The mask is specified by a boolean expression # # "@FILE" The mask is specified by the boolean expression in # the text file FILE # # The input mask specification is transformed into a simple 0 and 1 mask # internally where 0 is the pass value and 1 is the stop value. The format # of the expression is still a TBD but I would eventually like to support # a boolean algebra that supports boolean combination of existing masks, # simple image expressions as in the IMEXPR task, and regions descriptors # similar to those defined in the PROS XRAY package. The latter have the # problem in that they must be limited to 2D images (box, rectangle, ellipse, # annulus, wedge, etc). It maybe possible to expand this to 3D in some cases, # e.g. cubes, spheres, ellipsoids etc although dealing with the angles may # become complicated. At any rate I will put aside the issue of on the fly # mask generation for the moment. If a section is specified on the input # image but not on the mask image then imio/mio will automatically track # the proper section in the mask. Is a section is specified on the mask # that section of the mask will be used. It must correspond in size to # the input image or image section. pointer procedure mp_open (pmsource, refim, pmname, sz_pmname) char pmsource[ARB] #I the pixel mask specificiation pointer refim #I the reference image pointer char pmname[ARB] #O the pixel mask name int sz_pmname #I the maximum pixel name length pointer sp, fname, kfname pointer pmim, pm int ip, flags, invflag pointer im_pmmap(), mp_pmmap() int imaccess(), imstati() bool streq() errchk im_pmmap(), mp_pmmap(), imgstr() begin call smark (sp) call salloc (fname, SZ_FNAME, TY_CHAR) call salloc (kfname, SZ_FNAME, TY_CHAR) # Remove leading whitespace from the pixel source specification. ip = 1 while (IS_WHITE(pmsource[ip])) ip = ip + 1 call strcpy (pmsource[ip], Memc[fname], SZ_FNAME) flags = 0 pmname[1] = EOS # If the mask is undefined specify an empty mask. if (Memc[fname] == EOS || streq (Memc[fname], "EMPTY")) { ifnoerr (pmim = im_pmmap ("EMPTY", READ_ONLY+BOOLEAN_MASK, refim)) { call strcpy ("EMPTY", pmname, sz_pmname) pm = imstati (pmim, IM_PMDES) call mp_invert (pm) call imseti (pmim, IM_PMDES, pm) } else pmim = NULL # If the mask specification is a keyword. } else if (Memc[fname] == '!') { # Invert the specified mask. Note there is a bug in the # invert mask flag which needs to be worked around. ip = 1 if (Memc[fname+ip] == '^') { ip = ip + 1 flags = BOOLEAN_MASK invflag = NO } else { #flags = INVERT_MASK + BOOLEAN_MASK flags = BOOLEAN_MASK invflag = YES } # Find the mask name. ifnoerr (call imgstr (refim, Memc[fname+ip], Memc[kfname], SZ_FNAME)) { iferr (pmim = mp_pmmap (Memc[kfname], refim, flags, invflag)) { pmim = NULL } else if (invflag == NO) { call strcpy ("^", pmname, sz_pmname) call strcat (Memc[kfname], pmname, sz_pmname) } else { call strcpy (Memc[kfname], pmname, sz_pmname) } } else pmim = NULL # If the mask specification is a mask / or image file. } else if (imaccess (Memc[fname], READ_ONLY) == YES) { #flags = BOOLEAN_MASK+INVERT_MASK flags = BOOLEAN_MASK invflag = YES call strcpy (Memc[fname], pmname, sz_pmname) iferr (pmim = mp_pmmap (Memc[fname], refim, flags, invflag)) pmim = NULL else call strcpy (Memc[fname], pmname, sz_pmname) } else if (Memc[fname] == '^') { if (imaccess (Memc[fname+1], READ_ONLY) == YES) { flags = BOOLEAN_MASK invflag = NO call strcpy (Memc[fname], pmname, sz_pmname) iferr (pmim = mp_pmmap (Memc[fname+1], refim, flags, invflag)) pmim = NULL else call strcpy (Memc[fname], pmname, sz_pmname) } else pmim = NULL } else { pmim = NULL } call sfree (sp) return (pmim) end # MP_PMMAP - Open a pixel mask READ_ONLY. The input mask may be a pixel # list image or a non-pixel list image. The invflag is temporary, put into # deal with the fact that mio has a bug in this flag. pointer procedure mp_pmmap (pmname, refim, flags, invflag) char pmname[ARB] #I the pixel list or image name pointer refim #I the reference image descriptor int flags #I the pixel list or image flags int invflag #I invert mask flag, remove when pmio fixed pointer sp, section, pmim, pm, tmp_refim int use_section pointer im_pmmap(), mp_immap() int imstati() errchk im_pmmap(), mp_immap() begin # Does the pmname include an image section. call smark (sp) call salloc (section, SZ_FNAME, TY_CHAR) call imgsection (pmname, Memc[section], SZ_FNAME) if (Memc[section] == EOS) { use_section = NO tmp_refim = refim } else { use_section = YES tmp_refim = NULL } # Open the mask as a pixel list. ifnoerr (pmim = im_pmmap (pmname, READ_ONLY+flags, tmp_refim)) { if (use_section == YES) call mp_section (pmim) if (invflag == YES) { pm = imstati (pmim, IM_PMDES) call mp_invert (pm) call imseti (pmim, IM_PMDES, pm) } # Open the mask as an image file. } else ifnoerr (pmim = mp_immap (pmname)) { if (invflag == YES) { pm = imstati (pmim, IM_PMDES) call mp_invert (pm) call imseti (pmim, IM_PMDES, pm) } } else { pmim = NULL } call sfree (sp) return (pmim) end # MP_IMMAP -- Map an image as a pixel file pointer procedure mp_immap (pmname) char pmname[ARB] #I the pixel list or image name pointer sp, v1, v2, im, pm, data, pmim int ndim, npix pointer immap(), pm_newmask(), im_pmmapo() int imgnli() begin call smark (sp) call salloc (v1, IM_MAXDIM, TY_LONG) call salloc (v2, IM_MAXDIM, TY_LONG) call amovkl (long(1), Meml[v1], IM_MAXDIM) call amovkl (long(1), Meml[v2], IM_MAXDIM) # Open the input image. im = immap (pmname, READ_ONLY, 0) ndim = IM_NDIM(im) npix = IM_LEN(im,1) # Open the mask with a depth of 1 bit. pm = pm_newmask (im, 1) # Copy the image to a mask. while (imgnli (im, data, Meml[v1]) != EOF) { # may need to convert negative values here ... call pm_plpi (pm, Meml[v2], Memi[data], 0, npix, PIX_SRC) call amovl (Meml[v1], Meml[v2], ndim) } call imunmap (im) pmim = im_pmmapo (pm, NULL) call sfree (sp) return (pmim) end # MP_SECTION -- Create the a new mask from the specified mask section. procedure mp_section (pmim) pointer pmim #U mask image descriptor pointer newpm, newpmim, sp, v1, v2, ibuf pointer pl_create(), im_pmmapo() int ndim, depth, npix int imgnls() begin call smark (sp) call salloc (v1, IM_MAXDIM, TY_LONG) call salloc (v2, IM_MAXDIM, TY_LONG) call amovkl (long(1), Meml[v1], IM_MAXDIM) call amovkl (long(1), Meml[v2], IM_MAXDIM) ndim = IM_NDIM(pmim) depth = 1 npix = IM_LEN(pmim,1) newpm = pl_create (ndim, IM_LEN(pmim,1), depth) while (imgnls (pmim, ibuf, Meml[v1]) != EOF) { call pm_plps (newpm, Meml[v2], Mems[ibuf], 1, npix, PIX_SRC) call amovl (Meml[v1], Meml[v2], ndim) } call imunmap (pmim) newpmim = im_pmmapo (newpm, NULL) pmim = newpmim call sfree (sp) end # MP_MPCOPY -- Copy the input to the output mask setting the mapping # parameters appropriately procedure mp_mpcopy (im, pmim, pmout) pointer im #I the input image descriptor pointer pmim #I the input mask descriptor pointer pmout #I the output mask descriptor pointer sp, axlen, v, oldpm, newpm int naxes, depth pointer pl_create() int imstati(), mp_samesize() int pm_stati() int refim, mapstat begin call smark (sp) call salloc (axlen, IM_MAXDIM, TY_LONG) call salloc (v, IM_MAXDIM, TY_LONG) # Create new mask. oldpm = imstati (pmim, IM_PLDES) call pl_gsize (oldpm, naxes, Meml[axlen], depth) newpm = pl_create (naxes, Meml[axlen], depth) # Store old values of the input mask reference image and mapping # descriptors here. Maybe ... refim = pm_stati (oldpm, P_REFIM) mapstat = pm_stati (oldpm, P_MAPXY) # Set the input mask mapping parameters. call pm_seti (oldpm, P_REFIM, im) if (mp_samesize (im, pmim) == YES) call pm_seti (oldpm, P_MAPXY, NO) # Restore old values of the input mask reference image and mapping # descriptors here. Maybe ... # Store old values of the output reference image and mapping descriptors # here. Don't need to do this since this is the desired behavior. # Set the input mask mapping parameters. call pm_seti (newpm, P_REFIM, im) if (mp_samesize (im, pmim) == YES) call pm_seti (newpm, P_MAPXY, NO) # Restore old values of the output mask reference image and mapping # descriptors here. Don't need to do this since this is the # desired behavior. # Copy the input to the output mask using the mapping parameters # as appropriate call amovkl (long(1), Meml[v], IM_MAXDIM) call pm_rop (oldpm, Meml[v], newpm, Meml[v], Meml[axlen], PIX_SRC) call imseti (pmout, IM_PLDES, newpm) call sfree (sp) end # MP_MIOPEN - Open an mio descriptor and set the mapping parameters # appropriately. This should be done by doing pm_stati calls on # the pm descriptor via the P_REFIM and P_MAPXY parameters and the # corresponding PRIVATE1 / PRIVATE2 parameters in plio but this # mechanism is not working at present. For now test im / pmim for # equality in number of dimensions and size. pointer procedure mp_miopen (im, pmim) pointer im #I the input image descriptor pointer pmim #I the input mask image descriptor pointer pm, mp int samesize pointer mio_openo() int imstati(), mp_samesize() begin # Open the pixel mask. pm = imstati (pmim, IM_PLDES) # Open the mio descriptor which set the mapping status using # the image descriptor, i.e. the mapping status is yes if the # image was opened with a section. mp = mio_openo (pm, im) # Turn off mapping if the image and mask are exactly the same # size. samesize = mp_samesize (im, pmim) if (samesize == YES) call pm_seti (pm, P_MAPXY, NO) return (mp) end # MP_SAMESIZE -- Return YES if the image and mask are the same size. int procedure mp_samesize (im, pmim) pointer im #I the input image descriptor pointer pmim #I the input image descriptor int i, samesize begin if (IM_NDIM(im) == IM_NDIM(pmim)) { samesize = YES do i = 1, IM_NDIM(im) { if (IM_LEN(im,i) == IM_LEN(pmim,i)) next samesize = NO break } } else { samesize = NO } return (samesize) end # MP_INVERT -- Invert a pixel mask. procedure mp_invert (pm) pointer pm #U plio descriptor pointer sp, axlen, v, newpm int naxes, depth pointer pl_create() begin # Allocate some working space. call smark (sp) call salloc (axlen, IM_MAXDIM, TY_LONG) call salloc (v, IM_MAXDIM, TY_LONG) # Get pixel mask characteristics. call pl_gsize (pm, naxes, Meml[axlen], depth) # Create the new inverted mask. newpm = pl_create (naxes, Meml[axlen], depth) call amovkl (long(1), Meml[v], IM_MAXDIM) call pl_rop (pm, Meml[v], newpm, Meml[v], Meml[axlen], PIX_NOT(PIX_SRC)) # Close the old mask and update the mask pointer. call pl_close (pm) pm = newpm call sfree (sp) end # MP_COPY -- Make a copy of an existing pixel mask. pointer procedure mp_copy (oldpm) pointer oldpm #I old pixel mask pointer pointer sp, axlen, v, newpm int naxes, depth pointer pl_create() begin call smark (sp) call salloc (axlen, IM_MAXDIM, TY_LONG) call salloc (v, IM_MAXDIM, TY_LONG) call pl_gsize (oldpm, naxes, Meml[axlen], depth) newpm = pl_create (naxes, Meml[axlen], depth) call amovkl (long(1), Meml[v], IM_MAXDIM) call pl_rop (oldpm, Meml[v], newpm, Meml[v], Meml[axlen], PIX_SRC) call sfree (sp) return (newpm) end iraf-xdimsum-main/src/xdsrc/t_avshift.x000066400000000000000000000022011455666516400205140ustar00rootroot00000000000000# T_AVSHIFT -- Compute the average shifts between the reference coordinates # in pixels (columns 1 and 2) and the input coordinates in pixels (columns # 3 and 4). procedure t_avshift() double sumdx, sumdy real x1, y1, x2, y2, dx, dy pointer sp, input int fd, npts int open(), fscan(), nscan() begin call smark (sp) call salloc (input, SZ_FNAME, TY_CHAR) call clgstr ("input", Memc[input], SZ_FNAME) fd = open (Memc[input], READ_ONLY, TEXT_FILE) # Loop over the coordinates. npts = 0 sumdx = 0.0d0 sumdy = 0.0d0 while (fscan (fd) != EOF) { call gargr (x1) call gargr (y1) call gargr (x2) call gargr (y2) if (nscan() < 4) next npts = npts + 1 sumdx = sumdx + (x1 - x2) sumdy = sumdy + (y1 - y2) } # Compute the average shift. if (npts == 0) { call printf ("INDEF INDEF 0\n") } else if (npts == 1) { dx = sumdx dy = sumdy call printf ("%g %g 1\n") call pargr (dx) call pargr (dy) } else { dx = sumdx / npts dy = sumdy / npts call printf ("%g %g %d\n") call pargr (dx) call pargr (dy) call pargi (npts) } call close (fd) call sfree (sp) end iraf-xdimsum-main/src/xfirstpass.cl000066400000000000000000000256731455666516400177610ustar00rootroot00000000000000# Combine the input images into a single mosaic after sky subtraction, bad pixel # corrections, and cosmic ray cleaning. Object masks are not used in the first # pass. The output is a list of sky subtracted, bad pixel cleaned, and cosmic # ray cleaned images, a list of cosmic ray masks, and the combined image # and associated exposure map image. A file describing the position of the # input images in the output image is also produced. procedure xfirstpass (inlist, reference, output, expmap) # Xfirstpass calls the xdimsum tasks xslm, maskfix, xzap, xnzap, badpixupdate, # xdshifts, xnregistar, and fileroot. # # Xfirstpass also calls the IRAF tasks sections and delete as well as the # CL builtins mktemp and time. string inlist {"", prompt="The list of input images"} string reference {"", prompt="The reference image in input image list"} string output {"", prompt="The output combined image"} string expmap {".exp",prompt="The output exposure map or suffix\n"} string statsec {"",prompt="The image section for computing image stats"} real nsigrej {3.0,prompt="The nsigma rejection for computing image stats"} int maxiter {20, prompt="The maximum number of iterations for image stats\n"} bool xslm {yes,prompt="Do the sky subtraction step?"} string sslist {".sub",prompt="The output sky subtracted image list or suffix"} bool newxslm {no,prompt="Use new version of xslm ?"} bool forcescale {yes,prompt="Force recalculation of image medians in xslm ?"} int nmean {6,min=1,prompt="Number of images to use for sky image in xslm"} int nskymin {3,min=0,prompt="Minimum number of frames to use for sky image in xslm"} int nreject {1,min=0,prompt="Number of pixels for xslm minmax reject"} bool cache {yes,prompt="Enable cacheing in new version of xslm ?\n"} bool maskfix {yes,prompt="Do the bad pixel correction step ?"} string bpmask {"",prompt="The input bad pixel mask"} bool forcefix {yes,prompt="Force bad pixel fixing in maskfix ?\n"} bool xzap {yes,prompt="Do the cosmic ray correction step ?"} string crmasks {".crm",prompt="The output cosmic ray mask list or suffix"} bool newxzap {no,prompt="Use new version of xzap ?"} bool badpixupdate {yes,prompt="Update bad pixel mask ?"} int nrepeats {3,prompt="Number of repeats for bad status ?\n"} bool mkshifts {no,prompt="Determine the shiftlist interactively ?"} bool chkshifts {yes,prompt="Check the new shifts ?"} real cradius {5.0, prompt="Centroiding radius in pixels for mkshifts"} real maxshift {5.0, prompt="Maximum centroiding shift in pixels for mkshifts\n"} bool xnregistar {yes,prompt="Do the image combining step ?"} string shiftlist {"",prompt="The input / output shift file"} string sections {".corners", prompt="The output sections list file or suffix"} bool fractional {no, prompt="Do fractional shifts in xnregistar step ?"} bool pixin {yes,prompt="Are input coords in reference object pixels ?"} bool ab_sense {yes,prompt="Is A through B axis rotation counterclockwise ?"} real xscale {1.,prompt="X pixels per A coordinate unit"} real yscale {1.,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.0,prompt="Angle in degrees from A CCW to X"} int ncoavg {1,min=1,prompt="Number of internal coaverages per frame"} real secpexp {1.0,prompt="Seconds per unit exposure time"} real y2n_angle {0.,prompt="Angle in degrees from Y to N N through E"} bool rotation {yes,prompt="Is N through E CCW ?\n"} struct *imglist struct *shlist begin int ifile, nin, nref string itlist, stlist, trefim, ctlist, toutput, img, j1, j2, j3, j4 string texpmap, tsections, tsslist, tcrmasks, ushiftlist print ("start xfirstpass") time("") print("") # Create temporary files. itlist = mktemp ("tmp$xfirstpass") stlist = mktemp ("tmp$xfirstpass") ctlist = mktemp ("tmp$xfirstpass") ushiftlist = mktemp ("tmp$xfirstpass") # Get query parameters. sections (inlist, option="fullname", > itlist) nin = sections.nimages trefim = reference tsslist = sslist tcrmasks = crmasks toutput = output texpmap = expmap if (substr (texpmap, 1, 1) == ".") { fileroot (toutput, validim+) texpmap = fileroot.root // texpmap if (fileroot.extension != "") texpmap = texpmap // "." // fileroot.extension } tsections = sections if (substr (tsections, 1, 1) == ".") { fileroot (toutput, validim+) tsections = fileroot.root // tsections } # Create temporary list of filenames for sky subtracted output files and # determine the name of the reference image in the output sky subtracted # image list. if (substr (tsslist, 1, 1) == ".") { if (trefim != "") { fileroot (trefim, validim+) trefim = fileroot.root // tsslist } imglist = itlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tsslist print (img, >> stlist) } } else { sections (tsslist, option="fullname", > stlist) if (nin != sections.nimages) { print ("Error: Input and sky subtracted image lists do not match") delete (itlist, ver-) delete (stlist, ver-) return } if (trefim != "") { fileroot (trefim, validim+) trefim = fileroot.root ifile = 0 imglist = itlist while (fscan (imglist, img) != EOF) { ifile += 1 fileroot (img, validim+) img = fileroot.root if (img == trefim) break } nref = ifile if (nref == 0) { trefim = "" } else { ifile = 0 imglist = stlist while (fscan (imglist, img) != EOF) { ifile += 1 if (ifile != nref) next fileroot (img, validim+) trefim = fileroot.root break } } } } # Create temporary list of filenames for the cosmic ray masks. if (substr (tcrmasks, 1, 1) == ".") { imglist = stlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tcrmasks // ".pl" print (img, >> ctlist) } } else { sections (tcrmasks, option="fullname", > ctlist) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } } # Call xslm, maskfix, xzap, badpixupdate, and xnregistar. if (xslm) { print ("Begin first pass sky subtraction") time("") print("-------Sky subtracting images with xslm--------------") if (newxslm) { xnslm ("@" // itlist, "", nmean, "@" // stlist, hmasks=".hom", forcescale=forcescale, useomask=no, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, cache=cache, del_hmasks=no) } else { xslm ("@" // itlist, "", nmean, "@" // stlist, ssmasks=".ssm", hmasks=".hom", forcescale=forcescale, useomask=no, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, del_ssmasks=yes, del_hmasks=no) } print("") } if (maskfix) { print ("Begin first pass bad pixel correction") time("") print("-------Correcting bad pixels with maskfix------------") if (bpmask == "") { print ("Error: The bad pixel image is undefined") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } maskfix ("@" // stlist, bpmask, 0, forcefix=forcefix) print("") } if (xzap) { print ("Begin first pass cosmic ray removal") time("") if (newxzap) { print("-------Zapping cosmic rays using xnzap -------------") xnzap ("@" // stlist, "", "@" // stlist, "@" // ctlist, zboxsz=5, skyfiltsize=15, sigfiltsize=25, nsigzap=5.0, nsigneg=0.0, nrejzap=1, nrings=0, nsigobj=5.0, ngrowobj=0, del_crmask=no, verbose=no) } else { print("-------Zapping cosmic rays using xzap -------------") xzap ("@" // stlist, "", "@" // stlist, "@" // ctlist, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, checklimits+, zboxsz=5, zmin=-32768.0, zmax=32767.0, nsigzap=5.0, nsigobj=2.0, subsample=2, skyfiltsize=15, ngrowobj=0, nrings=0, nsigneg=0.0, del_crmask=no, del_wmasks=yes, del_wimages=yes, verbose=no) } print("") if (badpixupdate) { print ("Begin first pass bad pixel mask update") time("") if (bpmask == "") { print ("Error: The bad pixel image is undefined") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } print("-------Updating bad pixel file with badpixupdate ----") badpixupdate ("@" // ctlist, nrepeats, bpmask) print("") } } if (mkshifts) { print ("------- Making the shiftlist---------------------------") if (access (shiftlist)) { print (" The shifts list ", shiftlist, " already exists") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } else { xdshifts ("@" // stlist, trefim, shiftlist, cradius, datamin=INDEF, datamax=INDEF, background=INDEF, niterate=3, maxshift=maxshift, chkshifts=chkshifts) print("") copy (shiftlist, ushiftlist, verbose-) } } else if (! access (shiftlist)) { print (" The shifts list ", shiftlist, " is undefined") delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) return } else { print ("------- Checking the shiftlist---------------------------") imglist = stlist shlist = shiftlist while (fscan (imglist, img) != EOF && fscan (shlist, j1, j2, j3, j4) != EOF) { print (img, " ", j2, " ", j3, " ", j4, >> ushiftlist) } } if (xnregistar) { print ("Begin first pass image combining") time("") if (shiftlist == "") { print("-------The shifts file is undefined ----------------") } else if (! access (shiftlist)) { print("-------The shifts file does not exist --------------") } else { print("------- Creating rejection masks using xmskcombine --") xmskcombine ("@" // stlist, bpmask, "", "", "", ".rjm", nprev_omask=0) print("-------Coadding images using xnregistar --------------") xnregistar (ushiftlist, "REJMASK", toutput, texpmap, tsections, sinlist="@" // itlist, blkrep=yes, mag=1.0, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation) } print("") } delete (itlist, ver-) delete (stlist, ver-) delete (ctlist, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) imglist = "" shlist = "" print ("finish xfirstpass") time("") end iraf-xdimsum-main/src/xfshifts.cl000066400000000000000000000147021455666516400174000ustar00rootroot00000000000000# Compute accurate shifts for a list of images taken in time sequence with # a known approximate shift between adjacent images using star finding and # list centroiding and matching techniques. procedure xfshifts (inlist, output, shifts, hwhmpsf, threshold, xlag, ylag, cbox) string inlist {prompt="The input sky subtracted image sequence"} string output {prompt="The output img, pixel shifts, and exposure time file"} string shifts {prompt="The optional output relative shifts file"} real hwhmpsf {1.25, prompt="The hwhm of the image psf in pixels"} real threshold {50, prompt="The detection threshold in counts"} real xlag {0.0, prompt="Initial shift in x in pixels"} real ylag {0.0, prompt="Initial shift in y in pixels"} int cbox {7, prompt="The centering box size in pixels"} real fradius {2.5, prompt="Fitting radius in hwhmpsf"} real sepmin {5.0, prompt="Minimum separation in hwhmpsf"} real datamin {INDEF, prompt="Lower good data limit"} real datamax {INDEF, prompt="Upper good data limit"} real background {INDEF, prompt="Mean background level for centroiding"} real roundlo {0.0, prompt="Lower ellipticity limit"} real roundhi {0.5, prompt="Upper ellipticity limit"} real sharplo {0.5, prompt="Lower sharpness limit"} real sharphi {2.0, prompt="Upper sharpness limit"} int niterate {3, prompt="The maximum number of centering iterations"} real maxshift {5.0, prompt="The maximum X and Y shift in pixels"} int nxblock {INDEF, prompt="X dimension of working block size in pixels"} int nyblock {INDEF, prompt="Y dimension of working block size in pixels"} struct *imglist struct *shlist begin real thwhmpsf, tthreshold, txlag, tylag real dx, dy, sumdx, sumdy int tcbox int i, nimages, idx, idy string tinlist, toutput, tshifts string coofiles, inimages, inshifts, img, refimg, cooimg string imcout, shiftsdb, keyword, line bool findshift print ("start") time ("") # Get query parameters. tinlist = mktemp ("tmp$xfshifts") sections (inlist, option="fullname", > tinlist) count (tinlist) | scan (nimages) if (nimages <= 0) { print ("The input image list is empty") delete (tinlist, verify-) return } toutput = output if (access (toutput)) { print ("The output file: ", toutput, " already exists") delete (tinlist, verify-) return } tshifts = shifts if (tshifts != "") { if (access (tshifts)) { print ("The shifts file: ", tshifts, " already exists") delete (tinlist, verify-) return } } thwhmpsf = hwhmpsf tthreshold = threshold txlag = xlag tylag = ylag tcbox = cbox # Contruct temporary file names for xregister. inimages = mktemp ("tmp$xfshifts") coofiles = mktemp ("tmp$xfshifts") inshifts = mktemp ("tmp$xfshifts") imcout = mktemp ("tmp$xfshifts") shiftsdb = mktemp ("tmp$xfshifts") # Construct the output coordinate file list. imglist = tinlist i = 0 while (fscan (imglist, img) != EOF) { i += 1 fileroot (img, validim+) img = fileroot.root delete ("im" // i // ".coo.*", go_ahead+, verify-, >& "dev$null") print ("im" // i // ".coo.1", >> coofiles) } # Find stars in the images. print ("Begin star finding ...") time ("") imglist = tinlist i = 0 while (fscan (imglist, img) != EOF) { i += 1 fileroot (img, validim+) img = fileroot.root #print (" Finding stars in ", img) starfind (img, "im" // i // ".coo.1", thwhmpsf, tthreshold, datamin=datamin, datamax=datamax, fradius=fradius, sepmin=sepmin, npixmin=5, maglo=INDEF, maghi=INDEF, roundlo=roundlo, roundhi=roundhi, sharplo=sharplo, sharphi=sharphi, wcs="logical", wxformat="", wyformat="", boundary="nearest", constant=0.0, nxblock=nxblock, nyblock=nyblock, verbose-) } # Contruct the reference image, input image, and coordinate file list. imglist = tinlist for (i = 1; i <= nimages; i = i + 1) { if (fscan (imglist, img) == EOF) { break } fileroot (img, validim+) img = fileroot.root if (i == 1) { print (img, " ", img, " ", "im1" // ".coo.1", >> inimages) } else { print (refimg, " ", img, " ", "im" // i - 1 // ".coo.1", >> inimages) } refimg = img } # Construct the input shifts file for imcentroid. print (-txlag, -tylag, >> inshifts) # Call imcentroid. print ("Begin list centroiding and computing relative shifts ...") time ("") imglist = inimages i = 1 while (fscan (imglist, refimg, img, cooimg) != EOF) { #print (" Aligning lists in images ", img, " and ", refimg) if (refimg == img) { # Set the shift to zero. print (img, " ", 0.0, " ", 0.0, >& shiftsdb) } else { # Compute the shift. imcentroid (img, refimg, cooimg, shifts=inshifts, boxsize=tcbox, bigbox=tcbox, negative=no, background=background, lower=datamin, upper=datamax, niterate=niterate, tolerance=0, maxshift=maxshift, verbose-, >& imcout) # Record the shift. findshift = no shlist = imcout while (fscan (shlist, line) != EOF) { keyword = substr (line, 1, 7) if (keyword == "#Shifts") { if (fscan (shlist, img, dx, keyword, dy, keyword) != EOF) { print (img, " ", dx, " ", dy, >> shiftsdb) findshift = yes } } } if (! findshift) { print (" Warning shift for image ", img, " is undefined") print (img, " ", -txlag, " ", -tylag, >> shiftsdb) } delete (imcout, verify-, >& "dev$null") } i = i + 1 } # Create the output file to use as input by sregister. Convert the # shifts to integer. print ("Begin accumulating total shifts ...") time ("") sumdx = 0.0 sumdy = 0.0 imglist = shiftsdb while (fscan (imglist, img, dx, dy) != EOF) { sumdx = sumdx - dx sumdy = sumdy - dy if (sumdx == 0.0) { idx = 0 } else { idx = sumdx + (abs (sumdx) / sumdx) * 0.5 } if (sumdy == 0.0) { idy = 0 } else { idy = sumdy + (abs (sumdy) / sumdy) * 0.5 } printf ("%s %0.3f %0.3f 1.0\n", img, sumdx, sumdy, >> toutput) } # Cleanup. if (tshifts != "") { copy (shiftsdb, tshifts, verbose-) } delete (shiftsdb, verify-) delete (inshifts, verify-) delete (inimages, verify-) delete ("@" // coofiles, verify-, go_ahead=yes, default_action=yes, allversions=yes, subfiles=yes, >& "dev$null") delete (coofiles, verify-) delete (tinlist, verify-) shlist = "" imglist = "" print ("finish") time ("") end iraf-xdimsum-main/src/ximstat/000077500000000000000000000000001455666516400167075ustar00rootroot00000000000000iraf-xdimsum-main/src/ximstat/mimstat.h000066400000000000000000000031661455666516400205440ustar00rootroot00000000000000# Header file for the IMSTATMISTICS task. define LEN_MIMSTAT 20 define MIS_SUMX Memd[P2D($1)] define MIS_SUMX2 Memd[P2D($1+2)] define MIS_SUMX3 Memd[P2D($1+4)] define MIS_SUMX4 Memd[P2D($1+6)] define MIS_LO Memr[P2R($1+8)] define MIS_HI Memr[P2R($1+9)] define MIS_MIN Memr[P2R($1+10)] define MIS_MAX Memr[P2R($1+11)] define MIS_MEAN Memr[P2R($1+12)] define MIS_MEDIAN Memr[P2R($1+13)] define MIS_MODE Memr[P2R($1+14)] define MIS_STDDEV Memr[P2R($1+15)] define MIS_SKEW Memr[P2R($1+16)] define MIS_KURTOSIS Memr[P2R($1+17)] define MIS_NPIX Memi[$1+18] define MIS_SW Memi[$1+19] define LEN_NSWITCHES 8 define MIS_SKURTOSIS Memi[$1] define MIS_SSKEW Memi[$1+1] define MIS_SSTDDEV Memi[$1+2] define MIS_SMODE Memi[$1+3] define MIS_SMEDIAN Memi[$1+4] define MIS_SMEAN Memi[$1+5] define MIS_SMINMAX Memi[$1+6] define MIS_SNPIX Memi[$1+7] define MIS_FIELDS "|image|npix|min|max|mean|midpt|mode|stddev|skew|kurtosis|mask|" define MIS_NFIELDS 11 define IS_FIELDS "|image|npix|min|max|mean|midpt|mode|stddev|skew|kurtosis|" define IS_NFIELDS 10 define MIS_KIMAGE "IMAGE" define MIS_KNPIX "NPIX" define MIS_KMIN "MIN" define MIS_KMAX "MAX" define MIS_KMEAN "MEAN" define MIS_KMEDIAN "MIDPT" define MIS_KMODE "MODE" define MIS_KSTDDEV "STDDEV" define MIS_KSKEW "SKEW" define MIS_KKURTOSIS "KURTOSIS" define MIS_KMASK "MASK" define MIS_FIMAGE 1 define MIS_FNPIX 2 define MIS_FMIN 3 define MIS_FMAX 4 define MIS_FMEAN 5 define MIS_FMEDIAN 6 define MIS_FMODE 7 define MIS_FSTDDEV 8 define MIS_FSKEW 9 define MIS_FKURTOSIS 10 define MIS_FMASK 11 define MIS_FCOLUMN "%10d" define MIS_FINTEGER "%10d" define MIS_FREAL "%10.4g" define MIS_FSTRING "%20s" iraf-xdimsum-main/src/ximstat/mimstat.x000066400000000000000000000662421455666516400205700ustar00rootroot00000000000000include include "mimstat.h" # MST_ALLOCATE -- Allocate space for the statistics structure. procedure mst_allocate (mst) pointer mst #O the statistics descriptor begin call calloc (mst, LEN_MIMSTAT, TY_STRUCT) call malloc (MIS_SW(mst), LEN_NSWITCHES, TY_INT) end # MST_FREE -- Free the statistics structure. procedure mst_free (mst) pointer mst #O the statistics descriptor begin call mfree (MIS_SW(mst), TY_INT) call mfree (mst, TY_STRUCT) end # MST_FIELDS -- Procedure to decode the fields string into a list of the # fields to be computed and printed. int procedure mst_fields (fieldstr, fields, max_nfields) char fieldstr[ARB] #I string containing the list of fields int fields[ARB] #O fields array int max_nfields #I maximum number of fields int nfields, flist, field pointer sp, fname int fntopenb(), fntgfnb(), strdic() begin nfields = 0 call smark (sp) call salloc (fname, SZ_FNAME, TY_CHAR) flist = fntopenb (fieldstr, NO) while (fntgfnb (flist, Memc[fname], SZ_FNAME) != EOF && (nfields < max_nfields)) { field = strdic (Memc[fname], Memc[fname], SZ_FNAME, MIS_FIELDS) if (field == 0) next nfields = nfields + 1 fields[nfields] = field } call fntclsb (flist) call sfree (sp) return (nfields) end # MST_SWITCHES -- Set the processing switches. procedure mst_switches (mst, fields, nfields, nclip) pointer mst #I the statistics pointer int fields[ARB] #I fields array int nfields #I maximum number of fields int nclip #I the number of clipping iterations pointer sw int mst_isfield() begin # Initialize. sw = MIS_SW(mst) call amovki (NO, Memi[sw], LEN_NSWITCHES) # Set the computation switches. MIS_SNPIX(sw) = mst_isfield (MIS_FNPIX, fields, nfields) MIS_SMEAN(sw) = mst_isfield (MIS_FMEAN, fields, nfields) MIS_SMEDIAN(sw) = mst_isfield (MIS_FMEDIAN, fields, nfields) MIS_SMODE(sw) = mst_isfield (MIS_FMODE, fields, nfields) if (nclip > 0) MIS_SSTDDEV(sw) = YES else MIS_SSTDDEV(sw) = mst_isfield (MIS_FSTDDEV, fields, nfields) MIS_SSKEW(sw) = mst_isfield (MIS_FSKEW, fields, nfields) MIS_SKURTOSIS(sw) = mst_isfield (MIS_FKURTOSIS, fields, nfields) # Adjust the computation switches. if (mst_isfield (MIS_FMIN, fields, nfields) == YES) MIS_SMINMAX(sw) = YES else if (mst_isfield (MIS_FMAX, fields, nfields) == YES) MIS_SMINMAX(sw) = YES else if (MIS_SMEDIAN(sw) == YES || MIS_SMODE(sw) == YES) MIS_SMINMAX(sw) = YES else MIS_SMINMAX(sw) = NO end # MST_PHEADER -- Print the banner fields. procedure mst_pheader (fields, nfields) int fields[ARB] # fields to be printed int nfields # number of fields int i begin call printf ("#") do i = 1, nfields { switch (fields[i]) { case MIS_FIMAGE: call printf (MIS_FSTRING) call pargstr (MIS_KIMAGE) case MIS_FMASK: call printf (MIS_FSTRING) call pargstr (MIS_KMASK) case MIS_FNPIX: call printf (MIS_FCOLUMN) call pargstr (MIS_KNPIX) case MIS_FMIN: call printf (MIS_FCOLUMN) call pargstr (MIS_KMIN) case MIS_FMAX: call printf (MIS_FCOLUMN) call pargstr (MIS_KMAX) case MIS_FMEAN: call printf (MIS_FCOLUMN) call pargstr (MIS_KMEAN) case MIS_FMEDIAN: call printf (MIS_FCOLUMN) call pargstr (MIS_KMEDIAN) case MIS_FMODE: call printf (MIS_FCOLUMN) call pargstr (MIS_KMODE) case MIS_FSTDDEV: call printf (MIS_FCOLUMN) call pargstr (MIS_KSTDDEV) case MIS_FSKEW: call printf (MIS_FCOLUMN) call pargstr (MIS_KSKEW) case MIS_FKURTOSIS: call printf (MIS_FCOLUMN) call pargstr (MIS_KKURTOSIS) } } call printf ("\n") call flush (STDOUT) end # MST_ISFIELD -- Procedure to determine whether a specified field is one # of the selected fields or not. int procedure mst_isfield (field, fields, nfields) int field #I field to be tested int fields[ARB] #I array of selected fields int nfields #I number of fields int i, isfield begin isfield = NO do i = 1, nfields { if (field != fields[i]) next isfield = YES break } return (isfield) end # MST_INITIALIZE -- Initialize the statistics computation. procedure mst_initialize (mst, lower, upper) pointer mst #I pointer to the statistics structure real lower #I lower good data limit real upper #I upper good data limit begin if (IS_INDEFR(lower)) MIS_LO(mst) = -MAX_REAL else MIS_LO(mst) = lower if (IS_INDEFR(upper)) MIS_HI(mst) = MAX_REAL else MIS_HI(mst) = upper MIS_NPIX(mst) = 0 MIS_SUMX(mst) = 0.0d0 MIS_SUMX2(mst) = 0.0d0 MIS_SUMX3(mst) = 0.0d0 MIS_SUMX4(mst) = 0.0d0 MIS_MIN(mst) = MAX_REAL MIS_MAX(mst) = -MAX_REAL MIS_MEAN(mst) = INDEFR MIS_MEDIAN(mst) = INDEFR MIS_MODE(mst) = INDEFR MIS_STDDEV(mst) = INDEFR MIS_SKEW(mst) = INDEFR MIS_KURTOSIS(mst) = INDEFR end # MST_ACCUMULATE4 -- Accumulate sums up to the fourth power of the data for # data values between lower and upper. procedure mst_accumulate4 (mst, x, npts, lower, upper, minmax) pointer mst #I pointer to the statistics structure real x[ARB] #I the data array int npts #I the number of data points real lower #I lower data boundary real upper #I upper data boundary int minmax #I compute the minimum and maximum ? double xx, xx2, sumx, sumx2, sumx3, sumx4 real lo, hi, xmin, xmax int i, npix begin lo = MIS_LO(mst) hi = MIS_HI(mst) npix = MIS_NPIX(mst) sumx = 0.0 sumx2 = 0.0 sumx3 = 0.0 sumx4 = 0.0 xmin = MIS_MIN(mst) xmax = MIS_MAX(mst) if (IS_INDEFR(lower) && IS_INDEFR(upper)) { npix = npix + npts if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx sumx4 = sumx4 + xx2 * xx2 } } else { do i = 1, npts { xx = x[i] xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx sumx4 = sumx4 + xx2 * xx2 } } } else { if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx npix = npix + 1 xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx sumx4 = sumx4 + xx2 * xx2 } } else { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx sumx4 = sumx4 + xx2 * xx2 } } } MIS_NPIX(mst) = npix MIS_SUMX(mst) = MIS_SUMX(mst) + sumx MIS_SUMX2(mst) = MIS_SUMX2(mst) + sumx2 MIS_SUMX3(mst) = MIS_SUMX3(mst) + sumx3 MIS_SUMX4(mst) = MIS_SUMX4(mst) + sumx4 MIS_MIN(mst) = xmin MIS_MAX(mst) = xmax end # MST_ACCUMULATE3 -- Accumulate sums up to the third power of the data for # data values between lower and upper. procedure mst_accumulate3 (mst, x, npts, lower, upper, minmax) pointer mst #I pointer to the statistics structure real x[ARB] #I the data array int npts #I the number of data points real lower #I lower data boundary real upper #I upper data boundary int minmax #I compute the minimum and maximum ? double xx, xx2, sumx, sumx2, sumx3 real lo, hi, xmin, xmax int i, npix begin lo = MIS_LO(mst) hi = MIS_HI(mst) npix = MIS_NPIX(mst) sumx = 0.0 sumx2 = 0.0 sumx3 = 0.0 xmin = MIS_MIN(mst) xmax = MIS_MAX(mst) if (IS_INDEFR(lower) && IS_INDEFR(upper)) { npix = npix + npts if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx } } else { do i = 1, npts { xx = x[i] xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx } } } else { if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx npix = npix + 1 xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx } } else { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 xx2 = xx * xx sumx = sumx + xx sumx2 = sumx2 + xx2 sumx3 = sumx3 + xx2 * xx } } } MIS_NPIX(mst) = npix MIS_SUMX(mst) = MIS_SUMX(mst) + sumx MIS_SUMX2(mst) = MIS_SUMX2(mst) + sumx2 MIS_SUMX3(mst) = MIS_SUMX3(mst) + sumx3 MIS_MIN(mst) = xmin MIS_MAX(mst) = xmax end # MST_ACCUMULATE2 -- Accumulate sums up to the second power of the data for # data values between lower and upper. procedure mst_accumulate2 (mst, x, npts, lower, upper, minmax) pointer mst #I pointer to the statistics structure real x[ARB] #I the data array int npts #I the number of data points real lower #I lower data boundary real upper #I upper data boundary int minmax #I compute the minimum and maximum ? double xx, sumx, sumx2 real lo, hi, xmin, xmax int i, npix begin lo = MIS_LO(mst) hi = MIS_HI(mst) npix = MIS_NPIX(mst) sumx = 0.0 sumx2 = 0.0 xmin = MIS_MIN(mst) xmax = MIS_MAX(mst) if (IS_INDEFR(lower) && IS_INDEFR(upper)) { npix = npix + npts if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx sumx = sumx + xx sumx2 = sumx2 + xx * xx } } else { do i = 1, npts { xx = x[i] sumx = sumx + xx sumx2 = sumx2 + xx * xx } } } else { if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx npix = npix + 1 sumx = sumx + xx sumx2 = sumx2 + xx * xx } } else { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 sumx = sumx + xx sumx2 = sumx2 + xx * xx } } } MIS_NPIX(mst) = npix MIS_SUMX(mst) = MIS_SUMX(mst) + sumx MIS_SUMX2(mst) = MIS_SUMX2(mst) + sumx2 MIS_MIN(mst) = xmin MIS_MAX(mst) = xmax end # MST_ACCUMULATE1 -- Accumulate sums up to the first power of the data for # data values between lower and upper. procedure mst_accumulate1 (mst, x, npts, lower, upper, minmax) pointer mst #I pointer to the statistics structure real x[ARB] #I the data array int npts #I the number of data points real lower #I lower data boundary real upper #I upper data boundary int minmax #I compute the minimum and maximum ? double sumx real lo, hi, xx, xmin, xmax int i, npix begin lo = MIS_LO(mst) hi = MIS_HI(mst) npix = MIS_NPIX(mst) sumx = 0.0 xmin = MIS_MIN(mst) xmax = MIS_MAX(mst) if (IS_INDEFR(lower) && IS_INDEFR(upper)) { npix = npix + npts if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx sumx = sumx + xx } } else { do i = 1, npts sumx = sumx + x[i] } } else { if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx sumx = sumx + xx } } else { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 sumx = sumx + xx } } } MIS_NPIX(mst) = npix MIS_SUMX(mst) = MIS_SUMX(mst) + sumx MIS_MIN(mst) = xmin MIS_MAX(mst) = xmax end # MST_ACCUMULATE0 -- Accumulate sums up to the 0th power of the data for # data values between lower and upper. procedure mst_accumulate0 (mst, x, npts, lower, upper, minmax) pointer mst #I pointer to the statistics structure real x[ARB] #I the data array int npts #I the number of data points real lower #I lower data boundary real upper #I upper data boundary int minmax #I compute the minimum and maximum ? int i, npix real lo, hi, xx, xmin, xmax begin lo = MIS_LO(mst) hi = MIS_HI(mst) npix = MIS_NPIX(mst) xmin = MIS_MIN(mst) xmax = MIS_MAX(mst) if (IS_INDEFR(lower) && IS_INDEFR(upper)) { npix = npix + npts if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx } } } else { if (minmax == YES) { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 if (xx < xmin) xmin = xx if (xx > xmax) xmax = xx } } else { do i = 1, npts { xx = x[i] if (xx < lo || xx > hi) next npix = npix + 1 } } } MIS_NPIX(mst) = npix MIS_MIN(mst) = xmin MIS_MAX(mst) = xmax end # MST_STATS -- Procedure to compute the first four central moments of the # distribution. procedure mst_stats (mst) pointer mst #I statistics structure double mean, var, stdev pointer sw bool fp_equalr() begin sw = MIS_SW(mst) # Compute the basic statistics regardless of the switches. if (fp_equalr (MIS_MIN(mst), MAX_REAL)) MIS_MIN(mst) = INDEFR if (fp_equalr (MIS_MAX(mst), -MAX_REAL)) MIS_MAX(mst) = INDEFR if (MIS_NPIX(mst) <= 0) return mean = MIS_SUMX(mst) / MIS_NPIX(mst) MIS_MEAN(mst) = mean if (MIS_NPIX(mst) < 2) return var = (MIS_SUMX2(mst) - MIS_SUMX(mst) * mean) / (MIS_NPIX(mst) - 1) if (var <= 0.0) { MIS_STDDEV(mst) = 0.0 return } else { stdev = sqrt (var) MIS_STDDEV(mst) = stdev } # Compute higher order moments if the switches are set. if (MIS_SSKEW(sw)== YES) MIS_SKEW(mst) = (MIS_SUMX3(mst) - 3.0d0 * MIS_MEAN(mst) * MIS_SUMX2(mst) + 3.0d0 * mean * mean * MIS_SUMX(mst) - MIS_NPIX(mst) * mean ** 3) / MIS_NPIX(mst) / stdev / stdev / stdev if (MIS_SKURTOSIS(sw) == YES) MIS_KURTOSIS(mst) = (MIS_SUMX4(mst) - 4.0d0 * mean * MIS_SUMX3(mst) + 6.0d0 * mean * mean * MIS_SUMX2(mst) - 4.0 * mean ** 3 * MIS_SUMX(mst) + MIS_NPIX(mst) * mean ** 4) / MIS_NPIX(mst) / stdev / stdev / stdev / stdev - 3.0d0 end # MST_IHIST -- Initilaize the histogram of the image pixels. int procedure mst_ihist (mst, binwidth, hgm, nbins, hwidth, hmin, hmax) pointer mst #I pointer to the statistics structure real binwidth #I histogram bin width in sigma pointer hgm #O pointer to the histogram int nbins #O number of bins real hwidth #O histogram resolution real hmin #O minimum histogram value real hmax #O maximum histogram value begin nbins = 0 if (binwidth <= 0.0) return (NO) hwidth = binwidth * MIS_STDDEV(mst) if (hwidth <= 0.0) return (NO) nbins = (MIS_MAX(mst) - MIS_MIN(mst)) / hwidth + 1 if (nbins < 3) return (NO) hmin = MIS_MIN(mst) hmax = MIS_MAX(mst) call malloc (hgm, nbins, TY_INT) return (YES) end # MST_HMEDIAN -- Estimate the median from the histogram. procedure mst_hmedian (mst, hgm, nbins, hwidth, hmin, hmax) pointer mst #I pointer to the statistics structure int hgm[ARB] #I histogram of the pixels int nbins #I number of bins in the histogram real hwidth #I resolution of the histogram real hmin #I minimum histogram value real hmax #I maximum histogram value real h1, hdiff, hnorm pointer sp, ihgm int i, lo, hi bool fp_equalr() begin call smark (sp) call salloc (ihgm, nbins, TY_REAL) # Integrate the histogram and normalize. Memr[ihgm] = hgm[1] do i = 2, nbins Memr[ihgm+i-1] = hgm[i] + Memr[ihgm+i-2] hnorm = Memr[ihgm+nbins-1] call adivkr (Memr[ihgm], hnorm, Memr[ihgm], nbins) # Initialize the low and high bin numbers. lo = 0 hi = 1 # Search for the point which divides the integral in half. do i = 1, nbins { if (Memr[ihgm+i-1] > 0.5) break lo = i } hi = lo + 1 # Approximate the median. h1 = hmin + lo * hwidth if (lo == 0) hdiff = Memr[ihgm+hi-1] else hdiff = Memr[ihgm+hi-1] - Memr[ihgm+lo-1] if (fp_equalr (hdiff, 0.0)) MIS_MEDIAN(mst) = h1 else if (lo == 0) MIS_MEDIAN(mst) = h1 + 0.5 / hdiff * hwidth else MIS_MEDIAN(mst) = h1 + (0.5 - Memr[ihgm+lo-1]) / hdiff * hwidth call sfree (sp) end # MST_HMODE -- Procedure to compute the mode. procedure mst_hmode (mst, hgm, nbins, hwidth, hmin, hmax) pointer mst #I pointer to the statistics strucuture int hgm[ARB] #I histogram of the pixels int nbins #I number of bins in the histogram real hwidth #I resolution of the histogram real hmin #I minimum histogram value real hmax #I maximum histogram value int i, bpeak real hpeak, dh1, dh2, denom bool fp_equalr() begin # If there is a single bin return the midpoint of that bin. if (nbins == 1) { MIS_MODE(mst) = hmin + 0.5 * hwidth return } # If there are two bins return the midpoint of the greater bin. if (nbins == 2) { if (hgm[1] > hgm[2]) MIS_MODE(mst) = hmin + 0.5 * hwidth else if (hgm[2] > hgm[1]) MIS_MODE(mst) = hmin + 1.5 * hwidth else MIS_MODE(mst) = hmin + hwidth return } # Find the bin containing the histogram maximum. hpeak = hgm[1] bpeak = 1 do i = 2, nbins { if (hgm[i] > hpeak) { hpeak = hgm[i] bpeak = i } } # If the maximum is in the first bin return the midpoint of the bin. if (bpeak == 1) { MIS_MODE(mst) = hmin + 0.5 * hwidth return } # If the maximum is in the last bin return the midpoint of the bin. if (bpeak == nbins) { MIS_MODE(mst) = hmin + (nbins - 0.5) * hwidth return } # Compute the lower limit of bpeak. bpeak = bpeak - 1 # Do a parabolic interpolation to find the peak. dh1 = hgm[bpeak+1] - hgm[bpeak] dh2 = hgm[bpeak+1] - hgm[bpeak+2] denom = dh1 + dh2 if (fp_equalr (denom, 0.0)) { MIS_MODE(mst) = hmin + (bpeak + 0.5) * hwidth } else { MIS_MODE(mst) = bpeak + 1 + 0.5 * (dh1 - dh2) / denom MIS_MODE(mst) = hmin + (MIS_MODE(mst) - 0.5) * hwidth } #dh1 = hgm[bpeak] * (hmin + (bpeak - 0.5) * hwidth) + #hgm[bpeak+1] * (hmin + (bpeak + 0.5) * hwidth) + #hgm[bpeak+2] * (hmin + (bpeak + 1.5) * hwidth) #dh2 = hgm[bpeak] + hgm[bpeak+1] + hgm[bpeak+2] end # MST_PRINT -- Print the fields using builtin format strings. procedure mst_print (image, mask, mst, fields, nfields) char image[ARB] #I image name char mask[ARB] #I mask name pointer mst #I pointer to the statistics structure int fields[ARB] #I fields to be printed int nfields #I number of fields int i begin call printf (" ") do i = 1, nfields { switch (fields[i]) { case MIS_FIMAGE: call printf (MIS_FSTRING) call pargstr (image) case MIS_FMASK: call printf (MIS_FSTRING) call pargstr (mask) case MIS_FNPIX: call printf (MIS_FINTEGER) call pargi (MIS_NPIX(mst)) case MIS_FMIN: call printf (MIS_FREAL) call pargr (MIS_MIN(mst)) case MIS_FMAX: call printf (MIS_FREAL) call pargr (MIS_MAX(mst)) case MIS_FMEAN: call printf (MIS_FREAL) call pargr (MIS_MEAN(mst)) case MIS_FMEDIAN: call printf (MIS_FREAL) call pargr (MIS_MEDIAN(mst)) case MIS_FMODE: call printf (MIS_FREAL) call pargr (MIS_MODE(mst)) case MIS_FSTDDEV: call printf (MIS_FREAL) call pargr (MIS_STDDEV(mst)) case MIS_FSKEW: call printf (MIS_FREAL) call pargr (MIS_SKEW(mst)) case MIS_FKURTOSIS: call printf (MIS_FREAL) call pargr (MIS_KURTOSIS(mst)) } } call printf ("\n") call flush (STDOUT) end # MST_FPRINT -- Print the fields using a free format. procedure mst_fprint (image, mask, mst, fields, nfields) char image[ARB] #I image name char mask[ARB] #I mask name pointer mst #I pointer to the statistics structure int fields[ARB] #I fields to be printed int nfields #I number of fields int i begin do i = 1, nfields { switch (fields[i]) { case MIS_FIMAGE: call printf ("%s") call pargstr (image) case MIS_FMASK: call printf ("%s") call pargstr (mask) case MIS_FNPIX: call printf ("%d") call pargi (MIS_NPIX(mst)) case MIS_FMIN: call printf ("%g") call pargr (MIS_MIN(mst)) case MIS_FMAX: call printf ("%g") call pargr (MIS_MAX(mst)) case MIS_FMEAN: call printf ("%g") call pargr (MIS_MEAN(mst)) case MIS_FMEDIAN: call printf ("%g") call pargr (MIS_MEDIAN(mst)) case MIS_FMODE: call printf ("%g") call pargr (MIS_MODE(mst)) case MIS_FSTDDEV: call printf ("%g") call pargr (MIS_STDDEV(mst)) case MIS_FSKEW: call printf ("%g") call pargr (MIS_SKEW(mst)) case MIS_FKURTOSIS: call printf ("%g") call pargr (MIS_KURTOSIS(mst)) } if (i < nfields) call printf (" ") } call printf ("\n") call flush (STDOUT) end iraf-xdimsum-main/src/ximstat/mkpkg000066400000000000000000000004461455666516400177470ustar00rootroot00000000000000# Make the XIMSTAT / XMIMSTAT tasks $checkout libpkg.a ../.. $update libpkg.a $checkin libpkg.a ../.. $exit libpkg.a: t_mimstat.x "mimstat.h" t_imstat.x "mimstat.h" mimstat.x "mimstat.h" mstcache.x ; iraf-xdimsum-main/src/ximstat/mstcache.x000066400000000000000000000064641455666516400207010ustar00rootroot00000000000000include include define MEMFUDGE 1.05 ## RS_CACHEN -- Cache N same sized images in memory using the image i/o ## buffer sizes. # #procedure rs_cachen (cache, nimages, im, old_size) # #int cache #I cache the image pixels in the imio buffer #int nimages #I the number of images #pointer im #I the current image descriptor #int old_size #O the old working set size # #int i, req_size, buf_size #int sizeof(), rs_memstat() # #begin # req_size = MEMFUDGE * IM_LEN(im,1) * sizeof (IM_PIXTYPE(im)) # do i = 2, IM_NDIM(im) # req_size = req_size * IM_LEN(im,i) # req_size = nimages * req_size # if (rs_memstat (cache, req_size, old_size) == YES) # call rs_pcache (im, INDEFI, buf_size) #end # MST_CACHE1 -- Cache 1 image in memory using the image i/o buffer sizes. procedure mst_cache1 (cache, im, old_size) int cache #I cache the image pixels in the imio buffer pointer im #I the image descriptor int old_size #O the old working set size int i, req_size, buf_size int sizeof(), mst_memstat() begin req_size = MEMFUDGE * IM_LEN(im,1) * sizeof (IM_PIXTYPE(im)) do i = 2, IM_NDIM(im) req_size = req_size * IM_LEN(im,i) if (mst_memstat (cache, req_size, old_size) == YES) call mst_pcache (im, INDEFI, buf_size) end # MST_MEMSTAT -- Figure out if there is enough memory to cache the image # pixels. If it is necessary to request more memory and the memory is # avalilable return YES otherwise return NO. int procedure mst_memstat (cache, req_size, old_size) int cache #I cache memory ? int req_size #I the requested working set size in chars int old_size #O the original working set size in chars int cur_size, max_size int begmem() begin # Find the default working set size. cur_size = begmem (0, old_size, max_size) # If cacheing is disabled return NO regardless of the working set size. if (cache == NO) return (NO) # If the requested working set size is less than the current working # set size return YES. if (req_size <= cur_size) return (YES) # Reset the current working set size. cur_size = begmem (req_size, old_size, max_size) if (req_size <= cur_size) { return (YES) } else { return (NO) } end # MST_PCACHE -- Cache the image pixels im memory by resetting the default image # buffer size. If req_size is INDEF the size of the image is used to determine # the size of the image i/o buffers. procedure mst_pcache (im, req_size, buf_size) pointer im #I the input image point int req_size #I the requested working set size in chars int buf_size #O the new image buffer size int i, def_size, new_imbufsize int sizeof(), imstati() begin # Find the default buffer size. def_size = imstati (im, IM_BUFSIZE) # Compute the new required image i/o buffer size in chars. if (IS_INDEFI(req_size)) { new_imbufsize = IM_LEN(im,1) * sizeof (IM_PIXTYPE(im)) do i = 2, IM_NDIM(im) new_imbufsize = new_imbufsize * IM_LEN(im,i) } else { new_imbufsize = req_size } # If the default image i/o buffer size is already bigger than # the requested size do nothing. if (def_size >= new_imbufsize) { buf_size = def_size return } # Reset the image i/o buffer. call imseti (im, IM_BUFSIZE, new_imbufsize) buf_size = new_imbufsize end iraf-xdimsum-main/src/ximstat/t_imstat.x000066400000000000000000000125041455666516400207260ustar00rootroot00000000000000# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. include include include "mimstat.h" # T_IMSTATISTICS -- Compute and print the statistics of images. procedure t_imstatistics () real lower, upper, binwidth, lsigma, usigma, low, up, hwidth, hmin, hmax pointer sp, fieldstr, fields, image, ist, v pointer im, buf, hgm int i, list, nclip, format, nfields, nbins, npix, cache, old_size real clgetr() pointer immap() int imtopenp(), btoi(), mst_fields(), imtgetim(), imgnlr(), mst_ihist() int clgeti() bool clgetb() errchk immap() begin call smark (sp) call salloc (fieldstr, SZ_LINE, TY_CHAR) call salloc (fields, IS_NFIELDS, TY_INT) call salloc (image, SZ_FNAME, TY_CHAR) call salloc (v, IM_MAXDIM, TY_LONG) # Open the list of input images, the fields and the data value limits. list = imtopenp ("images") call clgstr ("fields", Memc[fieldstr], SZ_LINE) lower = clgetr ("lower") upper = clgetr ("upper") nclip = clgeti ("nclip") lsigma = clgetr ("lsigma") usigma = clgetr ("usigma") binwidth = clgetr ("binwidth") format = btoi (clgetb ("format")) cache = btoi (clgetb ("cache")) # Allocate space for statistics structure call mst_allocate (ist) # Get the selected fields. nfields = mst_fields (Memc[fieldstr], Memi[fields], IS_NFIELDS) if (nfields <= 0) { call imtclose (list) call sfree (sp) return } # Set the processing switches call mst_switches (ist, Memi[fields], nfields, nclip) # Print header banner. if (format == YES) call mst_pheader (Memi[fields], nfields) # Loop through the input images. while (imtgetim (list, Memc[image], SZ_FNAME) != EOF) { # Open the image. iferr (im = immap (Memc[image], READ_ONLY, 0)) { call printf ("Error reading image %s ...\n") call pargstr (Memc[image]) next } if (cache == YES) call mst_cache1 (cache, im, old_size) # Accumulate the central moment statistics. low = lower up = upper do i = 0, nclip { call mst_initialize (ist, low, up) call amovkl (long(1), Meml[v], IM_MAXDIM) if (MIS_SKURTOSIS(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate4 (ist, Memr[buf], int (IM_LEN(im, 1)), low, up, MIS_SMINMAX(MIS_SW(ist))) } else if (MIS_SSKEW(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate3 (ist, Memr[buf], int (IM_LEN (im, 1)), low, up, MIS_SMINMAX(MIS_SW(ist))) } else if (MIS_SSTDDEV(MIS_SW(ist)) == YES || MIS_SMEDIAN(MIS_SW(ist)) == YES || MIS_SMODE(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate2 (ist, Memr[buf], int (IM_LEN(im,1)), low, up, MIS_SMINMAX(MIS_SW(ist))) } else if (MIS_SMEAN(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate1 (ist, Memr[buf], int (IM_LEN(im,1)), low, up, MIS_SMINMAX(MIS_SW(ist))) } else if (MIS_SNPIX(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate0 (ist, Memr[buf], int (IM_LEN(im,1)), low, up, MIS_SMINMAX(MIS_SW(ist))) } else if (MIS_SMINMAX(MIS_SW(ist)) == YES) { while (imgnlr (im, buf, Meml[v]) != EOF) call mst_accumulate0 (ist, Memr[buf], int (IM_LEN(im,1)), low, up, YES) } # Compute the central moment statistics. call mst_stats (ist) # Compute new limits and iterate. if (i < nclip) { if (IS_INDEFR(lsigma)) low = -MAX_REAL else if (lsigma > 0.0) low = MIS_MEAN(ist) - lsigma * MIS_STDDEV(ist) else low = -MAX_REAL if (IS_INDEFR(usigma)) up = MAX_REAL else if (usigma > 0.0) up = MIS_MEAN(ist) + usigma * MIS_STDDEV(ist) else up = MAX_REAL if (i > 0) { if (MIS_NPIX(ist) == npix) break } npix = MIS_NPIX(ist) } } # Accumulate the histogram. hgm = NULL if ((MIS_SMEDIAN(MIS_SW(ist)) == YES || MIS_SMODE(MIS_SW(ist)) == YES) && mst_ihist (ist, binwidth, hgm, nbins, hwidth, hmin, hmax) == YES) { call aclri (Memi[hgm], nbins) call amovkl (long(1), Meml[v], IM_MAXDIM) while (imgnlr (im, buf, Meml[v]) != EOF) call ahgmr (Memr[buf], int(IM_LEN(im,1)), Memi[hgm], nbins, hmin, hmax) if (MIS_SMEDIAN(MIS_SW(ist)) == YES) call mst_hmedian (ist, Memi[hgm], nbins, hwidth, hmin, hmax) if (MIS_SMODE(MIS_SW(ist)) == YES) call mst_hmode (ist, Memi[hgm], nbins, hwidth, hmin, hmax) } if (hgm != NULL) call mfree (hgm, TY_INT) # Print the statistics. if (format == YES) call mst_print (Memc[image], "", ist, Memi[fields], nfields) else call mst_fprint (Memc[image], "", ist, Memi[fields], nfields) call imunmap (im) if (cache == YES) call fixmem (old_size) } call mst_free (ist) call imtclose (list) call sfree (sp) end iraf-xdimsum-main/src/ximstat/t_mimstat.x000066400000000000000000000252771455666516400211160ustar00rootroot00000000000000include include include include include "mimstat.h" # T_MIMSTATISTICS -- Compute image statistics through masks. procedure t_mimstatistics() real lower, upper, lsigma, usigma, binwidth, low, up, hwidth, hmin, hmax pointer sp, inmasks, fieldstr, fields, image, imask, omask, masktemp, str, str2 pointer mst, vs, ve, im, pmim, pmout, opm, mp, buf, hgm, smsk int i, imlist, inlist, outlist, nclip, nfields, format, mval, npts, npix int nbins, in_invert, nbad, cache, old_size real clgetr() pointer mp_open(), mp_miopen(), im_pmmap() int imtopenp(), imtopen(), imtlen(), imtgetim(), immap(), clgeti() int mst_fields(), btoi(), mio_glsegr(), mst_ihist(), imstati() int mst_umask(), strmatch() bool clgetb() errchk immap() begin # Allocate working space. call smark (sp) call salloc (inmasks, SZ_FNAME, TY_CHAR) call salloc (fieldstr, SZ_LINE, TY_CHAR) call salloc (fields, MIS_NFIELDS, TY_INT) call salloc (image, SZ_FNAME, TY_CHAR) call salloc (imask, SZ_FNAME, TY_CHAR) call salloc (omask, SZ_FNAME, TY_CHAR) call salloc (masktemp, SZ_FNAME, TY_CHAR) call salloc (str, SZ_FNAME, TY_CHAR) call salloc (str2, SZ_FNAME, TY_CHAR) call salloc (vs, IM_MAXDIM, TY_LONG) call salloc (ve, IM_MAXDIM, TY_LONG) # Open the input image list. imlist = imtopenp ("images") if (imtlen (imlist) <= 0) { call eprintf ("The input image list is empty\n") call imtclose (imlist) call sfree (sp) return } # Get the input mask specification call clgstr ("imasks", Memc[inmasks], SZ_FNAME) if (Memc[inmasks] == '^') { in_invert = YES inlist = imtopen (Memc[inmasks+1]) } else { in_invert = NO inlist = imtopen (Memc[inmasks]) } if (imtlen (inlist) > 1 && imtlen (inlist) != imtlen (imlist)) { call eprintf ("The input mask and image lists don't match\n") call imtclose (inlist) call imtclose (imlist) call sfree (sp) return } # Open the output mask list. The number of output masks must be # zero equal to the number of input images. outlist = imtopenp ("omasks") if (imtlen (outlist) > 0 && imtlen(outlist) != imtlen(imlist)) { call eprintf ("The output mask and image lists don't match\n") call imtclose (outlist) call imtclose (inlist) call imtclose (imlist) call sfree (sp) return } # Get algorithm parameters. call clgstr ("fields", Memc[fieldstr], SZ_LINE) lower = clgetr ("lower") upper = clgetr ("upper") nclip = clgeti ("nclip") lsigma = clgetr ("lsigma") usigma = clgetr ("usigma") binwidth = clgetr ("binwidth") if (nclip > 0 && IS_INDEFR(lsigma) && IS_INDEFR(usigma)) nclip = 0 # Get the other parameters. format = btoi(clgetb ("format")) cache = btoi(clgetb ("cache")) # Allocate space for statistics structure. call mst_allocate (mst) # Get the selected fields. nfields = mst_fields (Memc[fieldstr], Memi[fields], MIS_NFIELDS) if (nfields <= 0) { call imtclose (outlist) call imtclose (inlist) call imtclose (imlist) call sfree (sp) return } # Set the processing switches call mst_switches (mst, Memi[fields], nfields, nclip) if (format == YES) call mst_pheader (Memi[fields], nfields) # Loop over the input images. while (imtgetim (imlist, Memc[image], SZ_FNAME) != EOF) { # Open the input image. iferr (im = immap (Memc[image], READ_ONLY, 0)) { call printf ("Error reading image %s ...\n") call pargstr (Memc[image]) next } # Open the input mask. if (imtgetim (inlist, Memc[str+1], SZ_FNAME) != EOF) { if (in_invert == YES) { Memc[str] = '^' pmim = mp_open (Memc[str], im, Memc[imask], SZ_FNAME) } else pmim = mp_open (Memc[str+1], im, Memc[imask], SZ_FNAME) } else if (imtlen (inlist) == 1) { pmim = mp_open (Memc[inmasks], im, Memc[imask], SZ_FNAME) } else { pmim = mp_open ("", im, Memc[imask], SZ_FNAME) } # Check the mask status and open an empty mask if there # was an error. if (pmim == NULL) { call printf ("Error reading mask for image %s ...\n") call pargstr (Memc[image]) call imunmap (im) next } # Get the output mask name if any and open a VIRTUAL output # mask. if (imtlen (outlist) > 0) { if (imtgetim (outlist, Memc[omask], SZ_FNAME) == EOF) { call imunmap (pmim) call imunmap (im) next } else { if (strmatch (Memc[omask], ".pl$") == 0) call strcat (".pl", Memc[omask], SZ_FNAME) if (Memc[imask] == '^') call xt_mkimtemp (Memc[imask+1], Memc[omask], Memc[masktemp], SZ_FNAME) else call xt_mkimtemp (Memc[imask], Memc[omask], Memc[masktemp], SZ_FNAME) pmout = im_pmmap (Memc[omask], NEW_IMAGE, 0) call mp_mpcopy (im, pmim, pmout) } } else { pmout = NULL } if (cache == YES) call mst_cache1 (cache, im, old_size) # Set up the input masking parameters. mp = mp_miopen (im, pmim) # Compute the image statistics. low = lower up = upper do i = 0 , nclip { # Set up the mask i/o boundaries. call amovkl (long(1), Meml[vs], IM_NDIM(im)) call amovl (IM_LEN(im,1), Meml[ve], IM_NDIM(im)) call mio_setrange (mp, Meml[vs], Meml[ve], IM_NDIM(im)) # Initialize the statistics computation. call mst_initialize (mst, low, up) # Accumulate the sums. if (MIS_SKURTOSIS(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate4 (mst, Memr[buf], npts, low, up, MIS_SMINMAX(MIS_SW(mst))) } else if (MIS_SSKEW(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate3 (mst, Memr[buf], npts, low, up, MIS_SMINMAX(MIS_SW(mst))) } else if (MIS_SSTDDEV(MIS_SW(mst)) == YES || MIS_SMEDIAN(MIS_SW(mst)) == YES || MIS_SMODE(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate2 (mst, Memr[buf], npts, low, up, MIS_SMINMAX(MIS_SW(mst))) } else if (MIS_SMEAN(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate1 (mst, Memr[buf], npts, low, up, MIS_SMINMAX(MIS_SW(mst))) } else if (MIS_SNPIX(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate0 (mst, Memr[buf], npts, low, up, MIS_SMINMAX(MIS_SW(mst))) } else if (MIS_SMINMAX(MIS_SW(mst)) == YES) { while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call mst_accumulate0 (mst, Memr[buf], npts, low, up, YES) } # Compute the central moment statistics. call mst_stats (mst) # Compute new limits and iterate. if (i < nclip) { if (IS_INDEFR(lsigma)) low = -MAX_REAL else if (lsigma > 0.0) low = MIS_MEAN(mst) - lsigma * MIS_STDDEV(mst) else low = -MAX_REAL if (IS_INDEFR(usigma)) up = MAX_REAL else if (usigma > 0.0) up = MIS_MEAN(mst) + usigma * MIS_STDDEV(mst) else up = MAX_REAL if (i > 0) { if (MIS_NPIX(mst) == npix) break } npix = MIS_NPIX(mst) } } # Estimate the median and the mode by accumulating the histogram. hgm = NULL if ((MIS_SMEDIAN(MIS_SW(mst)) == YES || MIS_SMODE(MIS_SW(mst)) == YES) && mst_ihist (mst, binwidth, hgm, nbins, hwidth, hmin, hmax) == YES) { call aclri (Memi[hgm], nbins) call amovkl (long(1), Meml[vs], IM_NDIM(im)) call amovl (IM_LEN(im,1), Meml[ve], IM_NDIM(im)) call mio_setrange (mp, Meml[vs], Meml[ve], IM_NDIM(im)) while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) call ahgmr (Memr[buf], npts, Memi[hgm], nbins, hmin, hmax) if (MIS_SMEDIAN(MIS_SW(mst)) == YES) call mst_hmedian (mst, Memi[hgm], nbins, hwidth, hmin, hmax) if (MIS_SMODE(MIS_SW(mst)) == YES) call mst_hmode (mst, Memi[hgm], nbins, hwidth, hmin, hmax) } if (hgm != NULL) call mfree (hgm, TY_INT) # Print the statistics. if (format == YES) call mst_print (Memc[image], Memc[imask], mst, Memi[fields], nfields) else call mst_fprint (Memc[image], Memc[imask], mst, Memi[fields], nfields) # Save the new mask to an output image. if (pmout != NULL) { call malloc (smsk, IM_LEN(im,1), TY_SHORT) call amovkl (long(1), Meml[vs], IM_NDIM(im)) call amovl (IM_LEN(im,1), Meml[ve], IM_NDIM(im)) call mio_setrange (mp, Meml[vs], Meml[ve], IM_NDIM(im)) call amovkl (long(1), Meml[vs], IM_NDIM(im)) opm = imstati (pmout, IM_PMDES) while (mio_glsegr (mp, buf, mval, Meml[vs], npts) != EOF) { nbad = mst_umask (Memr[buf], Mems[smsk], npts, low, up) if (nbad > 0) call pm_plps (opm, Meml[vs], Mems[smsk], 1, npts, PIX_SRC) } call mp_invert (opm) call imseti (pmout, IM_PMDES, opm) call mfree (smsk, TY_SHORT) } # Close the images and descriptors. call mio_close (mp) if (pmout != NULL) { call pm_savef (opm, Memc[omask], "", 0) call imunmap (pmout) call imunmap (pmim) call xt_delimtemp (Memc[omask], Memc[masktemp]) } else call imunmap (pmim) call imunmap (im) if (cache == YES) call fixmem (old_size) } call mst_free (mst) call imtclose (outlist) call imtclose (inlist) call imtclose (imlist) call sfree (sp) end # MST_UMASK -- Update the mask. int procedure mst_umask (pix, msk, npts, lower, upper) real pix[ARB] #I array of image pixels short msk[ARB] #O array of mask pixels, set to 1 and 0 int npts #I the number of pixels real lower #I the lower good data limit real upper #I the upper good data limit real lo, up int i, nbad begin if (IS_INDEFR(lower) && IS_INDEFR(upper)) return (0) if (IS_INDEFR(lower)) lo = -MAX_REAL else lo = lower if (IS_INDEFR(upper)) up = MAX_REAL else up = upper nbad = 0 do i = 1, npts { if (pix[i] < lo || pix[i] > up) { msk[i] = 0 nbad = nbad + 1 } else msk[i] = 1 } return (nbad) end iraf-xdimsum-main/src/xlist.cl000066400000000000000000000025371455666516400167100ustar00rootroot00000000000000# Create file sublists from a master list. procedure xlist (inlist, outlist, start, finish, exclude) # If input list contains files 1 through N, xlist generates an output # list containing files start to finish, and excluding file exclude. A prime # example of the use of xlist would be for generating lists of images to be # combined to make sky frames. string inlist {prompt="Input file list in sequence"} string outlist {prompt="Output file list"} int start {min=1,prompt="Number of first file to use in list"} int finish {min=1,prompt="Number of last file to use in list"} int exclude {min=0,prompt="Number of file to be excluded from list"} string suffix {"",prompt="Suffix to append to file names in output list"} string *inlst begin int ilist, istart, ifinish, ixfile string fname, outlst # Get query parameters. inlst = inlist outlst = outlist istart = start ifinish = finish ixfile = exclude # Now construct the list. ilist=1 while (fscan (inlst, fname) != EOF) { if (ilist > ifinish) break if (ilist > (istart-1)) { if (ilist != ixfile) { fileroot (fname, validim+) if (fileroot.extension == "") { print (fileroot.root // suffix, >> outlst) } else { print (fileroot.root // suffix // "." // fileroot.extension, >> outlst) } } } ilist += 1 } inlst = "" end iraf-xdimsum-main/src/xmaskpass.cl000066400000000000000000000532211455666516400175530ustar00rootroot00000000000000# Combine the input images into a single mosaic after sky subtraction, bad pixel # corrections, and cosmic ray cleaning. Object masks are created using the # input combines image and exposure map from the firstpass and then deregistered # into object masks for the individual images. Object masks are used in the # xslm, xzap, and xnzap tasks to compute better sky images and to unzap cosmic # rays that are part of object regions. The output is a list of sky subtracted, # bad pixel cleaned, and cosmic ray cleaned images, a list of cosmic ray masks, # a list of holes masks defining blank regions in the sky images, and the final # combined image and associated exposure map image. A file describing the # position of the input images in the output image is also produced. # The combined image object masks and the individual object masks are also # saved. procedure xmaskpass (input, inexpmap, sections, output, outexpmap) # Xmaskpass calls the xdimsum tasks mkmask, maskdereg, xslm, maskfix, xzap, # xnzap, badpixupdate, xnregistar, and fileroot. # # Xmaskpass also calls the IRAF tasks sections, imdelete and delete as well # as the CL builtins mktemp and time. string input {prompt="The input first pass combined image"} string inexpmap {prompt="The input first pass exposure map"} string sections {"", prompt="The input first pass sections file"} string output {prompt="The output combined image"} string outexpmap {".exp",prompt="The output exposure map or suffix\n"} string statsec {"",prompt="The image section for computing sky stats"} real nsigrej {3.0,prompt="The nsigma rejection limit for computing sky stats"} int maxiter {20, prompt="The maximum number of iterations for computing sky stats\n"} bool mkmask {yes,prompt="Create the combined image object mask ?"} string omask {".msk", prompt="The output combined image object mask"} bool chkmasks {no,prompt="Check the object masks interactively ?"} bool kpchking {yes,prompt="Keep checking the object masks ?",mode="q"} string mstatsec {"",prompt="The combined image section for computing sky stats"} real nsigcrmsk {1.5, prompt="Nthreshold factor for cosmic ray masking"} real nsigobjmsk {1.1, prompt="Nthreshold factor for object masking"} bool negthresh {no, prompt="Use negative object masking thresholds ?"} int ngrow {0, prompt="Object growing box half-width in pixels\n"} bool maskdereg {yes,prompt="Deregister mask sections from main object mask ?"} string ocrmasks {".ocm",prompt="The deregistered cosmic ray unzapping masks or suffix"} string objmasks {".obm",prompt="The deregistered object masks or suffix\n"} bool xslm {yes,prompt="Do the sky subtraction step ?"} string sslist {".sub",prompt="The output sky subtracted images or suffix"} bool newxslm {no,prompt="Use the new version of the xslm task ?"} string hmasks {".hom",prompt="The output holes masks or suffix"} bool forcescale {yes,prompt="Force recalculation of image medians in xslm ?"} bool useomask {yes,prompt="Use object masks to compute sky stats in xslm?"} int nmean {6,min=1,prompt="Number of images to use for sky image in xslm"} int nskymin {3,prompt="Minimum number of images to use for sky image in xslm"} int nreject {1,prompt="Number of pixels for xslm minmax reject"} bool cache {yes,prompt="Enable cacheing in the new xslm task ?\n"} bool maskfix {yes,prompt="Do the bad pixel correction step ?"} string bpmask {"",prompt="The input bad pixel mask image"} bool forcefix {yes,prompt="Force bad pixel fixing in maskfix ?\n"} bool xzap {yes,prompt="Do cosmic ray correction step ?"} string crmasks {".crm",prompt="The input / output cosmic ray masks or suffix"} bool newxzap {no,prompt="Use new version of xzap ?"} bool badpixupdate {yes,prompt="Do bad pixel file update ?"} int nrepeats {3,prompt="Number of repeats for bad pixel status ?\n"} bool xnregistar {yes,prompt="Do the image combining step ?"} string shiftlist {"",prompt="The input shift list file"} string rmasks {".rjm",prompt="The output rejection masks or suffix"} int nprev_omask {0, prompt="Number of previous deregistered object masks to combine"} bool fractional {no,prompt="Use fractional pixel shifts if mag = 1 ?"} bool pixin {yes,prompt="Are input coords in ref object pixels ?"} bool ab_sense {yes,prompt="Is A through B counterclockwise?"} real xscale {1.,prompt="X pixels per A coord unit"} real yscale {1.,prompt="Y pixels per B coord unit"} real a2x_angle {0.0,prompt="Angle in degrees from a CCW to x"} real mag {4.0,min=1,prompt="Magnification factor for xnregistar"} bool blkrep {yes,prompt="Use block replication to magnify ?"} int ncoavg {1,prompt="Number of internal coaverages per frame"} real secpexp {1.0,prompt="Seconds per unit exposure time"} real y2n_angle {0.,prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes,prompt="Is N through E counterclockwise ?\n"} bool del_bigmasks {no,prompt="Delete combined image masks at task termination ?"} bool del_smallmasks {no,prompt="Delete the individual object masks at task termination ?\n"} struct *imglist struct *shlist begin int fileno string sfim, expim, usections, tsslist, tcrmasks, thmasks, trmasks string outim, outexpim, tomask, tocrmasks, tobjmasks string tlist1, tlist2, ctlist2, ssmtlist2, htlist2, ocrtlist2 string objtlist2, ushiftlist, rtlist2, img, imgr, msk, imsk, omsk string j1, j2, j3, j4 print ("start xmaskpass") time ("") # Get query parameters. sfim = input if (! imaccess (sfim)) { print ("The combined input image ", sfim, " does not exist" ) return } expim = inexpmap if (! imaccess (expim)) { print ("The combined input exposure map ", expim, " does not exist" ) return } usections = sections if (! access (usections)) { print ("The input sections file ", usections, " does not exist" ) return } tsslist = sslist tcrmasks = crmasks thmasks = hmasks trmasks = rmasks outim = output outexpim = outexpmap if (substr (outexpim, 1, 1) == ".") { fileroot (outim, validim+) outexpim = fileroot.root // outexpim if (fileroot.extension != "") outexpim = outexpim // "." // fileroot.extension } tomask = omask tocrmasks = ocrmasks tobjmasks = objmasks # Create temporary lists of filenames for unskysubtracted and sky subtracted # output images, the cosmic ray masks, the holes masks, and the object and # inverse object masks. tlist1 = mktemp ("tmp$xmaskass") tlist2 = mktemp ("tmp$xmaskpass") ctlist2 = mktemp ("tmp$xmaskpass") ssmtlist2 = mktemp ("tmp$xmaskpass") htlist2 = mktemp ("tmp$xmaskpass") rtlist2 = mktemp ("tmp$xmaskpass") ocrtlist2 = mktemp ("tmp$xmaskpass") objtlist2 = mktemp ("tmp$xmaskpass") ushiftlist = mktemp ("tmp$xmaskpass") # Create the input image list. fileno = 0 imglist = usections while (fscan (imglist, img) != EOF) { fileno = fileno + 1 print (img, >> tlist1) } # Create the sky subtracted image list. if (substr (tsslist, 1, 1) == ".") { imglist = usections while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tsslist print (img, >> tlist2) } } else { sections (tsslist, option="fullname", > tlist2) if (fileno != sections.nimages) { print ("Error: Input and sky subtracted image lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) return } } # Create the cosmic ray mask list. if (substr (tcrmasks, 1, 1) == ".") { if (xzap) { imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tcrmasks // ".pl" print (img, >> ctlist2) } } else { imglist = usections while (fscan (imglist, img) != EOF) { fileroot (img, validim+) if (substr (tsslist, 1, 1) == ".") { img = fileroot.root // tsslist // tcrmasks // ".pl" } else { img = fileroot.root // ".sub" // tcrmasks // ".pl" } print (img, >> ctlist2) } } } else { sections (tcrmasks, option="fullname", > ctlist2) if (fileno != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) return } } # Create the holes mask list. if (substr (thmasks, 1, 1) == ".") { imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // thmasks // ".pl" print (img, >> htlist2) img = fileroot.root // ".ssm.pl" print (img, >> ssmtlist2) } } else { sections (thmasks, option="fullname", > htlist2) if (fileno != sections.nimages) { print ("Error: Input and holes image lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (htlist2, ver-) return } imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // ".ssm.pl" print (img, >> ssmtlist2) } } # Create the rejection mask list if (substr (trmasks, 1, 1) == ".") { imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // trmasks // ".pl" print (img, >> rtlist2) } } else { sections (trmasks, option="fullname", > rtlist2) if (fileno != sections.nimages) { print ("Error: Input and rejection image lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (htlist2, ver-) delete (ssmtlist2, ver-) delete (rtlist2, ver-) return } } # Get the input image root name. fileroot (sfim, validim+) sfim = fileroot.root # Get the combined image mask name. The output mask directory will default to # the input combined image directory. Get the individual object and cosmic ray # unzapping masks. The output individual mask directory defaults to the sky # subtracted image directory. if (substr (tomask, 1, 1) == ".") { #fileroot (outim, validim+) msk = fileroot.root // tomask // ".pl" imsk = fileroot.root // tomask // "i" // ".pl" } else { fileroot (tomask, validim+) msk = fileroot.root // ".pl" imsk = fileroot.root // "i" // ".pl" } if (substr (tocrmasks, 1, 1) == ".") { imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tocrmasks // ".pl" print (img, >> ocrtlist2) } } else { sections (tocrmasks, option="fullname", > ocrtlist2) if (fileno != sections.nimages) { print ("Error: Input image and cosmic ray unzapping mask lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) return } } if (substr (tobjmasks, 1, 1) == ".") { imglist = tlist2 while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tobjmasks // ".pl" print (img, >> objtlist2) } } else { sections (tobjmasks, option="fullname", > objtlist2) if (fileno != sections.nimages) { print ("Error: Input image and object mask lists do not match") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) return } } # Create the initial object mask if (mkmask) { print ("Begin mask pass inverse object mask creation") time ("") print ("-------Making mask for unzapping object cores ------------") if (imaccess (msk)) imdelete (msk, ver-) mkmask (sfim, expim, msk, nsigcrmsk, negthresh=no, statsec=mstatsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=chkmasks) if (chkmasks) { kpchking = yes while (kpchking) { if (imaccess (msk)) imdelete (msk, ver-) mkmask (sfim, expim, msk, nsigcrmsk, negthresh=no, statsec=mstatsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=0, interact=chkmasks) } } print ("") # Invert the mask for unzapping print ("-------Inverting mask for unzapping ----------------------") if (imaccess (imsk )) imdelete (imsk, ver-) minv (msk, imsk) print ("") } else if (! access (imsk)) { print ("The mask required by maskdereg ", imsk, "does not exist") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) return } else { print ("-------Using existing object mask ", imsk, "---------------") } print ("") # and deregister to make object mask for each frame. Note the cr+ in the # maskdegreg call. This will unzap the first pass crmasks even if xzap is # off. if (maskdereg) { print ("Begin mask pass individual inverse object mask creation") time ("") print("-------Deregistering unzap mask subsections ---------------") imdelete ("@" // ocrtlist2, ver-, >& "dev$null") maskdereg (imsk, usections, "@" // ocrtlist2, y2n_angle=y2n_angle, rotation=rotation, update+, mkcrmask+) print("") } if (mkmask) { print ("Begin mask pass object mask creation") time ("") print ("-------Making mask for sky subtraction -------------------") if (imaccess (msk)) imdelete (msk, ver-) mkmask (sfim, expim, msk, nsigobjmsk, negthresh=negthresh, statsec=mstatsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=ngrow, interact=chkmasks) print ("") if (chkmasks) { kpchking = yes while (kpchking) { if (imaccess (msk)) imdelete (msk, ver-) mkmask (sfim, expim, msk, nsigobjmsk, negthresh=negthresh, statsec=mstatsec, nsigrej=nsigrej, maxiter=maxiter, nsmooth=3, subsample=2, filtsize=15, ngrow=ngrow, interact=chkmasks) } } print ("") } else if (! access (msk)) { print ("The mask required by maskdereg ", msk, "does not exist") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) return } else { print ("-------Using existing object mask ", msk, "---------------") } if (maskdereg) { print ("Begin mask pass individual object mask creation") time ("") print("-------Deregistering sky subtraction mask subsections -----") imdelete ("@" // objtlist2, ver-, >& "dev$null") maskdereg (msk, usections, "@" // objtlist2, y2n_angle=y2n_angle, rotation=rotation, update+, mkcrmask- ) print("") } if (xslm) { print ("Begin mask pass sky subtraction") time ("") print("-------Sky subtracting images with xslm -------------------") imdelete ("@" // tlist2, ver-, >& "dev$null") imdelete ("@" // ssmtlist2, ver-, >& "dev$null") imdelete ("@" // htlist2, ver-, >& "dev$null") #xslm ("@" // tlist1, "OBJMASK", nmean, "@" // tlist2, if (newxslm) { xnslm ("@" // tlist1, "@" // objtlist2, nmean, "@" // tlist2, hmasks= "@" // htlist2, forcescale=forcescale, useomask=useomask, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, cache=cache, del_hmasks=no) } else { xslm ("@" // tlist1, "@" // objtlist2, nmean, "@" // tlist2, ssmasks ="@" // ssmtlist2, hmasks= "@" // htlist2, forcescale=forcescale, useomask=useomask, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, nreject=nreject, nskymin=nskymin, del_ssmasks=yes, del_hmasks=no) } print("") } if (maskfix) { print ("Begin mask pass bad pixel correction") time ("") print("-------Correcting bad pixels with maskfix------------------") if (bpmask == "") { print (" The bad pixel mask is undefined") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) return } maskfix ("@" // tlist2, bpmask, 0, forcefix=forcefix) print("") } if (xzap) { print ("Begin mask pass cosmic ray correction") time ("") if (newxzap) { print("-------Zapping cosmic rays using xnzap --------------------") #xnzap ("@" // tlist2, "CROBJMAS", "@" // tlist2, "@" // ctlist2, xnzap ("@" // tlist2, "@" // ocrtlist2, "@" // tlist2, "@" // ctlist2, zboxsz=5, skyfiltsize=15, sigfiltsize=25, nsigzap=5.0, nsigneg=0.0, nrejzap=1, nrings=0, nsigobj=0.0, ngrowobj=0, del_crmask=no, verbose=no) } else { print("-------Zapping cosmic rays using xzap ---------------------") #xzap ("@" // tlist2, "CROBJMAS", "@" // tlist2, "@" // ctlist2, xzap ("@" // tlist2, "@" // ocrtlist2, "@" // tlist2, "@" // ctlist2, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, checklimits+, zboxsz=5, zmin=-32768.0, zmax=32767.0, nsigzap=5, nsigobj=0.0, subsample=2, skyfiltsize=15, ngrowobj=0, nrings=0, nsigneg=0.0, del_crmask=no, del_wmasks=yes, del_wimages=yes, verb=no) } print("") if (badpixupdate) { print ("begin badpixupdate") time ("") if (bpmask == "") { print (" The bad pixel mask is undefined") delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) return } print("-------Updating bad pixel file with badpixupdate ----------") badpixupdate ("@" // ctlist2, nrepeats, bpmask) print("") } } else { print ("-------Unzapping existing CR masks -----------------------") imarith ("@" // ocrtlist2, "*", "@" // ctlist2, "@" // ctlist2 , title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) print("") } if (xnregistar) { print ("Begin mask pass image combining") time ("") if (shiftlist == "") { print("-------The shifts file is undefined ----------------") } else if (! access (shiftlist)) { print("-------The shifts file does not exist --------------") } else { print("-------Magnifying and coadding images with xnregistar -----") imglist = tlist2 shlist = shiftlist while (fscan (imglist, img) != EOF && fscan (shlist, j1, j2, j3, j4) != EOF) { print (img, " ", j2, " ", j3, " ", j4, >> ushiftlist) } imdelete ("@" // rtlist2, ver-, >& "dev$null") xmskcombine ("@" // tlist2, bpmask, "@" // ctlist2, "@" // htlist2, "@" // objtlist2, "@" // rtlist2, nprev_omask=nprev_omask) xnregistar (ushiftlist, "@" // rtlist2, outim, outexpim, "", sinlist="", blkrep=blkrep, mag=mag, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation) } } # Clean up. if (del_bigmasks) { if (imaccess (msk)) imdelete (msk, verify-, >& "dev$null") if (imaccess (imsk)) imdelete (imsk, verify-, >& "dev$null") } if (del_smallmasks) { imdelete ("@" // ocrtlist2, verify-, >& "dev$null") imdelete ("@" // objtlist2, verify-, >& "dev$null") } delete (tlist1, ver-) delete (tlist2, ver-) delete (ctlist2, ver-) delete (ssmtlist2, ver-) delete (htlist2, ver-) delete (rtlist2, ver-) delete (ocrtlist2, ver-) delete (objtlist2, ver-) if (access (ushiftlist)) delete (ushiftlist, ver-) imglist = "" shlist = "" print ("finish xmaskpass") time ("") end iraf-xdimsum-main/src/xmosaic.cl000066400000000000000000000211161455666516400172020ustar00rootroot00000000000000 # Combine the input images into a single mosaic after sky subtraction, bad pixel # corrections, and cosmic ray cleaning. Object masks are not used in the first # pass but are created from the combined image produced in the first pass step # and used in the mask pass to create better sky images and do unzap cosmic # rays that are part of object regions. The output is a list of sky subtracted, # bad pixel cleaned, and cosmic ray cleaned images, a list of cosmic ray masks, # a list of holes masks defining blank regions in the sky images, and the final # combined image and associated exposure map image. A file describing the # position of the input images in the output image is also produced. # The combined image object masks and the individual object masks are also # saved. procedure xmosaic (inlist, reference, output, expmap) # Xmosaic calls the xdimsum tasks xfirstpass, xmaskpass and fileroot. string inlist {prompt="The list of input images"} string reference {prompt="The reference image in input image list"} string output {prompt="Root name for output combined images"} string expmap {".exp",prompt="Root name for output exposure map image or suffix\n"} bool fp_xslm {yes,prompt="Do the first pass sky subtraction step ?"} bool fp_maskfix {yes,prompt="Do first pass bad pixel correction step ?"} bool fp_xzap {yes,prompt="Do first pass cosmic ray correction step ?"} bool fp_badpixupdate {yes,prompt="Do first pass bad pixel mask update ?"} bool fp_mkshifts {no,prompt="Determine first pass shifts interactively ?"} bool fp_xnregistar {yes,prompt="Do first pass image combining step ?\n"} bool mp_mkmask {yes,prompt="Create the combined image object mask ?"} bool mp_maskdereg {yes,prompt="Deregister masks ?"} bool mp_xslm {yes,prompt="Do the mask pass sky subtraction step ?"} bool mp_maskfix {yes,prompt="Do mask pass bad pixel correction step ?"} bool mp_xzap {yes,prompt="Do mask pass cosmic ray correction step ?"} bool mp_badpixupdate {yes,prompt="Do mask pass bad pixel mask update ?"} bool mp_xnregistar {yes,prompt="Do mask pass image combining step ?\n"} string statsec {"",prompt="The image section for computing sky stats"} real nsigrej {3.0,prompt="The nsigma rejection for computing sky stats"} int maxiter {20, prompt="The maximum number of iterations fo computing sky stats\n"} string sslist {".sub",prompt="The output sky-subtracted images or suffix"} string hmasks {".hom",prompt="The output holes masks or suffix"} bool newxslm {no,prompt="Use new version of xslm ?"} bool forcescale {yes,prompt="Force recalculation of image medians ?"} int nmean {6,min=1,prompt="Number of images to use in sky image"} int nreject {1,min=0,prompt="Number of pixels for sky image minmax reject"} int nskymin {3,min=0,prompt="Minimum number of image to use for sky image"} bool cache {yes,prompt="Enable cacheing in new version of xslm ?"} bool mp_useomask {yes,prompt="Use object mask to compute sky statistics ?\n"} string bpmask {"",prompt="The input pixel mask image"} bool forcefix {yes,prompt="Force bad pixel fixing ?\n"} string crmasks {".crm",prompt="The output cosmic ray masks or suffix"} bool newxzap {no,prompt="Use new version of xzap ?"} int nrepeats {3,prompt="Number of repeats for bad pixel status\n"} bool fp_chkshifts {yes,prompt="Check and confirm new shifts ?"} real fp_cradius {5.0,prompt="Centroiding radius in pixels for mkshifts"} real fp_maxshift {5.0,prompt="Maximum centroiding shift in pixels for mkshifts\n"} string rmasks {".rjm",prompt="The output rejection masks or suffix"} int mp_nprev_omask {0, prompt="Number of previous object masks to combine"} bool mp_blkrep {yes,prompt="Use block replication to magnify the image ?"} real mp_mag {4,min=1,prompt="Magnification factor for mask pass output image"} string shiftlist {"",prompt="Input or output shifts file"} string sections {".corners",prompt="The output sections file or suffix"} bool fractional {no,prompt="Use fractional pixel shifts if mag = 1 ?"} bool pixin {yes,prompt="Are input coords in ref object pixels ?"} bool ab_sense {yes,prompt="Is A through B counterclockwise ?"} real xscale {1.,prompt="X pixels per A coordinate unit"} real yscale {1.,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.,prompt="Angle in degrees from A CCW to X"} int ncoavg {1,min=1,prompt="Number of internal coaverages per frame"} real secpexp {1.0,prompt="Seconds per unit exposure time"} real y2n_angle {0.,prompt="Angle in degrees from Y to N N through E"} bool rotation {yes,prompt="Is N through E counterclockwise?\n"} string omask {".msk",prompt="The output combined image mask or suffix"} bool mp_chkmasks {no,prompt="Check the object masks ?"} bool mp_kpchking {yes,prompt="Keep checking the object masks ?"} string mp_statsec {"",prompt="The combined image section for computing mask stats"} real mp_nsigcrmsk {1.5,prompt="The nthreshold factor for cosmic ray masking"} real mp_nsigobjmsk {1.1,prompt="The ntrheshold factor for object masking"} bool mp_negthresh {no,prompt="Set negative object masking threshold ?"} int mp_ngrow {0,prompt="Object region growing radius in pixels\n"} string ocrmasks {".ocm",prompt="The output cosmic ray unzapping masks or suffix"} string objmasks {".obm",prompt="The output object masks or suffix"} bool del_bigmasks {no,prompt="Delete combined image masks at task termination ?"} bool del_smallmasks {no,prompt="Delete the individual object masks at task termination ?\n"} begin string tinlist, treference, tsslist, tcrmasks, thmasks, toutput string texpmap, tsections, toutput1, toutput2, texpmap1, texpmap2 string ext print ("start xmosaic") time ("") print ("") # Get query parameters. tinlist = inlist treference = reference tsslist = sslist tcrmasks = crmasks thmasks = hmasks toutput = output fileroot (toutput, validim+) toutput = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext toutput1 = toutput // "_fp" // ext toutput2 = toutput // "_mp" // ext texpmap = expmap if (substr (texpmap, 1, 1) == ".") { texpmap1 = toutput // "_fp" // texpmap // ext texpmap2 = toutput // "_mp" // texpmap // ext } else { fileroot (texpmap, validim+) ext = fileroot.extension if (ext != "") ext = "." // ext texpmap1 = fileroot.root // "_fp" // ext texpmap2 = fileroot.root // "_mp" // ext } tsections = sections if (substr (tsections, 1, 1) == ".") { tsections = toutput // "_fp" // tsections } # Call xfirstpass. if (fp_xslm || fp_maskfix || fp_xzap || fp_badpixupdate || fp_mkshifts || fp_xnregistar) { xfirstpass (tinlist, treference, toutput1, texpmap1, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, xslm=fp_xslm, sslist=tsslist, newxslm=newxslm, forcescale=forcescale, nmean=nmean, nskymin=nskymin, nreject=nreject, cache=cache, maskfix=fp_maskfix, bpmask=bpmask, forcefix=forcefix, xzap=fp_xzap, crmasks=tcrmasks, newxzap=newxzap, badpixupdate=fp_badpixupdate, nrepeats=nrepeats, mkshifts=fp_mkshifts, chkshifts=fp_chkshifts, cradius=fp_cradius, maxshift=fp_maxshift, xnregistar=fp_xnregistar, shiftlist=shiftlist, sections=tsections, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation) } print ("") # Call xmaskpass. if (mp_mkmask || mp_maskdereg || mp_xslm || mp_maskfix || mp_xzap || mp_badpixupdate || mp_xnregistar) { xmaskpass.kpchking = mp_kpchking xmaskpass (toutput1, texpmap1, tsections, toutput2, texpmap2, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, mkmask=mp_mkmask, omask=omask, chkmasks=mp_chkmasks, mstatsec=mp_statsec, nsigcrmsk=mp_nsigcrmsk, nsigobjmsk=mp_nsigobjmsk, negthresh=mp_negthresh, ngrow=mp_ngrow, maskdereg=mp_maskdereg, ocrmasks=ocrmasks, objmasks=objmasks, nprev_omask=mp_nprev_omask, xslm=mp_xslm, sslist=tsslist, hmasks=thmasks, newxslm=newxslm, forcescale=forcescale, useomask=mp_useomask, nmean=nmean, nskymin=nskymin, nreject=nreject, cache=cache, maskfix=mp_maskfix, bpmask=bpmask, forcefix=forcefix, xzap=mp_xzap, crmasks=tcrmasks, newxzap=newxzap, badpixupdate=mp_badpixupdate, nrepeats=nrepeats, xnregistar=mp_xnregistar, shiftlist=shiftlist, rmasks=rmasks, fractional=fractional, pixin=pixin, ab_sense=ab_sense, xscale=xscale, yscale=yscale, a2x_angle=a2x_angle, mag=mp_mag, blkrep=mp_blkrep, ncoavg=ncoavg, secpexp=secpexp, y2n_angle=y2n_angle, rotation=rotation, del_bigmasks=del_bigmasks, del_smallmasks=del_smallmasks) } print ("") print ("finish xmosaic") time ("") end iraf-xdimsum-main/src/xmshifts.cl000066400000000000000000000156401455666516400174110ustar00rootroot00000000000000# Compute accurate shifts for a list of images taken in time sequence with # a known approximate shift between adjacent images using star finding and # list matching techniques. # Note: Could rewrite the script to use fewer temporary files by looping # over starfind and xyxymatch inside the same loop instead of looping over # them in separate loops. procedure xmshifts (inlist, output, shifts, hwhmpsf, threshold, xlag, ylag, tolerance) string inlist {prompt="The input sky subtracted image sequence"} string output {prompt="The output img, pixel shifts, and exposure time file"} string shifts {"", prompt="The optional output relative shifts file"} real hwhmpsf {1.25, prompt="The hwhm of the image psf in pixels"} real threshold {50, prompt="The detection threshold in counts"} real xlag {0.0, prompt="Initial shift in x in pixels"} real ylag {0.0, prompt="Initial shift in y in pixels"} real tolerance {5.0, prompt="List match tolerance in pixels"} real fradius {2.5, prompt="Fitting radius in hwhmpsf"} real sepmin {5.0, prompt="Minimum separation in hwhmpsf"} real datamin {INDEF, prompt="Minimum good data value"} real datamax {INDEF, prompt="Maximum good data value"} real roundlo {0.0, prompt="Lower ellipticity limit"} real roundhi {0.5, prompt="Upper ellipticity limit"} real sharplo {0.5, prompt="Lower sharpness limit"} real sharphi {2.0, prompt="Upper sharpness limit"} int nxblock {INDEF, prompt="X dimension of working block size in pixels"} int nyblock {INDEF, prompt="Y dimension of working block size in pixels"} struct *imglist begin real thwhmpsf, tthreshold, ttol, txlag, tylag real xrm, yrm, xim,yim, dx, dy, sumdx, sumdy, tsep, sigma int i, nimages, npts, idx, idy string tinlist, toutput, tshifts string coofiles, infiles, matfiles, img, refimg, cooimg string shiftsdb # Get query parameters. tinlist = mktemp ("tmp$xmshifts") sections (inlist, option="fullname", > tinlist) count (tinlist) | scan (nimages) if (nimages <= 0) { print ("The input image list is empty") delete (tinlist, verify-) return } toutput = output if (access (toutput)) { print ("The output file: ", toutput, " already exists") delete (tinlist, verify-) return } tshifts = shifts if (tshifts != "") { if (access (tshifts)) { print ("The shifts file: ", tshifts, " already exists") delete (tinlist, verify-) return } } thwhmpsf = hwhmpsf tthreshold = threshold txlag = xlag tylag = ylag ttol = tolerance print ("start") time ("") # Contruct temporary file names. infiles = mktemp ("tmp$xmshifts") coofiles = mktemp ("tmp$xmshifts") matfiles = mktemp ("tmp$xmshifts") shiftsdb = mktemp ("tmp$xmshifts") # Construct the output coordinate file list. imglist = tinlist i = 0 while (fscan (imglist, img) != EOF) { i += 1 fileroot (img, validim+) img = fileroot.root delete ("im" // i // ".coo.*", go_ahead+, verify-, >& "dev$null") print ("im" // i // ".coo.1", >> coofiles) delete ("im" // i // ".mat.*", go_ahead+, verify-, >& "dev$null") print ("im"// i // ".mat.1", >> matfiles) } # Find stars in the images. print ("Begin star finding ...") time ("") imglist = tinlist i = 0 while (fscan (imglist, img) != EOF) { i += 1 fileroot (img, validim+) img = fileroot.root #print (" Finding stars in ", img) starfind (img, "im" // i // ".coo.1", thwhmpsf, tthreshold, datamin=datamin, datamax=datamax, fradius=fradius, sepmin=sepmin, npixmin=5, maglo=INDEF, maghi=INDEF, roundlo=roundlo, roundhi=roundhi, sharplo=sharplo, sharphi=sharphi, wcs="logical", wxformat="", wyformat="", boundary="nearest", constant=0.0, nxblock=nxblock, nyblock=nyblock, verbose-) } # Contruct the reference coordinates list, the input coordinates list, # and the matched coordinates list. Delete any existing match files. imglist = tinlist for (i = 1; i <= nimages; i = i + 1) { if (fscan (imglist, img) == EOF) { break } fileroot (img, validim+) img = fileroot.root delete ("im" // i // ".mat.*", go_ahead+, verify-, >& "dev$null") if (i == 1) { print ("im" // i // ".coo.1", " ", "im" // i // ".coo.1", " ", "im" // i // ".mat.1", >> infiles) } else { print ("im" // i // ".coo.1", " ", "im" // i - 1 // ".coo.1", " ", "im" // i // ".mat.1", >> infiles) } refimg = img } # Call xyxymatch. print ("Begin list matching ...") time ("") tsep = thwhmpsf * sepmin imglist = infiles while (fscan (imglist, img, refimg, cooimg) != EOF) { #print (" Matching lists ", img, " and ", refimg) if (img == refimg) { xyxymatch (img, refimg, cooimg, tolerance=ttol, refpoints="", xin=0.0, yin=0.0, xmag=1.0, ymag=1.0, xref=0.0, yref=0.0, xrot=0.0, yrot=0.0, xcolumn=1, ycolumn=2, xrcolumn=1, yrcolumn=2, separation=tsep, matching="tolerance", nmatch=30, ratio=10.0, nreject=10, xformat="%13.3f", yformat="%13.3f", interactive-, verbose-, icommands="") } else { xyxymatch (img, refimg, cooimg, tolerance=ttol, refpoints="", xin=txlag, yin=tylag, xmag=1.0, ymag=1.0, xref=0.0, yref=0.0, xrot=0.0, yrot=0.0, xcolumn=1, ycolumn=2, xrcolumn=1, yrcolumn=2, separation=tsep, matching="tolerance", nmatch=30, ratio=10.0, nreject=10, xformat="%13.3f", yformat="%13.3f", interactive-, verbose-, icommands="") } } # Compute the shifts. print ("Begin computing individual shifts ...") time ("") imglist = tinlist for (i = 1; i <= nimages; i = i + 1) { if (fscan (imglist, img) == EOF) { break } refimg = "im" // i // ".mat.1" avshift (refimg) | scan (dx, dy, npts) if (npts <= 0) { print (" Warning shift for ", img, " is undefined") dx = -txlag dy = -tylag } #print (" ", img, " ", dx, " ", dy) print (img, " ", dx, " ", dy, >> shiftsdb) } # Create the output file to use as input by xnregister. Convert the # shifts to integer but output real values for the present. print ("Begin accumulating total shifts ...") time ("") sumdx = 0.0 sumdy = 0.0 imglist = shiftsdb while (fscan (imglist, img, dx, dy) != EOF) { sumdx = sumdx - dx sumdy = sumdy - dy if (sumdx == 0.0) { idx = 0 } else { idx = sumdx + (abs (sumdx) / sumdx) * 0.5 } if (sumdy == 0.0) { idy = 0 } else { idy = sumdy + (abs (sumdy) / sumdy) * 0.5 } printf ("%s %0.3f %0.3f 1.0\n", img, sumdx, sumdy, >> toutput) } # Cleanup. if (tshifts != "") { copy (shiftsdb, tshifts, verbose-) } delete (shiftsdb, verify-) delete ("@" // matfiles, verify-, go_ahead=yes, default_action=yes, allversions=yes, subfiles=yes, >& "dev$null") delete (matfiles, verify-) delete (infiles, verify-) delete ("@" // coofiles, verify-, go_ahead=yes, default_action=yes, allversions=yes, subfiles=yes, >& "dev$null") delete (coofiles, verify-) delete (tinlist, verify-) imglist = "" print ("finish") time ("") end iraf-xdimsum-main/src/xmskcombine.cl000066400000000000000000000224061455666516400200610ustar00rootroot00000000000000# Register the input images using imcombine. procedure xmskcombine (inlist, bpmask, crmasks, hmasks, omasks, rmasks) string inlist {prompt="List of input sky subtracted images"} string bpmask {"", prompt="Input bad pixel file"} string crmasks {"", prompt="Input CR mask keyword or CR mask list"} string omasks {"", prompt="Input object mask keyword or object mask list"} string hmasks {"", prompt="Input holes mask keyword or holes mask list"} string rmasks {".rjm", prompt="The output combined rejection mask"} int nprev_omask {0, prompt="Number of previous object masks to use"} struct *simglist struct *himglist struct *crimglist struct *oimglist struct *rimglist begin int nin, ncrm, nhom, nobm, imno, ixdim, iydim string tinlist, tbpmask, tcrmasks, thmasks, tomasks, trmasks string slist, clist, hlist, olist, rlist string img, tmpname, rmaskname string bparg, hmarg, crarg, omarg # Get the query parameters. tinlist = inlist tbpmask = bpmask tcrmasks = crmasks thmasks = hmasks tomasks = omasks trmasks = rmasks # Create the image names list slist = mktemp ("tmp$xnregistar") sections (tinlist, option="fullname", > slist) nin = sections.nimages if (nin <= 0) { print ("The input sky subtracted image list is empty") delete (slist, verify-) return } # Create the cosmic ray image list clist = mktemp ("tmp$xnregistar") sections (tcrmasks, option="fullname", > clist) ncrm = sections.nimages if (ncrm > 1 && (ncrm != nin)) { print ("There are too few cosmic ray masks") delete (clist, verify-) delete (slist, verify-) return } # Create the holes image list hlist = mktemp ("tmp$xnregistar") sections (thmasks, option="fullname", > hlist) nhom = sections.nimages if (nhom > 1 && (nhom != nin)) { print ("There are too few holes masks") delete (hlist, verify-) delete (clist, verify-) delete (slist, verify-) return } # Create the object mask list. olist = mktemp ("tmp$xnregistar") sections (tomasks, option="fullname", > olist) nobm = sections.nimages if (nobm > 1 && (nobm != nin)) { print ("There are too few object masks") delete (olist, verify-) delete (hlist, verify-) delete (clist, verify-) delete (slist, verify-) return } # Create the output rejected pixel mask list. rlist = mktemp ("tmp$xnregistar") if (substr (trmasks, 1, 1) == ".") { simglist = slist while (fscan (simglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // trmasks print (img, >> rlist) } } else { sections (trmasks, option="fullname", > rlist) if (nin != sections.nimages) { print ("Error: Input and output image lists do not match") delete (rlist, verify-) delete (olist, verify-) delete (hlist, verify-) delete (clist, verify-) delete (slist, verify-) return } } # Delete any pre-xisting masks for the input images. imdelete ("@" // rlist, verify-, >& "dev$null") print ("Creating individual composite masks ...") if (imaccess (tbpmask)) { print ("Using bad pixel mask file: ", tbpmask) } # Initialize the image loop. simglist = slist himglist = hlist crimglist = clist oimglist = olist rimglist = rlist imno = 0 # Now create the combined mask images required for imcombine. # Treat the case of a defined bad pixel mask only as a special case # by simply adding the bad pixel mask name to the REJMASK keyword. if (tbpmask != "" && nhom <= 0 && ncrm <= 0 && nobm <= 0) { while (fscan (simglist, img) != EOF) { print ("Creating rejection mask for image: ", img) print (" Setting rejection mask to: ", tbpmask) hedit (img, "REJMASK", tbpmask, ,add+, delete-, verify-, show-, update+) } } else { while (fscan (simglist, img) != EOF) { # Strip off extension if present. fileroot (img, validim+) img = fileroot.root print ("Creating rejection mask for image: ", img) imno = imno + 1 # Get the bad pixel mask argument. if (imaccess (tbpmask)) { bparg = tbpmask } else { bparg = "1" } # Get the holes mask argument. if (thmasks == "") { hmarg = "1" } else { tmpname = "" hselect (img, thmasks, yes) | scan (tmpname) if (tmpname != "") { if (access (tmpname)) { print (" Using header holes mask file: ", tmpname) hmarg = tmpname } else { print (" Cannot find holes mask file: ", tmpname) hmarg = "1" } } else if (fscan (himglist, tmpname) != EOF) { if (access (tmpname)) { print (" Using holes mask file: ", tmpname) hmarg = tmpname } else if (nin > nhom) { hmarg = "1" } else { print (" Cannot find holes mask file: ", tmpname) hmarg = "1" } } else { hmarg = "1" } } # Get the cosmic ray mask argument. if (tcrmasks == "") { crarg = "1" } else { tmpname = "" hselect (img, tcrmasks, yes) | scan (tmpname) if (tmpname != "") { if (access (tmpname)) { print (" Using header cr mask file: ", tmpname) crarg = tmpname } else { print (" Cannot find cr mask file: ", tmpname) crarg = "1" } } else if (fscan (crimglist, tmpname) != EOF) { if (access (tmpname)) { print (" Using crmask file: ", tmpname) crarg = tmpname } else if (nin > ncrm) { crarg = "1" } else { print (" Cannot find cr mask file: ", tmpname) crarg = "1" } } else { crarg = "1" } } # Get the object mask argument. if (nprev_omask <= 0 || tomasks == "") { omarg = "1" } else { tmpname = "" hselect (img, tomasks, yes) | scan (tmpname) if (imaccess ("_objmask.pl")) imdelete ("_objmask.pl", verify-) if (tmpname != "") { xaddmask (slist, imno, nprev_omask, tomasks, "_objmask.pl") if (xaddmask.outarg == "1") { print (" Cannot find object mask files ") omarg = "1" } else { print (" Using previous mask files") omarg = "_objmask.pl" } } else { xaddmask (olist, imno, nprev_omask, "", "_objmask.pl") if (xaddmask.outarg == "1") { print (" Cannot find object mask files ") omarg = "1" } else { print (" Using previous mask files") omarg = "_objmask.pl" } } } # Get the output composite mask name and delete any existing image of the # same name. rmaskname = "" if (fscan (rimglist, rmaskname) == EOF) break fileroot (rmaskname, validim+) rmaskname = fileroot.root // ".pl" if (imaccess (rmaskname)) imdelete (rmaskname, verify-) # Create the composite mask. Good data values will have a mask value of 1, # bad values a mask value of 0. if (bparg == "1" && hmarg == "1" && crarg == "1" && omarg == "1") { hselect (img, "i_naxis1", yes) | scan (ixdim) hselect (img, "i_naxis2", yes) | scan (iydim) imexpr ("repl(a,b)", rmaskname, "1", ixdim, dims="auto", intype="auto", outtype="auto", dims=ixdim//","//iydim, refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") } else if (crarg == "1" && omarg == "1") { imexpr ("a * b", rmaskname, bparg, hmarg, dims="auto", intype="auto", outtype="auto", refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") } else if (crarg == "1") { imexpr ("d == 1 ? 0 : a * b", rmaskname, bparg, hmarg, crarg, omarg, dims="auto", intype="auto", outtype="auto", refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") } else if (omarg == "1") { imexpr ("c == 1 ? 0 : a * b", rmaskname, bparg, hmarg, crarg, omarg, dims="auto", intype="auto", outtype="auto", refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") } else { imexpr ("c == 1 || d == 1 ? 0 : a * b", rmaskname, bparg, hmarg, crarg, omarg, dims="auto", intype="auto", outtype="auto", refim="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") } if (imaccess("_objmask.pl")) imdelete ("_objmask.pl", verify-) hedit (img, "REJMASK", rmaskname, ,add+, delete-, verify-, show-, update+) } } # Cleanup. delete (olist, verify-) delete (hlist, verify-) delete (clist, verify-) delete (slist, verify-) delete (rlist, verify-) simglist = "" himglist = "" crimglist = "" oimglist = "" rimglist = "" end iraf-xdimsum-main/src/xnregistar.cl000066400000000000000000000500071455666516400177260ustar00rootroot00000000000000# Register the input images using imcombine. procedure xnregistar (inlist, rmasks, output, expmap, sections) string inlist {prompt="List of sky subtracted images, N and E shifts, and exposures"} string rmasks {"", prompt="Input rection mask keyword or rejection mask list"} string output {prompt="The output combined image name"} string expmap {prompt="The output exposure map image"} string sections {"", prompt="The optional output sections file"} string sinlist {"", prompt="The list of image names to be written to sections "} bool blkrep {yes, prompt="Use blkrep rather than magnify ?"} real mag {1, min=1, prompt="Block replication factor"} bool fractional {no, prompt="Use fractional pixel shifts if mag = 1?"} bool pixin {yes, prompt="Are input coords in ref object pixels?"} bool ab_sense {yes, prompt="Is A thru B counterclockwise?"} real xscale {1.0,prompt="X pixels per A coordinate unit"} real yscale {1.0,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.0, prompt="Angle in degrees from A CCW to X"} int ncoavg {1, min=1, prompt="Number of coaverages per image"} real secpexp {1.0, prompt="Seconds per unit exposure time"} real y2n_angle {0.0, prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes, prompt="Is N thru E CCW?"} struct *imglist struct *nimglist struct *rimglist struct *shimglist struct *cmimglist begin real trmag, taxrad, txscale, tyscale, a, b, newx, newy, navg real xmin, xmax, ymin, ymax, xfrac, yfrac, texp, mexp, fx1, et1 int ip, nimages, nrin, nsin, tsign, ixmin, ixmax, iymin, iymax, ix, iy int ixdim, iydim, fx, fy bool verbose, first string tinlist, trmasks, toimg, texpmap, tsections, tsinlist, text string timg, nimg, rmskname, ntmpname, rtmpname, logfile string rlist, slist, ilist, bilist, tcmlist, olist, fxlist, etlist, shlist string cmlist struct theadline # Get the query parameters tinlist = inlist count (tinlist) | scan (nimages) trmasks = rmasks toimg = output fileroot (toimg, validim+) toimg = fileroot.root texpmap = expmap fileroot (texpmap, validim+) texpmap = fileroot.root tsections = sections # Get alternate image list. tsinlist = sinlist # Create the rejection mask list. rlist = mktemp ("tmp$xnregistar") sections (trmasks, option="fullname", > rlist) nrin = sections.nimages # Create the image names list. slist = mktemp ("tmp$xnregistar") sections (tsinlist, option="fullname", > slist) nsin = sections.nimages if (nsin > 0 && nsin != nimages) { print ("The input and sections image lists are not the same size") delete (rlist, verify-) delete (slist, verify-) return } # Set verbose output. For now this is a fixed parameter. verbose = NO if (verbose) logfile = "STDOUT" else logfile = "" # Create the temporary imcombine input image, and block replicated input image # list. Allos create a temporary combined mask list for use with those masks # which need to be altered to account from the fractional pixel effects. ilist = mktemp ("tmp$xnregistar") bilist = mktemp ("tmp$xnregistar") cmlist = mktemp ("tmp$xnregistar") tcmlist = mktemp ("tmp$xnregistar") # Create the imcombine offset list, flux conserve list, and exposure time # list, and fractional pixel shift list. olist = mktemp ("tmp$xnregistar") fxlist = mktemp ("tmp$xnregistar") etlist = mktemp ("tmp$xnregistar") shlist = mktemp ("tmp$xnregistar") # Set the magnification. if (blkrep) { trmag = nint (mag) } else { trmag = mag } # Initialize geoemtry parameters. taxrad = a2x_angle * 3.1415926535 / 180.0 if (ab_sense) { tsign = 1 } else { tsign = -1 } # If input coords are measured in pixels with respect to reference object # the scale is 1 but shifts are opposite sign of measured pixels. In this # case a2x_angle is zero abd ab_sense is yes. txscale = xscale tyscale = yscale if (pixin) { txscale = -1.0 tyscale = -1.0 taxrad = 0.0 tsign = 1 } # Delete existing output images. fileroot ("") text = fileroot.defextn if (imaccess (toimg//text)) { print ("Deleting existing output image ", toimg//text) imdelete (toimg//text, verify-) } if (imaccess (texpmap//text)) { print ("Deleting existing exposure image ", texpmap//text) imdelete (texpmap//text, verify-) } # Delete existing sections file. if (tsections != "") { if (access (tsections)) { print ("Deleting existing sections file ", tsections) delete (tsections, verify-) } } # Compute the min and max shift values. imglist = tinlist first = yes while (fscan (imglist, timg, a, b) != EOF) { # Compute the shifts. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the minimum and maximum shifts. if (first) { xmin = newx xmax = newx ymin = newy ymax = newy } else { if (newx < xmin) xmin = newx if (newx > xmax) xmax = newx if (newy < ymin) ymin = newy if (newy > ymax) ymax = newy } first = no } # Compute the minimum and maximum integer shift values. if (xmin != 0.0) { ixmin = int (xmin + 0.5 * (xmin / abs (xmin))) } else { ixmin = 0 } if (xmax != 0.0) { ixmax = int (xmax + 0.5 * (xmax / abs (xmax))) } else { ixmax = 0 } if (ymin != 0.0) { iymin = int (ymin + 0.5 * (ymin / abs (ymin))) } else { iymin = 0 } if (ymax != 0.0) { iymax = int (ymax + 0.5 * (ymax / abs (ymax))) } else { iymax = 0 } # Prepare the imcombine input lists. imglist = tinlist nimglist = slist ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present and create the input image file name. fileroot (timg, validim+) timg = fileroot.root # Create the input image list for imcombine. print (timg, >> ilist) # Create the block replicated input image list used if mag > 1. print ("_blk_"//ip, >> bilist) # Compute the shift. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the integer offsets for imcombine and store them in the # offsets file. if (newx != 0.0) { ix = int (newx + 0.5 * (newx / abs (newx))) } else { ix = 0 } if (newy != 0.0) { iy = int (newy + 0.5 * (newy / abs (newy))) } else { iy = 0 } print (ix, iy, >> olist) xfrac = newx - ix yfrac = newy - iy print (xfrac, yfrac, >> shlist) # Write the sections file for the later maskdereg step. if (tsections != "") { ix = 1 + ix - ixmin iy = 1 + iy - iymin hselect (timg, "i_naxis1", yes) | scan (ixdim) hselect (timg, "i_naxis2", yes) | scan (iydim) fx = ix + ixdim * trmag - 1 fy = iy + iydim * trmag - 1 if (fscan (nimglist, nimg) != EOF) { fileroot (nimg, validim+) nimg = fileroot.root print (nimg, " ", ix, iy, fx, fy, >> tsections) } else { print (timg, " ", ix, iy, fx, fy, >> tsections) } } # Set navg to 1 for now since the bundles feature is not being used. navg = 1 # Compute the flux correction factor mexp = (navg * ncoavg) / (trmag * trmag) print (mexp, >> fxlist) if (ip == 1) fx1 = mexp # Compute the total exposure time. If the exposure time is less than or # equal to 0 set it to 1 in the input list to imexamine for now. The image # will be excluded from the imcombine step by setting the entire bad pixel # mask to be zero. Setting mep to zero produces problems in imcombine. if (texp <= 0.0) { mexp = 1.0 } else { mexp = texp * navg * ncoavg * secpexp } print (mexp, >> etlist) if (ip == 1) et1 = mexp } imglist = tinlist rimglist = rlist shimglist = shlist # Loop over the input image and rejection mask lists copying name of # the rejection mask into the BPM keyword. Do any necessary shifting in # order to account for the fractional pixel shifts as necessary. ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present. fileroot (timg, validim+) timg = fileroot.root print ("Checking mask for image: ", timg) # Get the rejection mask. if (trmasks == "") { rmskname = "" } else { rmskname = "" hselect (timg, trmasks, yes) | scan (rmskname) if (rmskname != "") { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else if (fscan (rimglist, rmskname) != EOF) { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else if (nimages > nrin) { rmskname = "" } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else { rmskname = "" } } # Get fractional part of shift. if (abs (trmag - 1.0) < 0.001 && fractional) { if (fscan (shimglist, xfrac, yfrac) == EOF) { xfrac = 0.0 yfrac = 0.0 } } # Create a temporary mask name if necesary. #if (rmskname != "") { #ntmpname = "_msktmp"//ip//"."//rmskname #if (imaccess (ntmpname)) #imdelete (ntmpname, verify-) #rtmpname = "_rmsktmp"//ip//"."//rmskname #if (imaccess (rtmpname)) #imdelete (rtmpname, verify-) #} else { ntmpname = "_msktmp."//ip//".pl" if (imaccess (ntmpname)) imdelete (ntmpname, verify-) rtmpname = "_rmsktmp."//ip//".pl" if (imaccess (rtmpname)) imdelete (rtmpname, verify-) #} # Set the BPM keyword. # The exposure time is 0. Eliminate all data. if (texp <= 0.0) { print (" Warning the exposure time is <= 0 assume all bad") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "0", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=verbose, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname ,add+, delete-, verify-, show-, update+) # The rejection mask is undefined. Use all data. } else if (rmskname == "") { print (" Warning the mask is undefined assume all good") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "1", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=verbose, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) # The mask must be shifted a fractional pixel amount. } else if (abs (trmag - 1.0) < 0.001 && fractional) { print (" Shifting mask by ", xfrac, yfrac) imarith (rmskname, "*", "1000", ntmpname, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose=verbose, noact-) imshift (ntmpname, ntmpname, xfrac, yfrac, shifts_file="", interp_type="linear", boundary_type="constant", constant=0.0) imexpr ("a >= 999 ? 1 : 0", rtmpname, ntmpname, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=verbose, exprdb="none") hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) imdelete (ntmpname, verify-) # Magnification instead of block replication } else if (! blkrep) { imcopy (rmskname, rtmpname, verbose=verbose) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) # The mask is ok as is. No tmporary mask need be made. } else { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rmskname, ,add+, delete-, verify-, show-, update+) print (rmskname, >> cmlist) } } # Combine the images. if (abs (trmag - 1.0) < 0.001) { if (fractional) { print ("Shifting the input images ...") imshift ("@"//ilist, "@"//bilist, 0.0, 0.0, shifts_file=shlist, interp_type="linear", boundary_type="constant", constant=0.0) print ("Shifting the exposure maps ...") print ("Combining the input images ...") imcombine ("@"//bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@"//fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@"//cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@"//etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } else { print ("Combining the input images ...") imcombine ("@"//ilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@"//fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@"//cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@"//etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } } else { imdelete ("@"//bilist, verify-, >& "dev$null") if (blkrep) { print ("Block replicating the input images ...") blkrep ("@"//ilist, "@"//bilist, nint(trmag), nint(trmag)) print ("Block replicating the exposure time images ...") blkrep ("@"//cmlist, "@"//cmlist, nint(trmag), nint(trmag)) } else { print ("Magnifying the input images ...") magnify ("@"//ilist, "@"//bilist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") print ("Magnifying the exposure time images ...") imarith ("@"//cmlist, "*", "1000", "@"//cmlist, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose=verbose, noact-) magnify ("@"//cmlist, "@"//cmlist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") cmimglist = cmlist while (fscan (cmimglist, timg) != EOF) { imexpr ("a >= 999 ? 1 : 0", "_tmpname.pl", timg, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=verbose, exprdb="none") imdelete (timg, verify-) imrename ("_tmpname.pl", timg, verbose=verbose) } } print ("Combining the input images ...") imcombine ("@"//bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@"//fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@"//cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile=logfile, combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@"//etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } # Correct for the relative scaling to the first image. if (abs (fx1-1.) > 0.001) imarith (toimg, "*", fx1, toimg, title="", divzero=0., hparams="", pixtype="", calctype="", verbose=verbose, noact=no) if (abs (et1-1.) > 0.001) imarith (texpmap, "*", et1, texpmap, title="", divzero=0., hparams="", pixtype="", calctype="", verbose=verbose, noact=no) # Divide output image sum by exposure map. imarith (toimg, "/", texpmap, toimg, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) # Orient these to N at top, E at left for iraf default orient (toimg, y2n_angle, rotation=rotation, invert-) orient (texpmap, y2n_angle, rotation=rotation, invert-) # Remove the BPM keyword from the input images. imglist = tinlist while (fscan (imglist, timg) != EOF) { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) } # Copy header information from first input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. imglist = tinlist # rewind imglist if (fscan (imglist, timg, a, b) != EOF) { hselect (timg, "title", yes) | scan (theadline) hedit (toimg, "exptime", "1", add+, delete-, verify-, show-, update+) hedit (toimg, "title", "Final combined image: "//theadline, add+, delete-, verify-, show-, update+) hedit (texpmap, "title", "Exposure time map: "//theadline, add+, delete-, verify-, show-, update+) hedit (toimg, "BPM,CRMASK,CROBJMAS,HOLES,MASKFIX,OBJMASK,REJMASK,SKYMED,SKYSUB", add-, delete+, verify-, show-, update+) #addcomment (toimg, "Header data copied from file "//timg, ver-) } # Cleanup. delete (olist, verify-) delete (fxlist, verify-) delete (etlist, verify-) delete (shlist, verify-) delete (ilist, verify-) if (access (tcmlist)) { imdelete ("@"//tcmlist, verify-, >& "dev$null") delete (tcmlist, verify-) } delete (cmlist, verify-) imdelete ("@"//bilist, verify-, >& "dev$null") delete (bilist, verify-) delete (rlist, verify-) delete (slist, verify-) imglist = "" nimglist = "" rimglist = "" shimglist = "" cmimglist = "" end iraf-xdimsum-main/src/xnregistar.cl.old000066400000000000000000000502461455666516400205100ustar00rootroot00000000000000# Register the input images using imcombine. procedure xnregistar (inlist, rmasks, output, expmap, sections) string inlist {prompt="List of sky subtracted images, N and E shifts, and exposures"} string rmasks {"", prompt="Input rection mask keyword or rejection mask list"} string output {prompt="The output combined image name"} string expmap {prompt="The output exposure map image"} string sections {"", prompt="The optional output sections file"} string sinlist {"", prompt="The list of image names to be written to sections "} bool blkrep {yes, prompt="Use blkrep rather than magnify ?"} real mag {1, min=1, prompt="Block replication factor"} bool fractional {no, prompt="Use fractional pixel shifts if mag = 1?"} bool pixin {yes, prompt="Are input coords in ref object pixels?"} bool ab_sense {yes, prompt="Is A thru B counterclockwise?"} real xscale {1.0,prompt="X pixels per A coordinate unit"} real yscale {1.0,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.0, prompt="Angle in degrees from A CCW to X"} int ncoavg {1, min=1, prompt="Number of coaverages per image"} real secpexp {1.0, prompt="Seconds per unit exposure time"} real y2n_angle {0.0, prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes, prompt="Is N thru E CCW?"} struct *imglist struct *nimglist struct *rimglist struct *shimglist begin real trmag, taxrad, txscale, tyscale, a, b, newx, newy, navg real xmin, xmax, ymin, ymax, xfrac, yfrac, texp, mexp int ip, nimages, nrin, nsin, tsign, ixmin, ixmax, iymin, iymax, ix, iy int ixdim, iydim, fx, fy bool first string tinlist, trmasks, toimg, texpmap, tsections, tsinlist, text string timg, nimg, rmskname, ntmpname, rtmpname string rlist, slist, ilist, bilist, tcmlist, olist, fxlist, etlist, shlist string cmlist struct theadline # Get the query parameters tinlist = inlist count (tinlist) | scan (nimages) trmasks = rmasks toimg = output fileroot (toimg, validim+) toimg = fileroot.root texpmap = expmap fileroot (texpmap, validim+) texpmap = fileroot.root tsections = sections # Get alternate image list. tsinlist = sinlist # Create the rejection mask list. rlist = mktemp ("tmp$xnregistar") sections (trmasks, option="fullname", > rlist) nrin = sections.nimages # Create the image names list. slist = mktemp ("tmp$xnregistar") sections (tsinlist, option="fullname", > slist) nsin = sections.nimages if (nsin > 0 && nsin != nimages) { print ("The input and sections image lists are not the same size") delete (rlist, verify-) delete (slist, verify-) return } # Create the temporary imcombine input image, and block replicated input image # list. Allos create a temporary combined mask list for use with those masks # which need to be altered to account from the fractional pixel effects. ilist = mktemp ("tmp$xnregistar") bilist = mktemp ("tmp$xnregistar") cmlist = mktemp ("tmp$xnregistar") tcmlist = mktemp ("tmp$xnregistar") # Create the imcombine offset list, flux conserve list, and exposure time # list, and fractional pixel shift list. olist = mktemp ("tmp$xnregistar") fxlist = mktemp ("tmp$xnregistar") etlist = mktemp ("tmp$xnregistar") shlist = mktemp ("tmp$xnregistar") # Set the magnification. if (blkrep) { trmag = nint (mag) } else { trmag = mag } # Initialize geoemtry parameters. taxrad = a2x_angle * 3.1415926535 / 180.0 if (ab_sense) { tsign = 1 } else { tsign = -1 } # If input coords are measured in pixels with respect to reference object # the scale is 1 but shifts are opposite sign of measured pixels. In this # case a2x_angle is zero abd ab_sense is yes. txscale = xscale tyscale = yscale if (pixin) { txscale = -1.0 tyscale = -1.0 taxrad = 0.0 tsign = 1 } # Delete existing output images. fileroot ("") text = fileroot.defextn if (imaccess (toimg // text)) { print ("Deleting existing output image ", toimg // text) imdelete (toimg // text, verify-) } if (imaccess (texpmap // text)) { print ("Deleting existing exposure image ", texpmap // text) imdelete (texpmap // text, verify-) } # Delete existing sections file. if (tsections != "") { if (access (tsections)) { print ("Deleting existing sections file ", tsections) delete (tsections, verify-) } } # Compute the min and max shift values. imglist = tinlist first = yes while (fscan (imglist, timg, a, b) != EOF) { # Compute the shifts. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the minimum and maximum shifts. if (first) { xmin = newx xmax = newx ymin = newy ymax = newy } else { if (newx < xmin) xmin = newx if (newx > xmax) xmax = newx if (newy < ymin) ymin = newy if (newy > ymax) ymax = newy } first = no } # Compute the minimum and maximum integer shift values. if (xmin != 0.0) { ixmin = int (xmin + 0.5 * (xmin / abs (xmin))) } else { ixmin = 0 } if (xmax != 0.0) { ixmax = int (xmax + 0.5 * (xmax / abs (xmax))) } else { ixmax = 0 } if (ymin != 0.0) { iymin = int (ymin + 0.5 * (ymin / abs (ymin))) } else { iymin = 0 } if (ymax != 0.0) { iymax = int (ymax + 0.5 * (ymax / abs (ymax))) } else { iymax = 0 } # Prepare the imcombine input lists. imglist = tinlist nimglist = slist ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present and create the input image file name. fileroot (timg, validim+) timg = fileroot.root # Create the input image list for imcombine. print (timg, >> ilist) # Create the block replicated input image list used if mag > 1. print ("_blk_" // ip, >> bilist) # Compute the shift. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the integer offsets for imcombine and store them in the # offsets file. if (newx != 0.0) { ix = int (newx + 0.5 * (newx / abs (newx))) } else { ix = 0 } if (newy != 0.0) { iy = int (newy + 0.5 * (newy / abs (newy))) } else { iy = 0 } print (ix, iy, >> olist) xfrac = newx - ix yfrac = newy - iy print (xfrac, yfrac, >> shlist) # Write the sections file for the later maskdereg step. if (tsections != "") { ix = 1 + ix - ixmin iy = 1 + iy - iymin hselect (timg, "i_naxis1", yes) | scan (ixdim) hselect (timg, "i_naxis2", yes) | scan (iydim) fx = ix + ixdim * trmag - 1 fy = iy + iydim * trmag - 1 if (fscan (nimglist, nimg) != EOF) { fileroot (nimg, validim+) nimg = fileroot.root print (nimg, " ", ix, iy, fx, fy, >> tsections) } else { print (timg, " ", ix, iy, fx, fy, >> tsections) } } # Set navg to 1 for now since the bundles feature is not being used. navg = 1 # Compute the flux correction factor mexp = (navg * ncoavg) / (trmag * trmag) print (mexp, >> fxlist) # Compute the total exposure time. If the exposure time is less than or # equal to 0 set it to 1 in the input list to imexamine for now. The image # will be excluded from the imcombine step by setting the entire bad pixel # mask to be zero. Setting mep to zero produces problems in imcombine. if (texp <= 0.0) { mexp = 1.0 } else { mexp = texp * navg * ncoavg * secpexp } print (mexp, >> etlist) } imglist = tinlist rimglist = rlist shimglist = shlist # Loop over the input image and rejection mask lists copying name of # the rejection mask into the BPM keyword. Do any necessary shifting in # order to account for the fractional pixel shifts as necessary. ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present. fileroot (timg, validim+) timg = fileroot.root print ("Checking mask for image: ", timg) # Get the rejection mask. if (trmasks == "") { rmskname = "" } else { rmskname = "" hselect (timg, trmasks, yes) | scan (rmskname) if (rmskname != "") { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else if (fscan (rimglist, rmskname) != EOF) { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else if (nimages > nrin) { rmskname = "" } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else { rmskname = "" } } # Get fractional part of shift. if (abs (trmag - 1.0) < 0.001 && fractional) { if (fscan (shimglist, xfrac, yfrac) == EOF) { xfrac = 0.0 yfrac = 0.0 } } # Create a temporary mask name if necesary. if (rmskname != "") { ntmpname = "_msktmp" // ip // "." // rmskname if (imaccess (ntmpname)) imdelete (ntmpname, verify-) rtmpname = "_rmktmp" // ip // "." // rmskname if (imaccess (rtmpname)) imdelete (rtmpname, verify-) } else { ntmpname = "_msktmp." // ip // ".pl" if (imaccess (ntmpname)) imdelete (ntmpname, verify-) rtmpname = "_rmsktmp." // ip // ".pl" } # Set the BPM keyword. # The exposure time is 0. Eliminate all data. if (texp <= 0.0) { print (" Warning the exposure time is <= 0 assume all bad") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "0", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) # The rejection mask is undefined. Use all data. } else if (rmskname == "") { print (" Warning the mask is undefined assume all good") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "1", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) # The mask must be shifted a fractional pixel amount. } else if (abs (trmag - 1.0) < 0.001 && fractional) { print (" Shifting mask by ", xfrac, yfrac) imarith (rmskname, "*", "1000", ntmpname, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) imshift (ntmpname, ntmpname, xfrac, yfrac, shifts_file="", interp_type="linear", boundary_type="constant", constant=0.0) imexpr ("a >= 999 ? 1 : 0", rtmpname, ntmpname, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) imdelete (ntmpname, verify-) # The mask is ok as is. No tmporary mask need be made. } else { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rmskname, ,add+, delete-, verify-, show-, update+) print (rmskname, >> cmlist) } } # Delete the existing images. if (imaccess ("_jimlist.pl")) { imdelete ("_jimlist.pl", verify-) } if (imaccess ("_jcmlist.pl")) { imdelete ("_jcmlist.pl", verify-) } # Combine the images. if (abs (trmag - 1.0) < 0.001) { if (fractional) { print ("Shifting the input images ...") imshift ("@" // ilist, "@" // bilist, 0.0, 0.0, shifts_file=shlist, interp_type="linear", boundary_type="constant", constant=0.0) print ("Shifting the exposure maps ...") print ("Combining the input images ...") imcombine ("@" // bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="_jimlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="_jcmlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } else { print ("Combining the input images ...") imcombine ("@" // ilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="_jimlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="_jcmlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } } else { imdelete ("@" // bilist, verify-, >& "dev$null") if (blkrep) { print ("Block replicating the input images ...") blkrep ("@" // ilist, "@" // bilist, nint(trmag), nint(trmag)) print ("Block replicating the exposure time images ...") blkrep ("@" // cmlist, "@" // cmlist, nint(trmag), nint(trmag)) } else { print ("Magnifying the input images ...") magnify ("@" // ilist, "@" // bilist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") print ("Magnifying the exposure time images ...") imarith ("@" // cmlist, "*", "1000", "@" // cmlist, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) magnify ("@" // cmlist, "@" // cmlist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") cmimglist = cmlist while (fscan (cmimglist, img) != EOF) { imexpr ("a >= 999 ? 1 : 0", "_tmpname.pl", img, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") imdelete (img, verify-) imrename ("_tmpname.pl", img, verbose-) } } print ("Combining the input images ...") imcombine ("@" // bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="_jimlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="_jcmlist.pl", expmasks="", sigmas="", logfile="", combine="average", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } # Normalize the combined image. This is necessary since imcombine does # not currently sum. imarith (nimages, "-", "_jimlist.pl", "_jimlist.pl", title="", divzero=0., hparams="", pixtype="", calctype="", ver-, noact-) imarith ("_jimlist.pl", "*", toimg, toimg, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) imdelete ("_jimlist.pl", verify-) # Normalize the exposure map. This is necessary since imcombine does not # currently sum. imarith (nimages, "-", "_jcmlist.pl", "_jcmlist.pl", title="", divzero=0., hparams="", pixtype="", calctype="", ver-, noact-) imarith ("_jcmlist.pl", "*", texpmap, texpmap, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) imdelete ("_jcmlist.pl", verify-) # Divide output image sum by exposure map. imarith (toimg, "/", texpmap, toimg, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) # Orient these to N at top, E at left for iraf default orient (toimg, y2n_angle, rotation=rotation, invert-) orient (texpmap, y2n_angle, rotation=rotation, invert-) # Remove the BPM keyword from the input images. imglist = tinlist while (fscan (imglist, timg) != EOF) { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) } # Copy header information from first input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. imglist = tinlist # rewind imglist if (fscan (imglist, timg, a, b) != EOF) { hselect (timg, "title", yes) | scan (theadline) hedit (toimg, "exptime", "1", add+, delete-, verify-, show-, update+) hedit (toimg, "title", "Final combined image: " // theadline, add+, delete-, verify-, show-, update+) hedit (texpmap, "title", "Exposure time map: " // theadline, add+, delete-, verify-, show-, update+) hedit (toimg, "BPM,CRMASK,CROBJMAS,HOLES,MASKFIX,OBJMASK,REJMASK,SKYMED,SKYSUB", add-, delete+, verify-, show-, update+) #addcomment (toimg, "Header data copied from file " // timg, ver-) } # Cleanup. delete (olist, verify-) delete (fxlist, verify-) delete (etlist, verify-) delete (shlist, verify-) delete (ilist, verify-) if (access (tcmlist)) { imdelete ("@" // tcmlist, verify-, >& "dev$null") delete (tcmlist, verify-) } delete (cmlist, verify-) imdelete ("@" // bilist, verify-, >& "dev$null") delete (bilist, verify-) delete (rlist, verify-) delete (slist, verify-) imglist = "" nimglist = "" rimglist = "" shimglist = "" end iraf-xdimsum-main/src/xnregistar.cl.old1000066400000000000000000000466411455666516400205750ustar00rootroot00000000000000# Register the input images using imcombine. procedure xnregistar (inlist, rmasks, output, expmap, sections) string inlist {prompt="List of sky subtracted images, N and E shifts, and exposures"} string rmasks {"", prompt="Input rection mask keyword or rejection mask list"} string output {prompt="The output combined image name"} string expmap {prompt="The output exposure map image"} string sections {"", prompt="The optional output sections file"} string sinlist {"", prompt="The list of image names to be written to sections "} bool blkrep {yes, prompt="Use blkrep rather than magnify ?"} real mag {1, min=1, prompt="Block replication factor"} bool fractional {no, prompt="Use fractional pixel shifts if mag = 1?"} bool pixin {yes, prompt="Are input coords in ref object pixels?"} bool ab_sense {yes, prompt="Is A thru B counterclockwise?"} real xscale {1.0,prompt="X pixels per A coordinate unit"} real yscale {1.0,prompt="Y pixels per B coordinate unit"} real a2x_angle {0.0, prompt="Angle in degrees from A CCW to X"} int ncoavg {1, min=1, prompt="Number of coaverages per image"} real secpexp {1.0, prompt="Seconds per unit exposure time"} real y2n_angle {0.0, prompt="Angle in degrees from Y to N N thru E"} bool rotation {yes, prompt="Is N thru E CCW?"} struct *imglist struct *nimglist struct *rimglist struct *shimglist struct *cmimglist begin real trmag, taxrad, txscale, tyscale, a, b, newx, newy, navg real xmin, xmax, ymin, ymax, xfrac, yfrac, texp, mexp int ip, nimages, nrin, nsin, tsign, ixmin, ixmax, iymin, iymax, ix, iy int ixdim, iydim, fx, fy bool first string tinlist, trmasks, toimg, texpmap, tsections, tsinlist, text string timg, nimg, rmskname, ntmpname, rtmpname string rlist, slist, ilist, bilist, tcmlist, olist, fxlist, etlist, shlist string cmlist struct theadline # Get the query parameters tinlist = inlist count (tinlist) | scan (nimages) trmasks = rmasks toimg = output fileroot (toimg, validim+) toimg = fileroot.root texpmap = expmap fileroot (texpmap, validim+) texpmap = fileroot.root tsections = sections # Get alternate image list. tsinlist = sinlist # Create the rejection mask list. rlist = mktemp ("tmp$xnregistar") sections (trmasks, option="fullname", > rlist) nrin = sections.nimages # Create the image names list. slist = mktemp ("tmp$xnregistar") sections (tsinlist, option="fullname", > slist) nsin = sections.nimages if (nsin > 0 && nsin != nimages) { print ("The input and sections image lists are not the same size") delete (rlist, verify-) delete (slist, verify-) return } # Create the temporary imcombine input image, and block replicated input image # list. Allos create a temporary combined mask list for use with those masks # which need to be altered to account from the fractional pixel effects. ilist = mktemp ("tmp$xnregistar") bilist = mktemp ("tmp$xnregistar") cmlist = mktemp ("tmp$xnregistar") tcmlist = mktemp ("tmp$xnregistar") # Create the imcombine offset list, flux conserve list, and exposure time # list, and fractional pixel shift list. olist = mktemp ("tmp$xnregistar") fxlist = mktemp ("tmp$xnregistar") etlist = mktemp ("tmp$xnregistar") shlist = mktemp ("tmp$xnregistar") # Set the magnification. if (blkrep) { trmag = nint (mag) } else { trmag = mag } # Initialize geoemtry parameters. taxrad = a2x_angle * 3.1415926535 / 180.0 if (ab_sense) { tsign = 1 } else { tsign = -1 } # If input coords are measured in pixels with respect to reference object # the scale is 1 but shifts are opposite sign of measured pixels. In this # case a2x_angle is zero abd ab_sense is yes. txscale = xscale tyscale = yscale if (pixin) { txscale = -1.0 tyscale = -1.0 taxrad = 0.0 tsign = 1 } # Delete existing output images. fileroot ("") text = fileroot.defextn if (imaccess (toimg // text)) { print ("Deleting existing output image ", toimg // text) imdelete (toimg // text, verify-) } if (imaccess (texpmap // text)) { print ("Deleting existing exposure image ", texpmap // text) imdelete (texpmap // text, verify-) } # Delete existing sections file. if (tsections != "") { if (access (tsections)) { print ("Deleting existing sections file ", tsections) delete (tsections, verify-) } } # Compute the min and max shift values. imglist = tinlist first = yes while (fscan (imglist, timg, a, b) != EOF) { # Compute the shifts. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the minimum and maximum shifts. if (first) { xmin = newx xmax = newx ymin = newy ymax = newy } else { if (newx < xmin) xmin = newx if (newx > xmax) xmax = newx if (newy < ymin) ymin = newy if (newy > ymax) ymax = newy } first = no } # Compute the minimum and maximum integer shift values. if (xmin != 0.0) { ixmin = int (xmin + 0.5 * (xmin / abs (xmin))) } else { ixmin = 0 } if (xmax != 0.0) { ixmax = int (xmax + 0.5 * (xmax / abs (xmax))) } else { ixmax = 0 } if (ymin != 0.0) { iymin = int (ymin + 0.5 * (ymin / abs (ymin))) } else { iymin = 0 } if (ymax != 0.0) { iymax = int (ymax + 0.5 * (ymax / abs (ymax))) } else { iymax = 0 } # Prepare the imcombine input lists. imglist = tinlist nimglist = slist ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present and create the input image file name. fileroot (timg, validim+) timg = fileroot.root # Create the input image list for imcombine. print (timg, >> ilist) # Create the block replicated input image list used if mag > 1. print ("_blk_" // ip, >> bilist) # Compute the shift. newx = trmag * (txscale * a * cos (taxrad) + tyscale * b * tsign * sin (taxrad)) newy = trmag * (tyscale * b * tsign * cos (taxrad) - txscale * a * sin (taxrad)) # Determine the integer offsets for imcombine and store them in the # offsets file. if (newx != 0.0) { ix = int (newx + 0.5 * (newx / abs (newx))) } else { ix = 0 } if (newy != 0.0) { iy = int (newy + 0.5 * (newy / abs (newy))) } else { iy = 0 } print (ix, iy, >> olist) xfrac = newx - ix yfrac = newy - iy print (xfrac, yfrac, >> shlist) # Write the sections file for the later maskdereg step. if (tsections != "") { ix = 1 + ix - ixmin iy = 1 + iy - iymin hselect (timg, "i_naxis1", yes) | scan (ixdim) hselect (timg, "i_naxis2", yes) | scan (iydim) fx = ix + ixdim * trmag - 1 fy = iy + iydim * trmag - 1 if (fscan (nimglist, nimg) != EOF) { fileroot (nimg, validim+) nimg = fileroot.root print (nimg, " ", ix, iy, fx, fy, >> tsections) } else { print (timg, " ", ix, iy, fx, fy, >> tsections) } } # Set navg to 1 for now since the bundles feature is not being used. navg = 1 # Compute the flux correction factor mexp = (navg * ncoavg) / (trmag * trmag) print (mexp, >> fxlist) # Compute the total exposure time. If the exposure time is less than or # equal to 0 set it to 1 in the input list to imexamine for now. The image # will be excluded from the imcombine step by setting the entire bad pixel # mask to be zero. Setting mep to zero produces problems in imcombine. if (texp <= 0.0) { mexp = 1.0 } else { mexp = texp * navg * ncoavg * secpexp } print (mexp, >> etlist) } imglist = tinlist rimglist = rlist shimglist = shlist # Loop over the input image and rejection mask lists copying name of # the rejection mask into the BPM keyword. Do any necessary shifting in # order to account for the fractional pixel shifts as necessary. ip = 0 while (fscan (imglist, timg, a, b, texp) != EOF) { ip += 1 # Strip off extension if present. fileroot (timg, validim+) timg = fileroot.root print ("Checking mask for image: ", timg) # Get the rejection mask. if (trmasks == "") { rmskname = "" } else { rmskname = "" hselect (timg, trmasks, yes) | scan (rmskname) if (rmskname != "") { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else if (fscan (rimglist, rmskname) != EOF) { if (access (rmskname)) { print (" Using rejection mask file: ", rmskname) } else if (nimages > nrin) { rmskname = "" } else { print (" Cannot find rejection mask file: ", rmskname) rmskname = "" } } else { rmskname = "" } } # Get fractional part of shift. if (abs (trmag - 1.0) < 0.001 && fractional) { if (fscan (shimglist, xfrac, yfrac) == EOF) { xfrac = 0.0 yfrac = 0.0 } } # Create a temporary mask name if necesary. #if (rmskname != "") { #ntmpname = "_msktmp" // ip // "." // rmskname #if (imaccess (ntmpname)) #imdelete (ntmpname, verify-) #rtmpname = "_rmsktmp" // ip // "." // rmskname #if (imaccess (rtmpname)) #imdelete (rtmpname, verify-) #} else { ntmpname = "_msktmp." // ip // ".pl" if (imaccess (ntmpname)) imdelete (ntmpname, verify-) rtmpname = "_rmsktmp." // ip // ".pl" if (imaccess (rtmpname)) imdelete (rtmpname, verify-) #} # Set the BPM keyword. # The exposure time is 0. Eliminate all data. if (texp <= 0.0) { print (" Warning the exposure time is <= 0 assume all bad") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "0", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) # The rejection mask is undefined. Use all data. } else if (rmskname == "") { print (" Warning the mask is undefined assume all good") print (" Creating temporary mask ", rtmpname) hselect (timg, "i_naxis1,i_naxis2", yes) | scan (ixdim, iydim) imexpr ("repl(a,b)", rtmpname, "1", ixdim, dims=ixdim//","//iydim, intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) # The mask must be shifted a fractional pixel amount. } else if (abs (trmag - 1.0) < 0.001 && fractional) { print (" Shifting mask by ", xfrac, yfrac) imarith (rmskname, "*", "1000", ntmpname, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) imshift (ntmpname, ntmpname, xfrac, yfrac, shifts_file="", interp_type="linear", boundary_type="constant", constant=0.0) imexpr ("a >= 999 ? 1 : 0", rtmpname, ntmpname, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) imdelete (ntmpname, verify-) # Magnification instead of block replication } else if (! blkrep) { imcopy (rmskname, rtmpname, verbose-) hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rtmpname, ,add+, delete-, verify-, show-, update+) print (rtmpname, >> cmlist) print (rtmpname, >> tcmlist) # The mask is ok as is. No tmporary mask need be made. } else { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) hedit (timg, "BPM", rmskname, ,add+, delete-, verify-, show-, update+) print (rmskname, >> cmlist) } } # Combine the images. if (abs (trmag - 1.0) < 0.001) { if (fractional) { print ("Shifting the input images ...") imshift ("@" // ilist, "@" // bilist, 0.0, 0.0, shifts_file=shlist, interp_type="linear", boundary_type="constant", constant=0.0) print ("Shifting the exposure maps ...") print ("Combining the input images ...") imcombine ("@" // bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } else { print ("Combining the input images ...") imcombine ("@" // ilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } } else { imdelete ("@" // bilist, verify-, >& "dev$null") if (blkrep) { print ("Block replicating the input images ...") blkrep ("@" // ilist, "@" // bilist, nint(trmag), nint(trmag)) print ("Block replicating the exposure time images ...") blkrep ("@" // cmlist, "@" // cmlist, nint(trmag), nint(trmag)) } else { print ("Magnifying the input images ...") magnify ("@" // ilist, "@" // bilist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") print ("Magnifying the exposure time images ...") imarith ("@" // cmlist, "*", "1000", "@" // cmlist, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) magnify ("@" // cmlist, "@" // cmlist, trmag, trmag, x1=INDEF, x2=INDEF, dx=INDEF, y1=INDEF, y2=INDEF, dy=INDEF, interpolation="linear", boundary="nearest", constant=0.0, fluxconserve-, logfile="") cmimglist = cmlist while (fscan (cmimglist, timg) != EOF) { imexpr ("a >= 999 ? 1 : 0", "_tmpname.pl", timg, dims="auto", intype="auto", outtype="auto", ref="auto", bwidth=0, btype="nearest", bpixval=0.0, rangecheck=yes, verbose=no, exprdb="none") imdelete (timg, verify-) imrename ("_tmpname.pl", timg, verbose-) } } print ("Combining the input images ...") imcombine ("@" // bilist, toimg, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="goodvalue", maskvalue=1, blank=0.0, scale="@" // fxlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) print ("Combining the exposure time images ...") imcombine ("@" // cmlist, texpmap, headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", combine="sum", reject="none", project-, outtype="real", outlimits="", offsets=olist, masktype="none", maskvalue=0, blank=0.0, scale="@" // etlist, zero="none", weight="none", statsec="", expname="", lthreshold=INDEF, hthreshold=INDEF, nlow=1, nhigh=1, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0.0) } # Divide output image sum by exposure map. imarith (toimg, "/", texpmap, toimg, title="", divzero=0., hparams="", pixtype="real", calctype="real", ver-, noact-) # Orient these to N at top, E at left for iraf default orient (toimg, y2n_angle, rotation=rotation, invert-) orient (texpmap, y2n_angle, rotation=rotation, invert-) # Remove the BPM keyword from the input images. imglist = tinlist while (fscan (imglist, timg) != EOF) { hedit (timg, "BPM", add-, delete+, verify-, show-, update+) } # Copy header information from first input frame into the final mosaic and # exposure map images. Set mosaic exposure time to 1 second, delete exposure # time info from exposure map, and reset image titles. Add comment card about # origin of header information. imglist = tinlist # rewind imglist if (fscan (imglist, timg, a, b) != EOF) { hselect (timg, "title", yes) | scan (theadline) hedit (toimg, "exptime", "1", add+, delete-, verify-, show-, update+) hedit (toimg, "title", "Final combined image: " // theadline, add+, delete-, verify-, show-, update+) hedit (texpmap, "title", "Exposure time map: " // theadline, add+, delete-, verify-, show-, update+) hedit (toimg, "BPM,CRMASK,CROBJMAS,HOLES,MASKFIX,OBJMASK,REJMASK,SKYMED,SKYSUB", add-, delete+, verify-, show-, update+) #addcomment (toimg, "Header data copied from file " // timg, ver-) } # Cleanup. delete (olist, verify-) delete (fxlist, verify-) delete (etlist, verify-) delete (shlist, verify-) delete (ilist, verify-) if (access (tcmlist)) { imdelete ("@" // tcmlist, verify-, >& "dev$null") delete (tcmlist, verify-) } delete (cmlist, verify-) imdelete ("@" // bilist, verify-, >& "dev$null") delete (bilist, verify-) delete (rlist, verify-) delete (slist, verify-) imglist = "" nimglist = "" rimglist = "" shimglist = "" cmimglist = "" end iraf-xdimsum-main/src/xnslm.cl000066400000000000000000000123431455666516400167020ustar00rootroot00000000000000# Sky subtract a list of images using a running mean frame, akin to a local # sky flatfield. # # Sky frames are scaled by their median values before combining. Medians are # used because the data is unflattened. The image medians are computed by # the rskysub task. The computed median is written into the SKYMED header # keyword. If a SKYMED keyword already exists then the median is not recomputed # unless the forcescale parameter is enabled. # # Boolean parameter usomasks determines if scaling of images by their medians # excludes masked regions. For cases where variation due to objects exceeds # the residual flatfield variation in the input images, this parameter should # be yes. For dim objects and noticeable residual flatfield problems it should # be no. Note that even with useomask=no rskysub will mask out pixels. procedure xnslm (inlist, omasks, nmean, outlist) # Calls the xdimsum tasks rskysub. # Also calls the tasks sections and delete and the CL builtin tasks mktemp. string inlist {prompt="List of input images to be sky subtracted"} string omasks {"", prompt="The input object mask keyword or list"} int nmean {min=1,prompt="Number of images to use to make sky frame"} string outlist {".sub", prompt="The output sky subtracted images or suffix"} string hmasks {".hom", prompt="The output holes masks or suffix"} bool forcescale {no, prompt="Force recalculation of input image medians ?"} bool useomask {no, prompt="Use object masks to compute input image medians ?"} string statsec {"", prompt="The sky statistics image section"} real nsigrej {3.0, prompt="The nsigma sky statistics rejection limit"} int maxiter {20, prompt="The maximum number of sky statistics iterations"} int nskymin {3, min=0, prompt="The minimum number of frames to use for sky"} int nreject {1, min=0, prompt="The number of high and low side pixels to reject"} bool cache {yes, prompt="Attempt to cache images in memory ?"} bool del_hmasks {no, prompt="Delete holes masks on task termination ?"} struct *imglist begin string imlist, omsklist, outimlist, hmsklist string tomasks, toutlist, thmasks, img int nin, nomasks, tnmean, nsmin # Make temporary files. imlist = mktemp ("tmp$xnslm") omsklist = mktemp ("tmp$xnslm") outimlist = mktemp ("tmp$xnslm") hmsklist = mktemp ("tmp$xnslm") # Get query parameters and initialize sections (inlist, option="fullname", > imlist) nin = sections.nimages tnmean = nmean tomasks = omasks sections (tomasks, option="fullname", > omsklist) nomasks = sections.nimages if (tomasks == "") { useomask = no } else if (nomasks > 0) { if (nomasks > 1 && nin != nomasks) { print ("Input and object mask image lists do not match") delete (imlist, ver-) delete (omsklist, ver-) return } } else { useomask = no } toutlist = outlist if (substr (toutlist, 1, 1) == ".") { imglist = imlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // toutlist print (img, >> outimlist) } } else { sections (toutlist, option="fullname", > outimlist) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) return } } thmasks = hmasks if (substr (thmasks, 1, 1) == ".") { imglist = outimlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // thmasks print (img, >> hmsklist) } } else { sections (thmasks, option="fullname", > hmsklist) if (nin != sections.nimages) { print ("Error: Input and holes mask image lists do not match") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) delete (hmsklist, ver-) return } } # Check the value of nskymin. if (nskymin > tnmean) { print ("Parameter nskymin must be <= nmean") delete (imlist, ver-) delete (omsklist, ver-) delete (outimlist, ver-) delete (hmsklist, ver-) return } else if (nskymin == 0) { nsmin = tnmean } else { nsmin = nskymin } # Call the rskysub task. rskysub ("@" // imlist, "@" // outimlist, imasks="@" // omsklist, omasks="", hmasks= "@" // hmsklist, rescale=forcescale, scale="median", useimasks=useomask, skyscale="SKYMED", statsec=statsec, lower=INDEF, upper=INDEF, maxiter=maxiter, lnsigrej=nsigrej, unsigrej=nsigrej, binwidth=0.1, resubtract=yes, combine="average", ncombine=tnmean, nmin=nsmin, nlorej=nreject, nhirej=nreject, blank=0, skysub="SKYSUB", holes="HOLES", cache=cache, verbose=yes) # Cleanup. delete (imlist, ver-) delete (omsklist, ver-) delete (outimlist, ver-) if (del_hmasks) { imdelete ("@" // hmsklist, verify-, >& "dev$null") } delete (hmsklist, ver-) imglist = "" end iraf-xdimsum-main/src/xnzap.cl000066400000000000000000000176401455666516400167060ustar00rootroot00000000000000# Clean cosmic rays from images using an average filter. procedure xnzap (inlist, omasks, outlist, crmasks) string inlist {prompt="The list of input images to be cosmic ray cleaned"} string omasks {"", prompt="The input object mask keyword or name"} string outlist {prompt="The output image list of cosmic ray cleaned images"} string crmasks {".crm", prompt="The output cosmic rays masks of suffix"} int zboxsz {5,min=3,prompt="Box size for averaging filter"} int skyfiltsize {15,min=0,prompt="Median filter size for local sky evaluation"} int sigfiltsize {25,min=0,prompt="Percentile filter size for local sigma evaluation"} real nsigzap {5.0,min=0.,prompt="Positive zapping threshold in number of sky sigma"} real nsigneg {0.0,min=0.,prompt="Negative zapping threshold in number of sigma"} int nrejzap {1,min=0,prompt="Number of high pixels to reject from averaging filter"} int nrings {0,min=0,prompt="Number of pixels to flag around CRs"} real nsigobj {5.0,min=0.,prompt="Number of sky sigma for object identification"} int ngrowobj {0,min=0,prompt="Number of pixels to flag as buffer around objects"} bool del_crmask {no, prompt="Delete cosmic ray mask after execution?"} bool verbose {yes,prompt="Verbose output?"} struct *imglist struct *outimglist struct *omskimglist struct *crmskimglist begin real lcrsig, hcrsig, crgrow, lobjsig, hobjsig, objgrow int nin, nomasks, navg, nbkg, nsig, nrej bool dounzap string tomasks, maskfile, infile, outfile, omskfile, img, outimg, str1 string tcrmasks, crmskfile, ext, oext, crimg # Expand input image lists into temporary files. infile = mktemp ("tmp$xnzap") outfile = mktemp ("tmp$xnzap") omskfile = mktemp ("tmp$xnzap") crmskfile = mktemp ("tmp$xnzap") sections (inlist, option="fullname", >infile) nin = sections.nimages tomasks = omasks sections (tomasks, option="fullname", > omskfile) nomasks = sections.nimages if (tomasks == "") { dounzap = no } else if (nomasks > 0) { if (nomasks > 1 && nin != nomasks) { print ("Input and object mask image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } else { dounzap = yes } } else { dounzap = no } sections (outlist, option="fullname", >outfile) if (nin != sections.nimages) { print ("Error: Input and output image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } tcrmasks = crmasks if (substr (tcrmasks, 1, 1) == ".") { imglist = outfile while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tcrmasks // ".pl" print (img, >> crmskfile) } } else { sections (tcrmasks, option="fullname", > crmskfile) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } } # Define the filtering parameters. navg = zboxsz nbkg = max (1, (skyfiltsize - zboxsz) / 2) nsig = sigfiltsize nrej = nrejzap # Define the cosmic ray detection parameters. if (nsigzap <= 0) hcrsig = 65537.0 else hcrsig = nsigzap if (nsigneg <= 0.0) lcrsig = 65537.0 else lcrsig = nsigneg crgrow = nrings # Define the object detection parameters. if (nsigobj <= 0) hobjsig = 65537.0 else hobjsig = nsigobj lobjsig = 65537.0 objgrow = ngrowobj imglist = infile outimglist = outfile omskimglist = omskfile crmskimglist = crmskfile # Loop through input files. while (fscan (imglist, img) != EOF && fscan (crmskimglist, crimg) != EOF) { # Strip extension off input file name. fileroot (img, validim+) img = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext # Read name of output file. if (fscan (outimglist, outimg) == EOF) { print ("Error: Cannot find output image name in xzap") imglist = ""; delete (infile, verify-) outimglist = ""; delete (outfile, verify-) omskimglist = ""; delete (omskfile, verify-) return } # Strip extension off output file name. fileroot (outimg, validim+) outimg = fileroot.root oext = fileroot.extension if (oext != "") oext = "." // oext # Check the cosmic ray image name. fileroot (crimg, validim+) crimg = fileroot.root // ".pl" # Check for existence and status of the output image. if ( ! imaccess (outimg // oext)) { print ("Creating cosmic ray corrected image ", outimg) } else if (img // ext == outimg // oext) { imgets (outimg // oext, "CRMASK", >& "dev$null") if (imgets.value == "0") { print ("Creating cosmic ray corrected image ", outimg) } else { print ("Image ", outimg, " has already been cosmic ray corrected") next } } else { print ("Image ", outimg, " already exists") next } if (imaccess (crimg)) { imdelete (crimg, verify-) } # Get the mask file if any if (dounzap) { maskfile = "" hselect (img // ext, tomasks, yes) | scan (maskfile) if (maskfile != "") { if (access (maskfile)) { print (" Using header object mask : ", maskfile) } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else if (fscan (omskimglist, maskfile) != EOF) { if (access (maskfile)) { print (" Using object mask : ", maskfile) } else if (nin > nomasks) { maskfile = "" } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else { maskfile = "" } if (maskfile != "") { minv (maskfile, crimg) } } else { maskfile = "" } # Detect the cosmic rays. if (img // ext == outimg // oext) { str1 = "_out_" if (oext != "") str1 = str1 // oext craverage (img // ext, str1, crmask=crimg, average="", sigma="", navg=navg, nrej=nrej, nbkg=nbkg, nsig=sigfiltsize, var0=0.0, var1=0.0, var2=0.0, crval=1, lcrsig=lcrsig, hcrsig=hcrsig, crgrow=crgrow, objval=0, lobjsig=lobjsig, hobjsig=hobjsig, objgrow=objgrow) imdelete (img // ext, verify-) imrename (str1, outimg // oext, verbose-) } else { craverage (img // ext, outimg // oext, crmask=crimg, average="", sigma="", navg=navg, nrej=nrej, nbkg=nbkg, nsig=sigfiltsize, var0=0.0, var1=0.0, var2=0.0, crval=1, lcrsig=lcrsig, hcrsig=hcrsig, crgrow=crgrow, objval=0, lobjsig=lobjsig, hobjsig=hobjsig, objgrow=objgrow) } if (dounzap && maskfile != "") { imarith (maskfile, "*", crimg, crimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) } # Record CR mask name in headers of input and output images. hedit (img // ext // "," // outimg // oext, "CRMASK", crimg, add+, ver-, show+, update+, >& "dev$null") # Clean up. if (del_crmask) delete (crimg, verify-) if (verbose) print (" Done") } imglist = ""; delete (infile, verify-) outimglist = ""; delete (outfile, verify-) omskimglist = ""; delete (omskfile, verify-) crmskimglist = ""; delete (crmskfile, verify-) end iraf-xdimsum-main/src/xrshifts.cl000066400000000000000000000112261455666516400174120ustar00rootroot00000000000000# Compute accurate shifts for a list of images taken in time sequence with # a known approximate shift between adjacent images using cross-corelation # techniques. procedure xrshifts (inlist, output, shifts, regions, xlag, ylag, window, cbox) string inlist {prompt="The input sky subtracted image sequence"} string output {prompt="The output img, pixel shifts, and exposure time file"} string shifts {prompt="Optional output relative shifts file"} string regions {"[*,*]", prompt="Reference image regions used for correlation"} real xlag {0, prompt="Initial shift in x in pixels"} real ylag {0, prompt="Initial shift in y in pixels"} int window {21, prompt="Width of the correlation window"} int cbox {7, prompt="Width of the centering box"} string background {"none", enum="|none|mean|median|plane|", prompt="Background fitting function"} string correlation {"discrete", enum="|discrete|fourier|", prompt="Cross-correlation function"} string function {"centroid", enum="|none|centroid|sawtooth|parabolic|mark|", prompt="Correlation peak centering algorithm"} real tolerance {5.0, prompt="Maximum difference of shift from lag"} bool interactive {no, prompt="Run in interactive mode ?"} struct *imglist begin # Declare local variables. real txlag, tylag real sumdx, sumdy, dx, dy int ixlag, iylag, twindow, tcbox int i, nimages, idx, idy string tinlist, toutput, tshifts, tregions string img, refimages, inimages, refname, shiftsdb print ("start") time ("") # Get query parameters. tinlist = mktemp ("tmp$xrshifts") sections (inlist, option="fullname", > tinlist) count (tinlist) | scan (nimages) if (nimages <= 0) { print ("The input image list is empty") delete (tinlist, verify-) return } toutput = output if (access (toutput)) { print ("The output file: ", toutput, " already exists") delete (tinlist, verify-) return } tshifts = shifts if (tshifts != "") { if (access (tshifts)) { print ("The shifts file: ", tshifts, " already exists") delete (tinlist, verify-) return } } tregions = regions txlag = xlag tylag = ylag twindow = window tcbox = cbox # Contruct temporary file names for xregister. inimages = mktemp ("tmp$xrshifts") refimages = mktemp ("tmp$xrshifts") shiftsdb = mktemp ("tmp$xrshifts") # Contruct the reference and input images list. imglist = tinlist for (i = 1; i <= nimages; i = i + 1) { if (fscan (imglist, img) == EOF) { break } if (i == 1) { refname = img print (img, >> refimages) } else if (i == nimages) { print (img, >> inimages) } else { print (img, >> refimages) print (img, >> inimages) } } print ("Begin computing cross-correlation functions") time ("") # Call xregister. ixlag = nint (txlag) iylag = nint (tylag) xregister ("@" // inimages, "@" // refimages, tregions, shiftsdb, output="", databasefmt-, append-, records="", coords="", xlag=ixlag, ylag=iylag, dxlag=0, dylag=0, background=background, border=INDEF, loreject=INDEF, hireject=INDEF, apodize=0.0, filter="none", correlation=correlation, xwindow=twindow, ywindow=twindow, function=function, xcbox=tcbox, ycbox=tcbox, interp_type="linear", boundary_type="nearest", constant=0.0, interactive=interactive, verbose-, graphics="stdgraph", display="stdimage", gcommands="", icommands="") # Create the output file to use as input by sregister. imglist = shiftsdb # Write the results for the first image. print (refname, " 0.0 0.0 1.0", >> toutput) # Convert the remaining shifts to integer and record. If the shift # is undefined or zero set it to the negative of the initial lag. print ("Begin accumulating total shifts ...") time ("") sumdx = 0.0 sumdy = 0.0 while (fscan (imglist, img, dx, dy) != EOF) { if (dx == INDEF || abs (-dx - txlag) > tolerance ) { dx = -txlag dy = -tylag print (" Warning the shift for image ", img, "is undefined") } else if (dy == INDEF || abs (-dy - tylag) > tolerance) { dx = -txlag dy = -tylag print (" Warning the shift for image ", img, "is undefined") } sumdx = sumdx - dx sumdy = sumdy - dy if (sumdx == 0.0) { idx = 0 } else { idx = sumdx + (abs (sumdx) / sumdx) * 0.5 } if (sumdy == 0.0) { idy = 0 } else { idy = sumdy + (abs (sumdy) / sumdy) * 0.5 } print (img, " ", sumdx, sumdy, " 1.0", >> toutput) } # Cleanup. if (tshifts != "") { print (refname, " 0.0 0.0 ", >> tshifts) concatenate (shiftsdb, tshifts, out_type="in_type", append+) } delete (shiftsdb, verify-) delete (refimages, verify-) delete (inimages, verify-) delete (tinlist, verify-) imglist = "" print ("finish") time ("") end iraf-xdimsum-main/src/xslm.cl000066400000000000000000000377471455666516400165430ustar00rootroot00000000000000# Sky subtract a list of images using a running mean frame, akin to a local # sky flatfield. # # Sky frames are scaled by their median values before combining. Medians are # used because the data is unflattened. The image medians are computed with # the iterstat or maskstat tasks depending on whether or not masking is # enabled. The computed median is written into the SKYMED header keyword. # If a SKYMED keyword already exists then the median is not recomputed unless # the forcescale parameter is enabled. # # Boolean parameter premask determines if scaling of images by their medians # excludes masked regions. For cases where variation due to objects exceeds # the residual flatfield variation in the input images, this parameter should # be yes. For dim objects and noticeable residual flatfield problems it should # be no. Note that even with premask=no imcombine will mask out pixels. # Xslm runs quicker with premask=no procedure xslm (inlist, omasks, nmean, outlist) # Calls the xdimsum scripts xlist, iterstat, minv, maskstat, and addcomment. # # Also calls the tasks imstat, imcopy, imreplace, sections, delete, imgets # hedit, imcombine, imarith, imdelete, and imexpr. string inlist {prompt="List of input images to be sky subtracted"} string omasks {"", prompt="The input object mask keyword or list"} int nmean {min=1,prompt="Number of images to use to make sky frame"} string outlist {".sub", prompt="The output sky subtracted images or suffix"} string ssmasks {".ssm", prompt="The output sky subtraction masks or suffix"} string hmasks {".hom", prompt="The output holes masks or suffix"} bool forcescale {no, prompt="Force recalculation of input image medians ?"} bool useomask {yes, prompt="Use object masks to compute sky statistics ?"} string statsec {"", prompt="The sky statistics image section"} real nsigrej {3.0, prompt="The nsigma sky statistics rejection limit"} int maxiter {20, prompt="The maximum number of sky statistics iterations"} int nskymin {3, min=0, prompt="The minimum number of frames to use for sky"} int nreject {1, min=0, prompt="The number of high and low side pixels to reject"} bool del_ssmasks {yes, prompt="Delete sky substraction masks on task termination ?"} bool del_hmasks {no, prompt="Delete holes masks on task termination ?"} struct *imglist struct *omskimglist struct *outimglist struct *ssmskimglist struct *hmskimglist begin real valmed, imcscale int tnmean, nin, nomasks, nsmin, ip, nml, nmh, start, finish, nrej int nskyframes, maxcsky string tomasks, outimlist, toutlist, imlist, omsklist, img, maskfile string subimg, templist, ext, tssmasks, ssmsklist, ssmsk, thmasks string hmsklist, hmsk bool msk, skysub, scalecalc struct theadline # Make temporary files. imlist = mktemp ("tmp$xslm") omsklist = mktemp ("tmp$xslm") outimlist = mktemp ("tmp$xslm") ssmsklist = mktemp ("tmp$xslm") hmsklist = mktemp ("tmp$xslm") # Get query parameters and initialize sections (inlist, option="fullname", > imlist) nin = sections.nimages tnmean = nmean tomasks = omasks sections (tomasks, option="fullname", > omsklist) nomasks = sections.nimages if (tomasks == "") { msk = no useomask = no } else if (nomasks > 0) { if (nomasks > 1 && nin != nomasks) { print ("Input and object mask image lists do not match") delete (imlist, ver-) delete (omsklist, ver-) return } else { msk = yes } } else { msk = no useomask = no } toutlist = outlist if (substr (toutlist, 1, 1) == ".") { imglist = imlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // toutlist print (img, >> outimlist) } } else { sections (toutlist, option="fullname", > outimlist) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) return } } tssmasks = ssmasks if (substr (tssmasks, 1, 1) == ".") { imglist = outimlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tssmasks print (img, >> ssmsklist) } } else { sections (tssmasks, option="fullname", > ssmsklist) if (nin != sections.nimages) { print ("Error: Input and sky masks image lists do not match") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) delete (ssmsklist, ver-) return } } thmasks = hmasks if (substr (thmasks, 1, 1) == ".") { imglist = outimlist while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // thmasks print (img, >> hmsklist) } } else { sections (thmasks, option="fullname", > hmsklist) if (nin != sections.nimages) { print ("Error: Input and holes mask image lists do not match") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) delete (ssmsklist, ver-) delete (hmsklist, ver-) return } } # Check the value of nskymin. if (nskymin > tnmean) { print ("Parameter nskymin must be <= nmean") delete (imlist, ver-) delete (outimlist, ver-) delete (omsklist, ver-) delete (ssmsklist, ver-) delete (hmsklist, ver-) return } else if (nskymin == 0) { nsmin = tnmean } else { nsmin = nskymin } # Calculate the scaling factors for all frames. If we are using object masking # first get the name of the object mask from the image header keyword OBJMASK # and then insert this name into the keyword BPM for later use in imcombine. imglist = imlist omskimglist = omsklist skysub = no while (fscan (imglist, img) != EOF) { # Determine whether or not to compute the scaling factor scalecalc = forcescale if (! forcescale) { templist = "" hselect (img, "SKYMED", yes) | scan (templist) if (templist == "") scalecalc = yes } if (scalecalc) { print ("Calculating scaling for ", img) } # Determine the name of the mask file and store it in the image header. if (msk) { maskfile = "" hselect (img, tomasks, yes) | scan (maskfile) if (maskfile != "") { if (access (maskfile)) { print (" Using header object mask : ", maskfile) } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else if (fscan (omskimglist, maskfile) != EOF) { if (access (maskfile)) { print (" Using object mask : ", maskfile) } else if (nin > nomasks) { maskfile = "" } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else { maskfile = "" } if (maskfile != "") { hedit (img, "BPM", maskfile, add+, delete-, verify-, show-, update+) } } else { maskfile = "" } # Calculate the median of the image. If useomask=yes use only unmasked pixels. # Record this value into the image header with the card SKYMED. If SKYMED card # already exists in the header, do not recalculate unless the parameter # forcescale=yes. if (scalecalc) { #print ("Calculating scaling for ", img) if (msk && useomask) { maskstat (img, maskfile, 0.0, statsec=statsec, lower=INDEF, upper=INDEF, iterstat+, nsigrej=nsigrej, maxiter=maxiter, show-) imcscale = 1.0 / maskstat.median print (" Setting scaling factor to 1 / ", maskstat.median) } else { iterstat (img, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show-) imcscale = 1.0 / iterstat.imedian print (" Setting scaling factor to 1 / ", iterstat.imedian) } skysub = yes hedit (img, "SKYMED", imcscale, add+, delete-, verify-, show-, update+) } } # Initialize and check parameter values. ip=0 if (tnmean > nin) { tnmean = nin - 1 print("Xslm parameter nmean too big resetting t0: ", tnmean) } if (tnmean < 1) { print("Nmedian is too small") delete (imlist, ver-) delete (omsklist, ver-) return } # Begin main loop imglist = imlist omskimglist = omsklist outimglist = outimlist ssmskimglist = ssmsklist hmskimglist = hmsklist while (fscan (imglist, img) != EOF && fscan (outimglist, subimg) != EOF && fscan (ssmskimglist, ssmsk) != EOF && fscan (hmskimglist, hmsk) != EOF) { # Increment pointer. ip += 1 # Get the output sky subtracted image name. If the image already exists # delete it and any associated masks if the sky median of any image was # recomputed. fileroot (subimg, validim+) subimg = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext fileroot (ssmsk, validim+) ssmsk = fileroot.root // ".pl" fileroot (hmsk, validim+) hmsk = fileroot.root // ".pl" if (skysub || ! imaccess (subimg // ext)) { print ("Creating sky subtracted image ", subimg) if (imaccess (subimg // ext)) { imdelete (subimg // ext, ver-) } } else { print ("Sky subtracted image ", subimg, " already exists") next } # Construct lists of input images and masks for this sky image. nml = tnmean / 2 nmh = tnmean - nml if (ip - nml < 1) { start = 1 finish = max (ip + (ip - 1), nsmin + 1) } else if (ip + nmh > nin) { start = min (ip - (nin - ip), nin - nsmin) finish = nin } else { start = ip - nml finish = ip + nmh } if ((finish - start) <= 2 * nreject) { nrej = max ((finish - start) / 2 - 1, 0) } else { nrej = nreject } nskyframes = finish - start print (" Frame ",ip," Sky frames: start = ",start, " finish = ",finish," nreject = ",nrej) templist = mktemp ("tmp$xslm") xlist (imlist, templist, start, finish, ip, suffix="") # Construct sky. If we are using object masking, the parameter imcombine. # plfile is used to create a .pl file called ssmsk which, for each pixel in # the sky frame, counts the number of images excluded from the final average by # either pixel masking or rejection. This will later be used to create the # "holes" image. If there are any "holes" (i.e. regions where no images # contributed to the final sky), the parameter imcombine.blank sets those # pixels to 0. Note that these steps are not necessary if we are not masking, # as nrej has been forced to be small enough so that at least one pixel will # remain in the average. if (imaccess ("_skytemp")) imdelete ("_skytemp", ver-) if (imaccess (ssmsk)) { imdelete (ssmsk, ver-) } if (msk) { imcombine ("@"//templist, "_skytemp", headers="", bpmasks="", rejmasks="", nrejmasks=ssmsk, expmasks="", sigmas="", logfile="", comb="average", reject="minmax", project-, outtype="real", outlimits="", offsets="none", masktype="goodval", maskval=0., blank=0., scale="!SKYMED", zero="none", weight="none", statsec="", expname="", lthresh=INDEF, hthresh=INDEF, nlow=nrej, nhi=nrej, nkeep=0, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0) } else { imcombine ("@"//templist, "_skytemp", headers="", bpmasks="", rejmasks="", nrejmasks="", expmasks="", sigmas="", logfile="", comb="average", reject="minmax", project-, outtype="real", outlimits="", offsets="none", masktype="none", blank=0., scale="!SKYMED", zero="none", weight="none", statsec="", expname="", lthresh=INDEF, hthresh=INDEF, nlow=nrej, nhi=nrej, nkeep=0, mclip+, lsigma=3.0, hsigma=3.0, rdnoise="0.0", gain="1.0", snoise="0.0", sigscale=0.1, pclip=-0.5, grow=0) } # Divide image by _skytemp frame to produce temporary ratio image _sclmsktemp. if (imaccess ("_sclmsktemp")) { imdelete ("_sclmsktemp", ver-) } imarith (img, "/", "_skytemp", "_sclmsktemp", divzero=0., title="", hparams="", pixtype="real", calctype="real", ver-, noact-) # Calculate median of unmasked (sky) pixels in _sclmsktemp and save in variable # valmed. Delete _sclmsktemp image afterward. if (msk) { maskfile = "" hselect (img, tomasks, yes) | scan (maskfile) if (maskfile != "") { if (access (maskfile)) { print (" Using header object mask : ", maskfile) } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else if (fscan (omskimglist, maskfile) != EOF) { if (access (maskfile)) { print (" Using object mask : ", maskfile) } else if (nin > nomasks) { maskfile = "" } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else { maskfile = "" } maskstat ("_sclmsktemp", maskfile, 0., lower=0., upper=INDEF, iterstat+, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, show-) valmed = maskstat.median } else { maskfile = "" iterstat ("_sclmsktemp", statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show-) valmed = iterstat.imedian } imdelete ("_sclmsktemp", ver-) # Rescale _skytemp to object frame median and subtract from object. Replace # with IMEXPR task. imexpr ("a - b * c", subimg // ext, img, "" // valmed, "_skytemp", dims="auto", intype="real", outtype="real", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) # If we are using object masking, find "holes" in the sky subtracted frame # wherever the sky frame had no unrejected pixels entering into the coaverage. if (msk) { if (imaccess (hmsk)) { imdelete (hmsk, ve-) } imstat (ssmsk, format-, fields="max", lower=INDEF, upper=INDEF, binwidth=0.1, nclip=0, lsigma=3.0, usigma=3.0, cache-) | scan (maxcsky) if (maxcsky == nskyframes && ! del_hmasks) { #imstat (ssmsk, format-, fields="npix", lower=nskyframes, #upper=nskyframes, binwidth=0.1) | scan (nholes) #print ("There are ", nholes, " holes in output image ", #subimg) print (" Creating holes mask: ", hmsk) imexpr ("a >= b ? 0 : 1", hmsk, ssmsk, "" // nskyframes, dims="auto", intype="auto", outtype="auto", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) hedit (subimg // ext, fields="HOLES", value=hmsk, add+, delete-, verify-, update+, show-) } if (del_ssmasks) { imdelete (ssmsk, ve-) } } # Add comment card to header of sky subtracted image. if (msk) { print ("Object masked and sky subtracted with nmean=", tnmean, "nreject=", nreject) | scan (theadline) } else { print ("Sky subtracted with nmean=", tnmean, "nreject=", nreject) | scan (theadline) } hedit (subimg // ext, "SKYSUB", theadline, add+, delete-, verify-, update+, show-) # Clean up. imdelete ("_skytemp", ver-) delete (templist, ver-) } if (msk) { imglist = imlist outimglist = outimlist while (fscan (imglist, img) != EOF && fscan (outimglist, subimg) != EOF) { hedit (img, "BPM", maskfile, add-, delete+, verify-, show-, update+) hedit (subimg, "BPM", maskfile, add-, delete+, verify-, show-, update+) } } delete (imlist, ver-) delete (omsklist, ver-) delete (outimlist, ver-) delete (ssmsklist, ver-) delete (hmsklist, ver-) imglist = "" outimglist = "" omskimglist = "" ssmskimglist = "" hmskimglist = "" end iraf-xdimsum-main/src/xzap.cl000066400000000000000000000337011455666516400165240ustar00rootroot00000000000000# Clean cosmic rays from images using median filtering. procedure xzap (inlist, omasks, outlist, crmasks) # Calls xdimsum scripts fileroot.cl, iterstat.cl, makemask.cl, minv.cl # # Also calls sections, minmax, fmedian, imarith, imcopy, imdelete, imreplace, # imexpr, boxcar, hedit, and delete tasks. # # If omasks is defined then the input object mask is used to unzap cosmic # rays in object regions. This object mask must be the inverse of the # usual object mask, i.e. pixels in object regions are 0's, pixels elsewhere # are 1's. In xdimsum the object mask is usually stored in the keyword # CROBJMAS. # # The name of the output cosmic ray mask is written into the keyword # CRMASK in both the input and the output images. string inlist {prompt="List of input images to be cosmic ray cleaned"} string omasks {"", prompt="The input object mask keyword or list"} string outlist {prompt="List of output cosmic ray cleaned images"} string crmasks {".crm", prompt="The output cosmic ray masks or suffix"} string statsec {"",prompt="Image section to use for computing sky sigma"} real nsigrej {3.0, prompt="The n-sigma sky rejection parameter"} int maxiter {20, prompt="The maximum number of iterations"} bool checklimits {yes,prompt="Check min and max pix values before filtering?"} int zboxsz {5,min=3,prompt="Box size for fmedian filter"} real zmin {-32768.0,prompt="Minimum data value for fmedian filter"} real zmax {32767.0,prompt="Maximum data value for fmedian filter"} real nsigzap {5.0,min=0.,prompt="Zapping threshold in number of sky sigma"} real nsigobj {2.0,min=0.,prompt="Number of sky sigma for object identification"} int subsample {1,min=0,prompt="Block averaging factor before median filtering"} int skyfiltsize {15,min=0,prompt="Median filter size for local sky evaluation"} int ngrowobj {0,min=0,prompt="Number of pixels to flag as buffer around objects"} int nrings {0,min=0,prompt="Number of pixels to flag around CRs"} real nsigneg {0.0,min=0.,prompt="Number of sky sigma for negative zapping"} bool del_crmask {no, prompt="Delete cosmic ray mask after execution?"} bool del_wimages {yes,prompt="Delete working images after execution?"} bool del_wmasks {yes,prompt="Delete working .pl masks after execution?"} bool verbose {yes,prompt="Verbose output?"} struct *imglist struct *outimglist struct *omskimglist struct *crmskimglist begin real skysig, skymode, crthresh, objthresh, negthresh, dmin, dmax int nomasks, nbox, nbox2, nin string infile, maskfile, omskfile, crmskfile, outfile, tomasks string tcrmasks, img, outimg, crimg, ext, oext bool maskobj, dounzap, maskneg # Expand file lists into temporary files. infile = mktemp ("tmp$xzap") outfile = mktemp ("tmp$xzap") omskfile = mktemp ("tmp$xzap") crmskfile = mktemp ("tmp$xzap") sections (inlist, option="fullname", > infile) nin = sections.nimages tomasks = omasks sections (tomasks, option="fullname", > omskfile) nomasks = sections.nimages if (tomasks == "") { dounzap = no } else if (nomasks > 0) { if (nomasks > 1 && nin != nomasks) { print ("Error: Input and object mask image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } else { dounzap = yes } } else { dounzap = no } sections (outlist, option="fullname", > outfile) if (nin != sections.nimages) { print ("Error: Input and output image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } tcrmasks = crmasks if (substr (tcrmasks, 1, 1) == ".") { imglist = outfile while (fscan (imglist, img) != EOF) { fileroot (img, validim+) img = fileroot.root // tcrmasks // ".pl" print (img, >> crmskfile) } } else { sections (tcrmasks, option="fullname", > crmskfile) if (nin != sections.nimages) { print ("Error: Input and cosmic ray image lists do not match") delete (infile, ver-) delete (outfile, ver-) delete (omskfile, ver-) delete (crmskfile, ver-) return } } # Check input parameters. if (nsigobj <= 0.0) { print ("Warning: No internal object masking will be done in xzap") maskobj = no } else { maskobj = yes } if (nsigneg > 0.0) maskneg = yes else maskneg = no imglist = infile outimglist = outfile omskimglist = omskfile crmskimglist = crmskfile # Loop through input files: while (fscan (imglist,img) != EOF && fscan (crmskimglist, crimg) != EOF) { # Strip extension off input file name. fileroot (img, validim+) img = fileroot.root ext = fileroot.extension if (ext != "") ext = "." // ext fileroot (crimg, validim+) crimg = fileroot.root // ".pl" # Read name of output file. if (fscan (outimglist, outimg) == EOF) { print ("Error: Cannot find output image name in xzap") imglist = ""; delete (infile, verify-) outimglist = ""; delete (outfile, verify-) omskimglist = ""; delete (omskfile, verify-) return } # Strip extension off output file name. fileroot (outimg, validim+) outimg = fileroot.root oext = fileroot.extension if (oext != "") oext = "." // oext if ( ! imaccess (outimg // oext)) { print ("Creating cosmic ray corrected image ", outimg) } else if (img // ext == outimg // oext) { imgets (outimg // oext, "CRMASK", >& "dev$null") if (imgets.value == "0") { print ("Creating cosmic ray corrected image ", outimg) } else { print ("Image ", outimg, " has already been cosmic ray corrected") next } } else { print ("Image ", outimg, " already exists") next } # Calculate sky mean and RMS noise using iterative sigma rejection. if (verbose) print (" Computing image statistics") iterstat (img // ext, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, lower=INDEF, upper=INDEF, show-) skymode = iterstat.imean skysig = iterstat.isigma # Median filter image to produce file _fmedtemp if (verbose) print (" Median filtering") # First, check limits of data range. Wildly large (positive or negative) data # values will screw up fmedian calculation unless checklimits = yes and zmin # and zmax are set to appropriate values, e.g. zmin=-32768, zmax=32767. Note # that the old fmedian bug which occurred if zmin=hmin and zmax=hmax has been # fixed in IRAF version 2.10.1. The pipe to dev$null however is included # because V2.10.1 and .2 have debugging print statements accidentally left in # the fmedian code. if (imaccess ("_fmedtemp")) imdelete ("_fmedtemp", ver-) if (checklimits) { minmax (img // ext, force+, update+, ve-) if (verbose) { print(" Data minimum = ", minmax.minval, " maximum = ", minmax.maxval) } if (minmax.minval < zmin || minmax.maxval > zmax) { if (minmax.minval < zmin) { dmin = zmin } else { dmin = minmax.minval } if (minmax.maxval > zmax) { dmax = zmax } else { dmax = minmax.maxval } if (verbose) { print (" Truncating data range ",dmin," to ",dmax) } fmedian (img // ext, "_fmedtemp", zboxsz, zboxsz, hmin=-32768, hmax=32767, zmin=dmin, zmax=dmax, zloreject=INDEF, zhireject=INDEF, unmap+, boundary="reflect", constant=0.0, verbose-) } else { fmedian (img // ext, "_fmedtemp", zboxsz, zboxsz, hmin=-32768, hmax=32767, zmin=INDEF, zmax=INDEF, zloreject=INDEF, zhireject=INDEF, unmap+, boundary="reflect", constant=0.0, verbose-) } } else { fmedian (img // ext, "_fmedtemp", zboxsz, zboxsz, hmin=-32768, hmax=32767, zmin=INDEF, zmax=INDEF, zloreject=INDEF, zhireject=INDEF, unmap+, boundary="reflect", constant=0.0, verbose-) } # Take difference to produce "unsharp masked" image _crtemp if (imaccess ("_crtemp")) imdelete ("_crtemp", ver-) imarith (img // ext, "-", "_fmedtemp", "_crtemp", title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) # Threshold _crtemp at nsigzap * skysig to make CR masks _peakstemp. # Potential CRs --> 1 # Blank sky --> 0 # Note that crthresh will be positive by definition. if (verbose) print (" Masking potential CR events") if (imaccess ("_peakstemp" // ".pl")) { imdelete ("_peakstemp" // ".pl", ver-) } crthresh = nsigzap * skysig imexpr ("a >= b ? 1 : 0", "_peakstemp" // ".pl", "_crtemp", "" // crthresh, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) # Object masking: create mask identifying where objects might be. if (imaccess (crimg)) { imdelete (crimg, ver-) } if (maskobj) { if (verbose) print (" Creating object mask") objthresh = nsigobj * skysig if (imaccess ("_objfmedtemp" // ".pl")) { imdelete ("_objfmedtemp" // ".pl", ver-) } makemask ("_fmedtemp", "_objfmedtemp" // ".pl", hinlist="", subsample=subsample, filtsize=skyfiltsize, nsmooth=0, statsec=statsec, nsigrej=nsigrej, maxiter=maxiter, threshtype="constant", nsigthresh=2.0, constth=objthresh, negthresh=no, ngrow=ngrowobj, checklimits=checklimits, zmin=-32767, zmax=32767, verbose-) # Invert mask to make "objects" --> 0 and "sky" --> 1. minv ("_objfmedtemp" // ".pl", "_objfmedtemp" // ".pl") # If not masking objects, final CR mask is just _peakstemp. If we are # masking objects, take product of object and CR masks to make crm_//img imarith ("_peakstemp" // ".pl", "*", "_objfmedtemp" // ".pl", crimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-) } else { imcopy ("_peakstemp" // ".pl", crimg, verbose-) } # Grow additional buffer region around identified CRs. if (nrings > 0) { if (verbose) print (" Growing mask rings around CR hits") nbox = 2 * nrings + 1 nbox2 = nbox * nbox imarith (crimg, "*", nbox2, crimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-) boxcar (crimg, crimg, nbox, nbox, boundary=nearest, constant=0.0) imreplace (crimg, 1, lower=1, upper=INDEF, radius=0.0) } # Identify negative pixels if desired. No "rings" are grown around negative # pixels. if (maskneg) { if (verbose) print (" Masking deviant negative pixels") if (access ("_negtemp" // ".pl")) { delete ("_negtemp" // ".pl", ver-) } negthresh = -1. * nsigneg * skysig imexpr ("a >= b ? 1 : 0", "_negtemp" // ".pl", "_crtemp", "" // negthresh, dims="auto", intype="auto", outtype="int", refim="auto", rangecheck=yes, bwidth=0, btype="nearest", bpixval=0.0, exprdb="none", verbose-) imarith (crimg, "+", "_negtemp" // ".pl", crimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", verbose-, noact-) imreplace (crimg, 1, lower=1, upper=INDEF, radius=0.0) } # Unzap pixels which are where objects are as defined by objmask files if (dounzap) { if (verbose) print (" Unzapping CRs which are object pixels") maskfile = "" hselect (img // ext, tomasks, yes) | scan (maskfile) if (maskfile != "") { if (access (maskfile)) { print (" Using header object mask : ", maskfile) } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else if (fscan (omskimglist, maskfile) != EOF) { if (access (maskfile)) { print (" Using object mask : ", maskfile) } else if (nin > nomasks) { maskfile = "" } else { print (" Cannot find object mask: ", maskfile) maskfile = "" } } else { maskfile = "" } if (maskfile != "") imarith (maskfile, "*", crimg, crimg, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) } # Remove processing keywords from the cosmic ray mask. hedit (crimg, "SKYMED,SKYSUB,MASKFIX", "", add-, del+, ver-, show-, update+, >& "dev$null") # Multiply CR mask by crm_//img to make "comic rays only" image _cronlytmp # Could combine two imarith statements into 1 imexpr call except for the # option of keeping the _cronlytemp image. if (verbose) print (" Replacing CR hits with local median") if (imaccess ("_cronlytemp")) imdelete ("_cronlytemp", ver-) imarith ("_crtemp", "*", crimg, "_cronlytemp", title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) # Subtract _cronlytemp from data to produce clean image "outimg". Note that # this effectively replaces the masked regions with the local median, since # _cronlytemp = img - _fmedtemp. imarith (img // ext, "-" , "_cronlytemp", outimg // oext, title="", divzero=0.0, hparams="", pixtype="", calctype="", ver-, noact-) # Record CR mask name in headers of input and output images hedit (img // ext // "," // outimg // oext, "CRMASK", crimg, add+, ver-, show-, update+, >& "dev$null") # Clean up. if (del_crmask) delete (crimg, verify-) if (del_wmasks) { delete ("_peakstemp" // ".pl", ve-) if (maskobj) delete ("_objfmedtemp" // ".pl", ve-) if (maskneg) delete ("_negtemp" // ".pl", ve-) } if (del_wimages) { imdelete ("_fmedtemp", ve-) imdelete ("_crtemp", ve-) imdelete ("_cronlytemp", ve-) } if (verbose) print (" Done") } imglist = ""; delete (infile, verify-) outimglist = ""; delete (outfile, verify-) omskimglist = ""; delete (omskfile, verify-) crmskimglist = ""; delete (crmskfile, verify-) end iraf-xdimsum-main/xdimsum.cl000066400000000000000000000043011455666516400164330ustar00rootroot00000000000000# { XDIMSUM -- Package definition script for the XDIMSUM IR array imaging # reduction package. # Load necessary packages. # Currently artdata is only required for the demos task. It is not required # for the main xdimsum package. artdata # Crutil is required by the new experiment cosmic ray zapping task xnzap. imred crutil # Define the package. This is not required if xdimsum is not an external # pacakge. cl < "xdimsum$lib/zzsetenv.def" package xdimsum, bin = xdimsumbin$ # Main XDIMSUM tasks task badpixupdate = "xdimsum$src/badpixupdate.cl" task iterstat = "xdimsum$src/iterstat.cl" task miterstat = "xdimsum$src/miterstat.cl" task maskdereg = "xdimsum$src/maskdereg.cl" task maskfix = "xdimsum$src/maskfix.cl" task maskstat = "xdimsum$src/maskstat.cl" task mkmask = "xdimsum$src/mkmask.cl" task orient = "xdimsum$src/orient.cl" task sigmanorm = "xdimsum$src/sigmanorm.cl" task xdshifts = "xdimsum$src/xdshifts.cl" task xfirstpass = "xdimsum$src/xfirstpass.cl" task xfshifts = "xdimsum$src/xfshifts.cl" task xlist = "xdimsum$src/xlist.cl" task xmaskpass = "xdimsum$src/xmaskpass.cl" task xmskcombine = "xdimsum$src/xmskcombine.cl" task xmosaic = "xdimsum$src/xmosaic.cl" task xmshifts = "xdimsum$src/xmshifts.cl" task xnregistar = "xdimsum$src/xnregistar.cl" task xnslm = "xdimsum$src/xnslm.cl" task xnzap = "xdimsum$src/xnzap.cl" task xrshifts = "xdimsum$src/xrshifts.cl" task xslm = "xdimsum$src/xslm.cl" task xzap = "xdimsum$src/xzap.cl" # Additional hidden XDIMSUM tasks required by the main XDIMSUM tasks. task addcomment = "xdimsum$src/addcomment.cl" task avshift = "xdimsum$src/x_xdimsum.e" task fileroot = "xdimsum$src/fileroot.cl" task makemask = "xdimsum$src/makemask.cl" task maskinterp = "xdimsum$src/x_xdimsum.e" task minv = "xdimsum$src/minv.cl" task xaddmask = "xdimsum$src/xaddmask.cl" hidetask addcomment avshift fileroot maskinterp minv xaddmask # Demos set demos = "xdimsum$demos/" task demos = "demos$demos.cl" # Cache task parameters to avoid background execution problems. May need # to go through and eventually replace some of these calls, e.g. replace # imgets with hselect, etc. cache sections fileroot imgets minmax iterstat miterstat maskstat xaddmask clbye() iraf-xdimsum-main/xdimsum.hd000066400000000000000000000027471455666516400164440ustar00rootroot00000000000000# Help directory for XDIMSUM package $doc = "xdimsum$doc/" $src = "xdimsum$src/" $demos = "xdimsum$demos/" guide hlp = doc$guide.hlp badpixupdate hlp = doc$badpixupdate.hlp, src = src$badpixupdate.cl demos hlp = doc$demos.hlp, src = demos$demos.cl iterstat hlp = doc$iterstat.hlp, src = src$iterstat.cl miterstat hlp = doc$miterstat.hlp, src = src$miterstat.cl makemask hlp = doc$makemask.hlp, src = src$makemask.cl maskdereg hlp = doc$maskdereg.hlp, src = src$maskdereg.cl maskfix hlp = doc$maskfix.hlp, src = src$maskfix.cl maskstat hlp = doc$maskstat.hlp, src = src$maskstat.cl mkmask hlp = doc$mkmask.hlp, src = src$mkmask.cl orient hlp = doc$orient.hlp, src = src$orient.cl xmosaic hlp = doc$xmosaic.hlp, src = src$xmosaic.cl sigmanorm hlp = doc$sigmanorm.hlp, src = src$sigmanorm.cl xdshifts hlp = doc$xdshifts.hlp, src = src$xdshifts.cl xfirstpass hlp = doc$xfirstpass.hlp, src = src$xfirstpass.cl xfshifts hlp = doc$xfshifts.hlp, src = src$xfshifts.cl xlist hlp = doc$xlist.hlp, src = src$xlist.cl xmaskpass hlp = doc$xmaskpass.hlp, src = src$xmaskpass.cl xmshifts hlp = doc$xmshifts.hlp, src = src$xmshifts.cl xmskcombine hlp = doc$xmskcombine.hlp, src = src$xmskcombine.cl xnregistar hlp = doc$xnregistar.hlp, src = src$xnregistar.cl xnslm hlp = doc$xnslm.hlp, src = src$xnslm.cl xnzap hlp = doc$xnzap.hlp, src = src$xnzap.cl xrshifts hlp = doc$xrshifts.hlp, src = src$xrshifts.cl xslm hlp = doc$xslm.hlp, src = src$xslm.cl xzap hlp = doc$xzap.hlp, src = src$xzap.cl iraf-xdimsum-main/xdimsum.men000066400000000000000000000033341455666516400166210ustar00rootroot00000000000000 xmosaic - Driver sript for first pass and mask pass processing steps xfirstpass - Driver script for first pass processing steps xmaskpass - Driver script for mask pass processing steps xslm - Sky subtract images using running mean and imcombine xnslm - Sky subtract images using running mean maskfix - Fix bad pixel in images using a bad pixel mask xzap - Remove cosmic rays from images using median filtering xnzap - Remove cosmis rays from images using averaging filter badpixupdate - Update bad pixel mask to include bad pixels detected by xzap xmskcombine - Combine bad pixel, cosmic ray, holes, and object masks xnregistar - Mosaic the images using sub-pixel replication and masking mkmask - Create the initial master object mask maskdereg - Deregister master object mask to individual object masks xdshifts - Compute shifts using image display and centroiding techniques xfshifts - Compute shifts using star finding and centroiding techniques xmshifts - Compute shifts using star finding and list matching techniques xrshifts - Compute shifts using x-correlation techniques xlist - Create image sublists used by xslm iterstat - Compute image statistics using iterative rejection miterstat - Compute image statistics using a mask and iterative rejection maskstat - Compute mask statistics using iterative rejection makemask - Make an object mask for a single image sigmanorm - Renormalize mosaic image to uniform pixel-to-pixel rms orient - Reorient image to N up and E left or undo re-orientation demos - Xdimsum demo data script guide - Guide to using xdimsum with the xmosaic task iraf-xdimsum-main/xdimsum.par000066400000000000000000000001551455666516400166220ustar00rootroot00000000000000# XDIMSUM # iraf,s,h,"V2.10.4","V2.10.2|V2.10.3|V2.10.4|V2.11", IRAF version version,s,h,"January 24, 2003"