./0040777000151400000240000000000007330356224010174 5ustar phallgames./doc/0040777000151400000240000000000007215457670010752 5ustar phallgames./doc/biasfix.hlp0100644000151400000240000000263406174726426013103 0ustar phallgames.help biasfix Jul95 phat .ih NAME biasfix -- fix the 1200x800 CCD's bias discontinuities. .ih USAGE biasfix imname toprow .ih PARAMETERS .ls imname Name of image .le .ls toprow Top row of bottom section .le .ls numrows Number of rows to use for computing statistics .le .ls leftcol Leftmost column to use for statistics .le .ls rightcol Rightmost column to use for statistics .le .ih DESCRIPTION This script deals with the problem of the ~3 ADU discontinuities in the bias level shown by the 1200x800 CCD when binning. The location of the discontinuity is roughly dependent on the exposure time but will wander slightly and occasionally will jump by over 100 pixels. Fortunately the problem seems to be removable (to first order) using the overscan region. .sp 1) Examine each image to identify the TOP row of the BOTTOM bias section, if there is a jump in the bias level at all. .sp 2) Copy the images to a safe location, since the biasfix (and ccdproc) operations are done "in place". .sp 3) Run this routine, which computes the mean of 2 blocks of pixels, one each just below and just above the discontinuity, calculates the difference, and adds that # constant into the entire bottom half of the image. .sp 4) Do the first pass through "ccdproc". The overscan correction in this pass (polynomial-fitting) can proceed normally. .sp 21/04/93 created by Brian McLeod .ih SEE ALSO fixbias .endhelp ./doc/bindata.hlp0100644000151400000240000000225306174726430013050 0ustar phallgames.help bindata Jul95 phat .ih NAME bindata.cl -- bin data and plot histograms of it .ih USAGE bindata histype cumulative autoscale binwidth firstfile firstcol .ih PARAMETERS .ls histype Histogram type (normal|percent|sumpercent) .le .ls cumulative Cumulative histogram? .le .ls autoscale Automatically determine start & end bin values? .le .ls binwidth Bin width .le .ls firstfile File containing first variable .le .ls firstcol Column containing first variable (default=1) .le .ls secondfile File containing second variable .le .ls secondcol Column containing second variable (default=1) .le .ls z1 Starting value for bins .le .ls z2 Ending value for bins .le .ls outfile List out histogram to this filename .le .ls include Include z2 in top bin? .le .ih DESCRIPTION This task reads in data from one or two input files (call the data values 1 and 2 respectively), bins them as specified, and outputs one of three histogram types: .sp 1. normal plots 1 (cumulative: sum1) .sp 2. percent plots 1/2 (cumulative: (sum1)/(sum2) .sp 3. sumpercent plots 1/(1+2) (cumulative: (sum1)/(sum(1+2))) .ih BUGS Currently there is a limit of 1000 bins. .endhelp ./doc/bscount.hlp0100644000151400000240000000272706174726432013133 0ustar phallgames.help bscount date phat .ih NAME bscount -- estimate Bahcall & Soneira star counts for given (l,b) .ih USAGE bscount long lat mag filter option xtinct .ih PARAMETERS .ls long Galactic longitude (l) of field .le .ls lat Galactic latitude (b) of field .le .ls mag Apparent magnitude at which to calculate counts .le .ls filter Filter in which to calculate counts (B or V) .le .ls option Differential or integral counts? .le .ls xtinct Extinction (obscuration), in magnitudes .le .ls verbose Verbose output? (mag, counts, l, b, xtinct, filter, option)) .le .ih DESCRIPTION This task estimates the integral or differential star counts at the given B or V magnitude and Galactic coordinates, using Equations B1 and B2 in Appendix B of Bahcall & Soneira 1980 (ApJS 44, 73). (Although B&S80 only consider b>=20 degrees, the program works for all b; however, accuracy for |b|<20 cannot be assured, and b<0 values are calculated simply by assuming symmetry around the Galactic plane. The output values are either (stars mag-1 deg-2) for differential counts, or (stars deg-2) for integral counts. The average absolute error between this task's approximation and a full integration of their model is quoted by them as 15%. You can estimate the error for a particular field by comparing this tasks' output to the rigorously calculated values for certain coordinates tabulated in Tables 5 and 6 of B&S80 and interpolating between the fields. .ih BUGS Written by Pat Hall. .endhelp ./doc/checkfringe.hlp0100644000151400000240000000137106560176340013714 0ustar phallgames.help checkfringe Jul95 phat .ih NAME checkfringe -- interactively adjust defringing .ih USAGE checkfringe fiximage fringe outname .ih PARAMETERS .ls fiximage Name of (original) image to be defringed .le .ls fringe Fringe image to scale and subtract .le .ls outname Name of defringed image to create .le .ls fit Boolean prompt: Adjust parameters and refit image? .le .ls scale Scaling to use on fringe image .le .ls z Number of image to save .le .ls imsect [Image section] to use for iterative statistics .le DESCRIPTION This task scales and subtracts a fringe image from a data image and allows the user to interactively adjust the defringing until it is satisfactory. .ih SEE ALSO autodefringe, defringe, quickfringe, testfringe .endhelp ./doc/cubeexam.hlp0100644000151400000240000000240606174726436013245 0ustar phallgames.help cubeexam Jul95 phat .ih NAME cubeexam -- apply imexam to one band of a 3-D image cube .ih USAGE cubeexam image band .ih PARAMETERS .ls cube Image cube to be examined .le .ls band Specific band of cube to be examined .le .ih DESCRIPTION From adass.iraf.applications: .sp Q: I have stacked a series of 2D images into a cube (e.g. a single image from the cube is tt0066[1:12,1:12,4000]). I can display such individual images OK but commands like imexam or fitpsf always seem to take only the first image in the cube, i.e. tt0066[*,*,1]. The only workaround I've found is to copy out the band: .sp cl> imcopy tt0066[*,*,4000] junk cl> imexam junk .sp What is wrong and is there a better workaround? .sp .sp A: What you report, that IMEXAMINE ignores any image section, is a property of this task. This has to do with wanting to always use the parent image coordinates and not the image section coordinates; I won't go into the technical reasons why. It does this by removing any image section. There are better ways to do this now and IMEXAM should probably changed. In the meantime, the usage of cubeexam would then be: .sp cl> cubeexam tt00066 7 .sp to work on band 7. A temporary image will automatically be created and then deleted upon exiting. .endhelp ./doc/defringe.hlp0100644000151400000240000000305106560172013013215 0ustar phallgames.help defringe Jul95 phat .ih NAME defringe -- do sky illumination correction & remove fringing from images .ih USAGE defringe rootname imagelist logfile defstring biasimage .ih PARAMETERS .ls rootname Rootname for output images and image list .le .ls imagelist List of images to process (do not use an `@') .le .ls logfile Name of log file .le .ls defstring String to be appended to output images .le .ls biasimage Zero level calibration image for ccdproc .le .ls dofringe Boolean: Do fringe removal step? .le .ls gain Gain of CCD (for ccdclip in imcombine) .le .ls rdnoise Read noise of CCD (for ccdclip in imcombine) .le .ls forcescale Boolean: Force recalculation of image scales? .le .ls goon Boolean prompt: Continue with task using displayed sky+fringe image? .le .ih DESCRIPTION This task creates a sky+fringe image from a list of data images. The image can optionally be used to perform illumination correction and defringing steps. Before the subtraction is attempted, the sky+fringe image is displayed. If object residuals are present, you may wish to stop, create object masks, and rerun the task. You can use makeobjmask on the non-defringed images to create object masks for them directly, or you can use shiftnadd on the non-defringed images, run mkobjmask on the skysubbed output, insert the object mask names into the non-defringed image headers, and then rerun this task so that the objects are masked out during the creation of the sky+fringe image. .ih SEE ALSO autodefringe, checkfringe, quickfringe, testfringe .endhelp ./doc/optcoadd.hlp0100644000151400000240000003216306503630165013241 0ustar phallgames.help optcoadd Jul96 phat .ih NAME optcoadd -- produce coadded image, exposure map, and sky-subtracted image .ih USAGE optcoadd comblist outimage expmap normmap shiftlist scaling zeroing weighting magfac stack logfile .ih PARAMETERS .ls comblist List of images to combine .le .ls outimage Name of output coadded image .le .ls expmap Name of output exposure map image, which gives the weighted AVERAGE exposure time for each pixel in the coadded image. .le .ls normmap Name of output normalization map image, which can be used with `sigmanorm' to create a constant-rms version of the output coadded image. .le .ls shiftlist File with image shifts. These should be INTEGERS (for best results, take the exact shifts and round them off (file `prefix.roundoff.suffix' from shiftnadd) rather than truncate them) UNLESS parameter magfac>1, in which case they should be the exact image shifts (file `prefix.shiftexact.suffix' from shiftnadd). .le .ls scaling Imcombine scaling factors (none|@file|!|etc.). If scaling=@filename and "filename" does not exist, default scalings will be calculated that correct for extinction relative to a specified airmass. These scaling factors will then be combined with additional scaling factors (that correct for nonphotometric conditions, etc.) if desired. The final scaling factors can then optionally be inserted into the image headers and multiplied into the images prior to imcombining. .le .ls zeroing Imcombine zero-level offsets (@file|none|mode|!|etc.). If zeroing=@filename and "filename" does not exist, the iterative median of all images will be found, the average found, and "filename" created and filled with zero offsets for each image calculated as "average - iterative median". Note that the offsets found this way cannot be used within imcombine with weighted coadding, as some of the offsets will be negative. Set prescale=yes to get around this problem. .le .ls weighting Imcombine weights (none|@file|!|mode|etc.). If weighting=@filename and "filename" does not exist, the iterative variances of all images will be found (after pre-scaling) and combined with the exposure times (from the header keyword given by `expname') to produce the optimum weights=exptime/variance, which will then be listed in the newly created file "filename". .le .ls magfac Magnification factor for subpixel shifting (min=1, max=10). NOTE that this parameter should be set to the appropriate value even if the block-replication has been done with `irrotate' prior to starting this task. This ensures that e.g. the zero-level offsets will be properly recalculated if need be. .le .ls stack Boolean: Combine images by stacking & projecting? .le .ls logfile Name of log file .le .sp .ls normname Header keyword for normalization factor. This should be either the exposure time or mean value of the image, if the image rms is proportional to the square root of either of those, or the variance (rms**2) of the image. If given the value "" (null string) the variance will be found and inserted into the image header with keyword VARIANCE. .le .ls newmask=no Boolean: override bad pixel masks listed in image headers? .le .ls badmask Bad pixel mask to use instead .le .ls shiftsubpix=no Boolean: Do image shifts account for subpixel shifting? .le .ls prescale=no Boolean: Scale images before, not during, imcombine? .le .ls unscale=yes Boolean: Undo scaling factors when done? .le .ls extcoeff Extinction coefficient for default scalings .le .ls airzero Airmass to scale images to? (INDEF=minimum airmass of all images in comblist) .le .ls scalecombine=no Boolean: Combine default & additional scalings? .le .ls scalecomname @filename or !keyword for additional scalings .le .ls putscale Boolean: Insert scaling factors into image headers? .le .ls wordscale="SCALEFAC" Scaling factor header keyword .le .ls defscale=no Boolean: Do scales include default airmass scaling? .le .ls prezero=no Boolean: Do zero offseting before, not during, imcombine? .le .ls unzero=yes Boolean: Undo zero offsets when done? .le .ls putzero=no Boolean: Insert zero offsets into image headers? .le .ls wordzero="ZEROVAL" Zero offset header keyword .le .ls putweight=no Boolean: Insert weights into image headers? .le .ls wordweight="WEIGHT" Weighting factor header keyword .le .ls stackimage Name of stacked image .le .ls unstack Boolean: delete stacked image when done? .le .ls scalesubpix=no Boolean: Do zero offsets account for subpixel shifting? .le .ls expname="EXPTIME" Header keyword for exposure time .le .ls maskedstat=no Boolean: Use `maskstat' with iterstat option, instead of just `iterstat', when finding default zero offsets and weights? The difference between the two is almost always insignificant, and maskstat is slower. .le .ls statfile="" File to for image statistics from iterstat or maskstat. This file will be created if it doesn't exist, to save time in later iterations of task. If it already exists, the statistics will be read in from it rather than recalculated. .le .ls stdpars=yes Boolean: Use standard imcombine parameters for coadd? These parameters are combine=average, rej=ccdclip, zeros given by `zeroing' (default = mode), scales given by `scaling' (default = none), weight given by `weighting' (default = none), expname=expname, lsig=hsig=5., nkeep=1., mclip+. NOTE that the GAIN and READNOISE parameters are still taken from imcoaddpars if stdpars=yes, as are the SIGSCALE, MASKTYPE, and MASKVAL parameters. .le .ls makeavg=no Boolean: Make pure coadd (comb=average,rej=none)? Note that otherwise the parameters are the same as when stdpars=yes. .le .ls flip=no Boolean: Flip image L-R after coadd? .le .ls cleanup=yes Boolean: Clean up blkrep'd images after use? .le .ls tpl=no Boolean: Account for throughput correction in normalization map? .le .ls optcoaddpars Parameter set for imcombine operation used in coadding. GAIN and READNOISE parameters are located here. See help page for imcombine for description. The files "phat$optcoadd8x12.par" and "phat$optcoadd2kx2k.par" contain default params for the SO 800x1200 and 2048x2048 CCDs, respectively. .le .ih DESCRIPTION This tasks coadds the input images using the specified integer-pixel offsets, producing a coadded image, a sky-subtracted coadded image, an exposure map, and an *.imshifts file listing images & offsets used by the photcheck and masklet tasks. The parameters for imcombine can be specified directly in the "imcoaddpars" parameter set, or default parameters "stdpars" or "makeavg" can be used. NOTE that even in those cases, the GAIN, READNOISE, SIGSCALE, MASKTYPE, and MASKVAL parameters are still taken from imcoaddpars. .sp The following steps are performed, in this order: .sp .nf 1. Calculate default (multiplicative) scaling factors that correct for extinction relative to a specified airmass if desired, combine these scaling factors with additional scaling factors (that correct for nonphotometric conditions, etc.) if desired, insert scaling factors into image headers if desired, and multiply the images by the scaling factors before imcombine, if desired. 2. Calculate (additive) zero level offsets using iterative (and masked, if desired) means, if desired, and insert into image headers if desired. 3. Determine default weights (=exptime/variance, where the variance is the square of the iterative (and optionally masked) rms of the image) and put into file if desired, and/or insert weights into image headers if desired. 4. Block replicate images and calculate subpixel shifts if desired, adjusting zero offsets as necessary. 5. Implement (additive) zero level offsets before imcombine if desired. 6. Coadd as requested, stacking if necessary. Will not overwrite an output image. 7. Set output image airmass to average of input image airmasses if default airmass scaling was not used, otherwise set it to the specified airmass to which all images were normalized. 8. Do sky subtraction by subtracting off iterative mean. 9. Create exposure maps & coadd them into a coadded-image exposure map, if the latter doesn't already exist. 10. Divide image by the weighted exposure time at each pixel, to get constant exposure time across the image. 11. Normalize image to the maximum total exposure time that went into it. 12. Flip image left-right if desired. 13. Undo pre-imcombine zero offsets if desired. 14. Undo pre-imcombine scalings if desired. 15. Create normalization maps & coadd them into a coadded-image normalization map, if the latter doesn't already exist. 16. Create the *.imshifts file, listing images & offsets, used by tasks "photcheck" to check the photometric stability of the data and "masklet" to produce individual image object masks from the coadded-image object mask. .fi .sp The default imcombine parameters (stdpars+) usually work quite well with prezero+ and prescale+, although nkeep=-2 is preferable if images of widely varying seeing are being coadded to avoid clipping the wings of bright objects. If you do experiment with different imcombine parameters, the task `photcomp' is a useful task for quickly and easily comparing the photometric differences between two images on the same coordinate system (i.e. the same set of images coadded two different ways). .sp .sp EXPOSURE MAPS .sp An exposure map of the weighted exposure time at each pixel is generated by imcombining the individual exposure map images in the same way as the actual images, except with scale=zero=none. This is used to scale the output image from imcombine to constant global exposure time. It is suggested that if weighting is used, the weights be calculated outside of imcombine, and inserted into a file. This allows for an accurate weighted exposure map to be generated in all cases, and for the weighted exposure time to be correctly calculated if stacking is done. .sp .sp NORMALIZATION MAPS .sp A normalization map is also generated. This can be used with sigmanorm to normalize the output image to constant rms. Each input image has rms=sigma_i (including effects of throughput correction, which however vary between pixels) and weight=weight_i, so each output pixel has sigma_out given by .sp .nf sigma_out^2 = sum_i(sigma_i^2 * weight_i^2)/(sum_i(weight_i))^2 .fi .sp where sum_i denotes a sum over all i images which contribute to the pixel. The normalization map is the inverse of the right-hand-side of this equation, normalized to a maximum of one. Thus when the square root of the normalization map is multiplied by the image, all pixels have equal sigma_out (RMS noise). In the case of roughly equal weights and negligible read noise, this is essentially the same as using the exposure map to do the normalization. .sp The parameter `normname' is the header keyword which contains the parameter to use in creating the normalization map. In the example above, the parameter was the variance of each image, which is the best value to use for the normname parameter. In the case of roughly equal weights and negligible read noise, the exposure time of each image (or mean, if poisson statistics have been preserved) can be used. .sp Using the exposure time is fine for a quick estimate or first pass; if normname="" the normalization factors will be calculated and inserted into the image headers as keyword VARIANCE, if this has not already been done. Note that the variances must include any scaling done before imcombining, but NOT any throughput correction. This is because the throughput correction image is taken into account explicitly (a different tpl_i for each pixel is divided into sigma_i in the equation above) while the variance is assumed constant across the image (one value of sigma_i for each image). .sp .sp This task calls tasks addcomment, iterstat, fileroot, filecalc, and stsdas.toolbox.imgtools.imcalc. .ih EXAMPLES .ih TIME REQUIREMENTS .ih BUGS 1. There is a known bug (IRAF buglog #244) in imcombine (all versions prior to V2.11) possibly applicable to the default parameters (combine=average, reject=ccdclip, and mclip=yes) for this task: .sp When combine=average, reject=(sigclip, avsigclip, ccdclip, or pclip), and mclip=yes (the value of mclip does not matter for pclip) the average will be incorrect if the number of low pixels rejected is greater than the number of unrejected pixels. For example if 3 low pixels are rejected and only 2 pixels remain then the final average will be incorrect for that pixel. There is no workaround other than to avoid this combination of parameters. .sp .sp 2. Only one bad pixel mask is allowed when stack=yes (this is a shortcoming of imcombine). If the first image in the list has an individual bad pixel mask (e.g. due to holes in the sky-subtracted image), that bad pixel mask will be used for the stacked image. This can be avoided by using newmask=yes, but the individual bad pixel masks can only be implemented in this case by multiplying the images by their individual bad pixel masks before running the task. .sp .sp 3. Weighted coadding cannot be used with the default zero level offsets, since some of those are negative. Workaround is to set prezero=yes. .ih SEE ALSO optcoaddirtf, irrotate, masklet, mkobjmask, photcomp, photcheck, shiftnadd .endhelp ./doc/fixbias.hlp0100644000151400000240000000045406561405073013071 0ustar phallgames.help fixbias Jul95 phat .ih NAME fixbias -- script to implement biasfix .ih USAGE cl < fixbias.cl .ih PARAMETERS .ls none .le .ih DESCRIPTION This script displays an image, copies it, unmodified, to image//orig, does biasfix on it, and then displays the fixed version. .ih SEE ALSO biasfix .endhelp ./doc/optcoaddirtf.hlp0100644000151400000240000003244206503630436014127 0ustar phallgames.help optcoadd Jul96 phat .ih NAME optcoadd -- produce coadded image, exposure map, and sky-subtracted image .ih USAGE optcoadd comblist outimage expmap normmap shiftlist scaling zeroing weighting magfac stack logfile .ih PARAMETERS .ls comblist List of images to combine .le .ls outimage Name of output coadded image .le .ls expmap Name of output exposure map image, which gives the weighted AVERAGE exposure time for each pixel in the coadded image. .le .ls normmap Name of output normalization map image, which can be used with `sigmanorm' to create a constant-rms version of the output coadded image. .le .ls shiftlist File with image shifts. These should be INTEGERS (for best results, take the exact shifts and round them off (file `prefix.roundoff.suffix' from shiftnadd) rather than truncate them) UNLESS parameter magfac>1, in which case they should be the exact image shifts (file `prefix.shiftexact.suffix' from shiftnadd). .le .ls scaling Imcombine scaling factors (none|@file|!|etc.). If scaling=@filename and "filename" does not exist, default scalings will be calculated that correct for extinction relative to a specified airmass. These scaling factors will then be combined with additional scaling factors (that correct for nonphotometric conditions, etc.) if desired. The final scaling factors can then optionally be inserted into the image headers and multiplied into the images prior to imcombining. .le .ls zeroing Imcombine zero-level offsets (@file|none|mode|!|etc.). If zeroing=@filename and "filename" does not exist, the iterative median of all images will be found, the average found, and "filename" created and filled with zero offsets for each image calculated as "average - iterative median". Note that the offsets found this way cannot be used within imcombine with weighted coadding, as some of the offsets will be negative. Set prescale=yes to get around this problem. .le .ls weighting Imcombine weights (none|@file|!|mode|etc.). If weighting=@filename and "filename" does not exist, the iterative variances of all images will be found (after pre-scaling) and combined with the exposure times (from the header keyword given by `expname') to produce the optimum weights=exptime/variance, which will then be listed in the newly created file "filename". .le .ls magfac Magnification factor for subpixel shifting (min=1, max=10). NOTE that this parameter should be set to the appropriate value even if the block-replication has been done with `irrotate' prior to starting this task. This ensures that e.g. the zero-level offsets will be properly recalculated if need be. .le .ls stack Boolean: Combine images by stacking & projecting? .le .ls logfile Name of log file .le .sp .ls normname Header keyword for normalization factor. This should be either the exposure time or mean value of the image, if the image rms is proportional to the square root of either of those, or the variance (rms**2) of the image. If given the value "" (null string) the variance will be found and inserted into the image header with keyword VARIANCE. .le .ls newmask=no Boolean: override bad pixel masks listed in image headers? .le .ls badmask Bad pixel mask to use instead .le .ls shiftsubpix=no Boolean: Do image shifts account for subpixel shifting? .le .ls prescale=no Boolean: Scale images before, not during, imcombine? .le .ls unscale=yes Boolean: Undo scaling factors when done? .le .ls extcoeff Extinction coefficient for default scalings .le .ls airzero Airmass to scale images to? (INDEF=minimum airmass of all images in comblist) .le .ls scalecombine=no Boolean: Combine default & additional scalings? .le .ls scalecomname @filename or !keyword for additional scalings .le .ls putscale Boolean: Insert scaling factors into image headers? .le .ls wordscale="SCALEFAC" Scaling factor header keyword .le .ls defscale=no Boolean: Do scales include default airmass scaling? .le .ls prezero=no Boolean: Do zero offseting before, not during, imcombine? .le .ls unzero=yes Boolean: Undo zero offsets when done? .le .ls putzero=no Boolean: Insert zero offsets into image headers? .le .ls wordzero="ZEROVAL" Zero offset header keyword .le .ls putweight=no Boolean: Insert weights into image headers? .le .ls wordweight="WEIGHT" Weighting factor header keyword .le .ls stackimage Name of stacked image .le .ls unstack Boolean: delete stacked image when done? .le .ls scalesubpix=no Boolean: Do zero offsets account for subpixel shifting? .le .ls expname="EXPTIME" Header keyword for exposure time .le .ls maskedstat=no Boolean: Use `maskstat' with iterstat option, instead of just `iterstat', when finding default zero offsets and weights? The difference between the two is almost always insignificant, and maskstat is slower. .le .ls statfile="" File to for image statistics from iterstat or maskstat. This file will be created if it doesn't exist, to save time in later iterations of task. If it already exists, the statistics will be read in from it rather than recalculated. .le .ls stdpars=yes Boolean: Use standard imcombine parameters for coadd? These parameters are combine=average, rej=ccdclip, zeros given by `zeroing' (default = mode), scales given by `scaling' (default = none), weight given by `weighting' (default = none), expname=expname, lsig=hsig=5., nkeep=1., mclip+. NOTE that the GAIN and READNOISE parameters are still taken from imcoaddpars if stdpars=yes, as are the SIGSCALE, MASKTYPE, and MASKVAL parameters. .le .ls makeavg=no Boolean: Make pure coadd (comb=average,rej=none)? Note that otherwise the parameters are the same as when stdpars=yes. .le .ls flip=no Boolean: Flip image L-R after coadd? .le .ls cleanup=yes Boolean: Clean up blkrep'd images after use? .le .ls tpl=no Boolean: Account for throughput correction in normalization map? .le .ls optcoaddpars Parameter set for imcombine operation used in coadding. GAIN and READNOISE parameters are located here. See help page for imcombine for description. The files "phat$optcoadd8x12.par" and "phat$optcoadd2kx2k.par" contain default params for the SO 800x1200 and 2048x2048 CCDs, respectively. .le .ih DESCRIPTION IRTF version -- calls perl scripts "irtfcoadd_?.p" and "irtfshift_?.p". You will need to edit the source code and insert the proper pathnames for these scripts before running. .sp This task coadds the input images using the specified integer-pixel offsets, producing a coadded image, a sky-subtracted coadded image, an exposure map, and an *.imshifts file listing images & offsets used by the photcheck and masklet tasks. The parameters for imcombine can be specified directly in the "imcoaddpars" parameter set, or default parameters "stdpars" or "makeavg" can be used. NOTE that even in those cases, the GAIN, READNOISE, SIGSCALE, MASKTYPE, and MASKVAL parameters are still taken from imcoaddpars. .sp The following steps are performed, in this order: .sp .nf 1. Calculate default (multiplicative) scaling factors that correct for extinction relative to a specified airmass if desired, combine these scaling factors with additional scaling factors (that correct for nonphotometric conditions, etc.) if desired, insert scaling factors into image headers if desired, and multiply the images by the scaling factors before imcombine, if desired. 2. Calculate (additive) zero level offsets using iterative (and masked, if desired) means, if desired, and insert into image headers if desired. 3. Determine default weights (=exptime/variance, where the variance is the square of the iterative (and optionally masked) rms of the image) and put into file if desired, and/or insert weights into image headers if desired. 4. Block replicate images and calculate subpixel shifts if desired, adjusting zero offsets as necessary. 5. Implement (additive) zero level offsets before imcombine if desired. 6. Coadd as requested, stacking if necessary. Will not overwrite an output image. 7. Set output image airmass to average of input image airmasses if default airmass scaling was not used, otherwise set it to the specified airmass to which all images were normalized. 8. Do sky subtraction by subtracting off iterative mean. 9. Create exposure maps & coadd them into a coadded-image exposure map, if the latter doesn't already exist. 10. Divide image by the weighted exposure time at each pixel, to get constant exposure time across the image. 11. Normalize image to the maximum total exposure time that went into it. 12. Flip image left-right if desired. 13. Undo pre-imcombine zero offsets if desired. 14. Undo pre-imcombine scalings if desired. 15. Create normalization maps & coadd them into a coadded-image normalization map, if the latter doesn't already exist. 16. Create the *.imshifts file, listing images & offsets, used by tasks "photcheck" to check the photometric stability of the data and "masklet" to produce individual image object masks from the coadded-image object mask. .fi .sp The default imcombine parameters (stdpars+) usually work quite well with prezero+ and prescale+, although nkeep=-2 is preferable if images of widely varying seeing are being coadded to avoid clipping the wings of bright objects. If you do experiment with different imcombine parameters, the task `photcomp' is a useful task for quickly and easily comparing the photometric differences between two images on the same coordinate system (i.e. the same set of images coadded two different ways). .sp .sp EXPOSURE MAPS .sp An exposure map of the weighted exposure time at each pixel is generated by imcombining the individual exposure map images in the same way as the actual images, except with scale=zero=none. This is used to scale the output image from imcombine to constant global exposure time. It is suggested that if weighting is used, the weights be calculated outside of imcombine, and inserted into a file. This allows for an accurate weighted exposure map to be generated in all cases, and for the weighted exposure time to be correctly calculated if stacking is done. .sp .sp NORMALIZATION MAPS .sp A normalization map is also generated. This can be used with sigmanorm to normalize the output image to constant rms. Each input image has rms=sigma_i (including effects of throughput correction, which however vary between pixels) and weight=weight_i, so each output pixel has sigma_out given by .sp .nf sigma_out^2 = sum_i(sigma_i^2 * weight_i^2)/(sum_i(weight_i))^2 .fi .sp where sum_i denotes a sum over all i images which contribute to the pixel. The normalization map is the inverse of the right-hand-side of this equation, normalized to a maximum of one. Thus when the square root of the normalization map is multiplied by the image, all pixels have equal sigma_out (RMS noise). In the case of roughly equal weights and negligible read noise, this is essentially the same as using the exposure map to do the normalization. .sp The parameter `normname' is the header keyword which contains the parameter to use in creating the normalization map. In the example above, the parameter was the variance of each image, which is the best value to use for the normname parameter. In the case of roughly equal weights and negligible read noise, the exposure time of each image (or mean, if poisson statistics have been preserved) can be used. .sp Using the exposure time is fine for a quick estimate or first pass; if normname="" the normalization factors will be calculated and inserted into the image headers as keyword VARIANCE, if this has not already been done. Note that the variances must include any scaling done before imcombining, but NOT any throughput correction. This is because the throughput correction image is taken into account explicitly (a different tpl_i for each pixel is divided into sigma_i in the equation above) while the variance is assumed constant across the image (one value of sigma_i for each image). .sp .sp This task calls tasks addcomment, iterstat, fileroot, filecalc, and stsdas.toolbox.imgtools.imcalc. .ih EXAMPLES .ih TIME REQUIREMENTS .ih BUGS 1. There is a known bug (IRAF buglog #244) in imcombine (all versions prior to V2.11) possibly applicable to the default parameters (combine=average, reject=ccdclip, and mclip=yes) for this task: .sp When combine=average, reject=(sigclip, avsigclip, ccdclip, or pclip), and mclip=yes (the value of mclip does not matter for pclip) the average will be incorrect if the number of low pixels rejected is greater than the number of unrejected pixels. For example if 3 low pixels are rejected and only 2 pixels remain then the final average will be incorrect for that pixel. There is no workaround other than to avoid this combination of parameters. .sp .sp 2. Only one bad pixel mask is allowed when stack=yes (this is a shortcoming of imcombine). If the first image in the list has an individual bad pixel mask (e.g. due to holes in the sky-subtracted image), that bad pixel mask will be used for the stacked image. This can be avoided by using newmask=yes, but the individual bad pixel masks can only be implemented in this case by multiplying the images by their individual bad pixel masks before running the task. .sp .sp 3. Weighted coadding cannot be used with the default zero level offsets, since some of those are negative. Workaround is to set prezero=yes. .ih SEE ALSO optcoadd, irrotate, masklet, mkobjmask, photcomp, photcheck, shiftnadd .endhelp ./doc/offlist.hlp0100644000151400000240000000175506174726471013127 0ustar phallgames.help offlist Jul95 phat .ih NAME offlist -- find the offsets on the sky between two lists of objects .ih USAGE offlist list1 list2 outlist limit .ih PARAMETERS .ih list1 First list of coordinates .ih list2 Second list of coordinates .ih outlist Output file name .ih limit Maximum separation to save, in arcminutes .ih all Boolean: List all objects closer than "limit" to each object? .ih DESCRIPTION This task finds the offsets on the sky between objects in two lists. The input lists should have the format: .sp 1. RA of object .sp 2. Dec of object .sp 3. ID# of object .sp The output has nine columns: .sp 1. ID # of first object .sp 2. RA of first object .sp 3. Dec of first object .sp 4. ID # of second object .sp 5. RA of second object .sp 6. Dec of second object .sp 7. Distance between objects, in arcmin, ... .sp 8. @ (at sign) .sp 9. ...position angle (measured E from N) .ih BUGS It would be nice to implement several different output display options. .ih SEE ALSO .endhelp ./doc/offset.hlp0100644000151400000240000000140206174726473012736 0ustar phallgames.help offset Jul95 phat .ih NAME offset -- find the offset on the sky between two objects .ih USAGE offset num1 ir1 id1 num2 ir2 id2 .ih PARAMETERS .ls num1 ID number of first object .le .ls ir1 RA coordinate of first object .le .ls id1 Dec coordinate of first object .le .ls num2 ID number of second object .le .ls ir2 RA coordinate of second object .le .ls id2 Dec coordinate of second object .le .ls outfile Output file name .le .ih DESCRIPTION This task takes the ID numbers and coordinates of two objects and computes the actual offset on the sky between them, in arsec both E-W and N-S, as well as the distance between them in arcminutes. Optionally these values can be output to a file instead of STDOUT. .ih SEE ALSO offlist .endhelp ./doc/patpostproc.hlp0100644000151400000240000000063306174726500014022 0ustar phallgames.help patpostproc Jul95 phat .ih NAME patpostproc -- get stats for and display a new CCD image .ih USAGE patpostproc oldlist newlist .ih PARAMETERS .ls image Image to get statistics for and to display .le .ls frame Frame in which to display image .le .ih DESCRIPTION This task is meant to be used immediately after a new image is acquired by the CCD. It displays the image and its statistics. .endhelp ./doc/shiftnadd.hlp0100644000151400000240000000573406174726530013422 0ustar phallgames.help shiftnadd Jul95 phat .ih NAME shiftnadd -- find offsets for a set of CCD images and coadd them .ih USAGE shiftnadd flatlist refimage prefix outstring fracshift coaddname expmap .ih PARAMETERS .ls flatlist List of images for which to find offsets .le .ls refimage Name of (flattened) reference image .le .ls prefix Prefix string for output files .le .ls outstring Suffix string for output files .le .ls fracshift Boolean: Create fractional-pixel-offset images? (yes|no) .le .ls coaddname Name for output coadded image .le .ls expmap Name of output exposure map image .le .ls shiftlist List of output, offset images .le .ls combdata Boolean: Combine shifts with earlier dataset? (yes|no) .le .ls expname Header keyword for exposure time .le .ls xref Reference object x coordinate (nearest integer) .le .ls yref Reference object y coordinate (nearest integer) .le .ls xshiftold Reference image x shift in earlier dataset .le .ls yshiftold Reference image y shift in earlier dataset .le .ls radius=5. Aperture photometry radius for imexamine .le .ls buffer=10. Aperture photometry sky buffer for imexamine .le .ls width=10. Aperture photometry sky annulus width for imexamine .le .ls bs=9. Centering box size for final shift calculation .le .ls doshift Boolean: Do offset measuring step? .le .ls stdpars Boolean: Use std imcombine parameters for coadd? .le .ls makeavg Boolean: Make pure coadd (comb=average,rej=none)? .le .ls addpars Parameter set: imcombine parameters .le .ih DESCRIPTION This tasks allows measurement of image offsets and coadding using those offsets. Procedure: .sp 1. Choose one image (which all images overlap) to be the reference image. .sp 2. imexam the reference image & get the coordinates (using 'r' or 'a') of ALL REFERENCE OBJECTS that are to be used. .sp 3. imexam all the images and get the coordinates (using 'r' or 'a' and 'n' to go to the next image) of ONLY THE BRIGHTEST or "BEST" reference object in each. .sp 4. You are asked for the X and Y coordinates of this "BEST" reference object. the coords file is printed to jog your memory. .sp 5. lintran is used to calculate the coarse shifts from just the "BEST" object .sp 6. The coarse shifts are used as input to imcentroid, which finds the final offsets using ALL reference objects available. The imcentroid parameters (e.g. boxsize) can be adjusted if deemed necessary. .sp Output: .sp prefix.refcoords.outstring registration objects' reference image coords .sp prefix.allcoords.outstring registration objects' coordinates in all images .sp prefix.coarse.outstring coarse shifts .sp prefix.shiftnadd.outstring final shifts, imcombine log, & misc. other info .sp prefix.shiftfrac.outstring fractional part of final shifts .sp prefix.shiftint.outstring integer part of final shifts .sp prefix.roundoff.outstring final shifts rounded off to integer shifts .sp coaddname.imh coadded image .ih SEE ALSO optcoadd .endhelp ./doc/strrev.hlp0100644000151400000240000000043106174726533012773 0ustar phallgames.help strrev Jul95 phat .ih NAME strrev -- parse a string into its reverse .ih USAGE strrev forward .ih PARAMETERS .ls forward Input string .le .ls reverse Output reversed string .le .ih DESCRIPTION This task takes a string and reverses it character by character. .endhelp ./doc/swap.hlp0100644000151400000240000000037706174726536012434 0ustar phallgames.help swap Jul95 phat .ih NAME swap -- swap the contents of two files .ih USAGE swap file1 file2 .ih PARAMETERS .ls file1 Name of first file .le .ls file2 Name of second file .le .ih DESCRIPTION This task swaps the contents of two files. .endhelp ./doc/undel.hlp0100644000151400000240000000054406174726542012562 0ustar phallgames.help undel Jul95 phat .ih NAME undel -- unprotect and delete a file(s) in one fell swoop .ih USAGE undel file1 .ih PARAMETERS .ls file1 Name of file(s) to unprotect and delete .le .ls verify Boolean: verify deletion? .le .ih DESCRIPTION This task removes the protection from a file or files and deletes them. .ih SEE ALSO protect, delete .endhelp ./doc/testfringe.hlp0100644000151400000240000000303306560172042013606 0ustar phallgames.help testfringe Jul98 phat .ih NAME testfringe -- test defringing within user-specified scaling range .ih USAGE testfringe fiximage fringe outname .ih PARAMETERS .ls fiximage Name of (original) image to be defringed .le .ls fringe Fringe image to scale and subtract .le .ls outname Name of defringed image to create .le .ls startscale First scaling to use (0.=default calculated) .le .ls stepscale Step between scaling values (0.=default=0.05) .le .ls nsteps Number of test images to make (0=until RMS rises) .le .ls fit Boolean prompt: Adjust parameters and refit image? .le .ls scale Scaling to use on fringe image .le .ls finalscale Scaling to use for final image .le .ls imsect [Image section] to use for iterative statistics .le .ls addhead Add iterstat output to image header? .le .ls display Display defringed image sections? .le .ls finaldisp Display original & final images when done? .le DESCRIPTION The user specifies the starting scaling, the step between scaling values, and the number of steps desired. This task then scales and subtracts the fringe image from the data image as specified. The resultant images (with the scaling value used appended to their titles) then have their iterative statistics output to the screen. Once the specified number of steps is reached (or the RMS of the resultant images increases, if nsteps=0), a new range of scaling values can be specified or a final image with the desired scaling can be saved. .ih SEE ALSO autodefringe, defringe, checkfringe, quickfringe .endhelp ./doc/imswap.hlp0100644000151400000240000000056506367434206012753 0ustar phallgames.help imswap Feb97 phat .ih NAME imswap -- swap two images .ih USAGE imswap img1 img2 .ih PARAMETERS .ls img1 Name of first image .le .ls img2 Name of second image .le .ih DESCRIPTION This task swaps two images. The first image is renamed to a temporary image, the second is renamed to the first image, and then the first image is renamed to the second. .endhelp ./doc/patcopy.hlp0100644000151400000240000000106506316401251013112 0ustar phallgames.help patcopy Jul95 phat .ih NAME patcopy -- copy a list of filenames to another list .ih USAGE patcopy oldlist newlist .ih PARAMETERS .ls oldlist List of original file names ("@" is optional) .le .ls newlist List of copied file names ("@" is optional) .le .ls verb Boolean: Print names of files as they are copied? .le .ih DESCRIPTION This task copies the files listed in "oldlist" to those listed in "newlist". If the lists do not contain the same numbers of files, the task exits with an error message and no copying. .ih SEE ALSO patrename .endhelp ./doc/patrename.hlp0100644000151400000240000000107706316401266013420 0ustar phallgames.help patrename Jul95 phat .ih NAME patrename -- rename a list of filenames to another list .ih USAGE patrename oldlist newlist .ih PARAMETERS .ls oldlist List of original file names ("@" is optional) .le .ls newlist List of renamed file names ("@" is optional) .le .ls verb Boolean: Print names of files as they are renamed? .le .ih DESCRIPTION This task renames the files listed in "oldlist" to those listed in "newlist". If the lists do not contain the same numbers of files, the task exits with an error message and no renaming. .ih SEE ALSO patcopy .endhelp ./doc/iteravg.hlp0100644000151400000240000000305606352646727013121 0ustar phallgames.help iteravg Jun97 phat .ih NAME average -- compute the average and standard deviation with iterative rejection .ih USAGE average option .ih PARAMETERS .ls option Chosen from "add", "subtract" or "new_sample", in which case the numbers averaged are those in STDIN. If no argument is given on the command line, "new_sample" is assumed. .le .wp .ls maxiter Maximum number of iterations for rejection .le .ls nsigrej Number of sigma from mean beyond which to reject points .le .ih DESCRIPTION Task \fIiteravg\fR computes the average and standard deviation of a list of numbers. Numeric input is read from STDIN with one number per line. The mean, sigma and number of points are calculated, and limits of mean +/- nsigrej * sigma calculated, and the mean, sigma, and number of points recalculated until maxiter iterations have been performed or the number of points did not change during the last integration, whereupon the mean, sigma, and number of points are written to the standard output. The rest of this description is taken from the \fIaverage\fR help page and has not been tested, but probably doesn't work. By default, the sample is taken to be the set of numbers in the standard input when \fIiteravg\fR is run. Additional points can be added to or deleted from the sample by rerunning \fIiteravg\fR with \fBoption\fR equal to one of the following: .nf add -- add points to the sample, recalculate mean and sigma sub -- subtract points from the sample .fi The sample is reinitialized by setting \fBoption\fR = "new_sample". .ih SEE ALSO average, lintran, iterstat ./doc/mkrgb.hlp0100644000151400000240000000533306362724123012546 0ustar phallgames.help mkrgb Jul97 phat .ih NAME mkrgb -- make Sun rgb rasterfiles from IRAF images .ih USAGE swap red green blue neg pos rgb .ih PARAMETERS .ls red, green, blue Name of images to drive red, green, blue color guns .le .ls neg = 0 Number of sigma for minimum intensity in faint-object rasterfile .le .ls pos = 8 Number of sigma for maximum intensity in faint-object rasterfile .le .ls rgb Root name for output Sun rasterfiles .le .sp .ls magred, maggreen, magblue Maximum mag/sqarcsec for red, green, blue images in common-magnitude-scale rasterfile. .le .ls pixfact Conversion of mag/sqarcsec to mag/pixel: =2.5*log10((pixels/arcsec)**2. .le .ls gogreen = no Independent green-gun image? (As opposed to sum of red & blue images.) .le .ls orient = yes Preserve orientation of IRAF images? (Left to themselves, the rasterfiles would be flipped up-down relative to the IRAF images.) .le .ls log = no Use logarithmic intensity mapping? .le .ls logfile Logfile of rgbsun commands; null string=no logging .le .ih DESCRIPTION This task uses "rgbsun" in the "color" package to make two Sun rgb rasterfiles from 3 IRAF images (if you have only two images, add them together and use that as the green image). Images must be 2-D, all the same size, and have approximately zero mean (mean << sigma). The task requires that header keywords ITERSIG and ZEROPT be present in the images (ITERSIG can be put there by running "iterstat addheader+" or "maskstat iterstat+ addheader+"). Note that ZEROPT should be a POSITIVE number -- it has the opposite sign from that typically used in photometric solutions. .sp The first rasterfile "rgb_faint" uses ITERSIG to scale the min & max intensity so as to emphasize the faintest objects possible in each image. The second rasterfile "rgb_scale" uses ZEROPT to set the max intensity to a fixed surface brightness in units of mag/arcsec converted to mag/pixel: max_cts=10**(-0.4*(magX+pixfact-zeropt)) where magX is magred, maggreen, or magblue. This allows direct comparison of "rgb_scale" files from different fields, since they have the same color scheme. Xview can be used to display the rasterfiles and to save them as PostScript. .sp The appearance of color images varies between monitors, between printers, and between monitors and printers. The default parameters chosen here should be used as a starting point. Generally I find that using log-mapping looks ok on screen, but NOT on printers, and that the default "rgb_faint" images look good on screen AND on paper, but the "rgb_scale" images look good only on screen. .ih BUGS Conceivably the task could be changed to do mask/iterstat addh- on each image, pulling out the mean and sigma, so that zero mean is not required. .endhelp ./doc/complete.hlp0100644000151400000240000001657406367445256013301 0ustar phallgames.help complete Jul97 phat .ih NAME complete -- calculate completeness corrections for mosaiced image .ih USAGE complete image1 image2 image3 untrim1 untrim2 untrim3 mask sum color21 color31 mlim1 spacing nbins nobjs nrepeat pixscale .ih PARAMETERS .ls image1 K (1st filter) image & catalog root name .le .ls image2 r (2nd filter) image & catalog root name (optional) .le .ls image3 Other filter image & catalog root name (optional) .le .ls untrim1 K (1st filter) area as f(m_lim) image name .le .ls untrim2 r (2nd filter) area as f(m_lim) image name (optional) .le .ls untrim3 Other filter area as f(m_lim) image name (optional) .le .ls mask Mask image from which to find x,y limits .le .ls sum Root name of comparison summed image .le .ls color21=0 Typical r-K (2nd - 1st filter) galaxy color (optional) .le .ls color31=0 Typical (3rd - 1st filter) galaxy color (optional) .le .ls mlim1=0 Magnitude of faintest bin in K (1st filter) .le .ls spacing Magnitude bin spacing (should evenly divide color21,31) .le .ls nbins Number of magnitude (flux) bins to create .le .ls nobjs Number of objects to simultaneously add to images .le .ls nrepeat Number of times to add nobjs to image at each flux bin .le .ls pixscale Scale of images in arcsec/pixel .le .sp .ls disimages Display temporary cleaned and altered images? .le .ls log_file (Optional) name of verbose log file .le .ls border=5 Size in pixels of FOCAS catalog border region (min=1) .le .ls cleanfactor=1 Area to increase FOCAS isophotes for cleaning (min=1) .le .ls firstseed=1. Starting seed integer for ARTDATA object positions .le .ls psf="moffat" Type of PSF for ARTDATA (gaussian|moffat|image|textfile) .le .ih DESCRIPTION This task is designed specifically to calculate the completeness corrections and useful areas as a function of magnitude for mosaiced images with variable sky sigma. It is assumed that object detection was performed on a summed image of all filters; this can be circumvented by specifying images in only one filter. This tasks REQUIRES existing image1.cat, image2.cat, image3.cat, & sum.cat, and also REQUIRES the following header keywords in the input images: rlambda, ebv, gain, rdnoise, fwhmpix, & zeropt. The output files are comparea_image? and complete_image? where ?=1,2,3 as appropriate. The magnitudes given are for the CENTERS of the magnitude bins, and the completeness values should be DIVIDED into the observed N(m) to get the true N(m). This task CANNOT BE RUN IN BATCH MODE due to a focas.mfilter/ffilter problem. The comparea_image? output will be ERRONEOUS unless the magnitude limits input to the task bracket all limiting magnitudes which exist in the image(s). Here is a fairly accurate overview of the task. Pardon the latex formatting. We assume that completeness is a function of signal-to-noise only, ignoring its dependence on surface brightness. In each filter, we calculate the fraction $f$ of simulated objects recovered by FOCAS as a function of counts in the normalized image. We know the area $A(\Delta m)$ of the image as a function of $\Delta m$=$m_{real}$$-$$m_{norm}$, where $m_{real}$ is the real magnitude of an object and $m_{norm}$$=$z.p.$-$2.5$\times$log10(counts) is the magnitude measured on the normalized constant-RMS image. Thus we calculate the completeness by summing over the fractional area at each $\Delta m$ multiplied by the fraction $f$ of recovered simulated objects with counts on the normalized image corresponding to that real magnitude: \begin{equation} C(m_{real})=\sum_{\Delta m} {{A(\Delta m)}\over{A_{tot}}} f(m_{real} - \Delta m) {{A(\Delta m)}\over{A_{tot}}} f(m_{real} - \Delta m) \end{equation} We also accounted for galactic extinction $A_{\lambda}$ in each filter of each field so that the final completeness values $C(m_{final})$=$C(m_{real}-A_{\lambda})$ were for identical values of $m_{final}$ in each field. The exact procedure followed in adding simulated objects to the images of each field was as follows. We took the normalized images from all filters which went into the summed image. For counts values separated by a factor of 1.585 (0\fm5) down to $\sim$0\fm5 below the 3$\sigma$ limit, we used FOCAS {\sc clean} to remove from the normalized images objects with fewer total counts than this in the \ks\ filter. We summed these cleaned image(s) and ran FOCAS on the sum to create a comparison catalog. We then added unresolved objects 30 at a time to the cleaned images in each filter simultaneously using the PSF of each image, an average color of $r-K_s$=4 and $J-K_s$=1.5 for the objects, and a random magnitude offset within the magnitude bin. We summed these altered images and reran FOCAS. Simulated objects should thus be recovered unless they merged with an object brighter than themselves in \ks\ and were not split by FOCAS. (Strictly speaking, this step should be repeated for each filter, each time removing objects brighter than the simulated objects {\it in that filter}.) This procedure yields the completeness in all filters simultaneously, albeit at different magnitudes as given by the average galaxy colors used. We repeated this procedure 34 times in each counts bin, each time including different randomly generated Poisson noise appropriate to the object's counts and the image gain. We repeated the entire procedure for each field, taking into account each field's galactic extinction. Here is a fairly accurate flow chart of the task. .nf #--for each field # --get x,y limits for that field and filter # --get g.e. for each filter # --choose each filter's fluxes so m_final (= m_real-g.e.) # = e.g. 20.25, 20.75, thus in the deepest part of the image where # m_norm1=m_real1, m_norm1 = e.g. 20.25+ge1, 20.75+ge1, ... # m_norm2=m_real2, m_norm2 = e.g. 20.25+ge2, 20.75+ge2, ... # --find scalings for individual-filter images # **for each mag bin: each mag bin represents a different mag in each filter # (m1=m1, m2=m1+color21, m3=m1+color31), but should really repeat for # each filter since the crowding is different to each filter's limit # (i.e. mk JuBBB39rootdefdir=piscis!/astr16/users/phall/IRAF/phat/_phat_phat.hdB[B49BSK9_phatdefdir=piscis!/astr16/users/phall/IRAF/phat/phatphat.menphat.hlpphat.hdphat.cli 7399DR]p~!1<Kbt~&6Hbw.;P`iz!2>GXdl|$4?HYeq#)71ZbrAMa}pz .3@@ERHRdq{    .phatdefdir=piscis!/astr16/users/phall/IRAF/phat/defdir=phat$src/doc=phat$doc/addcommentdoc$addcomment.hlpaddcomment.claddringdoc$addring.hlpaddring.clautodefringedoc$autodefringe.hlpautodefringe.clbiasfixdoc$biasfix.hlpbiasfix.clbindatadoc$bindata.hlpbindata.clbscountdoc$bscount.hlpbscount.clbtc_chipscalesdoc$btc_chipscales.hlpbtc_chipscales.clbtc_coadddoc$btc_coadd.hlpbtc_coadd.clbtc_crzapdoc$btc_crzap.hlpbtc_crzap.clbtc_dochipscalesdoc$btc_dochipscales.hlpbtc_dochipscales.clbtc_gainflipdoc$btc_gainflip.hlpbtc_gainflip.clbtc_getchipscalesdoc$btc_getchipscales.hlpbtc_getchipscales.clbtc_getsaulscalesdoc$btc_getsaulscales.hlpbtc_getsaulscales.clbtc_getshiftsdoc$btc_getshifts.hlpbtc_getshifts.clbtc_maskaligntrimdoc$btc_maskaligntrim.hlpbtc_maskaligntrim.clbtc_saulflipdoc$btc_saulflip.hlpbtc_saulflip.clbtc_testdoc$btc_test.hlpbtc_test.clcheckfringedoc$checkfringe.hlpcheckfringe.clcompletedoc$complete.hlpcomplete.clcubeexamdoc$cubeexam.hlpcubeexam.clcutdoc$cut.hlpcut.cldefringedoc$defringe.hlpdefringe.clfilerootdoc$fileroot.hlpfileroot.clfixbiasdoc$fixbias.hlpfixbias.clfocasflatdoc$focasflat.hlpfocasflat.climswapdoc$imswap.hlpimswap.clirrotatedoc$irrotate.hlpirrotate.clirshift2doc$irshift2.hlpirshift2.cliteravgdoc$iteravg.hlpiteravg.cliterstatdoc$iterstat.hlpiterstat.clmakeobjmaskdoc$makeobjmask.hlpmakeobjmask.clmaskstatdoc$maskstat.hlpmaskstat.clminvdoc$minv.hlpminv.clmkfringedoc$mkfringe.hlpmkfringe.clmkobjmaskdoc$mkobjmask.hlpmkobjmask.clmkrgbdoc$mkrgb.hlpmkrgb.clsctvdoc$sctv.hlpsctv.clpatcopydoc$patcopy.hlppatcopy.clpatrenamedoc$patrename.hlppatrename.clofflistdoc$offlist.hlpofflist.cloffsetdoc$offset.hlpoffset.cloptcoadddoc$optcoadd.hlpoptcoadd.cloptcoaddirtfdoc$optcoaddirtf.hlpoptcoaddirtf.clpatpostprocdoc$patpostproc.hlppatpostproc.clphotcheckdoc$photcheck.hlpphotcheck.clphotcompdoc$photcomp.hlpphotcomp.clphotscaledoc$photscale.hlpphotscale.clptvdoc$ptv.hlpptv.clquickfringedoc$quickfringe.hlpquickfringe.clscabdoc$scab.hlpscab.clshiftnadddoc$shiftnadd.hlpshiftnadd.clsigmanormdoc$sigmanorm.hlpsigmanorm.clstrrevdoc$strrev.hlpstrrev.clswapdoc$swap.hlpswap.cltestfringedoc$testfringe.hlptestfringe.cltrimdoc$trim.hlptrim.clundeldoc$undel.hlpundel.clYN,NCHv_rootroot.hd_phatpiscis!/astr16/users/phall/IRAF/phat/_phat.hdphatpiscis!/astr16/users/phall/IRAF/phat/phat.menpiscis!/astr16/users/phall/IRAF/phat/phat.hlppiscis!/astr16/users/phall/IRAF/phat/phat.clpiscis!/astr16/users/phall/IRAF/phat/phat.hdpiscis!/astr16/users/phall/IRAF/phat/phat.men_index'qpiscis!/astr16/users/phall/IRAF/phat/_phat.hdc Lpiscis!/astr16/users/phall/IRAF/phat/phat.hd'Froot.hd#.h./phat.cl0100644000151400000240000000566307217761355011464 0ustar phallgames# Package script task for PHAT: Pat Hall's Add-on Tasks set phat = /astr16/users/phall/IRAF/phat/ package phat reset helpdb = (envget ("helpdb") // ",phat$helpdb.mip") # CL scripts # $ means task has no parameters # no $ means task has parameters #task addcomment = "phat$src/addcomment.cl" task addpars = "phat$src/addpars.par" #task addring = "phat$src/addring.cl" task autodefringe = "phat$src/autodefringe.cl" task biasfix = "phat$src/biasfix.cl" task bindata = "phat$src/bindata.cl" task bscount = "phat$src/bscount.cl" task btc_chipscales = "phat$src/btc_chipscales.cl" task btc_coadd = "phat$src/btc_coadd.cl" task btc_crzap = "phat$src/btc_crzap.cl" task btc_dochipscales = "phat$src/btc_dochipscales.cl" task btc_gainflip = "phat$src/btc_gainflip.cl" task btc_getchipscales = "phat$src/btc_getchipscales.cl" task btc_getsaulscales = "phat$src/btc_getsaulscales.cl" task btc_getshifts = "phat$src/btc_getshifts.cl" task btc_maskaligntrim = "phat$src/btc_maskaligntrim.cl" task btc_saulflip = "phat$src/btc_saulflip.cl" task btc_test = "phat$src/btc_test.cl" task checkfringe = "phat$src/checkfringe.cl" task clot = "phat$src/clot.cl" task complete = "phat$src/complete.cl" task cubeexam = "phat$src/cubeexam.cl" task cut = "phat$src/cut.cl" task defringe = "phat$src/defringe.cl" #task fileroot = "phat$src/fileroot.cl" task focasflat = "phat$src/focasflat.cl" task $fixbias = "phat$src/fixbias.cl" task imswap = "phat$src/imswap.cl" #task irrotate = "phat$src/irrotate.cl" #task irshift2 = "phat$src/irshift2.cl" task iteravg = "phat$src/iteravg.cl" #task iterstat = "phat$src/iterstat.cl" #task makeobjmask = "phat$src/makeobjmask.cl" #task maskstat = "phat$src/maskstat.cl" #task minv = "phat$src/minv.cl" task mkfringe = "phat$src/mkfringe.cl" #task mkobjmask = "phat$src/mkobjmask.cl" task mkrgb = "phat$src/mkrgb.cl" #task sctv = "phat$src/sctv.cl" #task mycopy = "phat$src/mycopy.cl" #task myrename = "phat$src/myrename.cl" task offlist = "phat$src/offlist.cl" task offset = "phat$src/offset.cl" task optcoadd = "phat$src/optcoadd.cl" task optcoaddirtf = "phat$src/optcoaddirtf.cl" task optcoaddpars = "phat$src/optcoaddpars.par" task patcopy = "phat$src/patcopy.cl" task patrename = "phat$src/patrename.cl" task patpostproc = "phat$src/patpostproc.cl" #task photcheck = "phat$src/photcheck.cl" #task photcomp = "phat$src/photcomp.cl" #task photscale = "phat$src/photscale.cl" task ptv = "phat$src/ptv.cl" task quickfringe = "phat$src/quickfringe.cl" task scab = "phat$src/scab.cl" task shiftnadd = "phat$src/shiftnadd.cl" #task sigmanorm = "phat$src/sigmanorm.cl" task strrev = "phat$src/strrev.cl" task swap = "phat$src/swap.cl" task testfringe = "phat$src/testfringe.cl" #task trim = "phat$src/trim.cl" task undel = "phat$src/undel.cl" # SPP tasks #task igraph = "phat$src/x_phat.e" clbye() ./root.hd0100644000151400000240000000035106577243124011472 0ustar phallgames# Root help directory for PHAT: Pat Hall's Add-on Tasks. This dummy package is # needed to have `phat' appear as a module in some package, so that # the user can type "help phat" (with `phat' given as a task). _phat pkg = _phat.hd ./_phat.hd0100644000151400000240000000020706306670677011611 0ustar phallgames# Help definitions for PHAT: Pat Hall's Add-on Tasks phat men = phat.men, hlp = .., sys = phat.hlp, pkg = phat.hd, src = phat.cl ./optcoaddirtf.par0100644000151400000240000000301506426265447013365 0ustar phallgamesi_sigma,s,h,"",,,"IMCOMBINE: Sigma image (optional)" i_plfile,s,h,"",,,"IMCOMBINE: Rejected pixel list image (optional)" i_combine,s,h,"average",average|median,,"IMCOMBINE: Type of combine operation (median|average)" i_reject,s,h,"sigclip",none|minmax|ccdclip|crreject|sigclip|avsigclip|pclip,,"IMCOMBINE: Type of rejection" i_masktyp,s,h,"badvalue",none|goodvalue|badvalue|goodbits|badbits,,"IMCOMBINE: Mask type" i_maskval,r,h,0.,,,"IMCOMBINE: Mask value" i_blank,r,h,0.,,,"IMCOMBINE: Value if there are no pixels" i_statsec,s,h,"",,,"IMCOMBINE: Image section for computing statistics" i_expname,s,h,"exptime",,,"IMCOMBINE: Image header exposure time keyword" i_lthresh,r,h,INDEF,,,"IMCOMBINE: Lower threshold" i_hthresh,r,h,INDEF,,,"IMCOMBINE: Upper threshold" i_nlow,r,h,1.,0.,,"IMCOMBINE: minmax: Number of low pixels to reject" i_nhigh,r,h,1.,0.,,"IMCOMBINE: minmax: Number of high pixels to reject" i_nkeep,r,h,-2.,,,"IMCOMBINE: Minimum to keep (+) or maximum to reject(-)" i_lsigma,r,h,5.,0.,,"IMCOMBINE: Lower sigma clipping factor" i_hsigma,r,h,5.,0.,,"IMCOMBINE: Upper sigma clipping factor" i_rdnoise,s,h,"rn",,,"IMCOMBINE: ccdclip: CCD readout noise (electrons)" i_gain,s,h,"gain",,,"IMCOMBINE: ccdclip: CCD gain (electrons/ADU)" i_snoise,s,h,"0.",,,"IMCOMBINE: ccdclip: Sensitivity noise (fraction)" i_sigscale,r,h,0.1,0.,,"IMCOMBINE: Tolerance for sig-clip scaling corrections" i_pclip,r,h,-0.5,,,"IMCOMBINE: pclip: Percentile clipping parameter" i_grow,r,h,0.,,,"IMCOMBINE: Radius (pixels) for 1D neighbor rejection" mode,s,h,"q",,, ./optcoadd2kx2k.par0100644000151400000240000000301406353543452013353 0ustar phallgamesi_sigma,s,h,"",,,"IMCOMBINE: Sigma image (optional)" i_plfile,s,h,"",,,"IMCOMBINE: Rejected pixel list image (optional)" i_combine,s,h,"average",average|median,,"IMCOMBINE: Type of combine operation (median|average)" i_reject,s,h,"sigclip",none|minmax|ccdclip|crreject|sigclip|avsigclip|pclip,,"IMCOMBINE: Type of rejection" i_masktyp,s,h,"badvalue",none|goodvalue|badvalue|goodbits|badbits,,"IMCOMBINE: Mask type" i_maskval,r,h,0.,,,"IMCOMBINE: Mask value" i_blank,r,h,0.,,,"IMCOMBINE: Value if there are no pixels" i_statsec,s,h,"",,,"IMCOMBINE: Image section for computing statistics" i_expname,s,h,"exptime",,,"IMCOMBINE: Image header exposure time keyword" i_lthresh,r,h,INDEF,,,"IMCOMBINE: Lower threshold" i_hthresh,r,h,INDEF,,,"IMCOMBINE: Upper threshold" i_nlow,r,h,1.,0.,,"IMCOMBINE: minmax: Number of low pixels to reject" i_nhigh,r,h,1.,0.,,"IMCOMBINE: minmax: Number of high pixels to reject" i_nkeep,r,h,1.,,,"IMCOMBINE: Minimum to keep (+) or maximum to reject(-)" i_lsigma,r,h,5.,0.,,"IMCOMBINE: Lower sigma clipping factor" i_hsigma,r,h,5.,0.,,"IMCOMBINE: Upper sigma clipping factor" i_rdnoise,s,h,"11.",,,"IMCOMBINE: ccdclip: CCD readout noise (electrons)" i_gain,s,h,"1.8",,,"IMCOMBINE: ccdclip: CCD gain (electrons/ADU)" i_snoise,s,h,"0.",,,"IMCOMBINE: ccdclip: Sensitivity noise (fraction)" i_sigscale,r,h,0.1,0.,,"IMCOMBINE: Tolerance for sig-clip scaling corrections" i_pclip,r,h,-0.5,,,"IMCOMBINE: pclip: Percentile clipping parameter" i_grow,r,h,0.,,,"IMCOMBINE: Radius (pixels) for 1D neighbor rejection" mode,s,h,"q",,, ./optcoadd8x12.par0100644000151400000240000000301406353543461013114 0ustar phallgamesi_sigma,s,h,"",,,"IMCOMBINE: Sigma image (optional)" i_plfile,s,h,"",,,"IMCOMBINE: Rejected pixel list image (optional)" i_combine,s,h,"average",average|median,,"IMCOMBINE: Type of combine operation (median|average)" i_reject,s,h,"ccdclip",none|minmax|ccdclip|crreject|sigclip|avsigclip|pclip,,"IMCOMBINE: Type of rejection" i_masktyp,s,h,"badvalue",none|goodvalue|badvalue|goodbits|badbits,,"IMCOMBINE: Mask type" i_maskval,r,h,0.,,,"IMCOMBINE: Mask value" i_blank,r,h,0.,,,"IMCOMBINE: Value if there are no pixels" i_statsec,s,h,"",,,"IMCOMBINE: Image section for computing statistics" i_expname,s,h,"exptime",,,"IMCOMBINE: Image header exposure time keyword" i_lthresh,r,h,INDEF,,,"IMCOMBINE: Lower threshold" i_hthresh,r,h,INDEF,,,"IMCOMBINE: Upper threshold" i_nlow,r,h,1.,0.,,"IMCOMBINE: minmax: Number of low pixels to reject" i_nhigh,r,h,1.,0.,,"IMCOMBINE: minmax: Number of high pixels to reject" i_nkeep,r,h,1.,,,"IMCOMBINE: Minimum to keep (+) or maximum to reject(-)" i_lsigma,r,h,5.,0.,,"IMCOMBINE: Lower sigma clipping factor" i_hsigma,r,h,5.,0.,,"IMCOMBINE: Upper sigma clipping factor" i_rdnoise,s,h,"7.7",,,"IMCOMBINE: ccdclip: CCD readout noise (electrons)" i_gain,s,h,"2.2",,,"IMCOMBINE: ccdclip: CCD gain (electrons/ADU)" i_snoise,s,h,"0.",,,"IMCOMBINE: ccdclip: Sensitivity noise (fraction)" i_sigscale,r,h,0.1,0.,,"IMCOMBINE: Tolerance for sig-clip scaling corrections" i_pclip,r,h,-0.5,,,"IMCOMBINE: pclip: Percentile clipping parameter" i_grow,r,h,0.,,,"IMCOMBINE: Radius (pixels) for 1D neighbor rejection" mode,s,h,"q",,, ./phat.hd0100644000151400000240000000611507205254376011447 0ustar phallgames# Help directory for PHAT: Pat Hall's Add-on Tasks $defdir = "phat$src/" $doc = "phat$doc/" addcomment hlp = doc$addcomment.hlp, src=addcomment.cl addring hlp = doc$addring.hlp, src=addring.cl autodefringe hlp = doc$autodefringe.hlp, src=autodefringe.cl biasfix hlp = doc$biasfix.hlp, src=biasfix.cl bindata hlp = doc$bindata.hlp, src=bindata.cl bscount hlp = doc$bscount.hlp, src=bscount.cl btc_chipscales hlp = doc$btc_chipscales.hlp, src=btc_chipscales.cl btc_coadd hlp = doc$btc_coadd.hlp, src=btc_coadd.cl btc_crzap hlp = doc$btc_crzap.hlp, src=btc_crzap.cl btc_dochipscales hlp = doc$btc_dochipscales.hlp, src=btc_dochipscales.cl btc_gainflip hlp = doc$btc_gainflip.hlp, src=btc_gainflip.cl btc_getchipscales hlp = doc$btc_getchipscales.hlp, src=btc_getchipscales.cl btc_getsaulscales hlp = doc$btc_getsaulscales.hlp, src=btc_getsaulscales.cl btc_getshifts hlp = doc$btc_getshifts.hlp, src=btc_getshifts.cl btc_maskaligntrim hlp = doc$btc_maskaligntrim.hlp, src=btc_maskaligntrim.cl btc_saulflip hlp = doc$btc_saulflip.hlp, src=btc_saulflip.cl btc_test hlp = doc$btc_test.hlp, src=btc_test.cl checkfringe hlp = doc$checkfringe.hlp, src=checkfringe.cl #clot hlp = doc$clot.hlp, src=clot.cl complete hlp = doc$complete.hlp, src=complete.cl cubeexam hlp = doc$cubeexam.hlp, src=cubeexam.cl cut hlp = doc$cut.hlp, src=cut.cl defringe hlp = doc$defringe.hlp, src=defringe.cl fileroot hlp = doc$fileroot.hlp, src=fileroot.cl fixbias hlp = doc$fixbias.hlp, src=fixbias.cl focasflat hlp = doc$focasflat.hlp, src=focasflat.cl imswap hlp = doc$imswap.hlp, src=imswap.cl irrotate hlp = doc$irrotate.hlp, src = irrotate.cl irshift2 hlp = doc$irshift2.hlp, src = irshift2.cl iteravg hlp = doc$iteravg.hlp, src=iteravg.cl iterstat hlp = doc$iterstat.hlp, src=iterstat.cl makeobjmask hlp = doc$makeobjmask.hlp, src = makeobjmask.cl maskstat hlp = doc$maskstat.hlp, src = maskstat.cl minv hlp = doc$minv.hlp, src = minv.cl mkfringe hlp = doc$mkfringe.hlp, src=mkfringe.cl mkobjmask hlp = doc$mkobjmask.hlp, src = mkobjmask.cl mkrgb hlp = doc$mkrgb.hlp, src = mkrgb.cl sctv hlp = doc$sctv.hlp, src=sctv.cl patcopy hlp = doc$patcopy.hlp, src=patcopy.cl patrename hlp = doc$patrename.hlp, src=patrename.cl offlist hlp = doc$offlist.hlp, src=offlist.cl offset hlp = doc$offset.hlp, src=offset.cl optcoadd hlp = doc$optcoadd.hlp, src=optcoadd.cl optcoaddirtf hlp = doc$optcoaddirtf.hlp, src=optcoaddirtf.cl patpostproc hlp = doc$patpostproc.hlp, src=patpostproc.cl photcheck hlp = doc$photcheck.hlp, src = photcheck.cl photcomp hlp = doc$photcomp.hlp, src=photcomp.cl photscale hlp = doc$photscale.hlp, src = photscale.cl ptv hlp = doc$ptv.hlp, src = ptv.cl quickfringe hlp = doc$quickfringe.hlp, src = quickfringe.cl scab hlp = doc$scab.hlp, src=scab.cl shiftnadd hlp = doc$shiftnadd.hlp, src=shiftnadd.cl sigmanorm hlp = doc$sigmanorm.hlp, src = sigmanorm.cl strrev hlp = doc$strrev.hlp, src=strrev.cl swap hlp = doc$swap.hlp, src=swap.cl testfringe hlp = doc$testfringe.hlp, src=testfringe.cl trim hlp = doc$trim.hlp, src = trim.cl undel hlp = doc$undel.hlp, src=undel.cl #task hlp=doc$task.hlp, src=task.cl ./phat.hlp0100644000151400000240000003012507145001321011614 0ustar phallgames.help phat Apr95 phat .ih NAME phat -- Pat Hall's Add-on Tasks .ih DESCRIPTION .nf addcomment - add comment flag to image header addring - add rings around all objects in a mask image autodefringe - automatically defringe using RMS-minimizing scalings biasfix - fix discontinuities in the bias level bindata - bin data and plot histograms of it bscount - estimate Bahcall & Soneira star counts for given (l,b) btc_chipscales - find and/or apply BTC chip-to-chip photometric scalings btc_coadd - coadd BTC images using standard parameters btc_crzap - de-cosmic-ray BTC images using standard parameters btc_dochipscales - apply chip-to-chip photometric scalings to BTC data btc_gainflip - scale BTC chips to gain=1, and flip to common orientation btc_getchipscales - get chip-to-chip photometric scalings for BTC data btc_getsaulscales - get chip-to-chip photometric scalings for BTC SNe data btc_getshifts - get image shifts for dithered BTC data btc_maskaligntrim - mask BTC data w/<2/3 max exposure & align+trim dift filters btc_saulflip - flip SNe BTC data so NE=UL, and hedit to gain=1 checkfringe - interactively adjust defringing complete - calculate completeness corrections for mosaiced image cubeexam - apply imexam to one band of a 3-D image cube cut - cut a distribution on specified limits defringe - do sky illumination correction & defringe images fileroot - parse a filename into root and extension fixbias - script for biasfix focasflat - remove sky gradients from images using FOCAS sky determination imswap - swap two images irrotate - rotate and resample images and recalculate shifts for them irshift2 - measure scale and rotation between two images' coord systems iteravg - find iterative average and sigma of a list of numbers iterstat - find image statistics excluding deviant pixels makeobjmask - create object masks for input images maskstat - calculate images statistics from unmasked regions of an image minv - invert a mask of zeros and ones mkfringe - create fringe frame & optionally subtract it from images mkobjmask - interactively create object mask mkrgb - create color image from IRAF images offlist - find offsets on sky between lists of objects offset - find the offset on the sky between a pair of objects optcoadd - coadd a list of offset CCD images optcoaddirtf - coadd a list of offset CCD images (IRTF version, w/o STSDAS,CTIO) patcopy - copy one list of files to another list of files patpostproc - display new image & its statistics patrename - rename one list of files to another list of files photcheck - monitor photometric stability of a data set photcomp - compare photometric properties of 2 images on same coord sys. photscale - compute photometric scalings of a data set ptv - display image in range determined from iterative mean & sigma quickfringe - interactively adjust defringing ... and fast! scab - identify & interpolate over bleeding columns from saturated stars sctv - display image with display scaled to full range of values shiftnadd - find offsets for a set of CCD images and coadd them sigmanorm - normalize image by the square root of its exposure map strrev - parse a string into its reverse swap - swap the contents of two files testfringe - test defringing within user-specified scaling range trim - create constant-rms image with a certain minimum exposure time undel - unprotect and delete a file in one fell swoop .fi .sp .nf Here is a very rudimentary guide to the tasks in the PHAT (and/or PHIIRS) package which relate to CCD imaging reductions. For the rest, see the individual help files. IMAGES TO OBTAIN EACH NIGHT, OR AT LEAST EACH RUN Rule of thumb: 100,000e- total in each pixel, so that sqrt-N is <0.5%) BIAS: 30 frames DARK: at least 1 at each program exposure time; preferably 10 DOMEFLAT: 100,000e-/pix total, w/individ. exposures at same level as sky i.e. w/gain=2.2 and sky~3000 adu, 6600e-/pix/flat means 15 flats. (Or is it better to get 10,000e-/adu in each shot?) TWILIGHT FLAT: 50,000e-/pix total, w/individ. exposures at same level as sky ie w/gain=2.2 and sky~3000 adu, 6600e-/pix/flat means 8 flats. TURN TRACKING ON (make sure no bright star) and offset scope 30" in random direction between frames so that stars can be removed later. OK to combine twilight flats from more than one night on the same run. CCD DATA REDUCTION NOTES 1. setinstrument direct instrument=ccddb$kpno/direct.dat Input nonstandard biassec/trimsec params now if desired. If you transpose images to put NE more or less at top left from the start, be sure to edit the various *SEC params in the image headers! 2. ccdlist a*.imh Check to see that objects are objects, etc. Also insert filter header keywords as needed. 3. biasfix @fixlist (After inspecting to see if any images need fixing, that is.) If bias level jump is <~10 ADU, and sky is 2000+ ADU, then <0.5% effect. 4. MKBIAS: zerocombine a*.imh output=zero.imh ccdtype=zero 5. BIASSUB: ccdproc a*.imh ccdtype="" overscan+ trim+ zerocor+ zero=zero.imh flatcor- ":order 2 + f" seems the best fit to overscan region 6. MKDARK: darkcombine @list.dark1 output=dark1.imh scale=exposure rej=minmax nlo=0 nhi=1: darks of different exptimes should be combined separately. 7. DARKSUB (optional): ccdproc @list1 darkcor+ dark=dark1.imh make sure that the dark's integration time is matched to the images FLATFIELDING NOTES: --Ideal is blank sky (BLANK SKY FLAT). Usually there is not enough signal in such an image to flatfield without introducing additional noise. But if enough BLANK SKY FLATS (i.e. sparse object frames) can be coaveraged, ok; if there are not enough, they should be combined AND smoothed. --DOME FLATS would also be ideal if the dome illumination was truly uniform. But usually dome flats leave a large-scale residual illumination pattern on flatfielded images, necessitating an ILLUMINATION CORRECTION created from (in order of preference) BLANK SKY FLATS, TWILIGHT SKY FLATS, or the DOME FLATS themselves. You might want to do two illumination corrections, one using twilight flats and another with blank sky flats, if for example the blank sky flats have too little S/N and must be smoothed but there are small-scale features in the flattened images that can be removed with the (unsmoothed) twilight flats. --ILLUMCOR is most logically done by correcting just the flat field, using BLANK SKY or TWILIGHT SKY FLATS (MKSKYFLAT) or DOME FLATS (MKILLUMFLAT). --In practice, ILLUMCOR is most easily done as a separate step, using either flatfielded BLANK SKY FLATS (possibly smoothed with MKSKYCOR), TWILIGHT SKY FLATS (no special processing needed) or DOME FLATS (MKILLUMCOR). Thus, DO FLATCOR WITH DOMEFLATS AND ILLUMCOR WITH (TWIFLATS+)SKYFLATS. 8. MKFLAT: flatcombine a*.imh rej=crreject gain=gain scale=mode rdnoise=rdnoise For some reason you must make sure "zero" in ccdproc" is set correctly; can set this on the command line of course. Beware flats in same filter w/dift exptimes, & dome- vs. twilight- flats. (Flat/Dome)YYMMDD.*.imh are twilight/dome flats. Sky*.imh are blank sky flats. 9. FLATTEN: ccdproc a*.imh ccdtype="" flatcor+ flat=Flat* (fixpix+) Be careful since each night might have identically named Flat*imh. If you want to interpolate bad pixels with fixpix+, now is the time. 10. ILLUMCOR: USUALLY DONE USING #11: DEFRINGE.CL --Check the exposure in a given filter, skyflat or object, with the most sky counts, and see if it has structure. --If so, decide whether to use BLANK or TWILIGHT SKY FLATS to make the ILLUMINATION CORRECTION (or possibly DOMEFLATS). 10a. Defringing needed, BLANK SKY FLATS used for ILLUMINATION CORRECTION: Use the task DEFRINGE (see #11 below). 10b. Defringing needed, TWILIGHT SKY FLATS used for ILLUMINATION CORRECTION: Create the Sky flat using `combine': combine @skylist Sky subset+ scale=mode weight=mode combine=average rej=ccdclip gain=gain rdnoise=rdnoise where `skylist' is a list of twilight (or blank) sky exposures. Next, check Sky*imh to make sure stars are filtered out. If they aren't, run makeobjmask @skylist suffix=om ngrow=1 ver- 10c. ILLUMCOR but not defringing needed, BLANK or TWILIGHT SKY FLATS used: `mkskycor' is optional, depending on S/N. If it is done, hedit need not be done, and vice versa: (mkskycor @skylist n//@skylist boxmax=0.25 boxmin=5) or (hedit @skylist MKILLUM "fake" add+ ver- show+) ccdproc a*.imh illumcor+ illum=(n)Sky* 10d. DOME FLATS: not recommended for ILLUMCOR with the 8x12. 11. FRINGECOR: (DEFRINGE.CL) --make lists of temporally close blank-sky/sparse-object frames; one for each field is good start --combine images to create skyfringe frame: iterstat @list, 1./valmed-->SKYFRING imcombine @list skyfringe scale=!SKYFRING weight=!SKYFRING rej=ccdclip gain=gain rdnoise=rdnoise **note that if BPM exists in the image headers, it will get used!!!** **this allows for a redo of this step using object masks if desired** --mkskycor skyfringe out=sky --ccdproc @list illumcor+ illum=sky --imar skyfringe - sky = fringe --fringmed=iterstat.median*(real(imgets.value)) --imcalc @list,fringe @listout "im1-im2*"//fringmed 12: INSPECTION Inspect images to a) see which ones are good and should be kept for future processing b) see which ones of the above didn't get adequately defringed 13: CHECKFRINGE.CL If previous automatic defringing didn't work, use this interactive task to redo the fringe scaling & subtraction until you get it right. One image at a time; you must specify the name of the fringe image to scale and subtract and the name of the output image. 14: COADDING/COSMIC RAY & BAD PIXEL REJECTION (SHIFTNADD.CL/OPTCOADD.CL) `shiftnadd' combines image offsets calculation with first-step coadding. If you are comparing the images with others of different orientations or scales, you can use the shiftnadd output coadded image to measure the rotation or scaling parameters. `shiftnadd' can also include default airmass scaling if desired, avoiding an extra step to include it later. `optcoadd' is a much fancier program to produce a final coadded image, exposure map, and sky-subtracted coadded image. 15. IRSHIFT2 : get data needed to measure scale and rotation between two images' coordinate systems 16. IMMATCH.GEOMAP : calculate scale and rotation from irshift2 data 17. IRROTATE : rotate and resample images and recalculate shifts for them 18. PHOTCHECK : measure photometric stability of the individual images 19. PHOTSCALE : calculate photometric scalings from photcheck output 20. OPTCOADD : final coadd of the (possibly scaled and rotated) images using photometric scalings and magfac>1 if desired 21. TRIM : create constant-rms image w/a certain minimum exposure time 22. PHOTCAL : --When you have lots of stds, use `tvmark img coordsfile number+ interact+' to mark them in order using 'a', then edit coordsfile & put right numbers by them, then redo tvmark label+ and hit 'l' to put right labels on. --Do `phot coords=coordsfile' (maybe after `imexam imagec=coordsfile defk=a' to get better coords, but phot centering should be ok) --If you have other images, use irshift to get offsets, then lintran coordsfile >> coordsfilenew for each new image, and then phot coords=coordsfilenew. --Once you have done phot, do the following (adjusting parameters as needed): files *mag.2 >> data.photlist vi data.photlist # format: "std1 : im1" etc. mkapfile @data.photlist 7 data.apcor smallap=2 largeap=7 magf=data.apmags mknobsfile @data.photlist 1 data.imsets data.obs apercor=data.apcor apert=2 copy data.obs data.obsorig vi data.obs # Insert standard star codes into this file. vi data.config # Set up configuration file as desired fitparams data.obs photcal$catalogs/cat.dat data.config data.params --Note that mkimsets is not necessary. Just group the different standard fields and images together as follows: std1 : im1 #will be im1 im2 im3 if e.g. U B V std1 : im2 std2 : im3 ...etc. .fi .sp .ih SEE ALSO phiirs .endhelp ./phat.men0100644000151400000240000000677707205254405011642 0ustar phallgames PHAT --- Pat Hall's Add-on Tasks addcomment - add comment flag to image header addring - add rings around all objects in a mask image autodefringe - automatically defringe using RMS-minimizing scalings biasfix - fix discontinuities in the bias level bindata - bin data and plot histograms of it bscount - estimate Bahcall & Soneira star counts for given (l,b) btc_chipscales - find and/or apply BTC chip-to-chip photometric scalings btc_coadd - coadd BTC images using standard parameters btc_crzap - de-cosmic-ray BTC images using standard parameters btc_dochipscales - apply chip-to-chip photometric scalings to BTC data btc_gainflip - scale BTC chips to gain=1, and flip to common orientation btc_getchipscales - get chip-to-chip photometric scalings for BTC data btc_getsaulscales - get chip-to-chip photometric scalings for BTC SNe data btc_getshifts - get image shifts for dithered BTC data btc_maskaligntrim - mask BTC data w/<2/3 max exposure & align+trim dift filters btc_saulflip - flip SNe BTC data so NE=UL, and hedit to gain=1 checkfringe - interactively adjust defringing complete - calculate completeness corrections for mosaiced image cubeexam - apply imexam to one band of a 3-D image cube cut - cut a distribution on specified limits defringe - do sky illumination correction & defringe images fileroot - parse a filename into root and extension fixbias - script for biasfix focasflat - remove sky gradients from images using FOCAS sky determination imswap - swap two images irrotate - rotate and resample images and recalculate shifts for them irshift2 - measure scale and rotation between two images' coord systems iteravg - find iterative average and sigma of a list of numbers iterstat - find image statistics excluding deviant pixels makeobjmask - create object masks for input images maskstat - calculate images statistics from unmasked regions of an image minv - invert a mask of zeros and ones mkfringe - create fringe frame & optionally subtract it from images mkobjmask - interactively create object mask mkrgb - create color image from IRAF images offlist - find offsets on sky between lists of objects offset - find the offset on the sky between a pair of objects optcoadd - coadd a list of offset CCD images optcoaddirtf - coadd a list of offset CCD images (IRTF version w/o STSDAS,CTIO) patcopy - copy one list of files to another list of files patpostproc - display new image & its statistics patrename - rename one list of files to another list of files photcheck - monitor photometric stability of a data set photcomp - compare photometric properties of two images on same coord sys. photscale - compute photometric scalings of a data set ptv - display image in range determined from iterative mean & sigma quickfringe - interactively adjust defringing ... and fast! scab - identify & interpolate over bleeding columns from saturated stars sctv - display image with display scaled to full range of image values shiftnadd - find offsets for a set of CCD images and coadd them sigmanorm - normalize image by the square root of its exposure map strrev - parse a string into its reverse swap - swap the contents of two files testfringe - test defringing within user-specified scaling range trim - create constant-rms image with a certain minimum exposure time undel - unprotect and delete a file in one fell swoop ./src/0040777000151400000240000000000007330356246010767 5ustar phallgames./src/biasfix.cl0100644000151400000240000000434006561403317012723 0ustar phallgames# biasfix.cl-- fix the 1200x800's bias discontinuities. # # This script deals with the problem of the ~3 ADU discontinuities in the bias # level shown by the 1200x800 CCD when binning. The location of the # discontinuity is roughly dependent on the exposure time but will wander # slightly and occasionally will jump by over 100 pixels. Fortunately the # problem seems to be removable (to first order) using the overscan region. # # 1) Examine each image to identify the TOP row of the BOTTOM bias section, # if there is a jump in the bias level at all. # 2) Copy the images to a safe location, since the biasfix (and ccdproc) # operations done "in place". # 3) Run this routine, which computes the mean of 2 blocks of pixels, one each # just below and just above the discontinuity, calculates the difference, # and adds that # constant into the entire bottom half of the image. # 4) Do the first pass through "ccdproc". The overscan correction in this # pass (polynomial-fitting) can proceed normally. # # 21/04/93 created by Brian McLeod procedure biasfix(imname,toprow) string imname {prompt="Name of image"} int toprow {prompt="Top row of bottom section"} int numrows {20,prompt="Number of rows to use for computing statistics"} int leftcol {603,prompt="Leftmost column to use for statistics"} int rightcol {620,prompt="Rightmost column to use for statistics"} begin string iname,tname int ttoprow real bot,top,diff string botsection,topsection,botfixsection iname = imname ttoprow=toprow tname = mktemp("12x8") botsection = "["//leftcol//":"//rightcol//","//ttoprow-numrows+1//":"//ttoprow//"]" topsection = "["//leftcol//":"//rightcol//","//ttoprow+1//":"//ttoprow+numrows//"]" botfixsection = "[*,1:"//ttoprow//"]" print(botsection) print(topsection) print(botfixsection) imstat (iname//botsection, fields="mean", lower=INDEF, upper=INDEF, binwidth=0.1, format=no) | scan(bot) imstat (iname//topsection, fields="mean", lower=INDEF, upper=INDEF, binwidth=0.1, format=no) | scan(top) diff = bot - top print (bot,top,diff) imarith (iname//botfixsection, "-", diff, tname, title="", divzero=0., hparams="", pixtype="", calctype="", verbose=no, noact=no) imcopy (tname,iname//botfixsection, verbose=no) imdelete(tname,ver-) end ./src/bindata.cl0100644000151400000240000001172606561403331012702 0ustar phallgames# bindata.cl -- bin data and plot histograms of it # # This program reads in one or two columns of data (call them 1 and 2), # bins them as specified, and outputs one of three histogram types: # normal plots 1 (cumulative: sum1) # percent plots 1/2 (cumulative: (sum1)/(sum2) # sumpercent plots 1/(1+2) (cumulative: (sum1)/(sum(1+2))) # # Currently there is a limit of 1000 bins. # # 950724: created by Pat Hall # 950725: autoscaling ability & other minor bits added # 960226: option to print midpoint of bin as x coordinate # 970104: numerous revisions to (auto)scaling procedure bindata (histype, cumulative, autoscale, binwidth, firstfile, firstcol) string histype {enum="normal|percent|sumpercent",prompt="Histogram type"} bool cumulative {prompt="Cumulative histogram?"} bool autoscale {prompt="Automatically determine start & end bin values?"} real binwidth {prompt="Bin width"} string firstfile {prompt="File containing first variable"} int firstcol=1 {prompt="Column containing first variable"} string secondfile {prompt="File containing second variable",mode="q"} int secondcol=1 {prompt="Column containing second variable",mode="q"} real z1 {prompt="Starting value for bins",mode="q"} real z2 {prompt="Ending value for bins",mode="q"} bool midpt=yes {prompt="List midpoint coord instead of start for each bin?"} string outfile="" {prompt="List out histogram to this filename"} bool include=no {prompt="Include z2 in top bin?"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin real low, high, wide, val, x, plotval, xval, graphval, a, b, c real numer, denom, numerold, denomold real bin1[1000], bin2[1000] int onecol, twocol, z, y string hertype, test0, test1, test2, file1, file2, ooutfile bool go, ccumul, aauto, iinclude, mmidpt # struct val hertype = histype ccumul = cumulative aauto = autoscale if(!aauto){ low = z1 high = z2 } wide = binwidth file1 = firstfile onecol = firstcol if(hertype!="normal"){ file2 = secondfile twocol = secondcol } mmidpt=midpt ooutfile=outfile if(ooutfile=="")ooutfile="_temp_file_" del("_temp_file_", ver-, >& "dev$null") iinclude=include # make sure necessary packages are loaded go = yes # if(!defpac("focas")) {go=no} if(go) { #setup if(aauto){ test0=mktemp("auto") if(hertype=="normal"){ # copy(file1, test0, ver-, >& "dev$null") fields(file1, onecol, lines=1-999999999, >> test0) } else { concat(file1//","//file2, "._test0") fields("._test0", onecol, lines=1-999999999, >> test0) } # sort (test0, col=onecol, num+, rev-, >> test0//"x") sort (test0, col=1, num+, rev-, >> test0//"x") head (test0//"x", nlines=1) | scan(low) tail (test0//"x", nlines=1) | scan(high) z=1+int((high-low)/wide) #number of bins } else { z=int((high-low)/wide) #number of bins } #print(z) bin1=0. bin2=0. x=0 y=0 #read first dataset test1=mktemp(file1) fields(file1, onecol, >> test1) name=test1 while (fscan (name, val) !=EOF) { x=1+int((val - low)/wide) #= 1,2,... (bin number) if(iinclude){ if(val==z2)x=z } # print(x,bin1[x]) bin1[x]=bin1[x]+1 # print(bin1[x]) } #read second dataset, if necessary if(hertype!="normal"){ test2=mktemp(file2) fields(file2, twocol, >> test2) name = test2 while (fscan (name, val) !=EOF) { x=1+int((val - low)/wide) #= 1,2,... (bin number) bin2[x]=bin2[x]+1 } } #Compute and output plotting value for each bin plotval=0 #start numerold=0 #start denomold=0 #start for (y=1; y<=z; y+=1) { graphval=0. if (mmidpt) { #middle xval=((y-1)*wide)+low+(wide/2.) } else { #start xval=((y-1)*wide)+low } #print(xval, bin1[y], bin2[y]) if(hertype=="normal")graphval=bin1[y] #Avoid division by zero by setting 0/0=0 or x/0=1 if(hertype=="percent"){ if(bin2[y]==0.){ if(bin1[y]!=0.){ graphval=1. } else{ graphval=0. } } else{ graphval=bin1[y]/bin2[y] } } #Avoid division by zero by setting 0/0=0 or x/0=1 if(hertype=="sumpercent"){ if((bin1[y]+bin2[y])==0.){ if(bin1[y]!=0.){ graphval=1. } else{ graphval=0. } } else{ graphval=bin1[y]/(bin1[y]+bin2[y]) } } #Sum appropriately if cumulative=yes if(ccumul){ numer=bin1[y] if(hertype=="percent"){ denom=bin2[y] } else { denom=bin1[y]+bin2[y] } if(hertype=="normal"){ plotval=plotval+numer } else { numerold=numerold+numer denomold=denomold+denom if(denomold==0){ if(numerold==0){ plotval=plotval+0 } else { plotval=1 } } else { plotval=numerold/denomold } } } else { plotval=graphval } print(xval,plotval, >> ooutfile) #next y } #Plot the histogram and delete plotting file if list=no graph(ooutfile,point-) if(ooutfile=="_temp_file_")delete(ooutfile, ver-, >& "dev$null") } else { #print("WARNING: package FOCAS is not loaded, or package SYSTEM is.") #print("Please load FOCAS or unload SYSTEM and restart this task.") } if(aauto)del(test0//"*", ver-, >& "dev$null") del(test1, ver-, >& "dev$null") if(hertype!="normal")del(test2, ver-, >& "dev$null") del("_temp_file_", ver-, >& "dev$null") if(echog)beep end ./src/bscount.cl0100644000151400000240000000542606171341047012757 0ustar phallgames# bscount.cl -- estimate Bahcall & Soneira star counts for given (l,b) # # Taken from Appendix B of Bahcall & Soneira 1980, ApJS 44, 73. (B&S80) # # 950807: created # ...might eventually add capability to do multiple fields/mag ranges at once, # taking input from a file perhaps. procedure bscount (long,lat,mag,filter,option,xtinct) real long {min=0.,max=360.,prompt="Galactic longitude (l) of field"} real lat {min=-90.,max=90.,prompt="Galactic latitude (b) of field"} real mag {prompt="Apparent magnitude at which to calculate counts"} string filter {enum="B|V",prompt="Filter in which to calculate counts"} string option {enum="differential|integral",prompt="Differential or integral counts?"} real xtinct=0.0 {min=0.,prompt="Extinction (obscuration), in magnitudes"} bool verbose {prompt="Verbose output? (mag, counts, l, b, ext., filter, option)"} begin real l, b, m, extinct, mtmp, pi real c1, beta, mstar, alpha, mu, gamma, delta real c2, eta, mcross, kappa, lambda, sigma real T1a, T1b, T1, T2, T2a, T2b, T, A string ffilter, ooption bool verb pi=3.1415926 #l=long*2*pi/360. #b=lat*2*pi/360. l=abs(long*2*pi/360.) b=abs(lat*2*pi/360.) mtmp=mag ffilter=filter ooption=option extinct=xtinct m=mtmp-extinct verb=verbose #set up magnitude-dependent constants if(m<=12){ mu=0.03 gamma=0.36 } else { if(m>=20){ mu=0.09 gamma=0.04 } else { mu=0.0075*(m-12)+0.03 gamma=0.04*(12-m)+0.36 } } #set up option-dependent constants #differential V counts, stars mag-1 deg-2 if(ffilter=="V" && ooption=="differential"){ c1=200 alpha=-0.2 beta=0.01 delta=2 mstar=15 c2=400 kappa=-0.26 eta=0.065 lambda=1.5 mcross=17.5 } #integral V counts, stars deg-2 if(ffilter=="V" && ooption=="integral"){ c1=925 alpha=-0.132 beta=0.035 delta=3.0 mstar=15.75 c2=1050 kappa=-0.180 eta=0.087 lambda=2.50 mcross=17.5 } #differential B counts, stars mag-1 deg-2 if(ffilter=="B" && ooption=="differential"){ c1=235 alpha=-0.227 beta=0.0 delta=1.50 mstar=17 c2=370 kappa=-0.175 eta=0.06 lambda=2.0 mcross=18 } #integral B counts, stars deg-2 if(ffilter=="B" && ooption=="integral"){ c1=950 alpha=-0.124 beta=0.027 delta=3.1 mstar=16.60 c2=910 kappa=-0.167 eta=0.083 lambda=2.50 mcross=18 } #do the calculation. T is from eq. B1 of B&S80. T1a=(c1*10**(beta*(m-mstar)))/((1+10**(alpha*(m-mstar)))**delta) #T1b=((sin(b)*(1-mu*cos(l)/abs(tan(b))))**(3-5*gamma))**(-1.0) T1b=((sin(b)*(1-mu*cos(l)/(tan(b))))**(3-5*gamma))**(-1.0) T1=T1a*T1b T2a=(c2*10**(eta*(m-mcross)))/((1+10**(kappa*(m-mcross)))**lambda) #T2b=((1-abs(cos(b))*cos(l))**(1.45-0.20*abs(cos(b))*cos(l)))**(-1.0) T2b=((1-(cos(b))*cos(l))**(1.45-0.20*(cos(b))*cos(l)))**(-1.0) T2=T2a*T2b T=T1+T2 if(verb){ print(m//" "//T//" "//long//" "//lat//" "//extinct//" "//ffilter//" "//ooption) } else { print(T) } end ./src/checkfringe.cl0100644000151400000240000000726606561403604013557 0ustar phallgames# checkfringe.cl -- interactively adjust defringing # 950322: created from tpl.cl # 970227: added iterstat determination of RMS of each defringing test # 980729: added imsect parameter procedure checkfringe(fiximage,fringe,outname) string fiximage {prompt="Name of (original) image to be defringed"} string fringe {prompt="Fringe image to scale and subtract"} string outname {prompt="Name of defringed image to create"} string imsect="" {prompt="[Image section] to use for iterative statistics"} bool fit=yes {prompt="Adjust parameters and refit image?",mode="q"} real scale {prompt="Scaling to use on fringe image",mode="q"} int z {0,prompt="Number of image to save?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} begin string logimex, logsurf, countfile, rrootname, ooutname, ffunc string wweighting, fiximg, ffringe, titlestring, statsect real max, nncols, nnlines, sscale, indiv_exptime, avg_exptime, sum_exptime int x, y, zz, xxord, yyord, xx bool go, ffit, xxterms fiximg=fiximage ffringe=fringe ooutname=outname statsect=imsect zz=0 #countfile="log."//rrootname//".tplcount" # check for addcomment; if not defined abort task. go=yes if(!deftask("addcomment")) {go=no} if(go) { # Get initial scaling print("===> Displaying fringe image and original image...") display(ffringe,1) display(fiximg,2) imgets(fiximg,"FRINGMED",>&"dev$null") if(imgets.value!="0"){ sscale=real(imgets.value) } else { print(" ") print("===> Calculating initial fringe image scaling...") imgets(ffringe,"exptime") avg_exptime=real(imgets.value) imgets(fiximg,"exptime") indiv_exptime=real(imgets.value) imgets(fiximg,"SKYFRING") iterstat(fiximg//statsec,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) # new scaling = new median from iterstat * old scaling * exptime * avg_exptime sscale=iterstat.median*(real(imgets.value))*indiv_exptime/avg_exptime } #need to create countfile x=1 y=2 ffit=yes # Fitting loop while(ffit) { # (get new list of images) # copy(countfile,countfile//"_"//str(x)) if(x!=1){ # get new scaling sscale=scale # vi(countfile//"_"//str(x)) } # scale and subtract the fringe image print ("===> Scaling the fringe image by "//sscale//" and subtracting...") # imar (ffringe, "/", sscale, ffringe//"_"//str(x), ver-) # imar (ooutname//"_0", "-", ffringe//"_"//str(x), ooutname//"_"//str(x), ver-) imcalc(fiximg//","//ffringe,ooutname//"_"//str(x),"im1-im2*"//sscale,ver-) hedit(ooutname//"_"//str(x),"title","Defringed image using scale="//sscale,ver-,add+,update+,show-) # inspect the subtracted image print ("===> Displaying defringed image #"//str(x)//"...") y=y+1 if(y>4)y=1 displ (ooutname//"_"//str(x), y) iterstat (ooutname//"_"//str(x)//statsec,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) print ("===> RMS of defringed image #"//str(x)//statsec//" is "//iterstat.sigma) # clean up # abort loop? ffit=fit x+=1 } # clean up zz=z if(zz!=0){ imcopy(ooutname//"_"//str(zz),ooutname,ver-) hedit(ooutname,"FRINGMED",sscale,add+,ver-,show-,update+) addcomment(ooutname,"Defringed using FRINGMED-scaled copy of "//ffringe,ver-) imgets(fiximg,"title") titlestring=str(imgets.value) hedit(ooutname,"title",titlestring,add+,ver-,update+,show-) #del(countfile,ver-, >& "dev$null") #rename(countfile//"_"//str(zz),countfile, >& "dev$null") } else{ print("No images saved.") } y=0 zz=0 while(y& "dev$null") # del(countfile//"_"//str(y),ver-, >& "dev$null") y+=1 } } else{ print("The tasks `addcomment' are not loaded,") print("and this task needs them to run. Please load it and start again.") } if(echog)beep end ./src/cubeexam.cl0100644000151400000240000000101006171341047013054 0ustar phallgames# CUBEEXAM -- script to apply IMEXAM to a band of a 3D cube. # Notes: All IMEXAM parameters are used with their current settings. # Only one image and band may be specified at a time. # # usage: cubeexam band procedure cubeexam (cube, band) string cube {prompt="cube to be examined"} int band {prompt="band in cube to be examined"} begin string im3, sec, im2 im3 = cube im2 = mktemp (im3) imcopy (im3 // "[*,*,"//band//"]", im2, verbose=no) imexamine (im2) imdelete (im2, verify=no) end ./src/defringe.cl0100644000151400000240000001677206576302766013111 0ustar phallgames# defringe.cl -- do sky illumination correction & remove fringing from images # # Calls routines iterstat and addcomment. # # CHANGES: # 95/01/27: created # 95/03/22: many modifications begun # 96/02/26: allow saving of sky+fringe image when stopping task # 98/09/10: .imh replaced with .fits # 98/09/11: rewrote so iterstat not redone unnecessarily before skyfringe made procedure defringe(rootname,imagelist,logfile,defstring,biasimage) string rootname {prompt="Rootname for output images and image list"} string imagelist {prompt="List of images to process (do not use an `@')"} string logfile {prompt="Name of log file"} string defstring {prompt="String to be appended to output images"} string biasimage {prompt="Zero level calibration image for ccdproc"} bool dofringe {yes,prompt="Do fringe removal step?"} real gain {prompt="Gain of CCD (for ccdclip in imcombine)"} real rdnoise {prompt="Read noise of CCD (for ccdclip in imcombine)"} bool forcescale {no,prompt="Force recalculation of image scales?"} bool goon=yes {prompt="Continue with task using displayed sky+fringe image?",mode="q"} bool ssave=no {prompt="Save sky+fringe image?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} struct *list struct *list2 struct *list3 struct *datelist begin string ddefstring, ffringename, outlist, sskyfringename, sskyname, biasimg string rrootname, ddark, llogfile, bbadmask, eextension, normfile, img string flatlist, flat, flatbase, meanfile, currentflat, base, mmaskname string iimagelist, FlatImageList, fflatstr, check, ttplname, templist, flatdiv string datefile, thedate, ickinfo, name, tempstring, otherstring, tempfile real mean, nnumber, flatnorm, valmed, fringmed, ggain, rrdnoise, scale, scale2 real indiv_exptime, avg_exptime, sum_exptime int sstartno, eendno, i, j, numpix, x, y, z bool zzeroout, ttpl, sstdpars, go, fflatsave, force, ggoon rrootname = rootname iimagelist = imagelist llogfile = logfile ddefstring = defstring biasimg = biasimage ggain = gain rrdnoise = rdnoise force = forcescale outlist = "list."//rrootname//ddefstring sskyfringename=rrootname//ddefstring//".skyfringe.fits" # sky+fringe image ffringename=rrootname//ddefstring//".fringe.fits" # fringe image sskyname=rrootname//ddefstring//".sky.fits" # sky-flat image #The "go" parameter won't let the task run if you haven't loaded ccdred. go=yes if(!defpac("ccdred")) {go=no} if(!deftask("imcalc")) {go=no} if(!deftask("iterstat")) {go=no} if(!deftask("addcomment")) {go=no} if(go) { #Set up log file, appending if it already exists if(llogfile == "") llogfile=rrootname//".log" print(" ", >> llogfile) # Do iterstat to find each image's "true" median for use in scaling print("===> Finding image scales and weights...") tempfile = iimagelist list2 = tempfile sum_exptime = 0. scale = 1 scale2 = 1 i = 0 while (fscan(list2,img) !=EOF) { fileroot(img,validim+) flat=fileroot.root//ddefstring//".fits" print(flat, >> outlist) i = i + 1 force = forcescale imgets (img, "exptime") sum_exptime=sum_exptime+real(imgets.value) if (!force) { imgets (img,"SKYFRING",>&"dev$null") mean=real(imgets.value) if (mean == 0) { imgets (img,"ITERMED",>&"dev$null") valmed=real(imgets.value) if (valmed == 0) { force = yes } else { valmed = 1./valmed hedit(img,"SKYFRING",valmed,ad+,ve-,sho-,updat+) scale = scale + real(imgets.value) } } else { scale = scale + 1./real(imgets.value) } } if (force) { iterstat.nsigrej=5 iterstat.maxiter=10 iterstat(img,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) valmed = 1./iterstat.median hedit (img,"SKYFRING",valmed,add+,ver-,show-,update+) scale = scale + (1./valmed) } } sum_exptime=sum_exptime/i # Use this list of images to make the sky+fringe frame print("===> Creating template sky + fringe frame...") if(!imaccess(sskyfringename)){ imcombine("@"//tempfile, sskyfringename, sigma="", plfile="", combine="median", reject="ccdclip", project-, offsets="none", blank=0., scale="!SKYFRING", zero="none", weight="!SKYFRING", statsec="", lthresh=-100000, hthresh=100000, nlow=1, nhigh=1, nkeep=1, mclip+, lsigma=3, hsigma=3, rdnoise=rrdnoise, gain=ggain, snoise="0.", sigscale=0.1, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { beep; print (sskyfringename//" already exists... not overwritten.") } hedit(sskyfringename,"exptime",sum_exptime,add+,ver-,show-,update+) print("===> Displaying sky+fringe image for inspection. If object residuals") print("===> are present, you may wish to stop, create object masks, and rerun") print("===> the task. You can use makeobjmask on the non-defringed images to") print("===> create object masks for them directly, or you can use shiftnadd on") print("===> the non-defringed images, run mkobjmask on the skysubbed output,") print("===> insert the object mask names into the non-defringed image headers,") print("===> and then rerun this task so that the objects are masked out during") print("===> the creation of the sky+fringe image.") displ(sskyfringename,1) ggoon=goon if(!ggoon){ print("Task aborted-- illumination correction & defringing not done.") if(!ssave)imdel(sskyfringename,ver-) del(outlist,ver-) return } # "scale" is set equal to the average median of the input images. # It is multiplied into the sky+fringe frame to keep fringe counts accurate. scale = scale / i imar (sskyfringename, "*", scale, sskyfringename) # Insert title into fringe image header hedit (sskyfringename, "title", "Sky+fringe image for "//tempfile, add+,ver-,show-,update+) # Create sky illumination correction image mkskycor(sskyfringename,sskyname,xboxmin=5.,xboxmax=0.25,yboxmin=5.,yboxmax=0.25) #mkskycor(sskyfringename,out=sskyname,xboxmin=5.,xboxmax=0.25,yboxmin=5., #yboxmax=0.25) hedit (sskyname, "title", "Sky illumination correction image for "//iimagelist, add+,ver-,show-,update+) # Do illumination correction *on output images only* imcopy("@"//iimagelist, "@"//outlist, ver-) ccdproc("@"//outlist, illumcor+, illum=sskyname, zero=biasimg) imcopy(sskyfringename, ffringename, ver-) imar (ffringename, "-", sskyname, ffringename) # Subtract accurately scaled fringe image from each input image, if desired if(dofringe){ print("===> Subtracting scaled fringe image from each input image...") imgets(ffringename,"exptime") avg_exptime=real(imgets.value) #list = iimagelist list = outlist while (fscan (list, name) !=EOF) { # x=strlen(name) # check=substr(name,x-3,x) # base=substr(name,1,x) # if(check==".fits")base=substr(name,1,x-4) # flat=base//ddefstring//".fits" # print(flat, >> outlist) imgets(name,"exptime") indiv_exptime=real(imgets.value) imgets(name,"SKYFRING") iterstat(name,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) # new scaling = new median from iterstat * old scaling * exptime / avg_exptime fringmed=iterstat.median*(real(imgets.value))*indiv_exptime/avg_exptime imren (name, "_"//name, ver-) imcalc ("_"//name//","//ffringename, name, "im1-im2*"//fringmed, ver-) imdel ("_"//name, ver-) hedit(name,"FRINGMED",fringmed,add+,ver-,show-,update+) addcomment(name,"Defringed using scaled copy of "//ffringename,ver-) print(name//" was defringed using "//ffringename//" scaled by "//fringmed) } } print("===> Wrapping up... ") datefile = mktemp("date") date(>>datefile) datelist = datefile print("finished at "//datelist, >> llogfile) datelist = "" del(datefile, ver-) } else { beep print("WARNING: one or more of the packages `noao.imred.ccdred' or") print("`stsdas.toolbox.imgtools' or `PHIIRS' are not loaded!") print("Please load them and restart this task.") } if(echog)beep end ./src/fixbias.cl0100644000151400000240000000015506171341050012713 0ustar phallgamesdispl b0069 1 zr- zs- z1=900 z2=950 imcopy b0069 b0069orig biasfix b0069 displ b0069 2 zr- zs- z1=900 z2=950 ./src/imswap.cl0100644000151400000240000000045506305446032012576 0ustar phallgames# Swap two images procedure imswap(img1,img2) string img1 {prompt = "Name of first image"} string img2 {prompt = "Name of second image"} begin imrename(img2,"tmpswapdude",ver-) imrename(img1,img2,ver-) imrename("tmpswapdude",img1,ver-) print("Contents of "//img1//" and "//img2//" swapped.") end ./src/irtfcoadd_2.p0100644000151400000240000000057006503626447013327 0ustar phallgames#!/usr/local/bin/perl # cycle thru contents of file(s) given on command line using <> $iter=0; while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); if($iter==0) { ($avg, $rms, $num) = split " "; } else { ($one) = split " "; $out=$one/$avg; print "$out\n"; } $iter=1; } ./src/irtfcoadd_3.p0100644000151400000240000000044306503626447013327 0ustar phallgames#!/usr/local/bin/perl -w # cycle thru contents of file(s) given on command line using <> while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); ($one, $two) = split " "; printf "%4.0f%4.0f\n", $one, $two; } ./src/offlist.cl0100644000151400000240000000546607102330366012751 0ustar phallgames# offlist.cl -- find the offsets on the sky between two lists of objects # # Input format for both lists is: # 1 2 3 # ra dec id# # # Output is: # 1 2 3 4 5 6 7 8 9 # id1 ra1 dec1 id2 ra2 dec2 distance @ angle (measured E from N) # # ...for all objects closer than "limit" if all=yes, or just the closest # object closer than "limit" if all=no. procedure offlist(list1,list2,outlist,limit) string list1 {prompt = "First list of coordinates"} string list2 {prompt = "Second list of coordinates"} string outlist {prompt = "Output file"} real limit {prompt = "Max separation, in arcmin, to save"} bool all {prompt = "List all objects closer than limit?"} struct *el1 struct *el2 begin real dist, cdist, sdist, tdist, rn1, rn2, dn1, dn2, rt1, rt2, sigdig, distold real pa, cpa, spa, tpa, rd, dd, rds, dds, dt1, dt2, r1, r2, d1, d2, lim real pi=3.141592653585 int ipa string ir1, ir2, id1, id2, num1, num2, ooutlist, el3 string ir1old, ir2old, id1old, id2old, num1old, num2old bool aall, go el1=list1 el2=list2 el3=list2 ooutlist=outlist lim=limit distold=lim+1. aall=all go=no while(fscan(el1,ir1,id1,num1) !=EOF) { while(fscan(el2,ir2,id2,num2) !=EOF) { print (num1//" "//num2) r1=real(ir1) d1=real(id1) r2=real(ir2) d2=real(id2) #convert input RA to degrees rt1=15.0*r1 rt2=15.0*r2 #convert input RA,dec to radians rn1=rt1*pi/180.0 rn2=rt2*pi/180.0 dn1=d1*pi/180.0 dn2=d2*pi/180.0 #compute the distance using the formula: #cosine(distance) = sin(dn1)*sin(dn2) + cos(dn1)cos(dn2)cos(rn2-rn1) cdist = sin(dn1)*sin(dn2) + cos(dn1)*cos(dn2)*cos(rn2-rn1) if(cdist**2>=1.00)cdist=1.00 #fixes roundoff prob sdist = sqrt(1.00 - cdist**2) tdist = atan2(sdist,cdist) #theta=atan2(y,x) dist = tdist*180.00/pi #compute the position angle using the formula: #cos(pa)=(cos(dn1)sin(dn2) - sin(dn1)cos(dn2)cos(rn2-rn1))/(sin(tdist)) #cpa = (cos(dn1)*sin(dn2) - sin(dn1)*cos(dn2)*cos(rn2-rn1))/(sdist) cpa = cos(dn1)*sin(dn2) - sin(dn1)*cos(dn2)*cos(rn2-rn1) if(sdist==0.0){ pa = 360.0 } else { cpa = cpa/sdist if(cpa**2>=1.00)cpa=1.00 #fixes roundoff prob spa = sqrt(1.00 - cpa**2) tpa = atan2(spa,cpa) #theta=atan2(y,x) pa = tpa*180.00/pi } #is this the closest match found so far for this object? if(dist*60<=lim){ if(!aall && dist<=distold) { go=yes distold=dist ir1old=ir1 id1old=id1 ir2old=ir2 id2old=id2 num1old=num1 num2old=num2 } #output all matches if(aall){ print(num1//" "//ir1//" "//id1//" "//num2//" "//ir2//" "//id2//" "//dist*60//" @ "//pa, >> ooutlist) } } } #output closest match if(!aall && go)print(num1old//" "//ir1old//" "//id1old//" "//num2old//" "//ir2old//" "//id2old//" "//distold*60//" @ "//pa, >> ooutlist) distold=lim+1. go=no el2=el3 } end ./src/offset.cl0100644000151400000240000000430607077653256012602 0ustar phallgames# offset.cl -- Find the offset on the sky between two objects. # # This task takes the ID numbers and coordinates of two objects and computes # the offset on the sky between them, in seconds of time E-W and arcsec N-S, # as well as the distance between them in arcminutes. # Optionally these values can be output to a file instead of STDOUT. # #procedure offset(num1,ir1,id1,num2,ir2,id2) procedure offset(list1,list2) #string num1 {prompt = "ID number of CANDIDATE"} #real ir1 {prompt = "RA coordinate of CANDIDATE"} #real id1 {prompt = "Dec coordinate of CANDIDATE"} #string num2 {prompt = "ID number of OFFSET STAR"} #real ir2 {prompt = "RA coordinate of OFFSET STAR"} #real id2 {prompt = "Dec coordinate of OFFSET STAR"} string list1 {prompt = "First list of coordinates"} string list2 {prompt = "Second list of coordinates"} string outfile="STDOUT" {prompt = "Output file"} struct *el1 struct *el2 begin string ir1, ir2, id1, id2, num1, num2 real dist, cdist, sdist, tdist, rn1, rn2, dn1, dn2, rt1, rt2, sigdig real rd, dd, rds, dds, dt1, dt2, r1, r2, d1, d2 real pi=3.141592653585 string ooutlist ooutlist=outfile el1=list1 el2=list2 while(fscan(el1,ir1,id1,num1) !=EOF) { while(fscan(el2,ir2,id2,num2) !=EOF) { #set up dummy variables r1=real(ir1) d1=real(id1) r2=real(ir2) d2=real(id2) #convert input RA to degrees rt1=15.0*r1 rt2=15.0*r2 #convert input RA,dec to radians rn1=rt1*pi/180.0 rn2=rt2*pi/180.0 dn1=d1*pi/180.0 dn2=d2*pi/180.0 #compute the distance using the formula: #cosine(distance) = sin(d1)*sin(d2) + cos(d1)cos(d2)cos(r1-r2) #theta=atan2(y,x) cdist = sin(dn1)*sin(dn2) + cos(dn1)*cos(dn2)*cos(rn1-rn2) sdist = sqrt(1.00 - cdist**2) tdist = atan2(sdist,cdist) dist = tdist*180.00/pi #delta ra and dec rd=(rt2-rt1)*cos((dn1+dn2)/2.) dd=d2-d1 #Option 2: difference in RA and Dec (accurate for small separations only) # print("E-W on-sky separation in seconds of time: "//rd*240, >> ooutlist) print("E-W on-sky separation in arcsec: "//rd*3600, >> ooutlist) print("N-S on-sky separation in arcsec: "//dd*3600, >> ooutlist) print(num1//" is "//dist*60//" arcmin from "//num2, >> ooutlist) } } end ./src/irtfcoadd_1.p0100644000151400000240000000045006503626447013323 0ustar phallgames#!/usr/local/bin/perl -w # cycle thru contents of file(s) given on command line using <> while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); ($one, $two) = split " "; $out=$two/($one*$one); print "$out\n"; } ./src/optcoadd.cl0100644000151400000240000015374006561403761013107 0ustar phallgames# optcoadd -- coadd images with sub-pixel shift options and much, much more # # Calls addcomment, iterstat, fileroot, filecalc, stsdas.toolbox.imgtools.imcalc # # 960712: created from phiirs$ircoadd.cl # 960716: deleted internal scaling check, added subtracted-image creation # 960723: fixed edge problem in sky-subtracted image # 960806: made sky-subtracted image creation optional # 960807: fixed minor bug of ccomblist2 not existing in expmap creation only # 960812: fixed exposure map creation & created normalization map creation # 960815: fixed bug in normalization of expmap when dividing into outimage # 960816: changed so that statfile is used only if directly requested, # and added optional insertion of variances into image headers # 960817: fixed occasional bug in skysub + weighted-expmap normalization # 960822: moved check for necessary tasks earlier to avoid errors # 970425: added check for tpl image # 970429: changed expmap -- now sets bad pixels to -99999. # Also several other minor changes to bring in line with ircoadd # 970505: changed default expmap suffix from "em" to "exp" to avoid confusion # with ircoadd, whose output expmap is different than optcoadd's # 970507: changed creation of individual expmaps to replace pixels above # -10000. with exptime -- allows for -99999. bad pixels to be excluded # 970623: added ability to use imcombine snoise parameter # 980511: zeroing & scaling params double-checked (to 1%) before undoing # 980718: changed default oextimage to fits & fixed major unzeroing bug # # **Could cut down on transient memory needs by finding "wtfactor" needed to # convert _nm image to _wt image -- stack norm, then do wtfactor & stack wt # **Note that weights should add to 1 if taken from a file (probably matters # only when stacking and creating expmap, but do it always just to be safe) procedure optcoadd(comblist,outimage,expmap,normmap,shiftlist,scaling,zeroing,weighting,magfac,stack,logfile) string comblist {prompt="List of images to combine"} string outimage {prompt="Output coadded image"} string expmap {prompt="Output exposure map (default=outimage//exp)"} string normmap {prompt="Output normalization map (default=outimage//norm)"} string shiftlist {prompt="File with image shifts"} string scaling {prompt="Imcombine scaling (none|@file|!|etc.)"} string zeroing {"mode",prompt="Imcombine zero offsets (none|@file|mode|etc.)"} string weighting {prompt="Imcombine weighting (none|@file|!|etc.)"} int magfac {1,min=1,max=10,prompt="Magnification factor for subpixel shifting"} bool stack {prompt="Combine images by stacking & projecting?"} string logfile {prompt="Name of log file"} string normname {prompt="Header keyword for normalization factor",mode="q"} bool newmask=no {prompt="Override bad pixel masks listed in image headers?"} string badmask {prompt="Bad pixel mask to use instead",mode="q"} bool spshift=no {prompt="Do image shifts account for subpix shifting?",mode="q"} bool prescale=no {prompt="Scale images before, not during, imcombine?",mode="q"} bool unscale=yes {prompt="Undo scaling factors when done?",mode="q"} real extcoeff {prompt="Extinction coefficient for default scalings",mode="q"} real airzero {INDEF,min=0.,max=99.,prompt="Airmass to scale to? (INDEF=min. observed)",mode="q"} bool scalecombine=no {prompt="Combine default & additional scalings?",mode="q"} string morescalename {prompt="@filename or !keyword for additional scalings",mode="q"} bool putscale {prompt="Insert scaling factors into image headers?",mode="q"} string wordscale="SCALEFAC" {prompt="Scaling factor header keyword",mode="q"} bool defscale=no {prompt="Do scales include default airmass scaling?",mode="q"} bool prezero=no {prompt="Do zero offseting before, not during, imcombine?",mode="q"} bool unzero=yes {prompt="Undo zero offsets when done?",mode="q"} bool putzero=no {prompt="Insert zero offsets into image headers?",mode="q"} string wordzero="ZEROVAL" {prompt="Zero offset header keyword",mode="q"} bool putweight=no {prompt="Insert weights into image headers?",mode="q"} string wordweight="WEIGHT" {prompt="Weighting factor header keyword",mode="q"} string stackimage {prompt="Name of stacked image", mode="q"} bool unstack {prompt="Delete stacked image & expmap when done?",mode="q"} bool spscale=no {prompt="Do zero offsets account for subpix shifting?",mode="q"} string expname="EXPTIME" {prompt="Header keyword for exposure time"} bool maskedstat=no {prompt="Use maskstat to find default zeros & wts?"} string statfile="" {prompt="File for image statistics"} bool stdpars=yes {prompt="Use std imcombine parameters for coadd?"} bool makeavg=no {prompt="Make pure coadd (comb=average,rej=none)?"} bool flip=no {prompt="Flip image L-R after coadd?"} bool cleanup=yes {prompt="Clean up new created blkrep'd images after use?"} bool tpl=no {prompt="Account for throughput correction in norm. map?"} bool echog {yes,prompt="Beep when task is done?"} pset optcoaddpars {prompt="Imcombine parameters"} struct *list begin string sshiftfraclist, iinterp, sshiftlist, subimg, explist, sect, skysubimg string ccomblist, bbadmask, sshiftintlist, ooutimage, zzeroing, sstackimage string llogfile, check, zzeroname, sscalefile, sscalename, img, eexpname, blk string s_sigma, s_plfile, s_combine, s_reject, s_offsets, s_masktyp, eexpmap string s_scale, s_weight, s_statsec, s_expname, sscaling, intcosca, expmask string listimshift, wwordscale, wwordzero, subimgold, expmaskold, checkmore string ccomblist1, ccomblist2, sshiftexactlist, image, newbp, newzzeroname string oldbp, bprotlist, file_of_zeros, list_of_zeros, checkscale, checkweight string checkzero, newwweightname, oldzs, newzs, oldwts, newwts, wweightname string file_of_more, mmorescalename, file_of_air, wweighting, wwordweight string file_of_scales, list_of_scales, sstatfile, s_gain, s_rdnoise, nnormname string nnormmap, wtimg, wtlist, wtimgold, tplimg, tplimgold, oextimage, tpltmp string tmpimg, tmpimg2, s_snoise real s_maskval, s_blank, s_lthresh, s_hthresh, s_nlow, s_nhigh, s_nkeep, avg, x real s_lsigma, s_hsigma, s_pclip, s_grow, s_sigscale, sig real effairmass, wtavg, nncombine, exp, exposure, sf, zf, testold, eexptime real xold, yold, xnew, ynew, xshift, yshift, sscale, p, b, h, levelzero, wt real wt_avg_exptime, unwt_avg_exptime, eextcoeff, aairzero, air, sfavg, sfmin real sfmax, tmpzero, wait, waitold, tmpscale int mag, mag2, j, k, tpl1, tpl2 int xmin, ymin, newx, newy, oldx, oldy, test1, test1old, test2, test2old int sstartno, eendno, i, numpix, num, xdim, ydim, newxsize, newysize, ncoadds bool mmakescalefile, mmakestack, go, mmorehow, pputzero, ddefscale, pputscale bool nnewmask, uunstack, pprescale, uunscale, pputweight, sstack, getnorm, ttpl bool sspscale, ccleanup, noappend, pprezero, uunzero, sscalecombine, sspshift struct theadline #for zero/scale/weight=* # *ing how to do it # *name filename, if substr(*ing,1,1)==@ # word* header keyword, if substr(*ing,1,1)==! (or @ && pre*=yes) # pre* do zero/scale before imcombine # un* undo zero/scale after imcombine # Certain tasks/packages must be loaded for task to run. go=yes if(!defpac("imgtools")) {go=no} if(!deftask("addcomment")) {go=no} if(!deftask("fileroot")) {go=no} if(!deftask("filecalc")) {go=no} if(!deftask("iterstat")) {go=no} if(go) { # Set up parameters ccomblist = comblist ccomblist1 = ccomblist fileroot (outimage,validim+) ooutimage = fileroot.root oextimage = fileroot.extension # if(oextimage=="")oextimage="imh" if(oextimage=="")oextimage="fits" fileroot (expmap,validim+) eexpmap = fileroot.root if(eexpmap=="")eexpmap=ooutimage//"exp" nnormmap=normmap if(nnormmap=="")nnormmap=ooutimage//"norm" sshiftexactlist = shiftlist sshiftintlist = sshiftexactlist sscaling = scaling if(sscaling=="")sscaling="none" ddefscale=no aairzero=100. pprescale=no uunscale=no sscalename="_.imag_in_ary_fileJ" checkscale=substr(sscaling,1,1) if(checkscale=="!" || checkscale=="@"){ wwordscale = substr(sscaling,2,strlen(sscaling)) pprescale=prescale if(pprescale)uunscale=unscale if(checkscale=="@"){ sscalename = substr(sscaling,2,strlen(sscaling)) if(!access(sscalename)){ ddefscale=yes eextcoeff=extcoeff aairzero=airzero sscalecombine=scalecombine if(sscalecombine){ mmorescalename=morescalename checkmore=substr(mmorescalename,1,1) while(checkmore!="@" && checkmore!="!"){ print("Additional scales must have format ! or @filename.") mmorescalename=morescalename checkmore=substr(mmorescalename,1,1) } } } pputscale=putscale if(pputscale)wwordscale=wordscale } if(!ddefscale)ddefscale=defscale if(ddefscale && aairzero==100.)aairzero=airzero # if airzero=INDEF and airzero is needed later in the task, airzero=min(airmass) if(aairzero==INDEF && (ddefscale || (pprescale && checkscale=="@" && access(sscalename)))){ print("...one moment please...") file_of_air=mktemp(".foa") hsel("@"//ccomblist1,"AIRMASS",yes, >> file_of_air) list=file_of_air aairzero=100. while (fscan (list,air) != EOF) { aairzero=min(air,aairzero) } del(file_of_air,ver-,>&"dev$null") list="" } } zzeroing = zeroing if(zzeroing=="")zzeroing="none" pprezero=no uunzero=no checkzero=substr(zzeroing,1,1) if(checkzero=="!" || checkzero=="@"){ wwordzero = substr(zzeroing,2,strlen(zzeroing)) pprezero=prezero if(pprezero)uunzero=unzero if(checkzero=="@"){ zzeroname = substr(zzeroing,2,strlen(zzeroing)) pputzero=putzero if(pputzero)wwordzero=wordzero } } wweighting = weighting wwordweight="" if(wweighting=="")wweighting="none" checkweight=substr(wweighting,1,1) if(checkweight=="!")wwordweight=substr(wweighting,2,strlen(wweighting)) if(checkweight=="@"){ wweightname = substr(wweighting,2,strlen(wweighting)) pputweight=putweight if(pputweight)wwordweight=wordweight } mag = magfac mag2=mag*mag blk = "br"//mag ccomblist2 = ccomblist//blk bprotlist = ccomblist//blk//"pl" sspscale=no sspshift=no if(mag!=1){ if(zzeroing!="none")sspscale=spscale sspshift=spshift } sstack=stack sstackimage="fake_image_oog" if(sstack) { fileroot(stackimage,validim+) sstackimage = fileroot.root uunstack=unstack } llogfile = logfile nnormname=normname getnorm=no if(nnormname=="")getnorm=yes if(nnormname=="")nnormname="variance" if(wwordweight=="")wwordweight=wordweight nnewmask = newmask if(nnewmask)bbadmask = badmask eexpname = expname sstatfile = statfile if(sstatfile=="")sstatfile="_nonexistentFILEname_" ttpl = tpl ccleanup = cleanup # Check for bad parameter combinations and exit if necessary if(!pprescale && sstack && checkscale=="!"){ print("WARNING! You can't scale during imcombine from a header keyword") print("when stack=yes! (There is only one header for a stacked image.)") print("Use `@file' or prescale=yes instead.") return } if(!pprezero && sstack && checkzero=="!"){ print("WARNING! You can't take the zero offsets from a header keyword") print("when stack=yes! (There is only one header for a stacked image.)") print("Use `@filename' or prezero=yes instead.") return } if(checkweight!="@" && wweighting!="none" && sstack){ print("WARNING! Output image exposure time would have been incorrect.") print("If you want to use weights and stacking, put the weights in a file") print("before running the task; that way the output image exposure time") print("will be correctly calculated.") return } wt_avg_exptime=-1. unwt_avg_exptime=-1. s_sigma = i_sigma # imcombine parameters s_plfile = i_plfile s_combine = i_combine s_reject = i_reject s_masktyp = i_masktyp s_maskval = i_maskval s_blank = i_blank s_statsec = i_statsec s_expname = i_expname s_lthresh = i_lthresh s_hthresh = i_hthresh s_nlow = i_nlow s_nhigh = i_nhigh s_nkeep = i_nkeep s_lsigma = i_lsigma s_hsigma = i_hsigma s_rdnoise = i_rdnoise s_gain = i_gain s_snoise = i_snoise s_sigscale = i_sigscale s_pclip = i_pclip s_grow = i_grow # Set up log file, appending if it already exists. if(llogfile == "") llogfile="log."//ooutimage print("", >> llogfile) print("===> PHAT.OPTCOADD:", >> llogfile) if(mag!=1){ print("===> Input images from "//ccomblist1//" replicated by factor "//mag//" in each direction.", >> llogfile) print("===> Replicated images in "//ccomblist2//" coadded w/offsets from "//sshiftexactlist//blk, >> llogfile) } else { print("===> Images in "//ccomblist1//" coadded w/offsets from "//sshiftexactlist//",", >> llogfile) } print("===> weights="/wweighting//", stdpars="/stdpars//", makeavg="/makeavg//",", >> llogfile) print("===> scales="/sscaling//", zero offsets="/zzeroing//",", >> llogfile) print("===> pre-scaling="/pprescale//", un-scaling="/uunscale//", pre-zeroing="/pprezero//", un-zeroing="/uunzero//",", >> llogfile) print("===> defscale="/ddefscale//", subpixscale="/sspscale//", subpixshift="/sspshift//",", >> llogfile) print("===> to make image "//ooutimage//" and exposure map "//eexpmap, >> llogfile) # PRE-SCALING AND DEFAULT SCALING FACTORS FILE CREATION if(pprescale){ # Prevent imcombine from scaling twice sscaling="none" # If stacking, and image already exists, do not bother # if(sstack && access(sstackimage//".imh")){ # print("Not bothering to pre-scale... stacked image already exists.") # } else { print("===> Multiplying by additional scaling factors...") # In case of scalings taken from header keyword, make file_of_scales if(checkscale=="!"){ file_of_scales=mktemp(".fos") hsel("@"//ccomblist1,wwordscale,yes, >> file_of_scales) } # In case of scalings taken from file... if(checkscale=="@"){ # # ...create file of DEFAULT SCALING FACTORS if it doesn't exist... # if(!access(sscalename)){ file_of_air=mktemp(".foa") # get airmasses hsel("@"//ccomblist1,"AIRMASS",yes, >> file_of_air) # turn airmasses into scales list=file_of_air while (fscan (list,air) != EOF) { sf=10**(0.4*eextcoeff*(air-aairzero)) print(sf, >> sscalename) } del(file_of_air,ver-) # If combining default scales with other pre-existing scales... if(sscalecombine){ file_of_more=mktemp(".fom") if(checkmore=="@"){ copy(substr(mmorescalename,2,strlen(mmorescalename)),file_of_more,ver-) } if(checkmore=="!"){ hsel("@"//ccomblist1,substr(mmorescalename,2,strlen(mmorescalename)),yes, >> file_of_more) } # join files of default and additional scales del("tmp_."//sscalename,ver-,>&"dev$null") join(sscalename,file_of_more,output="tmp_."//sscalename) del(sscalename,ver-,>&"dev$null") del(file_of_more,ver-,>&"dev$null") list="" list="tmp_."//sscalename # create new scales & put into scale file while(fscan (list,air,sf) != EOF) { print(air*sf, >> sscalename) } del("tmp_."//sscalename,ver-,>&"dev$null") } # Finished with creation of default scalings file } list="" file_of_scales=sscalename # End of taking scales from list subroutine } list="" # Allow imcombine to do sigscaling as requested even when pre-scaling if(s_sigscale!=0.){ del ("_avg.file.tmp", ver-, >& "dev$null") type (file_of_scales | average opt="new_sample", >> "_avg.file.tmp") sfavg=average.mean sfmin=1.E20 sfmax=-1.E20 list=file_of_scales while (fscan (list,sf) != EOF) { sfmin=min(sfmin,sf) sfmax=max(sfmax,sf) } if((sfavg-sfmin/sfavg)>=s_sigscale || (sfmax-sfavg/sfavg)>=s_sigscale)s_sigscale=0. del ("_avg.file.tmp", ver-, >& "dev$null") list="" } # Do multiplicative scaling unless it has already been done list_of_scales=mktemp(".los") join(ccomblist1,file_of_scales,output=list_of_scales) if(checkscale=="!")del(file_of_scales,ver-) list=list_of_scales while (fscan (list,img,sf) != EOF) { imgets(img,"PRESCALE",>&"dev$null") if(imgets.value=="0"){ imar(img,"*",sf,img,pixt="real",calct="real",ver-) hedit(img,"PRESCALE",sf,add+,ver-,show-,update+,>&"dev$null") if(ddefscale){ imgets(img,"AIRMASS",>&"dev$null") hedit(img,"AIRMOLD",imgets.value,add+,ver-,show-,update+,>&"dev$null") hedit(img,"AIRMASS",aairzero,add+,ver-,show-,update+,>&"dev$null") } } else { print("No action -- image "//img//" already pre-scaled by factor "//imgets.value) } } # } } list="" # put scale factors into image headers if desired if(checkscale=="@"){ if(pputscale){ del("_tmp.sscaling",ver-,>&"dev$null") join(ccomblist1,sscalename,out="_tmp.sscaling") list="_tmp.sscaling" while(fscan (list, img, sf) != EOF) { hedit(img,wwordscale,sf,add+,ver-,show-,update+,>&"dev$null") } del("_tmp.sscaling",ver-,>&"dev$null") } } list="" # DETERMINE ZERO-LEVEL OFFSETS IF NEEDED AND INSERT INTO HEADERS IF DESIRED if(checkzero=="@"){ if(!access(zzeroname)){ print("===) Finding iterative median zero offsets for the images...") del ("_zero.file.tmp?", ver-, >& "dev$null") del ("_avg.file.tmp", ver-, >& "dev$null") # first find iterative median of each image if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_zero.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_zero.file.tmp1", sstatfile, ver-) } else { iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_zero.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_zero.file.tmp1", sstatfile, ver-) } } else { if(sstatfile!="_nonexistentFILEname_")print("Using statistics from"//sstatfile) copy(sstatfile, "_zero.file.tmp1", ver-) } # next find the overall average of the means fields ("_zero.file.tmp1", 5, >> "_zero.file.tmp2") type ("_zero.file.tmp2" | average opt="new_sample", >> "_avg.file.tmp") # now compute the offset of each image from the overall average mean list="_avg.file.tmp" while (fscan (list, avg, sig, num) !=EOF) { lintran("_zero.file.tmp2",min=2,x2=avg,yfield=1,angle=180, >> zzeroname) } del ("_zero.file.tmp?", ver-) del ("_avg.file.tmp", ver-) } # now insert into image headers if desired if(pputzero) { if(access("_tmp.zzeroing"))del("_tmp.zzeroing",ver-) join(ccomblist1,zzeroname,out="_tmp.zzeroing") list="" list="_tmp.zzeroing" while (fscan (list, img, zf) !=EOF) { hedit(img,wwordzero,zf,add+,ver-,show-,update+) } del("_tmp.zzeroing",ver-,>&"dev$null") } } list="" # DETERMINE WEIGHTS IF NEEDED AND ADD TO IMAGE HEADERS IF DESIRED if(checkweight=="@"){ if(!access(wweightname)){ print("===) Creating file of optimal exptime/rms**2 weights for the images...") del ("_weight.file.tmp?", ver-, >& "dev$null") del ("_avg.file.tmp", ver-, >& "dev$null") # first find iterative rms of each image #hsel("@"//ccomblist1,"PRESCALE",yes, >> "_weight.file.tmp9") #count("_weight.file.tmp9") | scan (i,j,k) #if(j!=0){ #beep #print("WARNING! At least one image in "//ccomblist//" was pre-scaled;") #print("thus, the image weights being calculated will be erroneous.") #} if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 if(!access("_weight.file.tmp1"))maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_weight.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_weight.file.tmp1", sstatfile, ver-) } else { if(!access("_weight.file.tmp1"))iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_weight.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_weight.file.tmp1", sstatfile, ver-) } } else { copy (sstatfile, "_weight.file.tmp1", ver-) } fields ("_weight.file.tmp1", 3, >> "_weight.file.tmp2") # get the exptimes for the images hsel("@"//ccomblist1,eexpname,yes, >> "_weight.file.tmp0") join("_weight.file.tmp2","_weight.file.tmp0",out="_weight.file.tmp3") # compute the weights = exptime./(rms**2.) filecalc ("_weight.file.tmp3", "$2/($1*$1)", calctype="real", >> "_weight.file.tmp4") # find the sum of the weights type ("_weight.file.tmp4" | average opt="new_sample",>> "_avg.file.tmp") # normalize by the sum of the weights filecalc ("_weight.file.tmp4", "$1/"//average.sum, calctype="real", >> wweightname) del ("_weight.file.tmp?", ver-) del ("_avg.file.tmp", ver-) } if(pputweight){ if(access("_tmp.wweighting"))del("_tmp.wweighting",ver-) join(ccomblist1,wweightname,out="_tmp.wweighting") list="_tmp.wweighting" while (fscan (list, img, wt) !=EOF) { hedit(img,wwordweight,wt,add+,ver-,show-,update+) } del("_tmp.wweighting",ver-) } } list="" # IF DESIRED, DETERMINE NORMALIZATION FACTORS AND ADD TO IMAGE HEADERS if(getnorm){ print("===) Finding normalization factors (variances) and putting into image headers...") del ("_norm.file.tmp?", ver-, >& "dev$null") # first find iterative rms of each image if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 if(!access("_norm.file.tmp1"))maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_norm.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_norm.file.tmp1", sstatfile, ver-) } else { if(!access("_norm.file.tmp1"))iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_norm.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_norm.file.tmp1", sstatfile, ver-) } } else { copy (sstatfile, "_norm.file.tmp1", ver-) } fields ("_norm.file.tmp1", 3, >> "_norm.file.tmp2") # compute the normalization factor = (rms**2.) filecalc ("_norm.file.tmp2", "$1*$1", calctype="real", >> "_norm.file.tmp4") if(access("_tmp.norm"))del("_tmp.norm",ver-) join(ccomblist1,"_norm.file.tmp4",out="_tmp.norm") list="_tmp.norm" while (fscan (list, img, wt) !=EOF) { hedit(img,nnormname,wt,add+,ver-,show-,update+) } del("_tmp.norm",ver-) del ("_norm.file.tmp?", ver-) } list="" # SUBPIXEL SHIFTING noappend=no # First expand images if subpixel shifting is desired if (mag!=1){ if(!sspshift)sshiftintlist=sshiftexactlist//blk # If output image list already exists, do not append to it if (access(ccomblist2)){ noappend=yes print("WARNING! Output image list "//ccomblist2//" already exists.") print("Any images listed therein will be created if they do not exist,") print("but no image names will be appended to this preexisting file.") } print("===) Expanding images by factor "//mag//" in both directions...") list=ccomblist1 # Go through image list while (fscan (list, img) !=EOF) { fileroot(img,validim+) image=fileroot.root # Do the magnification as long as the image does not already exist or has not # already been rotated/magnified if(!access(image//blk//".fits")){ imgets(image,"ROTATED",>&"dev$null") if(imgets.value=="0"){ # Divide by mag squared to conserve total number of counts in input image. imar(image,"/",mag2,"_"//blk//image,pixt="real",calc="real",ver-) blkrep("_"//blk//image,image//blk,mag,mag) imdel("_"//blk//image,ver-) if(!noappend)print (image//blk, >> ccomblist2) # Now replicate the bad pixel mask, if not already done. imgets(image//blk,"BPMASK",>&"dev$null") if(imgets.value=="0")imgets(image//blk,"BPM",>&"dev$null") oldbp=imgets.value newbp=blk//oldbp if(!access(newbp)){ blkrep(oldbp,newbp,mag,mag) print(newbp//".pl", >> bprotlist) } # Insert the replicated bad pixel mask in the image header hedit(image//blk,"BPMASK",newbp,add+,ver-,show-,update+) hedit(image//blk,"BPM",newbp,add+,ver-,show-,update+) } else { # If input image already rotated, only print a warning. print("WARNING! "//image//".fits already rotated; not rotated again") } } else { # If output image already exists, only print a warning. print("WARNING! "//image//blk//".fits already exists; not overwritten") } # Next image } # # If output subpixel shifts file doesn't exist, create it if(!access(sshiftintlist)) { print("===> Calculating shifts for expanded images...") if (access("tmp"//sshiftintlist))del("tmp"//sshiftintlist,ver-) list="" list=sshiftexactlist # Convert old shifts to new while (fscan (list,xold,yold) != EOF) { xnew=mag*xold ynew=mag*yold print (xnew, ynew, >> "tmp"//sshiftintlist) } # Round off to integer shifts (in units of new pixels, natch). filecalc("tmp"//sshiftintlist,"$1;$2",format="%4.0f %4.0f", >> sshiftintlist) del("tmp"//sshiftintlist,ver-) # If output subpixel shifts file does exist, just print warning } else { if(sshiftintlist==sshiftexactlist//blk)print("WARNING! "//sshiftintlist//" already exists; not overwritten") } # Correction of zero offsets for lower flux/pixel in blkrep'd images, if needed if(!sspscale) { # Zero offsets from list if(checkzero=="@") { if(!access(zzeroname//blk)) { filecalc(zzeroname,"$1/"//mag2,format="%9.7f", >> zzeroname//blk) newzzeroname=zzeroname//blk zzeroname=newzzeroname zzeroing="@"//newzzeroname } } # Zero offsets from header keyword if(checkzero=="!"){ oldzs=mktemp(".oz") newzs=mktemp(".nz") hsel("@"//ccomblist1,wwordzero,yes, >> oldzs) filecalc(oldzs,"$1/"//mag2,format="%9.7f", >> newzs) join(ccomblist2,oldzs,output=newzs) list="" list=newzs while (fscan (list,img,levelzero) != EOF) { hedit(img,wwordzero,levelzero,add+,ver-,show-,update+) } del(oldzs,ver-) del(newzs,ver-) } } # End of subpixel shift option } list="" # INSERT NEW ZERO OFFSETS INTO REPLICATED IMAGE HEADERS IF DESIRED. if(access(ccomblist2) && checkzero=="@"){ if(pputzero) { if(!sspscale && access(zzeroname//blk))zzeroname=zzeroname//blk del("_tmp.zzeroing",ver-,>&"dev$null") join(ccomblist2,zzeroname,out="_tmp.zzeroing") list="_tmp.zzeroing" while (fscan (list, img, zf) !=EOF) { hedit(img,wwordzero,zf,add+,ver-,show-,update+) } del("_tmp.zzeroing",ver-,>&"dev$null") } } list="" # PRE-ZEROING: INCORPORATE ZERO OFFSETS BEFORE IMCOMBINE IF DESIRED if(pprezero){ print("===> Doing zero offsetting prior to imcombine...") # Prevent imcombine from zeroing twice zzeroing="none" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) # In case of zero offsets taken from header keyword, make file_of_zeros if(checkzero=="!"){ file_of_zeros=mktemp(".foz") hsel("@"//ccomblist2,wwordzero,yes, >> file_of_zeros) } if(checkzero=="@")file_of_zeros=zzeroname list_of_zeros=mktemp(".loz") join(ccomblist2,file_of_zeros,output=list_of_zeros) if(checkzero=="!")del(file_of_zeros,ver-) # If stacking, and image already exists, do not bother if(sstack && access(sstackimage//".fits")){ print("Not bothering to pre-zero... stacked image already exists.") } else { # Do zero offsetting unless it has already been done list=list_of_zeros while (fscan (list,img,levelzero) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value=="0"){ imar(img,"+",levelzero,img,pixt="real",calc="real",ver-) hedit(img,"PREZERO",levelzero,add+,ve-,sho-,updat+,>&"dev$null") } else { print("No action -- image "//img//" already zero-offset by "//imgets.value) } } } } list="" # COADD images # If output coadded image doesn't exist, create it! if (!access(ooutimage//"."//oextimage)){ # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) if (sstack){ # If output stacked image doesn't exist, create it! if (!access(sstackimage//"."//oextimage)){ print("===) Stacking the images...") imstack("@"//ccomblist2,sstackimage,title="Stacked images listed in "//ccomblist2) } if(nnewmask) { hedit(sstackimage,"BPM",bbadmask,add+,ver-,show-,update+) } print("===) Combining the images...") if (makeavg){ imcombine(sstackimage, ooutimage, sigma=s_sigma, plfile=s_plfile, combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } else{ if (stdpars) { imcombine(sstackimage, ooutimage, sigma="", plfile="", combine="average", reject="ccdclip", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale=sscaling, zero=zzeroing, weight=wweighting, statsec="", expname=eexpname, lthresh=INDEF, hthresh=INDEF, nlow=1., nhigh=1., nkeep=1., mclip+, lsigma=5., hsigma=5., rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { imcombine(sstackimage, ooutimage, sigma=s_sigma, plfile=s_plfile, combine=s_combine, reject=s_reject, project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise=s_snoise, sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } } # Stacked images only: compute correct UNWEIGHTED average exposure time del("tmp_"//ccomblist2,ver-,>&"dev$null") hsel ("@"//ccomblist2,eexpname,yes, >> "tmp_"//ccomblist2) type ("tmp_"//ccomblist2) | average (opt="new_sample") | scan (eexptime,p,b) hedit(ooutimage,eexpname,eexptime,add+,ver-,show-,update+) del("tmp_"//ccomblist2,ver-,>&"dev$null") # if(uunstack)imdel(sstackimage,ver-) } else{ if(nnewmask) { list=ccomblist2 while (fscan (list, img) !=EOF) { imgets(img,"BPMASK",>&"dev$null") if(imgets.value=="0") { imgets(img,"BPM",>&"dev$null") hedit(img,"BPMASK",imgets.value,add+,ver-,show-,update+) hedit(img,"BPM",bbadmask,add+,ver-,show-,update+) } else { hedit(img,"BPM",bbadmask,add+,ver-,show-,update+) } } } print("===) Combining the images...") if (makeavg){ imcombine("@"//ccomblist2, ooutimage, sigma=s_sigma, plfile=s_plfile, combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise=s_snoise, sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } else{ if (stdpars) { imcombine("@"//ccomblist2, ooutimage, sigma="", plfile="", combine="average", reject="ccdclip", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale=sscaling, zero=zzeroing, weight=wweighting, statsec="", expname=eexpname, lthresh=INDEF, hthresh=INDEF, nlow=1., nhigh=1., nkeep=1., mclip+, lsigma=5., hsigma=5., rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=0.1, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { imcombine("@"//ccomblist2, ooutimage, sigma=s_sigma, plfile=s_plfile, combine=s_combine, reject=s_reject, project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } } } list="" # Put original BPM back if necessary if(nnewmask) { list=ccomblist2 while (fscan (list, img) !=EOF) { imgets(img,"BPMASK",>&"dev$null") hedit(img,"BPM",imgets.value,add+,ver-,show-,update+) } } list="" # Header parameters for the coadded image hedit(ooutimage,"title","Coadded image from "//ccomblist2//" and "//sshiftintlist,ver-,show-,update+) time | scan (theadline) addcomment(ooutimage,"phat.optcoadd: "//theadline,ver-) addcomment(ooutimage,"Coadded from "//ccomblist2//" and "//sshiftintlist,ver-) addcomment(ooutimage,"makeavg="/makeavg//", zero shifts from "//zzeroing,ver-) addcomment(ooutimage,"scaling factors from "//sscaling//", and stdpars="//stdpars,ver-) # AIRMASS # Set airmass of coadded image to effective airmass if default scaling !used if(!ddefscale){ del("_airmass.tmp?",ver-,>&"dev$null") hsel("@"//ccomblist2, "airmass", yes, >> "_airmass.tmp1") type("_airmass.tmp1" | average opt="new_sample", >> "_airmass.tmp2") effairmass=real(average.mean) hedit(ooutimage,"airmass",(effairmass),add+,ver-,show-,update+) del("_airmass.tmp?",ver-,>&"dev$null") # Set airmass of coadded image to reference airmass if default scaling was used } else { hedit(ooutimage,"airmass",(aairzero),add+,ver-,show-,update+) } # EXPOSURE NORMALIZATION -- normalize coadded image to total exposure time. # If weighting was done w/a stacked image, first find correct WEIGHTED exptime del ("_exptime.tmp?", ver-, >& "dev$null") if(sstack && wweighting!="none"){ # First get individual image exposure times del ("_exptime.tmp?", ver-, >& "dev$null") hsel("@"//ccomblist2,eexpname,yes, >> "_exptime.tmp1") # Join individual image exptimes with weights join("_exptime.tmp1", wweightname, output="_exptime.tmp3") # Calculate individual image weighted exposure times filecalc ("_exptime.tmp3", "$1*$2", calctype="real", >> "_exptime.tmp4") # Calculate correct weighted exposure time type ("_exptime.tmp4" | average opt="new_sample",>> "_exptime.tmp5") # Insert correct weighted exposure time into image header hedit(ooutimage,eexpname,average.sum,add+,ver-,show-,update+) } # First find total exposure time of input images hsel("@"//ccomblist2,eexpname,yes, >> "_exptime.tmp6") type("_exptime.tmp6" | average opt="new_sample", >> "_exptime.tmp7") del ("_exptime.tmp?", ver-, >& "dev$null") unwt_avg_exptime=real(average.mean) eexptime=real(average.sum) # Get output exposure time of coadded image imgets(ooutimage,eexpname) wt_avg_exptime=real(imgets.value) # Insert total exposure time into coadded image header hedit(ooutimage,eexpname,eexptime,add+,ver-,show-,update+) # Multiply coadded image by (total_exposure_time/output_exposure_time) imar(ooutimage, "*", eexptime/wt_avg_exptime, ooutimage) print("", >> llogfile) print("Coadded image multiplied by "//eexptime/wt_avg_exptime//" to bring its flux", >> llogfile) print("in line with the total exposure time of "//eexptime//" s.", >> llogfile) # CREATE WEIGHTED EXPOSURE MAP # Create exposure maps if the output coadded-image exposure map does not exist. # Routine allows for images of different exposure times, sizes, and BPMs, while # creating as few images as possible consistent with meeting those criteria. explist="" if(!access(eexpmap//"."//oextimage)){ # Don't recreate exposure maps to be stacked if stacked expmap image exists if(!sstack || (sstack && !access("exp"//sstackimage//"."//oextimage))) { print("===) Creating exposure maps...") subimgold="_oops" testold=0. test1old=0 test2old=0 expmaskold="" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) list=ccomblist2 explist=ccomblist2//"exp" if(access(explist))del(explist,ver-,>&"dev$null") while (fscan (list, img) !=EOF) { # get image parameters: xsize, ysize, exptime, badpixelmask fileroot(img,validim+) imgets(img,"i_naxis1") test1=int(imgets.value) imgets(img,"i_naxis2") test2=int(imgets.value) imgets(img,eexpname) exposure=real(imgets.value) imgets(img,"BPMASK") expmask=str(imgets.value) # if any of those parameters differ from the previous image, need to create a # new exposure map for eventual coadding. if(test1!=test1old || test2!=test2old || exposure!=testold || expmask!=expmaskold) { subimg = mktemp(fileroot.root) print (subimg, >> explist) # imcalc(img,subimg,"im1*0+"//exposure,ver-) imcopy(img,subimg,ver-) imreplace(subimg,exposure,lower=-10000.,upper=INDEF) if(nnewmask)hedit(subimg,"BPM",bbadmask,add+,ver-,show-,update+) test1old=test1 test2old=test2 testold=exposure expmaskold=expmask subimgold=subimg } else { print (subimgold, >> explist) } } } # Create coadded-image exposure map print("===> Creating coadded-image exposure map...") if(sstack) { if(!access("exp"//sstackimage//"."//oextimage)) { print("===> Stacking exposure maps...") imstack("@"//explist,"exp"//sstackimage,title="Stacked exposure maps listed in "//explist) } else { print("Stacked exposure map image already exists-- not overwritten.") } if(nnewmask) { hedit("exp"//sstackimage,"BPM",bbadmask,add+,ver-,show-,update+) } imcombine("exp"//sstackimage, eexpmap, sigma="", plfile="", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale="none", zero="none", weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask) { imgets("exp"//sstackimage,"BPMASK",>&"dev$null") hedit("exp"//sstackimage,"BPM",imgets.value,add+,ve-,sho-,upda+) } if(uunstack)imdel("exp"//sstackimage,ver-) } else { imcombine("@"//explist, eexpmap, sigma="", plfile="", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale="none", zero="none", weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } # following line had been commented out; replaced with 2nd line following # imreplace(eexpmap, -99999., lower=INDEF, upper=-10000.) imreplace(eexpmap, -99999., lower=INDEF, upper=-1.) hedit(eexpmap,"title","Weighted exposure map for "//ooutimage,add+,ve-,sho-,updat+) imgets(eexpmap,"ncombine") nncombine=int(imgets.value) if(explist!=""){ imdel("@"//explist, ver-, >& "dev$null") del(explist, ver-, >& "dev$null") } } else { print("Output exposure map already exists-- new one not created.") print("Output exposure map already exists-- new one not created.", >> llogfile) } # SUBTRACT constant background from image and DIVIDE by normalized # WEIGHTED EXPOSURE MAP to get image with globally constant exposure time if(!access(ooutimage//"mask.pl")){ # create mask image with border pixels = 0 whether originally 0 or -99999 imar(eexpmap, "+", "99999.", "j1"//eexpmap, noact-, ver-) imar(eexpmap, "*", "j1"//eexpmap, "j2"//eexpmap, noact-, ver-) imreplace("j2"//eexpmap, 1., lower=0.01, upper=INDEF) imcopy("j2"//eexpmap, ooutimage//"mask.pl", ver-) imdel("j1"//eexpmap, ver-) imdel("j2"//eexpmap, ver-) } maskstat(ooutimage, ooutimage//"mask.pl", 1, lower=INDEF, upper=INDEF, iterstat+, ver-, printit+, >> llogfile) imar(ooutimage, "-", iterstat.mean, ooutimage, ver-, noact-) # imar(eexpmap,"/",wt_avg_exptime,"j1"//eexpmap,ver-,noact-) imar("j1"//eexpmap,"/",ooutimage//"mask.pl","j2"//eexpmap,ver-,noact-,divze=-99999.) imar(ooutimage,"/","j2"//eexpmap//"."//oextimage,ooutimage,ver-,noact-,divze=-99999.) imdel("j?"//eexpmap//"."//oextimage,ver-) # print("Weighted exposure map normalized by "//wt_avg_exptime, >> llogfile) print("and divided into output coadded image.", >> llogfile) # FLIP image over to correct orientation if necessary (N is up, E is left) if(flip){ imcopy(ooutimage//"[-*,*]", ooutimage, ver-) addcomment(ooutimage,"Image has been flipped L-R from orig. orientation",ver-) print("WARNING! Image has been flipped L-R! (i.e. imcopy orig[-*,*] new)") } } else { print("Output coadded image already exists-- coadding not done.") print("Output coadded image already exists-- coadding not done.", >> llogfile) } # NORMALIZATION MAPS # Create normalization maps if the output normalization map does not exist. # Routine allows for images of different exposure times, sizes, and BPMs, while # creating as few images as possible consistent with meeting those criteria. explist="" wtlist="" if(!access(nnormmap//"."//oextimage)){ # Don't recreate normalization maps to be stacked if stacked norm. image exists if(!sstack || (sstack && !access("norm"//sstackimage//"."//oextimage))) { print("===) Creating normalization maps...") subimgold="_oops" wtimgold="_oops" waitold=0. testold=0. test1old=0 test2old=0 expmaskold="" tplimgold="" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) list=ccomblist2 explist=ccomblist2//"norm" wtlist=ccomblist2//"wt" if(access(explist))del(explist,ver-,>&"dev$null") if(access(wtlist))del(wtlist,ver-,>&"dev$null") while (fscan (list, img) !=EOF) { # get image parameters: xsize, ysize, weight, norm.factor, badpixelmask fileroot(img,validim+) imgets(img,"i_naxis1") test1=int(imgets.value) imgets(img,"i_naxis2") test2=int(imgets.value) imgets(img,wwordweight) wait=real(imgets.value) imgets(img,nnormname) exposure=real(imgets.value) imgets(img,"BPMASK") expmask=str(imgets.value) imgets(img,"TPLIMG",>&"dev$null") tplimg=str(imgets.value) # if any of those parameters differ from the previous image, need to create a # new normalization map for eventual coadding. if(test1!=test1old || test2!=test2old || wait!=waitold || exposure!=testold || expmask!=expmaskold || tplimg!=tplimgold) { tmpimg = mktemp("_tmp") tmpimg2 = mktemp("_tmp2") subimg = mktemp("_nm") wtimg = mktemp("_wt") print (subimg, >> explist) print (wtimg, >> wtlist) # want to end up with wtimg = wait or -99999.; # subimg = exposure * (tpl**2.) * wait**2. or -99999.; # make tmpimg -99999 where img < -10000, 0 elsewhere imcopy(img,tmpimg,ver-) imreplace(tmpimg,0.,lower=-10000.,upper=INDEF) imreplace(tmpimg,-99999.,lower=INDEF,upper=-9999.) # make wtimg 0 where img < -10000, "wait" elsewhere imar(tmpimg,"+",99999.,wtimg,ver-) imreplace(wtimg,wait,lower=10000.,upper=INDEF) # tpl if(ttpl && access(tplimg)) { tpltmp=mktemp("tpltmp") imgets(tplimg,"i_naxis1") tpl1=int(imgets.value) imgets(tplimg,"i_naxis2") tpl2=int(imgets.value) # if tpl image is not same size as actual image, assume the image has been # copied to subsection of bigger image starting at (1,1), and that the rest of # the image is -99999 (thus no imar(img,"-",img,subimg) needed. (ie 61"+90") if(tpl1!=test1 || tpl2!=test2) { imcopy(img,subimg,ver-) # tpltmp = tmpimg + exposure * (wtimg / tplimg)**2. #imcalc(tmpimg//","//wtimg//","//tplimg,tpltmp,"im1+"//str(exposure)//"*(im2/im3)**2.",ver-) imcalc(wtimg//","//tplimg,tmpimg2,str(exposure)//"*(im1/im2)**2.",ver-) imar(tmpimg, "+", tmpimg2, tpltmp, ver-, noact-) imcopy(tpltmp, subimg//"[1:"//str(tpl1)//",1:"//str(tpl2)//"]", ver-) imdel(tmpimg2, ver-) imdel(tpltmp, ver-) } else { # subimg = tmpimg + exposure * (wtimg / tplimg)**2. #imcalc(tmpimg//","//wtimg//","//tplimg,subimg,"im1+"//str(exposure)//"*(im2/im3)**2.",ver-) imcalc(wtimg//","//tplimg,tmpimg2,str(exposure)//"*(im1/im2)**2.",ver-) imar(tmpimg,"+",tmpimg2,subimg,ver-,noact-) imdel(tmpimg2,ver-) } # no tpl } else { # subimg = tmpimg + exposure * wtimg**2. (exposure=exptime or variance) imcalc(wtimg,tmpimg2,"(im1**2.)*"//str(exposure),ver-) imar(tmpimg,"+",tmpimg2,subimg,ver-,noact-) imdel(tmpimg2,ver-) } # now make wtimg -99999 where img < -10000, "wait" elsewhere # tmpimg2 = mktemp("_tmp2") imren(wtimg,tmpimg2,ver-) imar(tmpimg2,"+",tmpimg,wtimg,ver-) imdel(tmpimg2,ver-) imdel(tmpimg,ver-) if(nnewmask)hedit(wtimg,"BPM",bbadmask,add+,ver-,show-,update+) if(nnewmask)hedit(subimg,"BPM",bbadmask,add+,ver-,show-,update+) test1old=test1 test2old=test2 tplimgold=tplimg waitold=wait testold=exposure expmaskold=expmask subimgold=subimg wtimgold=wtimg } else { print (subimgold, >> explist) print (wtimgold, >> wtlist) } } } # Create coadded-image normalization map # First create variance map print("===> Creating coadded-image normalization map...") if(sstack) { if(!access("norm"//sstackimage//"."//oextimage)) { print("===> Stacking variance maps...") imstack("@"//explist,"norm"//sstackimage,title="Stacked normalization maps listed in "//explist) } else { print("Stacked variance map image already exists-- not overwritten.") } if(nnewmask) { hedit("norm"//sstackimage,"BPM",bbadmask,add+,ver-,show-,updat+) } if(access("junknorm."//oextimage))imdel("junknorm."//oextimage,ver-) if(access(nnormmap//"pl.pl"))imdel(nnormmap//"pl.pl",ver-) imcombine("norm"//sstackimage, "junknorm", sigma="", plfile=nnormmap//"pl", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask){ imgets("norm"//sstackimage,"BPMASK",>&"dev$null") hedit("norm"//sstackimage,"BPM",imgets.value,ad+,ve-,sho-,upda+) } if(uunstack)imdel("norm"//sstackimage,ver-) } else { if(access("junknorm."//oextimage))imdel("junknorm."//oextimage,ver-) if(access(nnormmap//"pl.pl"))imdel(nnormmap//"pl.pl",ver-) imcombine("@"//explist, "junknorm", sigma="", plfile=nnormmap//"pl", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } if(explist!=""){ imdel("@"//explist, ver-, >& "dev$null") del(explist, ver-, >& "dev$null") } # Now create weight map if(sstack) { if(!access("wt"//sstackimage//"."//oextimage)) { print("===> Stacking weight maps...") imstack("@"//wtlist,"wt"//sstackimage,title="Stacked weight maps listed in "//wtlist) } else { print("Stacked weight map image already exists-- not overwritten.") } if(nnewmask) { hedit("wt"//sstackimage,"BPM",bbadmask,add+,ver-,show-,updat+) } if(access("junkweight."//oextimage))imdel("junkweight."//oextimage,ver-) imcombine("wt"//sstackimage, "junkweight", sigma="", plfile="", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask){ imgets("wt"//sstackimage,"BPMASK",>&"dev$null") hedit("wt"//sstackimage,"BPM",imgets.value,add+,ve-,sho-,upda+) } if(uunstack)imdel("wt"//sstackimage,ver-) } else { if(access("junkweight."//oextimage))imdel("junkweight."//oextimage,ver-) imcombine("@"//wtlist, "junkweight", sigma="", plfile="", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } if(wtlist!=""){ imdel("@"//wtlist, ver-, >& "dev$null") del(wtlist, ver-, >& "dev$null") } # Final steps to create normalization image imgets("junknorm","ncombine") nncombine=int(imgets.value) if(access(nnormmap//"num."//oextimage))imdel(nnormmap//"num."//oextimage,ver-) imar(nnormmap//"pl","-",nncombine,nnormmap//"num.fits") imar(nnormmap//"num.fits","*",-1.,nnormmap//"num.fits") imar("junknorm","*",nnormmap//"num.fits","junknorm",ver-,noact-) imar("junkweight","*",nnormmap//"num.fits","junkweight",ver-,noact-) #imar("junkweight","*",eexpmap,"junkweight",ver-,noact-) #imar("junkweight","*","junkweight","junkweight",ver-,noact-) #imar("junkweight","/","junknorm",nnormmap,ver-,noact-) imcalc("junkweight,"//eexpmap//",junknorm",nnormmap,"((im1*im2)**2.)/im3",nullval=0.,ver-) minmax(nnormmap,force+,update+,ver-) imar(nnormmap,"/",minmax.maxval,nnormmap,ver-,noact-) hedit(nnormmap,"title","Normalization map for "//ooutimage,add+,ve-,sho-,updat+) imdel("junkweight."//oextimage,ver-) imdel("junknorm."//oextimage,ver-) imdel(nnormmap//"num.fits",ver-) imdel(nnormmap//"pl.pl",ver-) if(flip){ imcopy(nnormmap//"[-*,*]", nnormmap, ver-) addcomment(nnormmap,"Image has been flipped L-R from orig. orientation",ver-) } } else { print("Output normalization map already exists-- new one not created.") print("Output normalization map already exists-- new one not created.", >> llogfile) } # UNDO PRE-ZEROING: if zeroing was done before imcombine, undo it if desired if(pprezero && uunzero){ # If block-replication was done, skip step if those images are to be deleted if(mag!=1 && ccleanup && !noappend){ print("", >> llogfile) } else { print("===> Undoing zero offsetting...") list=list_of_zeros while (fscan (list,img,levelzero) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value!="0"){ tmpzero=abs((real(imgets.value)-levelzero)/levelzero) if(tmpzero>=0.01){ print("WARNING! "//img//" pre-zeroing doesn't match list to 1%; unzeroing not done") } else { levelzero=real(imgets.value) imar(img,"-",levelzero,img,pixt="real",calc="real",ver-) hedit(img,"PREZERO","",del+,ver-,show-,updat+,>&"dev$null") } } else { print("No action -- "//img//" not pre-zeroed in the first place!") } } } } if(pprezero){ if(sstack && access(sstackimage//"."//oextimage)){print("", >> llogfile)} else{del(list_of_zeros,ver-,>&"dev$null")} } list="" # UNDO PRE-SCALING: if scaling was done before imcombine, undo it if desired if(pprescale && uunscale){ # If block-replication was done, skip step if those images are to be deleted if(mag!=1 && ccleanup && !noappend){ print("", >> llogfile) } else { print("===> Undoing scaling factors...") list=list_of_scales while (fscan (list,img,sf) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value!="0"){ print("WARNING! "//img//" still pre-scaled: pre-zeroing not undone first") } else { imgets(img,"PRESCALE",>&"dev$null") if(imgets.value!="0"){ tmpscale=abs((real(imgets.value)-sf)/sf) if(tmpscale>=0.01){ print("WARNING! "//img//" pre-scaling doesn't match list to 1%; unscaling not done") } else { imar(img,"/",sf,img,pixt="real",calct="real",ver-) hedit(img,"PRESCALE","",del+,ver-,sho-,updat+,>&"dev$null") if(ddefscale){ imgets(img,"AIRMOLD",>&"dev$null") hedit(img,"AIRMASS",imgets.value,add+,del-,ver-,sho-,updat+,>&"dev$null") hedit(img,"AIRMOLD","",del+,ver-,sho-,updat+,>&"dev$null") } } } else { print("No action -- "//img//" not pre-scaled in the first place!") } } } } } if(pprescale)del(list_of_scales,ver-,>&"dev$null") list="" # IMSHIFTS FILE # Create *.imshifts file, listing images & offsets used by masklet & photcheck if (!access(ooutimage//".imshifts")) { print("===> Creating output imshifts file...") if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) join(ccomblist2,sshiftintlist,output=ooutimage//".imshifts_tmp") # Find minimum x and y shift values and subtract them from output offsets listimshift=ooutimage//".imshifts_tmp" list="" list=listimshift xmin=100000 ymin=100000 while (fscan (list,img,newx,newy) != EOF) { if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } } newx=0 newy=0 list="" list=listimshift while (fscan (list,img,oldx,oldy) != EOF) { newx = oldx - xmin newy = oldy - ymin print(img, " ", newx, newy, >> ooutimage//".imshifts") } del(ooutimage//".imshifts_tmp",ver-) } else { print("Output imshifts file already exists-- not overwritten.") } # Clean up. if(mag!=1){ if(ccleanup && !noappend){ if(access(bprotlist)){ imdel("@"//bprotlist,ver-,>&"dev$null") del(bprotlist,ver-,>&"dev$null") } if(access(ccomblist2))imdel("@"//ccomblist2,ver-,>&"dev$null") del(ccomblist2,ver-,>&"dev$null") del(sshiftexactlist//blk,ver-,>&"dev$null") del(zzeroname//blk,ver-,>&"dev$null") } } else { del(ccomblist2,ver-,>&"dev$null") } print(" ") print(ooutimage//", "//eexpmap//" (exposure map), imshifts file,") print("and "//nnormmap//" (normalization map) have been created.") #print("Next task is `mkobjmask' or `photcheck'.") } else { print("WARNING: tasks stsdas.toolbox.imgtools.imcalc, addcomment,") print("filecalc, fileroot, and/or iterstat are not loaded!") print("Please load the appropriate package(s) and restart this task.") } list="" print(" ") if(echog)beep end ./src/irtfcoadd_4.p0100644000151400000240000000056606503626447013336 0ustar phallgames#!/usr/local/bin/perl # cycle thru contents of file(s) given on command line using <> $iter=0; while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); if($iter==0) { ($mag2) = split " "; } else { ($one) = split " "; $out=$one/$mag2; printf "%9.7f\n", $out; } $iter=1; } ./src/patpostproc.cl0100644000151400000240000000100406171341052013640 0ustar phallgames#patpostproc.cl -- get stats for and display a new CCD image procedure patpostproc(image) string image {prompt="Image to get stats for and display"} int frame {1,min=1,max=4,prompt="Frame in which to display image"} begin string iimage int fframe, ival iimage=image fframe=frame imget(iimage,"insfilte", >& "dev$null") ival=int(imgets.value) if (ival==0) { display(iimage, fframe) } else { display(iimage, fframe) hedit(iimage,"filters","(insfilte)",add+,ver-,show+,update+) } imstat(iimage) end ./src/irtfcoadd_5.p0100644000151400000240000000044106503626447013327 0ustar phallgames#!/usr/local/bin/perl -w # cycle thru contents of file(s) given on command line using <> while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); ($one, $two) = split " "; $out=$two*$one; print "$out\n"; } ./src/shiftnadd.cl0100644000151400000240000004306206561404076013251 0ustar phallgames#shiftnadd.cl--script to find offsets for a set of CCD images and coadd them. # # Procedure: # 1. Choose one image (which all images overlap) to be the reference image. # 2. imexam the reference image & get the coordinates (using 'r' or 'a') of # ALL REFERENCE OBJECTS that are to be used. # 3. imexam all the images and get the coordinates (using 'r' or 'a' and 'n' # to go to the next image) of ONLY THE BRIGHTEST or "BEST" reference object # in each. # 4. You are asked for the X and Y coordinates of this "BEST" reference object. # the coords file is printed to jog your memory. # 5. lintran is used to calculate the coarse shifts from just the "BEST" object # 6. The coarse shifts are used as input to imcentroid, which finds the final # offsets using ALL reference objects available. The imcentroid parameters # (e.g. boxsize) can be adjusted if deemed necessary. # # Output: # prefix.refcoords.outstring registration objects' reference image coords # prefix.allcoords.outstring registration objects' coordinates in all images # prefix.coarse.outstring coarse shifts # prefix.shiftnadd.outstring final shifts, imcombine log, & misc. other info # prefix.shiftfrac.outstring fractional part of final shifts # prefix.shiftint.outstring integer part of final shifts # prefix.roundoff.outstring final shifts rounded off to integer shifts # coaddname.imh coadded image # # CHANGES: # 94/12/28: created from irshift.cl # 95/01/27: added check for ctio package # 95/03/21: started to add in exposure map stuff, many other changes # 96/07/12: added output "shiftexact" file # 96/07/22: added default airmass scaling option # 96/07/23: fixed edge problem in sky-subracted image procedure shiftnadd(flatlist,refimage,prefix,outstring,fracshift,coaddname,expmap) string flatlist {prompt="List of images for which to find offsets"} string refimage {prompt="Name of (flattened) reference image"} string prefix {prompt="Prefix string for output files"} string outstring {prompt="Suffix string for output files"} bool fracshift {prompt="Create fractional-pixel-offset images? (yes|no)"} string coaddname {prompt="Name for output coadded image"} string expmap {prompt="Name of output exposure map image"} bool airscale {prompt="Use default airmass scaling?"} string shiftlist {prompt="List of output, offset images",mode="q"} real extcoeff {prompt="Extinction coefficient for default scalings",mode="q"} real airzero {INDEF,min=0.,max=99.,prompt="Airmass to scale to? (INDEF=min. observed)",mode="q"} bool combdata=no {prompt="Combine shifts with earlier dataset? (yes|no)"} string expname="exptime" {prompt="Header keyword for exposure time"} int xref {prompt="Reference object x coordinate (nearest integer)"} int yref {prompt="Reference object y coordinate (nearest integer)"} real xshiftold {prompt="Reference image x shift in earlier dataset"} real yshiftold {prompt="Reference image y shift in earlier dataset"} real radius=5. {prompt="Aperture photometry radius for imexamine"} real buffer=10. {prompt="Aperture photometry sky buffer for imexamine"} real width=10. {prompt="Aperture photometry sky annulus width for imexamine"} real bs=9. {prompt="Centering box size for final shift calculation"} bool doshift=yes {prompt="Do offset measuring step?"} bool stdpars=yes {prompt="Use std imcombine parameters for coadd?"} bool makeavg=no {prompt="Make pure coadd (comb=average,rej=none)?"} bool echog {yes,prompt="Beep when task is done?"} pset addpars {prompt="Imcombine parameters"} struct *list begin string subimg, explist, sect, check, img, eexpname, eexpmap, listimshift string subimgold, rrefimage, fflatlist, rrefcoords, aallcoords, rroundname string sshiftlist, coarsefile, ooffname, ooutstring, iintname, ffracname string pprefix, logoffname, ccoaddname, sl, sx, coaddlist, offsetlist string t_sigma, t_plfile, t_combine, t_reject, t_offsets, t_masktyp string t_scale, t_weight, t_zero, t_statsec, t_expname, file_of_air real t_maskval, t_blank, t_lthresh, t_hthresh, t_nlow, t_nhigh, t_nkeep real t_lsigma, t_hsigma, t_rdnoise, t_gain, t_pclip, t_grow, t_sigscale real weight, scalemed, stcoordx, stcoordy, nrows, ncols real xold, yold, bbs, xxshiftold, yyshiftold, xshiftnew, yshiftnew, astcoordx real astcoordy, avg, x, sig, nl, nx, y, eextcoeff, aairzero, air, texp real effairmass, wtavg, nncombine, exp, exposure, sf, zf, testold, eexptime int xmin, ymin, newx, newy, oldx, oldy, test1, test1old, test2, test2old, p int sstartno, eendno, i, numpix, num, xdim, ydim, newxsize, newysize, ncoadds bool ffracshift, ccombdata, go, dosh, aairscale fflatlist = flatlist rrefimage = refimage pprefix = prefix ooutstring = outstring ffracshift = fracshift if(ffracshift){ sshiftlist = shiftlist } ccoaddname = coaddname eexpmap = expmap if(eexpmap==""){ fileroot(ccoaddname,validim+) eexpmap=fileroot.root//"em" } aairscale=airscale eextcoeff=0. aairzero=100. if(aairscale){ eextcoeff=extcoeff aairzero=airzero if(aairzero==INDEF){ print("...one moment please...") file_of_air=mktemp("foa") hsel("@"//fflatlist,"AIRMASS",yes, >> file_of_air) list=file_of_air aairzero=100. while (fscan (list,air) != EOF) { aairzero=min(air,aairzero) } del(file_of_air,ver-,>&"dev$null") list="" } } ccombdata = combdata eexpname = expname bbs = bs #print("test1") #Do not let task run if needed tasks are not loaded go=yes if(!deftask("filecalc")){go=no} if(!deftask("fileroot")){go=no} if(!deftask("imcalc")){go=no} if(!deftask("iterstat")){go=no} if(go){ ooffname = pprefix//".shiftexact."//ooutstring logoffname = pprefix//".shiftnadd."//ooutstring rrefcoords = pprefix//".refcoords."//ooutstring aallcoords = pprefix//".allcoords."//ooutstring coarsefile = pprefix//".coarse."//ooutstring iintname = pprefix//".shiftint."//ooutstring ffracname = pprefix//".shiftfrac."//ooutstring rroundname = pprefix//".roundoff."//ooutstring t_sigma = j_sigma # imcombine parameters t_plfile = j_plfile t_combine = j_combine t_reject = j_reject t_masktyp = j_masktyp t_maskval = j_maskval t_blank = j_blank t_scale = j_scale t_weight = j_weight t_zero = j_zero t_statsec = j_statsec t_expname = j_expname t_lthresh = j_lthresh t_hthresh = j_hthresh t_nlow = j_nlow t_nhigh = j_nhigh t_nkeep = j_nkeep t_lsigma = j_lsigma t_hsigma = j_hsigma t_rdnoise = j_rdnoise t_gain = j_gain t_sigscale = j_sigscale t_pclip = j_pclip t_grow = j_grow if(doshift){ if(ccombdata){ print(" ") print("===) So you wanna add some new images to an old coadd, eh? Well, first make") print("===) sure you're using the same reference image as that old set. Then, take") print("===) a look at the *.shiftnadd.* file from that set, find the fractional") print("===) offsets made on the reference image, and enter them here:") xxshiftold=xshiftold yyshiftold=yshiftold } print(" ") print("===) Get the coordinates, in the reference image, of all objects you wish to") print(" use for registration, starting with the `best' reference object-- one") print(" which appears in all images.") print(" ") rimexam.radius=radius rimexam.buffer=buffer rimexam.width=width imexam(rrefimage, frame=1, logfile=rrefcoords, keep+) #Interactively ID objects print(" ") print("===) Choose one object that appears in all images, and find the position") print("===) (type 'a') of this best registration object in each frame (hit 'n' to go on") print("===> to the next frame, and 'q' when done). The file containing these positions") print("===> will be displayed for editing when done, in case mistakes were made.") print(" ") imexam("@"//fflatlist, frame=1, logfile=aallcoords, keep+) print(" ") print("===> In case mistakes were made, the coordinate file can now be edited.") vi(aallcoords) # Find offsets fields (rrefcoords, "1-2") | scan (xref, yref) lintran(aallcoords, x1=0.001, y1=0.001, x2=xref, y2=yref, angle=180, > coarsefile) print("===) Finding the final offsets, and saving to `shiftnadd' file.") del(logoffname, ver-, >& "dev$null") imcentroid("@"//fflatlist, rrefcoords, reference=rrefimage, shift=coarsefile, boxsize=bbs, > logoffname) del("temp.joinfile", ver-, >& "dev$null") del("temp.joinfile?", ver-, >& "dev$null") # read in length of temp.joinfile0 and cut out last two lines copy(logoffname,"temp.joinfile0") count("temp.joinfile0") | scan (nl) nx=nl-2 head("temp.joinfile0", nlines=nx, >> "temp.joinfile1") # find line on which the string "X-s" appears and cut out that line & all before !grep -n X-s temp.joinfile1 > temp.joinfile2 type("temp.joinfile2") | scan (sl) x=stridx(":",sl) sx=substr(sl,1,x) x=nx-real(sx) tail("temp.joinfile1", nlines=x, >> "temp.joinfile") # Cut down on number of output files print(" ", >> logoffname) print("#Coarse offsets:", >> logoffname) print(" ", >> logoffname) type(coarsefile, >> logoffname) del(coarsefile, ver-) if(ccombdata){ # Extract the new reference image shifts from the offsets file del("temp.joinfile?",ver-, >& "dev$null") grep(rrefimage,"temp.joinfile") | fields ("junk", "2", >> "temp.joinfile2") type("temp.joinfile2") | average >> "temp.joinfile3" xshiftnew=real(average.sum) del("temp.joinfile?",ver-) grep(rrefimage,"temp.joinfile") | fields ("junk", "4", >> "temp.joinfile2") type("temp.joinfile2") | average >> "temp.joinfile3" yshiftnew=real(average.sum) del("temp.joinfile?",ver-) # Want to take the calculated shift ($2 for x), cancel out the newly calculated # reference image shift ($2 - xshiftnew = -xnew+$2 = -1*xnew+$2) and add in # the old reference image shift (xold+(-1*xnew+$2) filecalc("temp.joinfile",xxshiftold//"+(-1*"//xshiftnew//"+$2);"//yyshiftold//"+(-1*"//yshiftnew//"+$4)",format="%8.2f%8.2f ", >> ooffname) # filecalc("temp.joinfile",xxshiftold//"+$2;"//yyshiftold//"+$4",format="%8.2f%8.2f ", >> ooffname) } else{ fields("temp.joinfile", "2,4", >> ooffname) } del("temp.joinfile*", ver-) list=ooffname while(fscan(list,x,y) !=EOF) { print(int(x),int(y), >> iintname) } join(iintname,ooffname,out="temp.joinfile") filecalc("temp.joinfile","$3-$1;$4-$2",forma="%6.2f%6.2f", >> ffracname) filecalc(ooffname,"$1;$2",format="%4.0f %4.0f", >> rroundname) print(" ", >> logoffname) print("#Final offsets:", >> logoffname) print(" ", >> logoffname) type(ooffname, >> logoffname) # del(ooffname, ver-) del("temp.joinfile", ver-) # End of "if doshift" } # Find & insert header parameter "SCALEFAC" used by imcombine print("===) Finding scales for coadding images...") file_of_air=mktemp("foa") hsel("@"//fflatlist,"$I,AIRMASS,"//eexpname,yes, >> file_of_air) list=file_of_air while (fscan (list,img,air,texp) != EOF) { imgets(img,"SCALEFAC",>&"dev$null") if(imgets.value=="0"){ sf=10**(0.4*eextcoeff*(air-aairzero)) hedit(img,"AIRSCALE",sf,add+,ver-,show-,update+) sf=texp*sf imgets(img,"scalefac") hedit(img,"SCALEFAC",sf,add+,ver-,show-,update+) } else { print("Image "//img//" already has SCALEFAC header keyword.") } } del(file_of_air,ver-) list="" # Find & insert header parameter "WEIGHT" used by imcombine print("===) Finding weights for coadding images...") list=fflatlist while(fscan(list,img) !=EOF) { imgets(img,"weight",>&"dev$null") if(imgets.value=="0"){ iterstat(img,nsigrej=5.,maxiter=10,print-,ver-) imgets(img,t_expname) weight=iterstat.median*real(imgets.value) hedit(img,"weight",weight,add+,ver-,show-,update+) } } list="" if(ffracshift){ print("===) Creating fractional-pixel-shifted images.") sshiftlist=fflatlist//ooutstring list=fflatlist while(fscan(list,img) !=EOF) { fileroot(img,validim+) print(fileroot.root//ooutstring//".imh",>>sshiftlist) } imshift("@"//fflatlist, "@"//sshiftlist, shifts=ffracname, interp="poly5", bound="nearest") } if(!access(eexpmap//".imh")){ print("===) Shifting and coadding the images.") if(ffracshift){ coaddlist=sshiftlist offsetlist=iintname } else { coaddlist=fflatlist offsetlist=rroundname } if (makeavg) { imcombine("@"//coaddlist, ccoaddname, sigma="", plfile="", combine="average", rej="none", project-, offsets=offsetlist, masktype="none", blank=0., scale="!SCALEFAC", zero="mode", weight="!WEIGHT", statsec="", expname=t_expname, lthresh=-100000, hthresh=100000, lsig=5., hsig=5., nkeep=1, mclip+, rdnoise=t_rdnoise, gain=t_gain, sigscale=0.1, grow=0., logfile='STDOUT', >> logoffname) } else { if(stdpars){ imcombine("@"//coaddlist, ccoaddname, sigma="", plfile="", combine="average", rej="ccdclip", project-, offsets=offsetlist, masktype="none", blank=0., scale="!SCALEFAC", zero="mode", weight="!WEIGHT", statsec="", expname=t_expname, lthresh=-100000, hthresh=100000, lsig=5., hsig=5., nkeep=1, mclip+, rdnoise=t_rdnoise, gain=t_gain, sigscale=0.1, grow=0., logfile='STDOUT', >> logoffname) } else{ imcombine("@"//coaddlist, ccoaddname, sigma=t_sigma, plfile=t_plfile, combine=t_combine, reject=t_reject, project-, offsets=offsetlist, masktype=t_masktyp, maskvalue=t_maskval, blank=t_blank, scale=t_scale, zero=t_zero, weight=t_weight, statsec=t_statsec, expname=t_expname, lthresh=t_lthresh, hthresh=t_hthresh, nlow=t_nlow, nhigh=t_nhigh, nkeep=t_nkeep, mclip+, lsigma=t_lsigma, hsigma=t_hsigma, rdnoise=t_rdnoise, gain=t_gain, sigscale=t_sigscale, pclip=t_pclip, grow=t_grow, logfile='STDOUT', >> logoffname) } } hedit(ccoaddname,"title","Coadded image from "//coaddlist//" using "//offsetlist,add+,ver-,show-,update+) iterstat(ccoaddname,nsigrej=5.,maxiter=10.,print-,ver-) fileroot(ccoaddname,validim+) imar(ccoaddname,"-",iterstat.median,fileroot.root//"sub",title="Sky-subtracted version of "//ccoaddname,ver-) # Set airmass of coadded image to "effective airmass" if(access(coaddlist//".airmass.tmp"))del(coaddlist//".airmass.tmp",ver-) if(access(coaddlist//".airmass.tmp2"))del(coaddlist//".airmass.tmp2",ver-) hsel("@"//coaddlist, "airmass", "yes", >> coaddlist//".airmass.tmp") type(coaddlist//".airmass.tmp" | average opt="new_sample", >> coaddlist//".airmass.tmp2") effairmass=real(average.mean) hedit(ccoaddname,"airmass",(effairmass),add+,ver-,show-,update+) del (coaddlist//".airmass.tmp*", ver-) } else{ print("Output coadded image already exists-- new one not created.") } # Create exposure maps if the output coadded-image exposure map does not exist. # The routine should allow for images of different exposure times and sizes, # while at the same time cutting down on the number of images that need to be # created if many input images have the same size and exposure time. if(!access(eexpmap//".imh")){ print("===) Creating exposure maps...") subimgold="_oops" testold=0. test1old=0 test2old=0 list=coaddlist explist=coaddlist//"exp" while (fscan (list, img) !=EOF) { fileroot(img,validim+) imgets(img,"i_naxis1") test1=int(imgets.value) imgets(img,"i_naxis2") test2=int(imgets.value) imgets(img,eexpname) exposure=real(imgets.value) if(test1!=test1old || test2!=test2old || exposure!=testold) { subimg = mktemp(fileroot.root) print (subimg, >> explist) imcalc(img,subimg,"im1*0+"//exposure,ver-) test1old=test1 test2old=test2 testold=exposure subimgold=subimg } else { print (subimgold, >> explist) } } # Create coadded-image exposure map print("===> Creating coadded-image exposure map...") imcombine("@"//explist, "junk"//eexpmap, sigma="", plfile=eexpmap//"pl", combine="average", reject="none", project-, offsets=rroundname, masktype="none", scale="none", zero="none", weight="none", expname=eexpname, mclip+, logfile='STDOUT', >> logoffname) imgets("junk"//eexpmap,"ncombine") nncombine=int(imgets.value) imdel("junk"//eexpmap, ver-, >& "dev$null") imdel("@"//explist, ver-, >& "dev$null") del(explist, ver-) # Following should yield accurate exposure map. We use the plfile from the # above imcombining, not the actual imcombined image. # Step 1: just to be safe, get rid of any possible negative values imreplace(eexpmap//"pl",0.,lower=INDEF,upper=0.) # Step 2: Since the plfile lists # images *not* used, we subtract total # images imar(eexpmap//"pl","-",nncombine,eexpmap//".imh") # Step 3: Then multiplying by -1 gives # of images used (positive quantity) imar(eexpmap,"*",-1.,eexpmap) imdel(eexpmap//"pl.pl",ver-) hedit(eexpmap,"title","Exposure map image for coadded image "//ccoaddname,ver-,show-,update+) } else{ print("Output exposure map already exists-- new one not created.") } # Create *.imshifts file, listing images & offsets used by masklet task print("===> Creating output imshifts file...") join(coaddlist,rroundname,output=ccoaddname//".imshiftt_tmp") # Find minimum x and y shift values and subtract them from output offsets listimshift=ccoaddname//".imshiftt_tmp" list=listimshift xmin=100000 ymin=100000 while (fscan (list,img,newx,newy) != EOF) { if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } } newx=0 newy=0 list=listimshift while (fscan (list,img,oldx,oldy) != EOF) { newx = oldx - xmin newy = oldy - ymin print(img, " ", newx, newy, >> ccoaddname//".imshifts") } del(ccoaddname//".imshiftt_tmp",ver-) # Set edges of sky-subtracted image to zero. fileroot(ccoaddname,validim+) imar(fileroot.root//"sub","*",eexpmap,fileroot.root//"sub") imar(fileroot.root//"sub","/",eexpmap,fileroot.root//"sub",divzero=0.) print("===> All done. *sub.imh can be used with mkobjmask.") } else{ print("WARNING: task(s) filecalc, fileroot, imcalc and/or iterstat are not") print("loaded! Please load the unloaded task(s) and restart this task.") } if(echog)beep end ./src/strrev.cl0100644000151400000240000000103606171341054012616 0ustar phallgamesprocedure strrev(forward) # Routine to parse a string into its reverse. string forward {prompt="Input string") string reverse {"",prompt="Reversed string") begin string fname # Equals filename string revname # Reversed version of input string int ilen,ipos,ic # String position markers # Get query parameter. fname = forward # Reverse filename string character by character --> revname. ilen = strlen(fname) revname = "" for (ic=ilen; ic>=1; ic-=1) { revname = revname // substr(fname,ic,ic) } reverse = revname end ./src/swap.cl0100644000151400000240000000045406207451246012253 0ustar phallgames#Swap the contents of two files procedure swap(file1,file2) string file1 {prompt = "Name of first file"} string file2 {prompt = "Name of second file"} begin rename(file2,"tmpswapdude") rename(file1,file2) rename("tmpswapdude",file1) print("Contents of "//file1//" and "//file2//" swapped.") end ./src/undel.cl0100644000151400000240000000045406561404143012405 0ustar phallgames#Unprotect and delete a file(s) in one fell swoop procedure undel(file1) string file1 {prompt = "File(s) to unprotect and delete"} bool verify=yes {prompt = "Verify deletion?"} begin bool yesno yesno=verify unprotect(file1) print(file1//" is now unprotected.") delete(file1, verify=yesno) end ./src/irtfshift_0.p0100644000151400000240000000101606503626447013364 0ustar phallgames#!/usr/local/bin/perl # cycle thru contents of file(s) given on command line using <> $iter=0; while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); if($iter==0) { ($xxshiftold, $xshiftnew, $yyshiftold, $yshiftnew) = split " "; } else { ($one, $two, $three, $four) = split " "; $outone=$xxshiftold+(-1*$xshiftnew+$two); $outtwo=$yyshiftold+(-1*$yshiftnew+$four); printf "%8.2f%8.2f\n", $outone, $outtwo; } $iter=1; } ./src/.exrc0100600000151400000240000000026406621416606011713 0ustar phallgamesset directory=/d/palung/hall/ set noautoindent set showmatch set wrapmargin=1 #a blank line will prevent the rest of the commands from being read. set optimize set redraw map  1G ./src/irtfshift_1.p0100644000151400000240000000054306503626447013371 0ustar phallgames#!/usr/local/bin/perl -w # cycle thru contents of file(s) given on command line using <> while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); ($one, $two, $three, $four) = split " "; $outone=$three-$one; $outtwo=$four-$two; printf "%6.2f%6.2f\n", $outone, $outtwo; } ./src/addpars.par0100644000151400000240000000320506173013567013102 0ustar phallgames#pset imcomcoaddpars {prompt="Imcombine parameters"} j_sigma,s,h,"",,,"IMCOMBINE: Sigma image (optional)" j_plfile,s,h,"",,,"IMCOMBINE: Rejected pixel list image (optional)" j_combine,s,h,"average",average|median,,"IMCOMBINE: Type of combine operation (median|average)" j_reject,s,h,"ccdclip",none|minmax|ccdclip|crreject|sigclip|avsigclip|pclip,,"IMCOMBINE: Type of rejection" j_masktyp,s,h,"none",none|goodvalue|badvalue|goodbits|badbits,,"IMCOMBINE: Mask type" j_maskval,r,h,0.,,,"IMCOMBINE: Mask value" j_blank,r,h,0.,,,"IMCOMBINE: Value if there are no pixels" j_scale,s,h,"exposure",,,"IMCOMBINE: Image scaling" j_weight,s,h,"exposure",,,"IMCOMBINE: Image weights" j_zero,s,h,"none",,,"IMCOMBINE: Image zero point offsets" j_statsec,s,h,"",,,"IMCOMBINE: Image section for computing statistics" j_expname,s,h,"exptime",,,"IMCOMBINE: Image header exposure time keyword" j_lthresh,r,h,INDEF,,,"IMCOMBINE: Lower threshold" j_hthresh,r,h,INDEF,,,"IMCOMBINE: Upper threshold" j_nlow,r,h,1.,0,,"IMCOMBINE: minmax: Number of low pixels to reject" j_nhigh,r,h,1.,0,,"IMCOMBINE: minmax: Number of high pixels to reject" j_nkeep,r,h,-1.,,,"IMCOMBINE: Minimum to keep (+) or maximum to reject(-)" j_lsigma,r,h,5.,0.,,"IMCOMBINE: Lower sigma clipping factor" j_hsigma,r,h,10.,0.,,"IMCOMBINE: Upper sigma clipping factor" j_rdnoise,r,h,7.7,,,"IMCOMBINE: ccdclip: CCD readout noise (electrons)" j_gain,r,h,2.2,,,"IMCOMBINE: ccdclip: CCD gain (electrons/ADU)" j_sigscale,r,h,0.1,0.,,"IMCOMBINE: Tolerance for sig-clip scaling corrections" j_pclip,r,h,-0.5,,,"IMCOMBINE: pclip: Percentile clipping parameter" j_grow,r,h,0.,,,"IMCOMBINE: Radius (pixels) for 1D neighbor rejection" ./src/optcoaddpars.par0100644000151400000240000000301406353543521014143 0ustar phallgamesi_sigma,s,h,"",,,"IMCOMBINE: Sigma image (optional)" i_plfile,s,h,"",,,"IMCOMBINE: Rejected pixel list image (optional)" i_combine,s,h,"average",average|median,,"IMCOMBINE: Type of combine operation (median|average)" i_reject,s,h,"ccdclip",none|minmax|ccdclip|crreject|sigclip|avsigclip|pclip,,"IMCOMBINE: Type of rejection" i_masktyp,s,h,"badvalue",none|goodvalue|badvalue|goodbits|badbits,,"IMCOMBINE: Mask type" i_maskval,r,h,0.,,,"IMCOMBINE: Mask value" i_blank,r,h,0.,,,"IMCOMBINE: Value if there are no pixels" i_statsec,s,h,"",,,"IMCOMBINE: Image section for computing statistics" i_expname,s,h,"exptime",,,"IMCOMBINE: Image header exposure time keyword" i_lthresh,r,h,INDEF,,,"IMCOMBINE: Lower threshold" i_hthresh,r,h,INDEF,,,"IMCOMBINE: Upper threshold" i_nlow,r,h,1.,0.,,"IMCOMBINE: minmax: Number of low pixels to reject" i_nhigh,r,h,1.,0.,,"IMCOMBINE: minmax: Number of high pixels to reject" i_nkeep,r,h,1.,,,"IMCOMBINE: Minimum to keep (+) or maximum to reject(-)" i_lsigma,r,h,5.,0.,,"IMCOMBINE: Lower sigma clipping factor" i_hsigma,r,h,5.,0.,,"IMCOMBINE: Upper sigma clipping factor" i_rdnoise,s,h,"7.7",,,"IMCOMBINE: ccdclip: CCD readout noise (electrons)" i_gain,s,h,"2.2",,,"IMCOMBINE: ccdclip: CCD gain (electrons/ADU)" i_snoise,s,h,"0.",,,"IMCOMBINE: ccdclip: Sensitivity noise (fraction)" i_sigscale,r,h,0.1,0.,,"IMCOMBINE: Tolerance for sig-clip scaling corrections" i_pclip,r,h,-0.5,,,"IMCOMBINE: pclip: Percentile clipping parameter" i_grow,r,h,0.,,,"IMCOMBINE: Radius (pixels) for 1D neighbor rejection" mode,s,h,"q",,, ./src/patcopy.cl0100644000151400000240000000240506316401211012742 0ustar phallgamesprocedure patcopy(oldlist,newlist) string oldlist {prompt="List of original file names"} string newlist {prompt="List of copied file names"} bool verb {yes,prompt="Print names of files as they are copied?"} struct *list begin string ooldlist, nnewlist, errstring, oldname, newname, ooldtemp, nnewtemp, y real x int errflag bool vverb ooldtemp=oldlist nnewtemp=newlist ooldlist=oldlist nnewlist=newlist vverb=verb x=strlen(ooldlist) y=substr(ooldlist,1,1) if(y=="@")ooldlist=substr(ooldlist,2,x) x=strlen(nnewlist) y=substr(nnewlist,1,1) if(y=="@")nnewlist=substr(nnewlist,2,x) del ("tmp.err", ver-, >& "dev$null") del ("tmp.copylist", ver-, >& "dev$null") join (ooldlist, nnewlist, output="tmp.copylist", >& "tmp.err") errflag=0 list="tmp.err" while (fscan (list, errstring) !=EOF) { if (errstring=="WARNING:") errflag=1 } if (errflag==0) { list="tmp.copylist" if(vverb){ while (fscan (list, oldname, newname) !=EOF) { copy (oldname, newname) print (oldname//" --> "//newname) } } else{ while (fscan (list, oldname, newname) !=EOF) { copy (oldname, newname) } } } else { print("WARNING! Number of input files does not match number of output files.") print("No copying done.") } del ("tmp.err", ver-) del ("tmp.copylist", ver-) end ./src/irtfshift_2.p0100644000151400000240000000044306503626447013371 0ustar phallgames#!/usr/local/bin/perl -w # cycle thru contents of file(s) given on command line using <> while (<>) { # skip blank lines or lines with # as first non-whitespace character next if (/^\s+$/ or /^#/ or /^\s+#/); ($one, $two) = split " "; printf "%4.0f%4.0f\n", $one, $two; } ./src/iteravg.cl0100644000151400000240000000542006720573001012732 0ustar phallgames#{ ITERAVG -- Compute the iterative average & RMS of a list of numbers. # Numeric input is via the standard input (one number per line). The mean, # sigma, and number of samples are written to the standard output. # # By default (iteravg called with no arguments), the sample is taken # to be the set of numbers in the standard input when iteravg is run, # modulo the limits imposed by the "lower" and "upper" parameters. # Additional points can be added to or deleted from the sample by # rerunning iteravg with one of the following arguments: # # add - add points to the sample, recalculate mean and sigma # sub - subtract points from the sample # # 990513: added lower and upper parameters { if ($nargs == 0) # if no arguments, don't query opstring = "new_sample" else opstring = option # get parameter "option" if (opstring == "add") # add, subtract, or start over? addsub_flag = 1 else if (opstring == "sub" || opstring == "subtract") addsub_flag = -1 else { # new sample (default) addsub_flag = 1 n = 0 # number of points in sample sum = 0 sumsqrs = 0 variance = 0 sigma = 0 mean = 0 } # Process data and save to temporary file del ("__iteravgtmp", ver-, >& "dev$null") while (scan (data_value) != EOF) if (nscan() == 1 && data_value != INDEF) { n += addsub_flag sum += addsub_flag * data_value sumsqrs += addsub_flag * data_value * data_value print (data_value, >> "__iteravgtmp") } # Iterate iter=0 nold=0 # minval=-100000000000000000000 # maxval=100000000000000000000 minval=lower maxval=upper for (iter=0; iter<=maxiter; iter+=1) { list="__iteravgtmp" if(iter>0) { while (fscan (list, data_value) != EOF) { if (data_value != INDEF && data_value<=maxval && data_value>=minval) { n += addsub_flag sum += addsub_flag * data_value sumsqrs += addsub_flag * data_value * data_value } } } # Find mean, var, sig if (n > 1) { mean = sum / n variance = (n * sumsqrs - sum * sum) / (n * (n-1)) if (variance < 0) # possible with roundoff error sigma = 0.0 else sigma = sqrt (variance) } # End loop? if ((n != 0 && n == nold) || iter==maxiter) { iter=maxiter+1 } else { nold=n maxval=mean+nsigrej*sigma minval=mean-nsigrej*sigma n=0 sum=0 sumsqrs=0 mean=0 sigma=0 variance=0 } } #type ("__iteravgtmp", >> "oog") #count ("__iteravgtmp") del ("__iteravgtmp", ver-, >& "dev$null") # print output if (n <= 0) print ("INDEF ", "INDEF ", n) else if (n == 1) print (sum, "INDEF ", 1) else { mean = sum / n variance = (n * sumsqrs - sum * sum) / (n * (n-1)) if (variance < 0) # possible with roundoff error sigma = 0.0 else sigma = sqrt (variance) print (mean, sigma, n) } } ./src/btc_saulflip.cl0100644000151400000240000000734407144614371013756 0ustar phallgamesprocedure btc_saulflip(filename) # Update SNe search image headers to gain=1, and flip all N-S # 980703: add addsky and badfixpix parameters # 990525: add BPMASK to header as well as BPM string filename {prompt="List of old and new image names"} string bpmroot="" {prompt="Root name of bad pixel masks to add to header"} string getstats="" {prompt="File name for iterstat output if desired"} bool addsky=yes {prompt="Add SKY level back in?"} bool badpixfix=yes {prompt="Interpolate over bad pixels using fixpix?"} bool cleanup=yes {prompt="Remove old images?"} bool echog {yes,prompt="Beep when task is done?"} struct *name # filename should list the names of the root image to be worked on begin string root, image, scales, bbpmroot, ggetstats, oldname, newname real iteravg, chipscale, sky bool ccleanup, aaddsky, bbadpixfix bbpmroot=bpmroot ggetstats=getstats aaddsky=addsky bbadpixfix=badpixfix ccleanup=cleanup # -- cycle through image sets name = filename while (fscan (name, oldname, newname) != EOF) { hsel (oldname, "ampid", yes) | scan i # -- update gain value in header imgets(oldname, "gainold", >& "dev$null") if ((imgets.value)=="0") { imgets(oldname, "gain", >& "dev$null") hedit (oldname,"gainold","(gain)",add+,ve-,sho+,updat+) hedit (oldname,"gain",1.0,add+,ve-,sho+,updat+) } else { print (oldname//" header already updated to gain=1!") } # -- flip chips N-S imgets(oldname, "flipns", >& "dev$null") if ((str(imgets.value)) != "yes") { imgets(oldname, "flip", >& "dev$null") if ((str(imgets.value)) != "yes") { imcopy (oldname//"[*,-*]", newname, ver-) if (ccleanup) imdel (oldname, ver-) hedit(newname,"flipns","yes",add+,ve-,sho+,updat+) hedit(newname,"flip","yes",add+,ve-,sho+,updat+) print (newname//" flipped N-S...") } else { print (oldname//" already flipped N-S!") hedit(oldname,"flipns","yes",add+,ve-,sho+,updat+) } } else { print (oldname//" already flipped N-S!") hedit(oldname,"flip","yes",add+,ve-,sho+,updat+) } # -- add bad pixel mask names to headers if (bbpmroot!="") { hedit(newname,"BPM",bbpmroot//"_"//i//".pl",add+,ver-,sho+,updat+) hedit(newname,"BPMASK",bbpmroot//"_"//i//".pl",add+,ver-,sho+,updat+) } # -- add sky back in if desired if (aaddsky) { imgets(newname, "addsky", >& "dev$null") if ((str(imgets.value))!="yes") { imgets(newname, "sky", >& "dev$null") if ((imgets.value)!="0") { print ("Adding sky back in to "//newname//"...") sky = real(imgets.value) imar (newname, "+", sky, newname, ver-, noact-, pixt="real", calct="real") hedit (newname,"addsky","yes",add+,ver-,show+,update+) imgets(newname, "itermean", >& "dev$null") if ((imgets.value)!="0") { hedit(newname,"itermean","(itermean+sky)",add+,ve-,sho-,updat+) hedit(newname,"itermode","(itermode+sky)",add+,ve-,sho-,updat+) hedit(newname,"itermed","(itermed+sky)",add+,ve-,sho-,updat+) } } else { print (newname//" does not contain SKY header keyword!") } } else { print (newname//" already has ADDSKY header keyword!") } } # -- fixpix if desired if (bbadpixfix) { imgets(newname, "fixpix", >& "dev$null") if ((imgets.value)=="0") { imgets(newname, "BPM", >& "dev$null") if ((imgets.value)!="0") { fixpix (newname, "BPM", linterp=1, cinterp=INDEF, ver+, pixels+) } else { print (newname//" does not contain BPM header keyword!") } } else { print (newname//" has already had FIXPIX done!") } } # -- iterstat if desired if (ggetstats!="") { print (newname//" flipped and header updated. Running iterstat.") iterstat (newname, print+, ver-, addh+, >> ggetstats) } } if(echog)beep end ./src/mkrgb.cl0100644000151400000240000000665006561403713012406 0ustar phallgames# mkrgb -- Make Sun rgb rasterfiles from IRAF images # # -- needs "color" package # -- needs "iterstat" previously run on images, and "zeropt" keyword in headers # (note that "zeropt" has the opposite sign than typ. used in phot. solutions # -- defaults are neg=0 pos=8 magr=19 magg=21 magb=23 log- # # 970712: created by Pat Hall # # -- add in (optional) (interactive) looping procedure mkrgb(red,green,blue,neg,pos,rgb) string red {prompt = "Input image for the red component"} string green {prompt = "Input image for the green component"} string blue {prompt = "Input image for the blue component"} real neg {0,prompt = "Number of sigma for minimum intensity"} real pos {8,prompt = "Number of sigma for maximum intensity"} string rgb {prompt = "Output root name for Sun 24-bit RGB rasterfiles"} real magred {19.,prompt = "Maximum mag/sqarcsec for red-gun image"} real maggreen {21.,prompt = "Maximum mag/sqarcsec for green-gun image"} real magblue {23.,prompt = "Maximum mag/sqarcsec for blue-gun image"} real pixfact {2.6,prompt = "2.5*log10((pixels/arcsec)**2."} bool gogreen {no,prompt = "Independent green-gun image?"} bool orient {yes,prompt = "Preserve orientation of IRAF images?"} bool log {no,prompt = "Use logarithmic intensity mapping?"} #bool interact {prompt = "Interactive parameter adjustment?"} string logfile {"",prompt = "Logfile of rgbsun commands; null string=no logging"} bool echog {yes,prompt="Beep when task is done?"} begin string imgred, imgblue, imggreen, rgbroot real sigred, siggreen, sigblue, zpred, zpgreen, zpblue real maxred, maxblue, maxgreen real mag_red, mag_blue, mag_green, negsig, possig if(orient) { imgred=red//"[*,-*]"; imgblue=blue//"[*,-*]"; imggreen=green//"[*,-*]" } else { imgred=red; imgblue=blue; imggreen=green } mag_red=magred; mag_blue=magblue; mag_green=maggreen negsig=neg; possig=pos; rgbroot=rgb print ("If error, check that images have had iterstat previously run on them.") # Faintest-object print hsel (imgred, "itersig", yes) | scan (sigred) hsel (imggreen, "itersig", yes) | scan (siggreen) hsel (imgblue, "itersig", yes) | scan (sigblue) rgbsun (imgred, imggreen, imgblue, rgbroot//"_faint", rz1=negsig*sigred, rz2=possig*sigred, gz1=negsig*siggreen, gz2=possig*siggreen, bz1=negsig*sigblue, bz2=possig*sigblue, logmap=log) if (logfile!="") { print ("rgbsun "//imgred//" "//imggreen//" "//imgblue//" "//rgbroot//"_faint rz1="//negsig*sigred//" rz2="//possig*sigred//" gz1="//negsig*siggreen//" gz2="//possig*siggreen//" bz1="//negsig*sigblue//" bz2="//possig*sigblue//" logmap="//log, >> logfile) } # Common magnitude scale print hsel (imgred, "zeropt", yes) | scan (zpred) hsel (imgblue, "zeropt", yes) | scan (zpblue) maxred=10**(-0.4*(mag_red+pixfact-zpred)) maxblue=10**(-0.4*(mag_blue+pixfact-zpblue)) if (gogreen) { hsel (imggreen, "zeropt", yes) | scan (zpgreen) maxgreen=10**(-0.4*(mag_green+pixfact-zpgreen)) } else { maxgreen=maxred+maxblue } rgbsun (imgred, imggreen, imgblue, rgbroot//"_scale", rz1=0, rz2=maxred, gz1=0, gz2=maxgreen, bz1=0, bz2=maxblue, logmap=log) if (logfile!="") { print ("rgbsun "//imgred//" "//imggreen//" "//imgblue//" "//rgbroot//"_scale rz1=0 rz2="/maxred//" gz1=0 gz2="/maxgreen//" bz1=0 bz2="/maxblue//" logmap="//log, >> logfile) } print("Display "//rgbroot//"_faint and "//rgbroot//"_scale with xview.") if(!orient){ print("Be sure to flip up/down before saving as PostScript") print("to preserve IRAF image orientation.") } if(echog)beep end ./src/iteravg.par0100644000151400000240000000063306720573001013117 0ustar phallgamesoption,s,a,new_sample,,,'Type of sample (new_sample, add, subtract)' nsigrej,r,h,,,,'Number of sigma for limits' maxiter,i,h,,,,'Maximum number of iterations' lower,r,h,INDEF,,,'Lower cutoff for valid data points' upper,r,h,INDEF,,,'Upper cutoff for valid data points' opstring,s,h addsub_flag,i,h data_value,r,h n,i,h sum,r,h sumsqrs,r,h mean,r,h variance,r,h sigma,r,h iter,i,h nold,i,h minval,r,h maxval,r,h ./src/btc_getchipscales.cl0100644000151400000240000000463607144614371014756 0ustar phallgamesprocedure btc_getchipscales(filename,scalename) # btc_getchipscales -- find chip-to-chip photometric scalings for BTC images # This program will fail if the ITERMEAN keyword is not in all image headers! string filename {prompt="File of root names of BTC image sets"} string scalename {prompt="Root name for output scaling files"} string extension="fits" {prompt="Image extension"} bool getscales {yes,prompt="Get individual image set scalings?"} bool avgscales {yes,prompt="Average lots of scalings together?"} bool savescales {yes,prompt="Accept and save average scaling?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string root, image, scales, extn, scale_name real avgmean, chipscale bool get_scales, avg_scales, save_scales name = filename scale_name = scalename extn = extension get_scales = getscales avg_scales = avgscales # -- cycle through images if (get_scales) { print ("Output to "//scale_name//"_chipscales:") while (fscan (name, root) != EOF) { # -- find average itermean hsel (root//"_?."//extn, "itermean", yes) | average | scan (avgmean) # -- get itermean for all 4 images in the set and divide by average itermean scales="" for (i=1; i<=4; i+=1) { image = root//"_"//i//"."//extn hsel (image, "itermean", yes) | scan (chipscale) chipscale=chipscale/avgmean scales = (scales//" "//chipscale) } # -- output print (root//scales) print (root//scales, >> scale_name//"_chipscales") } } # -- average lots of image set scalings together chip-by-chip while (avg_scales) { print ("Average scalings, RMS uncertainty and # of images used for chips 1-4:") fields (scale_name//"_chipscales",2) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",3) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",4) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",5) | iteravg >> scale_name//"_chipscalesavg") type (scale_name//"_chipscalesavg") print (" ") print ("If the above is unacceptable, answer `n' and the "//scale_name//"_chipscales") print ("file will be displayed for editing and the iterative average re-run.") save_scales=savescales if(save_scales){ print ("Saving to file "//scale_name//"_chipscalesavg") avg_scales=no } else { avg_scales=yes del (scale_name//"_chipscalesavg", ver-) vi (scale_name//"_chipscales") } } if(echog)beep end ./src/btc_getsaulscales.cl0100644000151400000240000000167707144614371015001 0ustar phallgamesprocedure btc_getsaulscales(filename) # program to find chip-to-chip photometric scalings for SNe btc images string filename {prompt="file of root names of BTC image sets"} string extension {prompt="image extension"} bool echog {yes,prompt="Beep when task is done?"} struct *name # filename should list the names of the root image to be worked on begin string root, image, scales, extn real avgmean, chipscale # -- cycle through images name = filename extn = extension while (fscan (name, root) != EOF) { # -- find average itermean hsel (root//"_?."//extn, "sky", yes) | average | scan (avgmean) # -- get sky for all 4 images in the set, divide by avgmean scales="" for (i=1; i<=4; i+=1) { image = root//"_"//i//"."//extn hsel (image, "sky", yes) | scan (chipscale) chipscale=chipscale/avgmean scales = (scales//" "//chipscale) } # -- output print (root//scales) } # -- (average or compare w/others) if(echog)beep end ./src/btc_test.cl0100644000151400000240000001265707144614371013121 0ustar phallgamesprocedure btc_test(im1,im2,im3,prefix,suffix) # --trim images to areas with < 2/3 (rounded down) of input images # --align B & R image to overlap region only # --optionally align I image to that same region # # 980710: created string im1 {prompt="Primary (reference) image"} string im2 {prompt="Secondary image"} string im3 {prompt="Tertiary image (optional)"} string prefix {prompt="Prefix string for output files"} string suffix {prompt="Suffix string for output files"} bool domask=yes {prompt="Mask image areas w/<2/3 max # of input images?"} bool doalign=yes {prompt="Align & trim images to match each other?"} bool delold {prompt="Delete existing versions of intermediate files?"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string bimage, rimage, iimage, s1, s2, s3, image, pl, imroot, imext string imrootr, imrootb, imrooti real x, y int xmin, ymin, xmax, ymax, i, j, k, numim, imnow, maxfrac, n, imax, imay int bxmin, bxmax, bymin, bymax, rxmax, rxmin, rymax, rymin, xoff, yoff int rxminoff, rxmaxoff, ryminoff, rymaxoff, ixmin, ixmax, iymin, iymax int bxnewmin, bxnewmax, bynewmin, bynewmax, rxnewmin, rxnewmax int rynewmin, rynewmax, ixnewmin, ixnewmax, iynewmin, iynewmax bool delex bimage=im1 rimage=im2 iimage=im3 delex=delold fileroot(bimage, validim+); imrootb=fileroot.root fileroot(rimage, validim+); imrootr=fileroot.root if(iimage!=""){ numim=3 fileroot(iimage, validim+); imrooti=fileroot.root } numim=2 image=bimage #--for each image, mask out areas with <2/3 (rounded down) of all images for (imnow=1; imnow<=numim; imnow+=1) { if(imnow==2){image=rimage} if(imnow==3){image=iimage} hsel (image, "plfmask", yes) | scan (pl) fileroot(image, validim+) imroot=fileroot.root imext=fileroot.extension fileroot(pl, validim+) pl=fileroot.root #--create trim masks from pixel list files if(delex)imdel(pl//"good.pl", ver-, >& "dev$null") if(!access(pl//"good.pl")){ minmax (pl, force+, update-, ver-) maxfrac = minmax.maxval/3. imdel ("tmp"//pl//".pl", ver-, >& "dev$null") imar (pl,"-",maxfrac,"tmp"//pl//".pl",ver-,noact-,calct="real",pixt="1") minv ("tmp"//pl, pl//"good.pl") imdel ("tmp"//pl, ver-) } #--find x boundaries for trimming if(delex)imdel(pl//"trans.pl", ver-, >& "dev$null") if(!access(pl//"trans.pl"))imtransp(pl//"good.pl[*,-*]",pl//"trans.pl") minmax (pl//"trans.pl", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s1=substr(s3,i+1,j-1); s1="["//s1//":" minmax (pl//"trans.pl[*,-*]", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); k=real(s2) imgets (pl//"trans.pl", "i_naxis2") j=int(imgets.value); i=j-k+1; s1=s1//i//"," # imdel (pl//"trans.pl", ver-) #--find y boundaries for trimming minmax (pl//"good.pl", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); s1=s1//s2//":" minmax (pl//"good.pl[*,-*]", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); k=real(s2) imgets (pl//"good.pl", "i_naxis2") j=int(imgets.value); i=j-k+1; s1=s1//i//"]" #--create trimmed images imdel("_tmp_"//image, ver-, >& "dev$null") imar(image,"*",pl//"good.pl","_tmp_"//image,ve-,noa-,calct="real",pixt="1") imcopy ("_tmp_"//image//s1, imroot//"trim", ver+) imdel ("_tmp_"//image, ver-) } #--do irshift2 & immatch.geomap on b & r images irshift2 (bimage, rimage, pprefix, ssuffix) hsel (bimage, "i_naxis1", "yes") | scan (imax) hsel (bimage, "i_naxis2", "yes") | scan (imay) immatch.geomap (pprefix//"br.geomapin."//ssuffix, pprefix//"br.geomapout."//ssuffix, 1, imax, 1, imay, fitgeo="shift") #--do irshift2 & immatch.geomap on b & i images if(iimage!=""){ irshift2 (bimage, rimage, pprefix, ssuffix) immatch.geomap (pprefix//"bi.geomapin."//ssuffix, pprefix//"bi.geomapout."//ssuffix, 1, imax, 1, imay, fitgeo="shift") } #--figure out b & r trimming sections #--extract real x & y offsets fields (pprefix//"br.geomapout."//ssuffix, "1,2", lines="26-26") | scan (x,y) #--round off to nearest integer i=int(x+0.5); j=int(y+0.5) #--get smallest & largest pixel coords of primary image bxmin=1; hsel (bimage, "i_naxis1", yes) | scan (bxmax) bymin=1; hsel (bimage, "i_naxis2", yes) | scan (bymax) bxnewmin=bxmin; bxnewmax=bxmax; bynewmin=bymin; bynewmax=bymax #--get ideal offset smallest pixel coords of trimmed 2nd image rxminoff=1+i; ryminoff=1+j #--get largest pixel coords of 2nd image hsel (rimage, "i_naxis1", yes) | scan (rxmax) hsel (rimage, "i_naxis2", yes) | scan (rymax) rxnewmin=rxminoff; rxnewmax=rxmax; rynewmin=ryminoff; rynewmax=rymax #--if ideal offset smallest pixel coords of trimmed 2nd image <0, adjust to =1 if(rxminoff<=0) { xoff=1-rxminoff; rxnewmin=1 bxnewmin=bxmin+xoff } if(ryminoff<=0) { yoff=1-ryminoff; rynewmin=1 bynewmin=bymin+yoff } #--get ideal offset largest pixel coords of trimmed 2nd image rxmaxoff=bxmax+i; rymaxoff=bymax+j #--if ideal offset largest 2nd image pixel coords larger than original 2nd image if(rxmaxoff>rxmax) { xoff=rxmaxoff-rxmax; rxnewmax=rxmax bxnewmax=bxnewmax+xoff } if(rymaxoff>rymax) { yoff=rymaxoff-rymax; rynewmax=rymax bynewmax=bynewmax+yoff } #--trim imroot//"trim" to imroot//"align" imcopy (imager//"["//rxnewmin//":"//rxnewmax//","//rynewmin//":"//rynewmax//"]", imrootr//"align") imcopy (imageb//"["//bxnewmin//":"//bxnewmax//","//bynewmin//":"//bynewmax//"]", imrootb//"align") #--figure out i trimming sections #--display if desired if(echog)beep end ./src/complete.cl0100644000151400000240000006230706561403625013117 0ustar phallgamesprocedure complete(image1,image2,image3,untrim1,untrim2,untrim3,mask,sum,color21,color31,mlim1,spacing,nbins,nobjs,nrepeat,pixscale) # complete.cl -- calculate completeness corrections for mosaiced image # # **OUTPUT: comparea_image? and complete_image? where ?=1,2,3 as appropriate # # **REQUIRES packages FOCAS, ARTDATA (mkobjects), CTIO (filecalc), # PHIIRS (fileroot), PHAT (imswap), # **REQUIRES rlambda, ebv, gain, rdnoise, fwhmpix, & zeropt in each image header # **REQUIRES existing image1.cat, image2.cat, image3.cat, & sum.cat # # 970731: working version finally debugged, by Pat Hall. # 970806: added insertion of xyminmax, and fixed minor related inefficiency bug # # **comparea_image? output will be ERRONEOUS unless mag limits input to the # task bracket all mlims which exist in the image(s). # **CANNOT BE RUN IN BATCH MODE due to focas.mfilter/ffilter problem. # # --could replace bright magnitude C(m) with (sum(areas,objs> logname) if(ddis)displ(ssum, 1) #--get Atot, minus border region print ("get total area, minus border region") print ("get total area, minus border region", >> logname) imdel ("tmp_"//msk, ver-, >& "dev$null") addring (msk, "tmp_"//msk, ngrow=bborder, badval=0) imstat ("tmp_"//msk, fields="mean,npix", format-, lower=INDEF, upper=INDEF) | scan(mmean,nnpix) Atot=(mmean*nnpix*ppixscale**2.)/3600. print(Atot, >> logname) print(Atot) imdel ("tmp_"//msk, ver-) #--get xminmax for the field print ("get xminmax for the field", >> logname) imtranspose (msk//"[*,-*]", "tmp_"//msk) minmax ("tmp_"//msk, force+, update-, ver-) s1=minmax.maxpix; x=stridx(",",s1); s2=substr(s1,x+1,strlen(s1)-1) print (s2) | scan (xmin) minmax ("tmp_"//msk//"[*,-*]", force+, update-, ver-) s1=minmax.maxpix; x=stridx(",",s1); s2=substr(s1,x+1,strlen(s1)-1) print (s2) | scan (xmax) hsel ("tmp_"//msk, "i_naxis2", yes) | scan (xlong) xmax=xlong+1-xmax imdel ("tmp_"//msk, ver-) #--get yminmax for the field print ("get yminmax for the field", >> logname) minmax (msk, force+, update-, ver-) s1=minmax.maxpix; x=stridx(",",s1); s2=substr(s1,x+1,strlen(s1)-1) print (s2) | scan (ymin) minmax (msk//"[*,-*]", force+, update-, ver-) s1=minmax.maxpix; x=stridx(",",s1); s2=substr(s1,x+1,strlen(s1)-1) print (s2) | scan (ymax) hsel (msk, "i_naxis2", yes) | scan (ylong) ymax=ylong+1-ymax #--border zones ymin=ymin+bborder; xmin=xmin+bborder ymax=ymax-bborder; xmax=xmax-bborder hedit (msk//","//ssum, "xmin", xmin, add+, ver-, show+, update+) hedit (msk//","//ssum, "ymin", ymin, add+, ver-, show+, update+) hedit (msk//","//ssum, "xmax", xmax, add+, ver-, show+, update+) hedit (msk//","//ssum, "ymax", ymax, add+, ver-, show+, update+) hedit (msk//","//ssum, "border", bborder, add+, ver-, show+, update+) #--copy all imgs to temporary imgs, get galactic extinction for that filter, # find equal skysig scales for tmp imgs, generate random object x,y positions, # match all r(j)k images' catalogs plus the summed image, addring to norm.imgs del ("_match1.mcat", ver-, >& "dev$null") match ("_match1.mcat", ssum//".cat", img1//".cat") # imdel("tmp_"//img1,ver-,>&"dev$null") imcopy(img1,"tmp_"//img1,ver-) # k=0; kmax=1; f1=1; f="f" hsel (img1, "itersig", yes) | scan (x) # hsel (ssum, "ebv", yes) | scan (ebv) hsel (img1, "rlambda", yes) | scan (rlambda1) alambda1=ebv*rlambda1 hedit (img1, "alambda1", alambda1, add+, ver-, update+, show-) # imdel ("tmp_"//msk, ver-, >& "dev$null") imdel ("tmp_"//norm1, ver-, >& "dev$null") addring (msk, "tmp_"//msk, ngrow=bborder, badval=0) imar (norm1, "*", "tmp_"//msk, "tmp_"//norm1, ver-, noact-) # if(img2!="") { match ("_match1.mcat", img2//".cat") imdel("tmp_"//img2,ver-,>&"dev$null") imcopy(img2,"tmp_"//img2,ver-) hsel (img2, "itersig", yes) | scan (y) f2=x/y print("f2="//f2) print("f2="//f2, >> logname) hsel (img2, "rlambda", yes) | scan (rlambda2) alambda2=ebv*rlambda2 kmax=2 imdel ("tmp_"//norm2, ver-, >& "dev$null") imar (norm2, "*", "tmp_"//msk, "tmp_"//norm2, ver-, noact-) # if(img3!="") { match ("_match1.mcat", img3//".cat") imdel("tmp_"//img3,ver-,>&"dev$null") imcopy(img3,"tmp_"//img3,ver-) hsel (img3, "itersig", yes) | scan (y) f3=x/y print("f3="//f3) print("f3="//f3, >> logname) hsel (img3, "rlambda", yes) | scan (rlambda3) alambda3=ebv*rlambda3 kmax=3 imdel ("tmp_"//norm3, ver-, >& "dev$null") imar (norm3, "*", "tmp_"//msk, "tmp_"//norm3, ver-, noact-) } } imdel ("tmp_"//msk, ver-) del ("_tmprandfile", ver-, >& "dev$null") total=nnrepeat*nnobjs*nnbins urand (total, 5, scale=1, >> "_tmprandfile") #--for each FINAL magnitude bin (index i) after g.e. correction # (i.e. detected mag is g.e. mags fainter) for (i=1; i<=nnbins; i+=1) { mag1=llimbin1-(i-1)*sspacing+alambda1 if(kmax>=2)mag2=llimbin1-(i-1)*sspacing+alambda2+color_21 if(kmax>=3)mag3=llimbin1-(i-1)*sspacing+alambda3+color_31 mag=mag1 #--extract cat of fainter-than-this objs from matched r(j)k+sum mcat print ("extract cat of objs w/m>"//mag//" in filter #1 from matched r(j)k+sum mcat") print ("extract cat of objs w/m>"//mag//" in filter #1 from matched r(j)k+sum mcat", >> logname) del ("_matchf.*cat", ver-, >& "dev$null") #--mfilter has problems in batch mode; none of the following work in batch mode. #--can't use ffilter instead, either. # mfilter ("f2 \"M "//mag//" 100\"", < "_match1.mcat", > "_matchf.mcat") # mfilter ("f2 'M "//mag//" 100'", < "_match1.mcat", > "_matchf.mcat") # s1="f2 \"M "//mag//" 100\"" # mfilter ("f2", s1, < "_match1.mcat", > "_matchf.mcat") # mfilter ("f2", "\"M "//mag//" 100\"", < "_match1.mcat", > "_matchf.mcat") # mfilter ("f2", "'M "//mag//" 100'", < "_match1.mcat", > "_matchf.mcat") mfilter ("f2 'M "//mag//" 100'", < "_match1.mcat", > "_matchf.mcat") mextract (1, < "_matchf.mcat", > "_matchf.cat") objects("_matchf.cat") #--clean summed image of objects w/this flux or less in this filter print ("clean summed image of objects w/this flux or less in this filter", >> logname) imdel ("cl_sum.imh", ver-, >& "dev$null") imcopy (ssum, "cl_sum", ver-) clean (cf, < "_matchf.cat") imswap (ssum, "cl_sum") del ("_matchf.*cat", ver-, >& "dev$null") if(ddis)displ("cl_sum", 2) #--COMPARISON CAT print("COMPARISON CAT") print("COMPARISON CAT", >> logname) #--rerun focas: create catalog del ("cl_sum.ar", ver-, >& "dev$null") del ("cl_sum.cat", ver-, >& "dev$null") hsel (ssum, "variance", yes) | scan (variance) del ("temp.file", ver-, >& "dev$null") skysig=sqrt(variance) print("cl_sum.cat", " ", "cl_sum", " ", "artdata", " ", skysig, "21", " ", "cl_sum.ar", >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcathesis $catpars del ("temp.file", ver-, >& "dev$null") #--detect detect ("cl_sum.cat", 1, ylong, -5*skysig, 5*skysig) sky ("cl_sum.cat") evaluate ("cl_sum.cat") #--splits del ("temp.file", ver-, >& "dev$null") print("cl_sum.cat", " ", "10", >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcatsize $catpars del ("temp.file", ver-, >& "dev$null") splits ("cl_sum.cat") del ("cl_sum.sky.imh", ver-, >& "dev$null") del ("cl_sum.sky.pix", ver-, >& "dev$null") #--for j=1 to nnrepeat iterations at each magnitude nrecovsum=0. ndenomsum=0. for (j=1; j<=nnrepeat; j+=1) { l=1; del ("_tmpcoo?", ver-, >& "dev$null") #--create coords+mag list of nnobjs psf objs to add to x,y image region for (l=1; l<=nnobjs; l+=1) { running=(i-1)*nnrepeat*nnobjs+(j-1)*nnobjs+l fields("_tmprandfile", "1-5", lines=running) | scan (x,y,z,a,b) x=x*(xmax-xmin)+xmin; y=y*(ymax-ymin)+ymin z=mag1+sspacing*(z-0.5) print (x, y, z, >> "_tmpcoo1") if (kmax>=2) { a=mag2+sspacing*(a-0.5) print (x, y, a, >> "_tmpcoo2") } if (kmax>=3) b=mag3+sspacing*(b-0.5) print (x, y, b, >> "_tmpcoo3") } #--ARTDATA CAT print ("ARTDATA CAT, filter 1 ("//img1//") mag #"//i//" ("//mag//") iteration #"//j) print ("ARTDATA CAT, filter 1 ("//img1//") mag #"//i//" ("//mag//") iteration #"//j, >> logname) #--recreate tmp image imdel ("tmp_"//img1, ver-, >& "dev$null") imcopy (img1, "tmp_"//img1, ver-) #--add objs+noise to img hsel ("tmp_"//img1, "zeropt", yes) | scan (zeropt) hsel ("tmp_"//img1, "gain", yes) | scan (g) hsel ("tmp_"//img1, "rdnoise", yes) | scan (rn) #print (zeropt, " ", g, " ", rn) hsel ("tmp_"//img1, "fwhmpix", yes) | scan (ffwhmpix) mkobjects ("tmp_"//img1, header="", background=0., objects="_tmpcoo1", star=sstar, radius=0.9*(ffwhmpix/2.), beta=2.5, ar=1., dist=1., exptime=1., magzero=zeropt, pa=0., poisson+, gain=g, rdnoise=rn, seed=sseed, comments+, xoff=0., yoff=0.) #--subtract original image imar ("tmp_"//img1, "-", img1, "tmp_"//img1, ver-) #--scale artdata-only image to equal skysub imar ("tmp_"//img1, "*", f1, "tmp_"//img1, ver-) #--add scaled residual images to summed-cleaned-img imdel ("do_img", ver-, >& "dev$null") imar ("tmp_"//img1, "+", "cl_sum", "do_img", ver-, noact-) if(kmax>=2){ #--recreate tmp image imdel ("tmp_"//img2, ver-, >& "dev$null") imcopy (img2, "tmp_"//img2, ver-) hsel ("tmp_"//img2, "zeropt", yes) | scan (zeropt) hsel ("tmp_"//img2, "gain", yes) | scan (g) hsel ("tmp_"//img2, "rdnoise", yes) | scan (rn) #print (zeropt, " ", g, " ", rn) hsel ("tmp_"//img2, "fwhmpix", yes) | scan (ffwhmpix) mkobjects ("tmp_"//img2, header="", background=0., objects="_tmpcoo2", star=sstar, radius=0.9*(ffwhmpix/2.), beta=2.5, ar=1., dist=1., exptime=1., magzero=zeropt, pa=0., poisson+, gain=g, rdnoise=rn, seed=sseed, comments+, xoff=0., yoff=0.) #--subtract original image imar ("tmp_"//img2, "-", img2, "tmp_"//img2, ver-) #--scale artdata-only image to equal skysub imar ("tmp_"//img2, "*", f2, "tmp_"//img2, ver-) #--add scaled residual images to summed-cleaned-img imar("do_img","+","tmp_"//img2,"do_img",ver-,noact-) } if(kmax>=3){ #--recreate tmp image imdel ("tmp_"//img3, ver-, >& "dev$null") imcopy (img3, "tmp_"//img3, ver-) hsel ("tmp_"//img3, "zeropt", yes) | scan (zeropt) hsel ("tmp_"//img3, "gain", yes) | scan (g) hsel ("tmp_"//img3, "rdnoise", yes) | scan (rn) hsel("tmp_"//img3, "fwhmpix", yes) | scan (ffwhmpix) mkobjects ("tmp_"//img3, header="", background=0., objects="_tmpcoo3", star=sstar, radius=0.9*(ffwhmpix/2.), beta=2.5, ar=1., dist=1., exptime=1., magzero=zeropt, pa=0., poisson+, gain=g, rdnoise=rn, seed=sseed, comments+, xoff=0., yoff=0.) #--subtract original image imar ("tmp_"//img3, "-", img3, "tmp_"//img3, ver-) #--scale artdata-only image to equal skysub imar ("tmp_"//img3, "*", f3, "tmp_"//img3, ver-) #--add scaled residual images to summed-cleaned-img imar("do_img","+","tmp_"//img3,"do_img",ver-,noact-) } #--mask summed image imar ("do_img", "*", msk, "do_img", ver-, noact-) if(ddis)displ("do_img", 3) if(ddis)sctv("tmp_"//img1, 4) #if(ddis)imexam("tmp_"//img1, keeplog+, logfile=logname) #--rerun focas: create catalog print("rerun focas & create catalog") hsel (ssum, "variance", yes) | scan (variance) del ("do_sum.ar", ver-, >& "dev$null") del ("do_sum.cat", ver-, >& "dev$null") del ("temp.file", ver-, >& "dev$null") skysig=sqrt(variance) print("do_img.cat", " ", "do_img", " ", "artdata", " ", skysig, "21", " ", "do_img.ar", >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcathesis $catpars #--detect detect ("do_img.cat", 1, ylong, -5*skysig, 5*skysig) sky ("do_img.cat") evaluate ("do_img.cat") #--splits del ("temp.file", ver-, >& "dev$null") print("do_img.cat", " ", "10", >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcatsize $catpars del ("temp.file", ver-, >& "dev$null") splits ("do_img.cat") del ("do_img.sky.imh", ver-, >& "dev$null") del ("do_img.sky.pix", ver-, >& "dev$null") #--create focas cat of artdata objects only imar ("tmp_"//img1, "*", msk, "tmp_"//img1, ver-, noact-) print("tmp_"//img1//".cat", " ", "tmp_"//img1, " ", "artdata", " ", 0.025*skysig, "6", " ", "tmpimg.ar", >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcathesis $catpars del ("temp.file", ver-, >& "dev$null") detect ("tmp_"//img1//".cat", 1, ylong, -0.025*skysig, 0.025*skysig) sky ("tmp_"//img1//".cat") evaluate ("tmp_"//img1//".cat") del ("tmp_"//img1//".sky.imh", ver-, >& "dev$null") del ("tmp_"//img1//".sky.pix", ver-, >& "dev$null") #--match summed-altered-img cat w/summed-cleaned-img cat, tossing matches print ("match summed-altered-img cat w/summed-cleaned-img cat, tossing matches", >> logname) #if(ddis)review("cl_sum.cat", "do_img.cat", "tmp_"//img1//".cat") match ("_match.mcat", "cl_sum.cat", "do_img.cat", "tmp_"//img1//".cat") mfilter ("e1", "i2", "i3", < "_match.mcat", > "_matchf.mcat") mextract (2, < "_matchf.mcat", > "_do_imgf.cat") #if(ddis)review("_do_imgf.cat") objects ("cl_sum.cat") objects ("do_img.cat") objects ("_do_imgf.cat") objects ("tmp_"//img1//".cat") objects ("_do_imgf.cat") | scan (s1, s2, s3, s4, s5, nrecov) objects ("tmp_"//img1//".cat") | scan (s1, s2, s3, s4, s5, ndenom) #--delete temporary images & catalogs imdel ("do_img", ver-, >& "dev$null") imdel ("tmp_"//img1, ver-, >& "dev$null") imdel ("tmp_"//img2, ver-, >& "dev$null") imdel ("tmp_"//img3, ver-, >& "dev$null") del ("tmpimg.ar", ver-, >& "dev$null") del ("tmp_"//img1//".cat", ver-, >& "dev$null") del ("_tmpcoo?", ver-, >& "dev$null") del ("_do_img*.cat", ver-) del ("_do_img*.ar", ver-) del ("do_img*.cat", ver-) del ("do_img*.ar", ver-) del ("_match.mcat", ver-) del ("_matchf.mcat", ver-) #--next j (nnrepeat iterations at each magnitude) nrecovsum=nrecovsum+nrecov ndenomsum=ndenomsum+ndenom print("nrecov="//nrecov, >> logname) print("nrecovsum="//nrecovsum, >> logname) print("ndenomsum="//ndenomsum, >> logname) } #--save info on the ith mag bin mnorm=mag1 if(ndenomsum==0.) { frecover=0. } else { frecover=nrecovsum/ndenomsum } print ("frecover="//frecover, >> logname) farray[i,1]=frecover farray[i,2]=mnorm #=mag1=mag print ("farray["//i//",1-2]="//farray[i,1]//" "//farray[i,2], >> logname) if (kmax>=2) { farray[i,3]=mag2 print ("farray["//i//",3]="//farray[i,3], >> logname) } if (kmax>=3) { farray[i,4]=mag3 print ("farray["//i//",4]="//farray[i,4], >> logname) } #farray 1 2 3 4 #i=1 frecov mag1=mnorm mag2 mag3 #i=2 frecov mag1=mnorm mag2 mag3 #... #--next magnitude bin i imdel ("cl_sum", ver-, >& "dev$null") del ("cl_sum.cat", ver-) del ("cl_sum.ar", ver-) } #--for each r(j)k image (index k), compute C(mfinal) for k-mag in filter #k for (k=1; k<=kmax; k+=1){ img=img1; norm="tmp_"//norm1; mag=mag1; llimbin=llimbin1; alambda=alambda1 if(k==2){ img=img2; norm="tmp_"//norm2; mag=mag2; llimbin=llimbin2; alambda=alambda2 } if(k==3){ img=img3; norm="tmp_"//norm3; mag=mag3; llimbin=llimbin3; alambda=alambda3 } print ("compute C(mfinal) for "//mag//" to "//llimbin//" in filter #"//k) print ("compute C(mfinal) for "//mag//" to "//llimbin//" in filter #"//k, >> logname) if(access("complete_"//img))print("Appending to complete_"//img) if(access("comparea_"//img))print("Appending to comparea_"//img) print("#"//img, >> "complete_"//img) print("#mag completeness raw", >> "complete_"//img) print("#"//img, >> "comparea_"//img) print("#mag area(sqarcmin) lost_area", >> "comparea_"//img) #--take untrim*orig image and subtract from maximum to get deltam at each pixel minmax (norm, force+, update-, ver-) imar (norm, "-", minmax.maxval, "_tmp_"//norm, ver-, noact-) imar ("_tmp_"//norm, "*", "-1.", "_tmp_"//norm, ver-, noact-) #if(ddis)sctv(norm, 3) #if(ddis)sctv("_tmp_"//norm, 4) #--get Area(delm) binned in (spacing) bins centered at #--0,1*spacing,2*spacing ... (z1=-0.5*spacing,z2=0.5*spacing) print("get Area(delm)", >> logname) del ("_Alist", ver-, >& "dev$null"); del ("_Zlist", ver-, >& "dev$null") binmax=1+int(2.5/sspacing) imhistog ("_tmp_"//norm, z1=-0.5*sspacing, z2=(binmax-0.5)*sspacing, binw=sspacing, top_closed=no, listout+, >> "_Alist") filecalc ("_Alist", "$1;$2*("//ppixscale//"**2.)/3600.", >> "_Zlist") list="_Zlist" i=1 while (fscan(list, deltam, area) !=EOF) { print (area, >& "dev$null") aarray[i,1]=area print (deltam, >& "dev$null") aarray[i,2]=minmax.maxval-deltam print (deltam, >& "dev$null") aarray[i,3]=deltam print ("aarray["//i//",1-3]="//aarray[i,1]//" "//aarray[i,2]//" "//aarray[i,3], >> logname) i=i+1 } imdel ("_tmp_"//norm, ver-) #aarray 1 2 3 4 #i=1 area mlim deltam tmp #i=2 area mlim deltam tmp #... #--get Area(m) binned in (spacing) bins centered on mreal=mfinal+g.e. mag values print("get Area(m)", >> logname) del ("_Alist", ver-, >& "dev$null"); del ("_Zlist", ver-, >& "dev$null") imhistog (norm, z1=llimbin-(nnbins-0.5)*sspacing+alambda, z2=llimbin+0.5*sspacing+alambda, binw=sspacing, listout+, >> "_Alist") filecalc ("_Alist", "$1;$2*("//ppixscale//"**2.)/3600.", >> "_Zlist") list="_Zlist" Asum=0. while (fscan(list, mreal, area) !=EOF) { mfinal=mreal-alambda #--"area" is the area which has a limiting magnitude in this bin. #--"Asum" is the area which has a limiting magnitude in this bin or brighter. Asum=Asum+area #--"Atmp" is the area which has a limiting magnitude fainter than this bin. Atmp=Atot-Asum print(mfinal, Atmp, area, >> "comparea_"//img) } del ("_Alist", ver-, >& "dev$null"); del ("_Zlist", ver-, >& "dev$null") #--one mreal=mfinal+g.e. bin at a time print("one mreal=mfinal+g.e. bin at a time", >> logname) #--since m_norm goes in 0.5m steps, m_norm=m_real-delta_m will too for (i=1; i<=nnbins; i+=1) { mreal=llimbin-(i-1)*sspacing+alambda #mreal=mnorm in deepest part mfinal=mreal-alambda ctmp=0. print("i="//i, >> logname) #--for each deltam up to deltam=2.5 (corresponding to 1% of peak exposure time) #--(A(del_m+0.25,del_m-0.25)/Atot) * f(m_real-delta_m) where #--f(m_real-delta_m) is f(m_norm) for the m_norm nearest m_real-deltam deltamax=1+int(2.5/sspacing) #--guarantees at least 2.5m above mlim for (deltam=0; deltam<=deltamax; deltam+=sspacing) { j=1+deltam/sspacing #--jth array entry = deltam above mlim mnorm=mreal-deltam #--find f(m_real-delta_m) = f(m_norm) for the m_norm nearest m_real-deltam index=1 diff=10. for (i2=1; i2<=nnbins; i2+=1) { mtmp=farray[i2,k+1] if ((abs(mtmp-mnorm)) < diff) { index=i2 diff=abs(mtmp-mnorm) #print ("deltam="//deltam, " i2="//i2, " mtmp="//mtmp, " index="//index, " mnorm="//mnorm, " diff="//diff, >> logname) } } # --(A(del_m+0.25,del_m-0.25)/Atot) * f(m_real-delta_m) aarray[j,4]=aarray[j,1]*farray[index,1]/Atot print ("j="/j//": aarray[j,4]="//aarray[j,4]//" aarray[j,1]="//aarray[j,1]//" farray["//index//",1]="//farray[index,1]//" ctmp="//ctmp, >> logname) # --sum individual A*f terms to get C(mfinal)=C(mreal) ctmp=ctmp+aarray[j,4] #--next delta_m } #--output C(mfinal) ctrue=ctmp if (ctmp>=1.) { ctmp=1. } print (mfinal, ctmp, ctrue, >> "complete_"//img) #--next filter k } #--next mfinal (magnitude) bin i } del ("_tmprandfile", ver-, >& "dev$null") del ("_match.mcat", ver-, >& "dev$null") del ("_match1.mcat", ver-, >& "dev$null") imdel ("tmp_"//norm1, ver-, >& "dev$null") imdel ("tmp_"//norm2, ver-, >& "dev$null") imdel ("tmp_"//norm3, ver-, >& "dev$null") } else { print("WARNING: packages FOCAS and/or ARTDATA, and/or tasks") print("filecalc, fileroot, and/or imswap are not loaded!") print("Please load the appropriate package(s) and restart this task.") } list="" if(echog)beep end #--for each field # --get x,y limits for that field and filter # --get g.e. for each filter # --choose each filter's fluxes so m_final (= m_real-g.e.) # = e.g. 20.25, 20.75, thus in the deepest part of the image where # m_norm1=m_real1, m_norm1 = e.g. 20.25+ge1, 20.75+ge1, ... # m_norm2=m_real2, m_norm2 = e.g. 20.25+ge2, 20.75+ge2, ... # --find scalings for individual-filter images # **for each mag bin: each mag bin represents a different mag in each filter # (m1=m1, m2=m1+color21, m3=m1+color31), but should really repeat for # each filter since the crowding is different to each filter's limit # (i.e. mk=mminval) { if(val<=mmaxval) { print(val, >> ooutfile) } } } count (iinfile//","//ooutfile) end ./src/iraf2unix0100744000151400000240000000003406560142175012606 0ustar phallgamesNR == 1, NR == 1 {print $0} ./src/testfringe.cl0100644000151400000240000001265206561404135013454 0ustar phallgames# testfringe.cl -- test defringing with user-specified scalings # 980729: created from checkfringe.cl procedure testfringe(fiximage,fringe,outname) string fiximage {prompt="Name of (original) image to be defringed"} string fringe {prompt="Fringe image to scale and subtract"} string outname {prompt="Name of final defringed image to create"} real startscale=0. {prompt="First scaling to use (0.=default calculated)",mode="q"} real stepscale=0. {prompt="Step between scaling values (0.=default=0.05)",mode="q"} int nsteps=0 {prompt="Number of test images to make (0=until RMS rises)",mode="q"} string imsect="" {prompt="[Image section] to use for statistics & display"} bool addhead=no {prompt="Add iterstat output to image header?"} bool display=no {prompt="Display defringed image sections?"} bool fit=yes {prompt="Adjust parameters and retest defringing?",mode="q"} real scale {prompt="Scaling to use on fringe image",mode="q"} real finalscale {prompt="Scaling to use for final image",mode="q"} bool finaldisp {yes,prompt="Display original & final images when done?"} #int z=0 {prompt="Number of image to save?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} begin string logimex, logsurf, rrootname, ooutname, ffunc string wweighting, fiximg, ffringe, titlestring, statsec real max, nncols, nnlines, sscale, indiv_exptime, avg_exptime, sum_exptime real sc_start, sc_step, itermed, oldrms, newrms, sc_final, ll, ul, mn, sig int x, y, zz, xxord, yyord, xx, steps, w, nx, npx, m bool go, ffit, xxterms, ddisplay, hadd, disfinal fiximg=fiximage ffringe=fringe ooutname=outname sc_start=startscale sc_step=stepscale if(sc_step==0.)sc_step=0.05 steps=nsteps if(steps==0)steps=999 statsec=imsect hadd=addhead ddisplay=display disfinal=finaldisp zz=0 # check for imcalc & addcomment; if not defined abort task. go=yes if(!deftask("addcomment")) {go=no} if(!deftask("imcalc")) {go=no} if(go) { # Get initial scaling if(ddisplay) { print("===> Displaying fringe & original image sections & iterstating the latter...") display(ffringe//statsec,1) display(fiximg//statsec,2) } else { print("===> Iterstating original image section...") } iterstat (fiximg//statsec,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-,addh=hadd) oldrms=iterstat.sigma if(sc_start!=0.){ sscale=sc_start } else { imgets(fiximg,"FRINGMED",>&"dev$null") if(imgets.value!="0"){ sscale=real(imgets.value) } else { imgets(ffringe,"exptime") avg_exptime=real(imgets.value) imgets(fiximg,"exptime") indiv_exptime=real(imgets.value) sscale=indiv_exptime/avg_exptime } } print ("===> Begin loop of subtracting scaled fringe images...") x=1; y=2; ffit=yes # Optional multiple loop while(ffit) { # Loop over requested scalings for (w=1; w<1+steps; w+=1) { # if new image... if(w!=1){ # ...get new scaling sscale=sscale+sc_step } # subtract the scaled fringe image # print ("===> Scaling fringe image by "//sscale//" and subtracting...") imcalc(fiximg//statsec//","//ffringe//statsec,ooutname//"_"//str(sscale),"im1-im2*"//sscale,ver-) #imcalc(fiximg//","//ffringe,ooutname//"_"//str(sscale),"im1-im2*"//sscale,ver-) hedit(ooutname//"_"//str(sscale),"title","Defringed image using scale="//sscale,ver-,add+,update+,show-) # display & iterstat the subtracted image if(ddisplay){ # print ("===> Displaying & iterstating defringed image #"//str(sscale)//statsec//"...") y=y+1 if(y>4)y=1 displ (ooutname//"_"//str(sscale), y) #displ (ooutname//"_"//str(sscale)//statsec, y) } # iterstat (ooutname//"_"//str(sscale),nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-,addh=hadd) imstat (ooutname//"_"//str(sscale),fields="mean,stddev,npix",lower=INDEF,upper=INDEF,for-) | scan(mn,sig,npx) m = 1 while (m <= 10) { ll = mn-5*sig ul = mn+5*sig imstat (ooutname//"_"//str(sscale),fields="mean,stddev,npix",lower=ll,upper=ul,for-) | scan(mn,sig,nx) if (nx == npx) break npx = nx m = m + 1 } print ("RMS of image "//ooutname//"_"//str(sscale)//" is "//sig) imdel (ooutname//"_"//str(sscale),ver-) #iterstat (ooutname//"_"//str(sscale)//statsec,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-,addh=hadd) # newrms=iterstat.sigma newrms=sig if(steps==999){ if(newrms>=oldrms){ w=1001 beep } } oldrms=newrms x+=1 } # optional multiple loop -- try another set of values? ffit=fit if(ffit) { sc_start=startscale sscale=sc_start sc_step=stepscale if(sc_step==0.)sc_step=0.05 steps=nsteps if(steps==0)steps=999 } } # ask for sscale and create full-size final image sc_final=finalscale if(sc_final!=0){ print("Creating final image...") imcalc(fiximg//","//ffringe,ooutname,"im1-im2*"//sc_final,ver-) hedit(ooutname,"FRINGMED",sc_final,add+,ver-,show-,update+) addcomment(ooutname,"Defringed using FRINGMED-scaled copy of "//ffringe,ve-) # hedit(ooutname,"title","Defringed image using scale="//sscale,ver-,add+,update+,show-) } else { print("No images saved.") } if(disfinal){ print("===> Displaying original and defringed images...") displ(fiximg, 1) displ(ooutname, 2) } ## clean up #y=0; zz=0 #while(y& "dev$null") # y+=1 #} } else{ print("Tasks stsdas.toolbox.imgtools.imcalc & phiirs.addcomment aren't loaded,") print("and this task needs them to run. Please load them and start again.") } if(echog)beep end ./src/mysetcat0100744000151400000240000000013206560142322012521 0ustar phallgames#! /bin/csh setcat $1 > /dev/null < Find the seeing (type 'a') in the reference image using") print("===> the best registration object (visible in all images).\n") rimexam.radius=radius rimexam.buffer=buffer rimexam.width=width if (ptv) { imexam(rrefimage, frame=1, logfile=rrefcoords, keep+, display="ptv(image='$1',frame=$2)") } else { imexam(rrefimage, frame=1, logfile=rrefcoords, keep+) } } # Auto-detect stars if (!access(sstarfind)) { see_ing=seeing hwhm=see_ing/2. imgets (rrefimage, "ITERSIG", >& "dev$null") if (imgets.value=="0") { iterstat (rrefimage, addh+, print+, ver-) imgets (rrefimage, "ITERSIG", >& "dev$null") } threshold=5*(real(imgets.value)) print("STARFINDing stars in "//rrefimage//" w/threshold "//threshold) starfind (rrefimage, sstarfind, hwhm, threshold) } #fields (sstarfind, "1-2", >> rrefcoords) fields (sstarfind, "1-2") | grep ("-v", "'^$'", >> rrefcoords) # Add saturated or otherwise missing stars if(ddisplayim){ tvmark ("1", rrefcoords, col=204, txsize=1) print("\n===> Mark saturated or other stars missed by STARFIND...\n") rimexam.radius=radius rimexam.buffer=buffer rimexam.width=width imexam(rrefimage, logfile=rrefcoords, keep+) } # First method: ID objects from images if(uuseimages){ # ... interactively ... if(ddisplayim){ print("\n===> Find the best registration object marked earlier and hit 'a' to") print("===> get its position in each frame. Hit 'n' to go to the next frame") print("===> and 'q' when done. The file containing these positions") print("===> will be displayed for editing when done, in case of mistakes.\n") print("===> It is useful to note images with bad seeing, tracking, etc.\n") if (ptv) { imexam("@"//fflatlist, frame=1, logfile=aallcoords, keep+, display="ptv(image='$1"//im_section//"',frame=$2)") } else { imexam("@"//fflatlist, frame=1, logfile=aallcoords, keep+, display="display(image='$1"//im_section//"',frame=$2)") } } else { # ... or non-interactively ... print("===> Images not displayed.") } if(edit_files){ print(" ") print("===> In case of mistakes, both coordinate files can now be edited.") vi(rrefcoords) vi(aallcoords) } print(" ") print("===> Finding the coarse offsets...") fields (rrefcoords, "1-2") | scan (xref, yref) lintran(aallcoords,x1=0.001,y1=0.001,x2=xref,y2=yref,angle=180, >coarsefile) } # Second method: estimate shifts from telescope offsets if(!uuseimages){ iinputlist=inputlist print("Generating initial shift file from file "//inputlist//".") while (fscan (iinputlist, pixscale, astcoordx, astcoordy, nrows, ncols, adelx, adely) !=EOF) { stcoordx=astcoordx/pixscale stcoordy=astcoordy/pixscale delx=adelx/pixscale dely=adely/pixscale x=stcoordx xold=stcoordx y=stcoordy yold=stcoordy #procedure:i=1 (0,-dely); i=2 (-delx,+dely); i=3 (-delx,-dely); i=4(-delx,+dely) for (i=1; i<=nrows; i+=1) { for (j=1; j<=ncols; j+=1) { y=yold+dely*(-1)**(i+1) print(x, y, >> aallcoords) yold=y } x=xold+delx xold=x y=yold+dely*(-1)**(i+1) yold=y } } print("===> Edit the file with :wq twice.") vi("-c ':g/0\.\ /s//0.00 /g'", aallcoords) vi("-c ':g/0\.$/s//0.00/g'", aallcoords) print(" ") print("===> Type in the reference image offsets (printed 2 lines below) when") print("===> requested, to zero the coordinate system on the reference image.") del("tempsortlist", ver-, >& "dev$null") join(fflatlist, aallcoords, out="tempsortlist") grep(rrefimage,"tempsortlist") del("tempsortlist",ver-) print("===> Finding the coarse offsets...") lintran(aallcoords, x2=xref, y2=yref, angle=180, > coarsefile) } # Common ending for both approaches. print(" ") print("===> Finding the final offsets...") del(logoffname, ver-, >& "dev$null") imcentroid("@"//fflatlist, rrefimage, rrefcoords, shift=coarsefile, boxsize=bbs, > logoffname) del("temp.joinfile", ver-, >& "dev$null") del("temp.joinfile?", ver-, >& "dev$null") # read in length of temp.joinfile0 and cut out last two lines copy(logoffname,"temp.joinfile0") count("temp.joinfile0") | scan (nl) nx=nl-2 head("temp.joinfile0", nlines=nx, >> "temp.joinfile1") # find line on which the string "X-s" appears and cut out that line & all before !grep -n X-s temp.joinfile1 > temp.joinfile2 type("temp.joinfile2") | scan (sl) x=stridx(":",sl) sx=substr(sl,1,x) x=nx-real(sx) tail("temp.joinfile1", nlines=x, >> "temp.joinfile") # Cut down on number of output files print(" ", >> logoffname) print("#Coarse offsets:", >> logoffname) print(" ", >> logoffname) type(coarsefile, >> logoffname) del(coarsefile, ver-) # Create exact shifts list fields("temp.joinfile", "2,4", >> ooffname) del("temp.joinfile*", ver-) # Create integer shifts list list=ooffname while(fscan(list,x,y) !=EOF) { print(int(x),int(y), >> iintname) } # Create fractional shifts list join(iintname,ooffname,out="temp.joinfile") filecalc("temp.joinfile","$3-$1;$4-$2",forma="%6.2f%6.2f", >> ffracname) flpr; flpr; flpr # Create optimum rounded-off integer offsets print(" ") print("===> Finding optimum rounded-off integer offsets...") old_x = 999.; old_y = 999. # for each 0.01 pixel step... for (i=-50; i<50; i+=1) { step = i / 100. # print (i) # ...recalculate integer offsets... list=ooffname del (rroundname, ver-, >& "dev$null") del ("temp."//rroundname, ver-, >& "dev$null") while(fscan(list,xoff,yoff) !=EOF) { xoff=xoff+step yoff=yoff+step if(((abs(xoff))>=0.5) && ((abs(yoff))>=0.5)) { print(xoff,yoff, >> "temp."//rroundname) } else { if((abs(xoff))<=0.5) { xoff=0. } if((abs(yoff))<=0.5) { yoff=0. } print(xoff,yoff, >> "temp."//rroundname) } filecalc("temp."//rroundname, "$1;$2", format="%4.0f %4.0f", >> rroundname) flpr; flpr; flpr del ("temp."//rroundname, ver-, >& "dev$null") } del ("temp."//rroundname, ver-, >& "dev$null") # calculate sum of squares of residuals of exact offsets - new integer offsets filecalc (ooffname//","//rroundname, "$1@1-$1@2+"//step) | average (option = "new_sample", >& "dev$null") flpr; flpr; flpr new_x=average.sumsqrs filecalc (ooffname//","//rroundname, "$2@1-$2@2+"//step) | average (option = "new_sample", >& "dev$null") flpr; flpr; flpr new_y=average.sumsqrs if (new_x < old_x) { old_x = new_x step_x = step } if (new_y < old_y) { old_y = new_y step_y = step } } # recalculate final integer offsets list=ooffname del(rroundname,ver-) del ("temp."//rroundname, ver-, >& "dev$null") while(fscan(list,xoff,yoff) !=EOF) { xoff=xoff+step_x yoff=yoff+step_y if(((abs(xoff))>=0.5) && ((abs(yoff))>=0.5)) { print(xoff,yoff, >> "temp."//rroundname) } else { if((abs(xoff))<=0.5) { xoff=0. } if((abs(yoff))<=0.5) { yoff=0. } print(xoff,yoff, >> "temp."//rroundname) } filecalc("temp."//rroundname,"$1;$2",format="%4.0f %4.0f", >>rroundname) flpr; flpr; flpr del ("temp."//rroundname, ver-, >& "dev$null") } del ("temp."//rroundname, ver-, >& "dev$null") print(" ", >> logoffname) print("#Final offsets:", >> logoffname) print(" ", >> logoffname) type(ooffname, >> logoffname) del("temp.joinfile", ver-) join(fflatlist,rroundname,out=pprefix//".imshifts."//ssuffix) # Produce photometric time series from *allcoords* file fields(aallcoords, "7") | graph (title="Flux of centering object as f(image number)", point-) # Create fractional-pixel-shifted images if(ffracshift){ sshiftlist=fflatlist//ssuffix print(" ") print("===> Creating fractional-pixel-shifted images listed in "//sshiftlist//".") list=fflatlist while(fscan(list,img) !=EOF) { fileroot(img,validim+) img=fileroot.root ext=fileroot.extension if(ext!="")ext="."//ext print(img//ssuffix//ext, >> sshiftlist) } iinterp=interp bboundary=boundary imshift("@"//fflatlist, "@"//sshiftlist, shifts=ffracname, interp=iinterp, bound=bboundary) if(bbadmask!="") { hedit("@"//sshiftlist,"BPM",bbadmask,add+,ver-,show-,update+) hedit("@"//sshiftlist,"BPMASK",bbadmask,add+,ver-,show-,update+) } } print("...it is accomplished. Next you should run `ircoadd' using") if(ffracshift)print(sshiftlist//" and "//iintname//" or") print(fflatlist//" and "//rroundname//".") } else { print("WARNING: tasks `filecalc', `fileroot', or package `phat' (if ptv=yes)" print("are not loaded! Please load them and restart this task.") } if(echog)beep end ./src/btc_maskaligntrim.cl0100644000151400000240000002571707146577232015013 0ustar phallgamesprocedure btc_maskaligntrim(im1,im2,im3,prefix,suffix) # --trim images to areas with < 2/3 (rounded down) of input images # --align B & R image to overlap region only # --optionally align I image to that same region # # 980710: created # 980724: blank regions of final images now have mean = rest of image # 980726: option to delete intermediate 'good' images # 000816: func=polynomial in immatch.geomap string im1 {prompt="Primary (reference) image"} string im2 {prompt="Secondary image"} string im3 {prompt="Tertiary image (optional)"} string prefix {prompt="Prefix string for output files"} string suffix {prompt="Suffix string for output files"} bool domask=yes {prompt="Mask image areas w/<2/3 max # of input images?"} bool doalign=yes {prompt="Compute shifts to align images with each other?"} bool dotrim=yes {prompt="Trim images to primary-secondary overlap region?"} bool delold=no {prompt="Delete existing versions of intermediate files?"} bool intract=yes {prompt="Fit x-y shifts interactively?"} bool display=yes {prompt="Display final aligned images?"} bool delgood=yes {prompt="Delete intermediate `good' images?"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string bimage, rimage, iimage, s1, s2, s3, image, pl, imroot, imext string imrootr, imrootb, imrooti, pprefix, ssuffix real x, y, alignmin, alignavg int xmin, ymin, xmax, ymax, i, j, k, numim, imnow, maxfrac, n, imax, imay int bxmin, bxmax, bymin, bymax, rxmax, rxmin, rymax, rymin, xoff, yoff int rxminoff, rxmaxoff, ryminoff, rymaxoff, ixmin, ixmax, iymin, iymax int bxnewmin, bxnewmax, bynewmin, bynewmax, rxnewmin, rxnewmax int rynewmin, rynewmax, ixnewmin, ixnewmax, iynewmin, iynewmax, iyoutmax int ixminoff, ixmaxoff, iyminoff, iymaxoff, ixoutmin, ixoutmax, iyoutmin bool maskdo, aligndo, trimdo, delex, intact, dsplay, dgood bimage=im1 rimage=im2 iimage=im3 pprefix=prefix ssuffix=suffix maskdo=domask aligndo=doalign trimdo=dotrim delex=delold intact=intract dsplay=display dgood=delgood numim=2 image=bimage fileroot(bimage, validim+); imrootb=fileroot.root fileroot(rimage, validim+); imrootr=fileroot.root if(iimage!=""){ numim=3 fileroot(iimage, validim+); imrooti=fileroot.root } if(maskdo) { #--for each image, mask out areas with <2/3 (rounded down) of all images print ("Masking out areas including <2/3 (rounded down) of input images...") for (imnow=1; imnow<=numim; imnow+=1) { if(imnow==2){image=rimage} if(imnow==3){image=iimage} hsel (image, "plfmask", yes) | scan (pl) fileroot(image, validim+) imroot=fileroot.root imext=fileroot.extension fileroot(pl, validim+) pl=fileroot.root #--create trim masks from pixel list files if(delex)imdel(pl//"good.pl", ver-, >& "dev$null") if(!access(pl//"good.pl")){ minmax (pl, force+, update-, ver-) maxfrac = minmax.maxval/3. imdel ("tmp"//pl//".pl", ver-, >& "dev$null") imar (pl,"-",maxfrac,"tmp"//pl//".pl",ver-,noact-,calct="real",pixt="1") print ("Ignore the following warning sign...") minv ("tmp"//pl, pl//"good.pl") imdel ("tmp"//pl, ver-) } #--find x boundaries for trimming if(delex)imdel(pl//"trans.pl", ver-, >& "dev$null") if(!access(pl//"trans.pl"))imtransp(pl//"good.pl[*,-*]",pl//"trans.pl") minmax (pl//"trans.pl", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s1=substr(s3,i+1,j-1); s1="["//s1//":" minmax (pl//"trans.pl[*,-*]", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); k=real(s2) imgets (pl//"trans.pl", "i_naxis2") j=int(imgets.value); i=j-k+1; s1=s1//i//"," # imdel (pl//"trans.pl", ver-) #--find y boundaries for trimming minmax (pl//"good.pl", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); s1=s1//s2//":" minmax (pl//"good.pl[*,-*]", force+, update-, ver-) s3=minmax.maxpix; i=stridx(",",s3); j=stridx("]",s3) s2=substr(s3,i+1,j-1); k=real(s2) imgets (pl//"good.pl", "i_naxis2") j=int(imgets.value); i=j-k+1; s1=s1//i//"]" #--create trimmed images imdel("_tmp_"//image, ver-, >& "dev$null") imar(image,"*",pl//"good.pl","_tmp_"//image,ve-,noa-,calct="real",pixt="1") if(delex)imdel(imroot//"good", ver-, >& "dev$null") imcopy ("_tmp_"//image//s1, imroot//"good", ver+) hedit (imroot//"*", "goodsec", image//s1, add+, ver-, show-, upda+) imdel ("_tmp_"//image, ver-) } } if (aligndo) { print ("") print ("Running irshift2 to compute shifts needed to align images...") print ("") #--do irshift2 & immatch.geomap on b & r images irshift2 (imrootb//"good", imrootr//"good", pprefix//"br", ssuffix) hsel (imrootb//"good", "i_naxis1", "yes") | scan (imax) hsel (imrootb//"good", "i_naxis2", "yes") | scan (imay) immatch.geomap (pprefix//"br.geomapin."//ssuffix, pprefix//"br.geomapout."//ssuffix, 1, imax, 1, imay, func="polynomial", fitgeo="shift", ver-, interact=intact) #--do irshift2 & immatch.geomap on b & i images if(iimage!=""){ irshift2 (imrootb//"good", imrooti//"good", pprefix//"bi", ssuffix) immatch.geomap (pprefix//"bi.geomapin."//ssuffix, pprefix//"bi.geomapout."//ssuffix, 1, imax, 1, imay, func="polynomial", fitgeo="shift", ver-, interact=intact) } } if (trimdo) { print ("Trimming images to overlap regions...") #--figure out b & r trimming sections #--extract real x & y offsets fields(pprefix//"br.geomapout."//ssuffix, "1,2", lines="26-26") | scan (x,y) #--round off to nearest integer if(x>=0) { i=int(x+0.5) } else { i=-1*int(0.5-x) } if(y>=0) { j=int(y+0.5) } else { j=-1*int(0.5-y) } #--get smallest & largest pixel coords of input primary image bxmin=1; hsel (imrootb//"good", "i_naxis1", yes) | scan (bxmax) bymin=1; hsel (imrootb//"good", "i_naxis2", yes) | scan (bymax) bxnewmin=bxmin; bxnewmax=bxmax; bynewmin=bymin; bynewmax=bymax #--get ideal offset smallest pixel coords of output 2nd image rxminoff=1+i; ryminoff=1+j #--get largest pixel coords of input 2nd image hsel (imrootr//"good", "i_naxis1", yes) | scan (rxmax) hsel (imrootr//"good", "i_naxis2", yes) | scan (rymax) rxnewmin=rxminoff; rynewmin=ryminoff #--if ideal offset smallest pixel coords of output 2nd image <0, adjust to =1 if(rxminoff<=0) { xoff=1-rxminoff; rxnewmin=1 bxnewmin=bxmin+xoff } if(ryminoff<=0) { yoff=1-ryminoff; rynewmin=1 bynewmin=bymin+yoff } #--get ideal offset largest pixel coords of output 2nd image rxmaxoff=bxmax+i; rymaxoff=bymax+j; rxnewmax=rxmaxoff; rynewmax=rymaxoff #--if ideal offset largest 2nd image pixel coords > than input 2nd image... if(rxmaxoff>rxmax) { xoff=rxmaxoff-rxmax; rxnewmax=rxmax bxnewmax=bxnewmax-xoff } if(rymaxoff>rymax) { yoff=rymaxoff-rymax; rynewmax=rymax bynewmax=bynewmax-yoff } #--if the above has made the new b coord > max input b coord... if(bxnewmax>bxmax) { xoff=bxnewmax-bxmax; bxnewmax=bxmax rxnewmax=rxnewmax-xoff } if(bynewmax>bymax) { yoff=bynewmax-bymax; bynewmax=bymax rynewmax=rynewmax-yoff } #--trim imroot//"good" to imroot//"align" print("Creating, iterstating, imreplacing "//imrootb//"align") imcopy (imrootb//"good["//bxnewmin//":"//bxnewmax//","//bynewmin//":"//bynewmax//"]", imrootb//"align") hedit (imrootb//"*", "alignsec", imrootb//"good["//bxnewmin//":"//bxnewmax//","//bynewmin//":"//bynewmax//"]", add+, ver-, show-, update+) iterstat (imrootb//"align", nsigrej=5., maxiter=10, print-, ver-, addh+, lower=1, upper=INDEF) minmax (imrootb//"align", force+, update-, ver-) alignmin=minmax.minval if (alignmin<=0.) { print("Now imreplacing "//imrootb//"align") alignavg=iterstat.mean imreplace(imrootb//"align", alignavg, low=INDEF, upp=1., rad=0.) } print("Creating, iterstating, imreplacing "//imrootr//"align") imcopy (imrootr//"good["//rxnewmin//":"//rxnewmax//","//rynewmin//":"//rynewmax//"]", imrootr//"align") hedit (imrootr//"*", "alignsec", imrootr//"good["//rxnewmin//":"//rxnewmax//","//rynewmin//":"//rynewmax//"]", add+, ver-, show-, update+) iterstat (imrootr//"align", nsigrej=5., maxiter=10, print-, ver-, addh+, lower=1, upper=INDEF) minmax (imrootr//"align", force+, update-, ver-) alignmin=minmax.minval if (alignmin<=0.) { print("Now imreplacing "//imrootr//"align") alignavg=iterstat.mean imreplace(imrootr//"align", alignavg, low=INDEF, upp=1., rad=0.) } #--figure out i trimming sections; non-overlap regions have mean=rest of img if(iimage!=""){ print ("Now working on "//imrooti) #--create blank i image from b image imar (imrootb//"align", "-", imrootb//"align", imrooti//"align", pixt="1", calct="real", ver-, noact-) #--extract real x & y offsets fields(pprefix//"bi.geomapout."//ssuffix, "1,2", lines="26-26") | scan (x,y) #--round off to nearest integer if(x>=0) { i=int(x+0.5) } else { i=-1*int(0.5-x) } if(y>=0) { j=int(y+0.5) } else { j=-1*int(0.5-y) } #--get ideal output size of output 3rd image ixoutmin=1; hsel (imrootb//"align", "i_naxis1", yes) | scan (ixoutmax) iyoutmin=1; hsel (imrootb//"align", "i_naxis2", yes) | scan (iyoutmax) #--get ideal offset smallest & largest pixel coords to go into output 3rd image ixminoff=bxnewmin+i; iyminoff=bynewmin+j ixmaxoff=bxnewmax+i; iymaxoff=bynewmax+j ixnewmin=ixminoff;ixnewmax=ixmaxoff;iynewmin=iyminoff;iynewmax=iymaxoff #--get largest pixel coords of input 3rd image hsel (imrooti//"good", "i_naxis1", yes) | scan (ixmax) hsel (imrooti//"good", "i_naxis2", yes) | scan (iymax) #--if ideal offset smallest pixel coords of output 3rd image <0, adjust to =1 if(ixminoff<=0) { xoff=1-ixminoff; ixnewmin=1; ixoutmin=1+xoff } if(iyminoff<=0) { yoff=1-iyminoff; iynewmin=1; iyoutmin=1+yoff } #--if ideal offset largest pixel coords of output 3rd image > input 3rd image... if(ixmaxoff>ixmax) { xoff=ixmaxoff-ixmax; ixnewmax=ixmax; ixoutmax=ixoutmax-xoff } if(iymaxoff>iymax) { yoff=iymaxoff-iymax; iynewmax=iymax; iyoutmax=iyoutmax-yoff } print("Creating & iterstating "//imrooti//"align") imcopy (imrooti//"good["//ixnewmin//":"//ixnewmax//","//iynewmin//":"//iynewmax//"]", imrooti//"align["//ixoutmin//":"//ixoutmax//","//iyoutmin//":"//iyoutmax//"]") hedit (imrooti//"*", "alignsec", imrooti//"good["//ixnewmin//":"//ixnewmax//","//iynewmin//":"//iynewmax//"] -> ["//ixoutmin//":"//ixoutmax//","//iyoutmin//":"//iyoutmax//"]", add+, ver-, show-, update+) iterstat (imrooti//"align", nsigrej=5., maxiter=10, print-, ver-, addh+, lower=1, upper=INDEF) minmax (imrooti//"align", force+, update-, ver-) alignmin=minmax.minval if (alignmin<=0.) { print("Now imreplacing "//imrooti//"align") alignavg=iterstat.mean imreplace(imrooti//"align", alignavg, low=INDEF, upp=1., rad=0.) } } #--display if desired if(dsplay) { print("Displaying aligned images...") displ (imrootb//"align", 1) displ (imrootr//"align", 2) if(iimage!="")displ(imrooti//"align", 3) } #--delete good images if desired if(dgood) { print("Deleting intermediate `good' images...") imdel (imrootb//"good", ver-) imdel (imrootr//"good", ver-) if(iimage!="")imdel(imrooti//"good", ver-) } } if(echog)beep end ./src/btc_crzap.cl0100644000151400000240000000202507144614371013245 0ustar phallgamesprocedure btc_crzap(inlist, outlist) # btc_crzap -- de-cosmic-ray btc images using standard parameters # 980728: created string inlist {prompt="List of input images (no @ at beginning)"} string outlist {prompt="List of output crzap images (can be same as input)"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string in_list, out_list, both_list, inimg, outimg int nlines1, nlines2 in_list = inlist out_list = outlist count (in_list) | scan (nlines1) count (out_list) | scan (nlines2) if (nlines1!=nlines2) { beep print ("Task aborted -- different number of input & output images!") } else { both_list=mktemp("both") join (in_list, out_list, output=both_list) name = both_list while (fscan (name, inimg, outimg) != EOF) { crzap (inimg, outimg, zbox=3, obox=3, nsig=3.5, nnegsig=0., nrings=1, nobjsig=2, skyfiltsize=10, skysubsam=3, ngrowobj=0, deletemask-, cleanpl+, cleanimh+, ver+, unzap-, checklimit+, statsec="[900:1150,900:1150]", echog-) } del (both_list, ver-) if(echog)beep } end ./src/quickfringe.cl0100644000151400000240000000776707100070747013622 0ustar phallgames# quickfringe.cl -- interactively adjust defringing ...and fast! # 950322: created from tpl.cl # 970227: added iterstat determination of RMS of each defringing test procedure quickfringe(fiximage,fringe,outname) string fiximage {prompt="Name of (original) image to be defringed"} string fringe {prompt="Fringe image to scale and subtract"} string outname {prompt="Name of defringed image to create"} bool dis=yes {prompt="Display fringe and original image at start?",mode="q"} bool fit=yes {prompt="Adjust parameters and refit image?",mode="q"} real scale {prompt="Scaling to use on fringe image",mode="q"} int z {0,prompt="Number of image to save?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} begin string logimex, logsurf, countfile, rrootname, iimagelist, ooutname, ffunc string wweighting, fiximg, ffringe, titlestring real max, nncols, nnlines, sscale, indiv_exptime, avg_exptime, sum_exptime real skyfring, ll, ul, mn, sig, nx, npx int x, y, zz, xxord, yyord, xx, m bool go, ffit, xxterms, ddis fiximg=fiximage ffringe=fringe ooutname=outname ddis=dis zz=0 # check for addcomment; if not defined abort task. go=yes if(!deftask("addcomment")) {go=no} if(go) { # Get initial scaling if(ddis){ print("===> Displaying fringe image and original image...") display(ffringe,1) display(fiximg,2) } imgets(fiximg,"FRINGMED",>&"dev$null") if(imgets.value!="0"){ sscale=real(imgets.value) } else { print(" ") print("===> Calculating initial fringe image scaling...") imgets(ffringe,"exptime") avg_exptime=real(imgets.value) imgets(fiximg,"exptime") indiv_exptime=real(imgets.value) imgets(fiximg,"SKYFRING") # iterstat(fiximg,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) # new scaling = new median from iterstat * old scaling * exptime * avg_exptime # sscale=iterstat.median*(real(imgets.value))*indiv_exptime/avg_exptime skyfring=real(imgets.value) imgets(fiximg,"itermed") sscale=(real(imgets.value))*skyfring*indiv_exptime/avg_exptime } #need to create countfile x=1 y=2 ffit=yes # Fitting loop while(ffit) { if(x!=1){ # get new scaling sscale=scale # vi(countfile//"_"//str(x)) } # scale and subtract the fringe image print ("===> Scaling the fringe image by "//sscale//" and subtracting...") # imar (ffringe, "/", sscale, ffringe//"_"//str(x), ver-) # imar (ooutname//"_0", "-", ffringe//"_"//str(x), ooutname//"_"//str(x), ver-) imcalc(fiximg//","//ffringe,ooutname//"_"//str(x),"im1-im2*"//sscale,ver-) hedit(ooutname//"_"//str(x),"title","Defringed image using scale="//sscale,ver-,add+,update+,show-) # inspect the subtracted image print ("===> Displaying defringed image #"//str(x)//"...") y=y+1 if(y>4)y=1 displ (ooutname//"_"//str(x), y) print ("===> Computing RMS of defringed image #"//str(x)//"...") # iterstat (ooutname//"_"//str(x),nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) imstat (ooutname//"_"//str(x),fields="mean,stddev,npix",lower=INDEF,upper=INDEF,for-) | scan(mn,sig,npx) m = 1 while (m <= 10) { ll = mn-5*sig ul = mn+5*sig imstat (ooutname//"_"//str(x),fields="mean,stddev,npix",lower=ll,upper=ul,for-) | scan(mn,sig,nx) if (nx == npx) break npx = nx m = m + 1 } beep print ("===> RMS of defringed image #"//str(x)//" is "//sig) beep # abort loop? ffit=fit x+=1 } # clean up zz=z if(zz!=0){ imren(ooutname//"_"//str(zz),ooutname,ver-) hedit(ooutname,"FRINGMED",sscale,add+,ver-,show-,update+) addcomment(ooutname,"Defringed using FRINGMED-scaled copy of "//ffringe,ver-) imgets(fiximg,"title") titlestring=str(imgets.value) hedit(ooutname,"title",titlestring,add+,ver-,update+,show-) } else{ print("No images saved.") } y=0 zz=0 while(y& "dev$null") y+=1 } } else{ print("The tasks `addcomment' are not loaded,") print("and this task needs them to run. Please load it and start again.") } if(echog)beep end ./src/scab.cl0100644000151400000240000005726207152520735012222 0ustar phallgamesprocedure scab(imlist) # scab -- scab over bleeding columns # 980807: created # 980809: fixed so that no pixel subscripts should ever be out of bounds # 980923: added imexam option # 990608: added CLOTDONE header card # 000811: renamed scab.cl from clot.cl ; changed header card name to SCABDONE # (but maintained compatibility with CLOTDONE) # 000813: if a saturated area ends while more than 1 pixel wide # and then starts up again after only 1 row, wacky hijinks ensue. # **speed up # **add mask # **below-sky? (see below) string imlist {prompt="Images on which to work (im1,im2,im3)"} string prefix="scab_" {prompt="Prefix for bleeding star lists for images"} int strip_width=9 {prompt="Default width of strip around bleeding stars"} real uplimit=4000 {prompt="Minimum value above mean for bleeding columns"} real bleedlimit {prompt="Minimum value found in bleeding columns",mode="q"} bool dodisp=yes {prompt="Display images for imexam?"} bool doimexam=yes {prompt="Interactively mark bleeding stars w/imexam?"} bool doscab=yes {prompt="Do interpolation (scabbing) step?"} bool interact=no {prompt="Interactively select bleeding limits?"} bool findisp=yes {prompt="Display before & after images when done?"} bool echog=yes {prompt="Beep when task is done?"} struct *list struct *list2 begin string img, sat_list, im_age, pre_fix, im_list, image, satlist, oldsatlist int n, nn, x, y, xleft, xright, m, mm, xstar, ystar, xcen, ymin, ymax, xstep, i int xmin, xmax, stripwidth, xlimleft, xlimright, xtmp, ytmp, xhitmp, xlotmp, l int frame, xleftstart, xrightstart, xleftold, xrightold int xleftlim, xrightlim real leftval, rightval, bleed_limit, pixval, scabval, mean, sig, val_z1, val_z2 real up_limit, oldpixval, testpixval bool fin_disp, inter_act, do_imexam, do_disp, do_scab im_list = mktemp("imlist") sections (imlist, >> im_list) pre_fix = prefix stripwidth = strip_width up_limit = uplimit do_disp = dodisp do_imexam = doimexam do_scab = doscab inter_act = interact fin_disp = findisp if (do_disp) { list=im_list frame=1 while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root imgets (im_age, "itermean") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (im_age, "itersig") if ((imgets.value)!="0") { sig=real(imgets.value) val_z1=mean-4*sig val_z2=mean+up_limit displ(im_age,frame,zr-,zs-,z1=val_z1,z2=val_z2) } else { beep print ("ITERSIG not found for "//im_age) display(im_age,frame) } } else { beep print ("ITERMEAN not found for "//im_age) display(im_age,frame) } frame=frame+1 } } if (do_imexam) { list=im_list; satlist=""; oldsatlist="" while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root satlist=pre_fix//im_age if (access(oldsatlist)) { type (oldsatlist, >> satlist) type (oldsatlist) } imexam (im_age, keeplog+, logf=satlist) vi ("-c ':g/$/s// "//stripwidth//"/g'", satlist) oldsatlist=satlist } } if (do_scab) { # do each saturated star list list=im_list while (fscan (list,image) != EOF) { imgets (image, "CLOTDONE", >& "dev$null") if (imgets.value=="yes") { hedit(img, "SCABDONE", "yes", add+, ver-, show-, upd-) } imgets (image, "SCABDONE", >& "dev$null") if (imgets.value!="yes" && !imaccess("_orig"//image)) { print("Now scabbing over image "//image) fileroot(image,validim+) im_age=fileroot.root satlist=pre_fix//im_age img = "_tmp"//image # get approx coords of saturated stars (x align more impt than y align) list2=satlist l=0 while (fscan (list2,xstar,ystar,stripwidth) != EOF) { m = stripwidth; mm=(m-1)/2 l = l+1 if (stripwidth != 0) { # imhistogram m-pixel-wide strip centered on star's x position print("Working on strip for star #"//l//" ("//xstar//","//ystar//")") if (l==1) { xmin=1; ymin=1 imgets (image, "i_naxis1") xmax=real(imgets.value) imgets (image, "i_naxis2") ymax=real(imgets.value) mean=0 imgets (image, "itermean") if((imgets.value)!="0") mean=real(imgets.value) } if (l==1 || inter_act) { xlotmp=max(xstar-mm,xmin); xhitmp=min(xstar+mm,xmax) imhistogram (image//"["//xlotmp//":"//xhitmp//",*]", z1=INDEF, z2=INDEF, binwidth=INDEF, nbins=512, autoscale+, top_closed-, hist_type="normal", listout-, plot_type="line", logy+, device="stdgraph") # select lower bleedcol cutoff (= bleed_limit) if (inter_act) { beep bleed_limit=bleedlimit } else { bleed_limit=mean+up_limit print("Minimum bleeding column value is "//bleed_limit) } } if (l==1) { print ("Copying to temporary working image...") imdel (img, ver-, >& "dev$null"); imcopy (image, img, ver-) } # --n=1: start with m-pixel-wide strip centered on star x,y # --n=1: check central pixel and find xleft & xright # --n>1: if xleft=xright check for > bleed_limit & you're done # check xleft: if < bleedlimit # keep checking right until > bleedlimit or until xright; # if xleft < xright then do same going left from xright # save xleft & xright for next iteration for (y=ystar; y<=ymax; y+=1) { # --n=1: start with m-pixel-wide strip centered on star x,y if (y==ystar) { print ("Scabbing...") xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # --check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymax+1 } } # --if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # --repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } # --save xleft & xright for next iteration xrightstart=xright ; xleftstart=xleft xrightold=xright ; xleftold=xleft # --n>1: } else { xcen=xstar; xleft=xleftold; xright=xrightold; leftval=0; rightval=0 # --n>1: if xleftold=xrightold check for > bleed_limit & you're done if (xleftold==xrightold) { imstat(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval >= bleed_limit) { imreplace(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } else { y=ymax+1 } } else { # check xleftold imstat(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", fields="mean", format-) | scan (testpixval) # if >= bleedlimit ... if (testpixval >= bleed_limit) { # ... keep checking left until xlimleft or < bleedlimit # stay within image boundaries xlimleft=max(xcen-mm,xmin); xlotmp=max(xleft-1,xmin) for (x=xlotmp; x>=xlimleft; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit, set new xleft if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xlimleft) { leftval = bleed_limit; xleft = xlimleft } if (x==xlimleft) break } # if < bleedlimit ... } else { # ... keep checking right until xright or > bleedlimit oldpixval = testpixval xlimright=min(xright,xmax); xlotmp=min(xleft+1,xmax) for (x=xlotmp; x<=xlimright; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) { leftval = oldpixval; xleft = x-1 } if (pixval > bleed_limit) break if (x==xlimright) { leftval=bleed_limit; xleft=xlimright } if (x==xlimright) break oldpixval = pixval } } # if xleft < xright then do same for rightval if (xleft < xrightold) { # check xrightold imstat(img//"["//xrightold//":"//xrightold//","//y//":"//y//"]", fields="mean", format-) | scan (testpixval) # if >= bleedlimit ... if (testpixval >= bleed_limit) { # ... keep checking right until xlimright or < bleedlimit # stay within image boundaries xlimright=min(xcen+mm,xmax); xlotmp=min(xright+1,xmax) for (x=xlotmp; x<=xlimright; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit, set new xright if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xlimright) { rightval = bleed_limit; xright = xlimright } if (x==xlimright) break } # if < bleedlimit ... } else { # ... keep checking left until xleft or > bleedlimit oldpixval = testpixval xlimleft=max(xleft,xmin); xlotmp=max(xright-1,xmin) for (x=xlotmp; x>=xlimleft; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) { rightval = oldpixval; xright = x+1 } if (pixval > bleed_limit) break if (x==xlimleft) { rightval=bleed_limit; xright = xlimleft } if (x==xlimleft) break oldpixval = pixval } } } # --replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } # --save xleft & xright for next iteration xrightold=xright ; xleftold=xleft # --end of xleft!=xright branch (218) } # --end of n>1 subloop in upward loop (207) } #print (y//" "//xleft//" "//xright//" "//leftval//" "//rightval) # --next row (next y) (153) } # --now work downwards along the edge of the replacement region ytmp=max(ystar-1,ymin) for (y=ytmp; y>=ymin; y-=1) { # --n=1: start w/same left & right limits as upwards branch did if (y==ytmp) { xleftold=xleftstart; xrightold=xrightstart } xcen=xstar; xleft=xleftold; xright=xrightold; leftval=0; rightval=0 # --n>1: if xleftold=xrightold check for > bleed_limit & you're done if (xleftold==xrightold) { #print("a") imstat(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval >= bleed_limit) { imreplace(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } else { y=ymin-1 } } else { #print("b") # check xleftold imstat(img//"["//xleftold//":"//xleftold//","//y//":"//y//"]", fields="mean", format-) | scan (testpixval) # if >= bleedlimit ... if (testpixval >= bleed_limit) { #print("c") # ... keep checking left until xmin or < bleedlimit # stay within image boundaries xlimleft=max(xcen-mm,xmin); xlotmp=max(xleft-1,xmin) for (x=xlotmp; x>=xlimleft; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit, set new xleft if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xlimleft) { leftval = bleed_limit; xleft = xlimleft } if (x==xlimleft) break } # if < bleedlimit ... } else { #print("d") # ... keep checking right until xright or > bleedlimit oldpixval = testpixval xlimright=min(xright,xmax); xlotmp=min(xleft+1,xmax) for (x=xlotmp; x<=xlimright; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) { leftval = oldpixval; xleft = x-1 } if (pixval > bleed_limit) break if (x==xlimright) { leftval=bleed_limit; xleft=xlimright } if (x==xlimright) break oldpixval = pixval } } # if xleft < xright then do same for rightval if (xleft < xrightold) { #print("e") # check xrightold imstat(img//"["//xrightold//":"//xrightold//","//y//":"//y//"]", fields="mean", format-) | scan (testpixval) # if >= bleedlimit ... if (testpixval >= bleed_limit) { #print("f") # ... keep checking right until xmax or < bleedlimit # stay within image boundaries xlimright=min(xcen+mm,xmax); xlotmp=min(xright+1,xmax) for (x=xlotmp; x<=xmax; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit, set new xright if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xlimright) { rightval = bleed_limit; xright = xlimright } if (x==xlimright) break } # if < bleedlimit ... } else { #print("g") # ... keep checking left until xleft or > bleedlimit oldpixval = testpixval xlimleft=max(xleft,xmin); xlotmp=max(xright-1,xmin) for (x=xlotmp; x>=xlimleft; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) { rightval = oldpixval; xright = x+1 } if (pixval > bleed_limit) break if (x==xlimleft) { rightval=bleed_limit; xright = xlimleft } if (x==xlimleft) break oldpixval = pixval } } # -- end of "xleft < xrightold" loop (368) } # --replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } # --save xleft & xright for next iteration xrightold=xright ; xleftold=xleft # --end of xleftold!=xrightold branch (328) } #print (y//" "//xleft//" "//xright//" "//leftval//" "//rightval) # --next row (next y) (318) } # --end of "if stripwidth != 0" loop (115) [extra indentation] } # **also repeat using min_sky instead of bleed_limit for oversubtracted regions # in SNe images, reversing the sign so to speak # --repeat for next star in satlist (111) } hedit(img, "SCABDONE", "yes", add+, ver-, show+, upd+) if (fin_disp) { if(imaccess(img)){ display (image, 1) display (img, 2) } } if(imaccess(img)){ imren (image, "_orig"//image, ver+) imren (img, image, ver+) } # --end of "Now scabbing over" loop (102) } else { print("SCABDONE header card and/or _orig"//image//" already exist;") print("scabbing already done on "//image//" -- not redone.") } # --repeat for next satlist (next list in im_list) (96) } # --end of do_scab loop (93) } del (im_list, ver-) if (echog) beep end ./src/focasflat.cl0100644000151400000240000001330307152533017013235 0ustar phallgamesprocedure focasflat (rootname, routname) # program to flatten a big (~2048^2) CCD image, ~20 minutes per image. # requires focas, iterstat, iraf2unix and mysetcat # 981108: added check for above, and copying if needed. # 981109: added stop if FOCASFLT header parameter already exists # 981110: added optional check and doit step, and if the ALIGNSEC header # contains "->" (which indicates the data does not occupy the full image, # i.e. the I-band doesn't cover the full B & R-band overlap region), then # iterstat is done on the good data region only (taken from ALIGNSEC) # 990808: now deletes "tmpsfiles" before attempting to create it # 000828: explicit display of final iterated statistics string rootname {prompt="Name of original image (no .imh included)"} string routname {prompt="Name of output image (no .imh included)"} bool check {no,prompt="Inspect sky image before continuing?"} bool doit {yes,prompt="Do subtraction after inspection?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} begin real ftime, sig, a, mn int xmax, ymax, k, word, chars, num1, num2, st, d, o string image, root, l, catpars, tempname, i, h, f, m, rroutname string alignsec bool go, ddoit, cheque struct c file temp.file, tmpsfiles root = rootname rroutname = routname//".imh" imgets(root, "i_naxis1") xmax = real(imgets.value) imgets(root, "i_naxis2") ymax = real(imgets.value) imgets(root, "exptime") ftime = real(imgets.value) imgets(root, "itersig") if (imgets.value!="0") { sig = real(imgets.value) imgets(root, "itermean") mn = real(imgets.value) } else { imgets(root, "alignsec") if ((stridx("->",imgets.value))!=0) { alignsec=substr(imgets.value,3+stridx("->",imgets.value),strlen(imgets.value)) iterstat(root//alignsec,addh+,ver-,print-) } else { iterstat (root, addh+, ver-, print-) } imgets(root, "itersig") sig = real(imgets.value) imgets(root, "itermean") mn = real(imgets.value) } cheque=check ddoit=yes go=yes if(!defpac("focas")) {go=no; print "FOCAS package not loaded!"} imgets (root, "FOCASFLT", >& "dev$null") if((imgets.value)!="0") {go=no; print "FOCASFLAT already run on image!"} if(go) { if(!access("iraf2unix")) {copy ("phat$src/iraf2unix", ".", ver+)} if(!access("mysetcat")) {copy ("phat$src/mysetcat", ".", ver+)} print ("Now working on image "//root//". Rotating images...") imdel ("rtff*.imh", ver-, >& "dev$null") imcopy (root, "rtff"//"a.imh", verbose-); imtrans ("rtff"//"a.imh[*,-*]", "rtff"//"b.imh") imtrans ("rtff"//"b.imh[*,-*]", "rtff"//"c.imh"); imtrans ("rtff"//"c.imh[*,-*]", "rtff"//"d.imh") # flatten the images using the FOCAS-based flattening routine. for (k=1; k <= 4; k+=1) { if (k<1.4) m = "a" if (k>1.5) m = "b" if (k>2.5) m = "c" if (k>3.5) m = "d" del ("temp.file", ver-, >& "dev$null") print ("Running FOCAS on image "//m//" to create its sky image...") print ("rtff"//m//".cat", " ", "rtff"//m, " ", "f", " ", ftime, " ", sig, >> "temp.file") !set catpars=`awk -f iraf2unix temp.file`; mysetcat $catpars print ("detect rtff"//m//".cat 1 "//ymax//" "//mn-5*sig//" "//mn+5*sig, >> "do_detmp.cl") cl (< "do_detmp.cl") del ("do_detmp.cl", ver-) sky ("rtff"//m//".cat") evaluate ("rtff"//"a.cat") del ("temp.file", ver-, >& "dev$null") } imdel ("rtff"//"b.imh", ver-); imdel ("rtff"//"c.imh", ver-); imdel ("rtff"//"d.imh", ver-) # rotate sky images back to common orientation print ("Rotating sky images back to common orientation...") imtrans ("rtff"//"d.sky.imh[*,-*]", "rtff"//"d.sky.imh"); imtrans ("rtff"//"b.sky.imh[-*,*]", "rtff"//"b.sky.imh") imtrans ("rtff"//"c.sky.imh[-*,*]", "rtff"//"c.sky.imh"); imtrans ("rtff"//"c.sky.imh[-*,*]", "rtff"//"c.sky.imh") del ("tmpsfiles", ver-); files ("rtff"//"*.sky.imh", > "tmpsfiles") # combine them into one print ("Combining sky images into one...") imcom ("@tmpsfiles", "rtff"//".avsky.imh", combine="median", reject="minmax", nlow=0, nhigh=1, scale="none", weight="none", zero="none") # scale it to the original image size print ("Scaling sky image to original image size...") blkrep ("rtff"//".avsky.imh", "rtff"//".avskye.imh", 8, 8) imstat ("rtff"//".avsky.imh", fields="mode", format-) | scan (a) imdel ("rtff"//".avsky.imh", ver-) imcopy("rtff"//".avskye.imh[1:"//xmax//",1:"//ymax//"]", root//".sky.imh", ver-) imdel("rtff"//".avskye.imh", ver-) # check sky image before continuing if(cheque) { print ("Displaying original image and focasflat sky image...") display (root, 1) display (root//".sky.imh", 2) ddoit=doit } # clean up temporary images imdel ("@tmpsfiles", ver-); imdel ("rtff"//"*.sky.imh", ver-) del ("tmpsfiles", ver-); del ("rtff"//"*.ar", ver-); del ("rtff"//"*.cat", ver-) # subtract the focas sky image from the original image & add back in the mode if(ddoit){ print ("Subtracting sky image from original & adding mode back in...") imar ("rtff"//"a", "-", root//".sky", rroutname) imdel ("rtff"//"a.imh", ver-); imdel ("rtff"//"*sky.imh", ver-) imar (rroutname, "+", a, rroutname) minmax (rroutname, force+) imgets(rroutname, "alignsec") if ((stridx("->",imgets.value))!=0) { alignsec=substr(imgets.value,3+stridx("->",imgets.value),strlen(imgets.value)) iterstat (rroutname//alignsec,addh+,ver-,print-) } else { iterstat (rroutname, addh+, ver-, print-) } hedit (rroutname,"FOCASFLT","yes",add+,del-,ver-,show+,update+) } else { print ("Sky image not subtracted.") imdel ("rtff"//"a.imh", ver-); imdel ("rtff"//"*sky.imh", ver-) } if(echog)beep } else { beep } end ./src/btc_gainflip.cl0100644000151400000240000001022407144614371013717 0ustar phallgamesprocedure btc_gainflip(filename) # scale btc chips to gain=1, and flip as desired # 980731: added fixpix option # 990525: add BPMASK to header as well as BPM string filename {prompt="List of root names of image sets"} string bpmroot="" {prompt="Root name of bad pixel masks to add to header"} string getstats="" {prompt="File name for iterstat output if desired"} bool gainmult=yes {prompt="Multiply all chips by their gain?"} bool flipns=yes {prompt="Flip chip #4 N-S (up-down)?"} bool flipew=yes {prompt="Flip all chips E-W (left-right)?"} bool badpixfix=yes {prompt="Interpolate over bad pixels using fixpix?"} bool echog {yes,prompt="Beep when task is done?"} struct *name # filename should list the names of the root image to be worked on begin string root, image, scales, bbpmroot, ggetstats real iteravg, chipscale bool bbadpixfix bbpmroot=bpmroot ggetstats=getstats bbadpixfix=badpixfix # -- cycle through image sets name = filename while (fscan (name, root) != EOF) { for (i=1; i<=4; i+=1) { image = root//"_"//i # image = root//"_"//i//".imh" # -- multiply image and existing iterstat header keywords by gain if (gainmult) { imgets(image, "gainold", >& "dev$null") if ((imgets.value)=="0") { imgets(image, "gain", >& "dev$null") imar (image,"*",real(imgets.value),image,ver-,noact-) hedit (image,"gainold","(gain)",add+,ve-,sho+,updat+) hedit (image,"gain",1.0,add+,ve-,sho+,updat+) imgets(image, "itermean", >& "dev$null") if ((imgets.value)!="0") { hedit(image,"itermean","(itermean*gainold)",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode*gainold)",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig*gainold)",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed*gainold)",add+,ve-,sho-,updat+) hedit(image,"variance","(variance*gainold*gainold)",ad+,ve-,sho-,updat+) } } else { print (image//" already multiplied by gain!") } } # -- flip chip #4 N-S if (flipns) { if(i==4) { imgets(image, "flipns", >& "dev$null") if ((str(imgets.value)) != "yes") { imgets(image, "flip", >& "dev$null") if ((str(imgets.value)) != "yes") { imcopy (image//"[*,-*]", image, ver-) hedit(image,"flipns","yes",add+,ve-,sho+,updat+) hedit(image,"flip","yes",add+,ve-,sho+,updat+) print (image//" flipped N-S...") } else { print (image//" already flipped N-S!") hedit(image,"flipns","yes",add+,ve-,sho+,updat+) } } else { print (image//" already flipped N-S!") hedit(image,"flip","yes",add+,ve-,sho+,updat+) } } } # -- flip all chips E-W if (flipew) { imgets(image, "flipew", >& "dev$null") if ((str(imgets.value)) != "yes") { imcopy (image//"[-*,*]", image, ver-) hedit (image,"flipew","yes",add+,ver-,show-,update+) print (image//" flipped E-W...") } else { print (image//" already flipped E-W!") } # -- add bad pixel mask names to headers if (bbpmroot!="") { hedit(image,"BPM",bbpmroot//"_"//i//".pl",add+,ver-,sho+,updat+) hedit(image,"BPMASK",bbpmroot//"_"//i//".pl",ad+,ve-,sho+,upda+) } } # -- fixpix if desired if (bbadpixfix) { print (image//" is having its bad pixels fixed...") imgets(image, "fixpix", >& "dev$null") if ((imgets.value)=="0") { imgets(image, "BPM", >& "dev$null") if ((imgets.value)!="0") { fixpix (image, "BPM", linterp=1, cinterp=INDEF, ver+, pixels+) } else { print (image//" does not contain BPM header keyword!") } } else { print (image//" has already had FIXPIX done!") } } } # -- iterstat if desired if (ggetstats!="") { print (root//" images flipped and gain-multiplied. Running iterstat.") iterstat (root//"_1", print+, ver-, addh+, >> ggetstats) iterstat (root//"_2", print+, ver-, addh+, >> ggetstats) iterstat (root//"_3", print+, ver-, addh+, >> ggetstats) iterstat (root//"_4", print+, ver-, addh+, >> ggetstats) # iterstat (root//"_?.imh", print+, ver-, addh+, >> ggetstats) } } if(echog)beep end ./src/mysetcatbp.gz0100744000151400000240000000016306560142201013462 0ustar phallgames@,mysetcatbpSVTOO.*N-IN,QP1TSOI-+QqwR1R1BC J.CNN.NC0 2 sRFq./src/optcoaddirtf.cl0100644000151400000240000015713206561403776014001 0ustar phallgames# optcoadd -- coadd images with sub-pixel shift options and much, much more # # Calls addcomment, iterstat, fileroot, filecalc, stsdas.toolbox.imgtools.imcalc # # 960712: created from phiirs$ircoadd.cl # 960716: deleted internal scaling check, added subtracted-image creation # 960723: fixed edge problem in sky-subtracted image # 960806: made sky-subtracted image creation optional # 960807: fixed minor bug of ccomblist2 not existing in expmap creation only # 960812: fixed exposure map creation & created normalization map creation # 960815: fixed bug in normalization of expmap when dividing into outimage # 960816: changed so that statfile is used only if directly requested, # and added optional insertion of variances into image headers # 960817: fixed occasional bug in skysub + weighted-expmap normalization # 960822: moved check for necessary tasks earlier to avoid errors # 970425: added check for tpl image # 970429: changed expmap -- now sets bad pixels to -99999. # Also several other minor changes to bring in line with ircoadd # 970505: changed default expmap suffix from "em" to "exp" to avoid confusion # with ircoadd, whose output expmap is different than optcoadd's # 970507: changed creation of individual expmaps to replace pixels above # -10000. with exptime -- allows for -99999. bad pixels to be excluded # 970623: added ability to use imcombine snoise parameter # 971031: IRTF version: filecalc and imcalc not used, so tpl can't be done # # **Could cut down on transient memory needs by finding "wtfactor" needed to # convert _nm image to _wt image -- stack norm, then do wtfactor & stack wt # **Note that weights should add to 1 if taken from a file (probably matters # only when stacking and creating expmap, but do it always just to be safe) procedure optcoadd(comblist,outimage,expmap,normmap,shiftlist,scaling,zeroing,weighting,magfac,stack,logfile) string comblist {prompt="List of images to combine"} string outimage {prompt="Output coadded image"} string expmap {prompt="Output exposure map (default=outimage//exp)"} string normmap {prompt="Output normalization map (default=outimage//norm)"} string shiftlist {prompt="File with image shifts"} string scaling {prompt="Imcombine scaling (none|@file|!|etc.)"} string zeroing {"mode",prompt="Imcombine zero offsets (none|@file|mode|etc.)"} string weighting {prompt="Imcombine weighting (none|@file|!|etc.)"} int magfac {1,min=1,max=10,prompt="Magnification factor for subpixel shifting"} bool stack {prompt="Combine images by stacking & projecting?"} string logfile {prompt="Name of log file"} string normname {prompt="Header keyword for normalization factor",mode="q"} bool newmask=no {prompt="Override bad pixel masks listed in image headers?"} string badmask {prompt="Bad pixel mask to use instead",mode="q"} bool spshift=no {prompt="Do image shifts account for subpix shifting?",mode="q"} bool prescale=no {prompt="Scale images before, not during, imcombine?",mode="q"} bool unscale=yes {prompt="Undo scaling factors when done?",mode="q"} real extcoeff {prompt="Extinction coefficient for default scalings",mode="q"} real airzero {INDEF,min=0.,max=99.,prompt="Airmass to scale to? (INDEF=min. observed)",mode="q"} bool scalecombine=no {prompt="Combine default & additional scalings?",mode="q"} string morescalename {prompt="@filename or !keyword for additional scalings",mode="q"} bool putscale {prompt="Insert scaling factors into image headers?",mode="q"} string wordscale="SCALEFAC" {prompt="Scaling factor header keyword",mode="q"} bool defscale=no {prompt="Do scales include default airmass scaling?",mode="q"} bool prezero=no {prompt="Do zero offseting before, not during, imcombine?",mode="q"} bool unzero=yes {prompt="Undo zero offsets when done?",mode="q"} bool putzero=no {prompt="Insert zero offsets into image headers?",mode="q"} string wordzero="ZEROVAL" {prompt="Zero offset header keyword",mode="q"} bool putweight=no {prompt="Insert weights into image headers?",mode="q"} string wordweight="WEIGHT" {prompt="Weighting factor header keyword",mode="q"} string stackimage {prompt="Name of stacked image", mode="q"} bool unstack {prompt="Delete stacked image & expmap when done?",mode="q"} bool spscale=no {prompt="Do zero offsets account for subpix shifting?",mode="q"} string expname="EXPTIME" {prompt="Header keyword for exposure time"} bool maskedstat=no {prompt="Use maskstat to find default zeros & wts?"} string statfile="" {prompt="File for image statistics"} bool stdpars=yes {prompt="Use std imcombine parameters for coadd?"} bool makeavg=no {prompt="Make pure coadd (comb=average,rej=none)?"} bool flip=no {prompt="Flip image L-R after coadd?"} bool cleanup=yes {prompt="Clean up new created blkrep'd images after use?"} bool tpl=no {prompt="Account for throughput correction in norm. map?"} bool echog {yes,prompt="Beep when task is done?"} pset optcoaddpars {prompt="Imcombine parameters"} struct *list begin string sshiftfraclist, iinterp, sshiftlist, subimg, explist, sect, skysubimg string ccomblist, bbadmask, sshiftintlist, ooutimage, zzeroing, sstackimage string llogfile, check, zzeroname, sscalefile, sscalename, img, eexpname, blk string s_sigma, s_plfile, s_combine, s_reject, s_offsets, s_masktyp, eexpmap string s_scale, s_weight, s_statsec, s_expname, sscaling, intcosca, expmask string listimshift, wwordscale, wwordzero, subimgold, expmaskold, checkmore string ccomblist1, ccomblist2, sshiftexactlist, image, newbp, newzzeroname string oldbp, bprotlist, file_of_zeros, list_of_zeros, checkscale, checkweight string checkzero, newwweightname, oldzs, newzs, oldwts, newwts, wweightname string file_of_more, mmorescalename, file_of_air, wweighting, wwordweight string file_of_scales, list_of_scales, sstatfile, s_gain, s_rdnoise, nnormname string nnormmap, wtimg, wtlist, wtimgold, tplimg, tplimgold, oextimage, tpltmp string tmpimg, tmpimg2, s_snoise real s_maskval, s_blank, s_lthresh, s_hthresh, s_nlow, s_nhigh, s_nkeep, avg, x real s_lsigma, s_hsigma, s_pclip, s_grow, s_sigscale, sig real effairmass, wtavg, nncombine, exp, exposure, sf, zf, testold, eexptime real xold, yold, xnew, ynew, xshift, yshift, sscale, p, b, h, levelzero, wt real wt_avg_exptime, unwt_avg_exptime, eextcoeff, aairzero, air, sfavg, sfmin real sfmax, tmpzero, wait, waitold, tmpscale int mag, mag2, j, k, tpl1, tpl2 int xmin, ymin, newx, newy, oldx, oldy, test1, test1old, test2, test2old int sstartno, eendno, i, numpix, num, xdim, ydim, newxsize, newysize, ncoadds bool mmakescalefile, mmakestack, go, mmorehow, pputzero, ddefscale, pputscale bool nnewmask, uunstack, pprescale, uunscale, pputweight, sstack, getnorm, ttpl bool sspscale, ccleanup, noappend, pprezero, uunzero, sscalecombine, sspshift struct theadline #for zero/scale/weight=* # *ing how to do it # *name filename, if substr(*ing,1,1)==@ # word* header keyword, if substr(*ing,1,1)==! (or @ && pre*=yes) # pre* do zero/scale before imcombine # un* undo zero/scale after imcombine # Certain tasks/packages must be loaded for task to run. go=yes #if(!defpac("imgtools")) {go=no} if(!deftask("addcomment")) {go=no} if(!deftask("fileroot")) {go=no} #if(!deftask("filecalc")) {go=no} if(!deftask("iterstat")) {go=no} if(go) { # Set up parameters ccomblist = comblist ccomblist1 = ccomblist fileroot (outimage,validim+) ooutimage = fileroot.root oextimage = fileroot.extension # if(oextimage=="")oextimage="imh" if(oextimage=="")oextimage="fits" fileroot (expmap,validim+) eexpmap = fileroot.root if(eexpmap=="")eexpmap=ooutimage//"exp" nnormmap=normmap if(nnormmap=="")nnormmap=ooutimage//"norm" sshiftexactlist = shiftlist sshiftintlist = sshiftexactlist sscaling = scaling if(sscaling=="")sscaling="none" ddefscale=no aairzero=100. pprescale=no uunscale=no sscalename="_.imag_in_ary_fileJ" checkscale=substr(sscaling,1,1) if(checkscale=="!" || checkscale=="@"){ wwordscale = substr(sscaling,2,strlen(sscaling)) pprescale=prescale if(pprescale)uunscale=unscale if(checkscale=="@"){ sscalename = substr(sscaling,2,strlen(sscaling)) if(!access(sscalename)){ ddefscale=yes eextcoeff=extcoeff aairzero=airzero sscalecombine=scalecombine if(sscalecombine){ mmorescalename=morescalename checkmore=substr(mmorescalename,1,1) while(checkmore!="@" && checkmore!="!"){ print("Additional scales must have format ! or @filename.") mmorescalename=morescalename checkmore=substr(mmorescalename,1,1) } } } pputscale=putscale if(pputscale)wwordscale=wordscale } if(!ddefscale)ddefscale=defscale if(ddefscale && aairzero==100.)aairzero=airzero # if airzero=INDEF and airzero is needed later in the task, airzero=min(airmass) if(aairzero==INDEF && (ddefscale || (pprescale && checkscale=="@" && access(sscalename)))){ print("...one moment please...") file_of_air=mktemp(".foa") hsel("@"//ccomblist1,"AIRMASS",yes, >> file_of_air) list=file_of_air aairzero=100. while (fscan (list,air) != EOF) { aairzero=min(air,aairzero) } del(file_of_air,ver-,>&"dev$null") list="" } } zzeroing = zeroing if(zzeroing=="")zzeroing="none" pprezero=no uunzero=no checkzero=substr(zzeroing,1,1) if(checkzero=="!" || checkzero=="@"){ wwordzero = substr(zzeroing,2,strlen(zzeroing)) pprezero=prezero if(pprezero)uunzero=unzero if(checkzero=="@"){ zzeroname = substr(zzeroing,2,strlen(zzeroing)) pputzero=putzero if(pputzero)wwordzero=wordzero } } wweighting = weighting wwordweight="" if(wweighting=="")wweighting="none" checkweight=substr(wweighting,1,1) if(checkweight=="!")wwordweight=substr(wweighting,2,strlen(wweighting)) if(checkweight=="@"){ wweightname = substr(wweighting,2,strlen(wweighting)) pputweight=putweight if(pputweight)wwordweight=wordweight } mag = magfac mag2=mag*mag blk = "br"//mag ccomblist2 = ccomblist//blk bprotlist = ccomblist//blk//"pl" sspscale=no sspshift=no if(mag!=1){ if(zzeroing!="none")sspscale=spscale sspshift=spshift } sstack=stack sstackimage="fake_image_oog" if(sstack) { fileroot(stackimage,validim+) sstackimage = fileroot.root uunstack=unstack } llogfile = logfile nnormname=normname getnorm=no if(nnormname=="")getnorm=yes if(nnormname=="")nnormname="variance" if(wwordweight=="")wwordweight=wordweight nnewmask = newmask if(nnewmask)bbadmask = badmask eexpname = expname sstatfile = statfile if(sstatfile=="")sstatfile="_nonexistentFILEname_" ttpl = tpl ccleanup = cleanup # Check for bad parameter combinations and exit if necessary if(!pprescale && sstack && checkscale=="!"){ print("WARNING! You can't scale during imcombine from a header keyword") print("when stack=yes! (There is only one header for a stacked image.)") print("Use `@file' or prescale=yes instead.") return } if(!pprezero && sstack && checkzero=="!"){ print("WARNING! You can't take the zero offsets from a header keyword") print("when stack=yes! (There is only one header for a stacked image.)") print("Use `@filename' or prezero=yes instead.") return } if(checkweight!="@" && wweighting!="none" && sstack){ print("WARNING! Output image exposure time would have been incorrect.") print("If you want to use weights and stacking, put the weights in a file") print("before running the task; that way the output image exposure time") print("will be correctly calculated.") return } wt_avg_exptime=-1. unwt_avg_exptime=-1. s_sigma = i_sigma # imcombine parameters s_plfile = i_plfile s_combine = i_combine s_reject = i_reject s_masktyp = i_masktyp s_maskval = i_maskval s_blank = i_blank s_statsec = i_statsec s_expname = i_expname s_lthresh = i_lthresh s_hthresh = i_hthresh s_nlow = i_nlow s_nhigh = i_nhigh s_nkeep = i_nkeep s_lsigma = i_lsigma s_hsigma = i_hsigma s_rdnoise = i_rdnoise s_gain = i_gain s_snoise = i_snoise s_sigscale = i_sigscale s_pclip = i_pclip s_grow = i_grow # Set up log file, appending if it already exists. if(llogfile == "") llogfile="log."//ooutimage print("", >> llogfile) print("===> PHAT.OPTCOADD:", >> llogfile) if(mag!=1){ print("===> Input images from "//ccomblist1//" replicated by factor "//mag//" in each direction.", >> llogfile) print("===> Replicated images in "//ccomblist2//" coadded w/offsets from "//sshiftexactlist//blk, >> llogfile) } else { print("===> Images in "//ccomblist1//" coadded w/offsets from "//sshiftexactlist//",", >> llogfile) } print("===> weights="/wweighting//", stdpars="/stdpars//", makeavg="/makeavg//",", >> llogfile) print("===> scales="/sscaling//", zero offsets="/zzeroing//",", >> llogfile) print("===> pre-scaling="/pprescale//", un-scaling="/uunscale//", pre-zeroing="/pprezero//", un-zeroing="/uunzero//",", >> llogfile) print("===> defscale="/ddefscale//", subpixscale="/sspscale//", subpixshift="/sspshift//",", >> llogfile) print("===> to make image "//ooutimage//" and exposure map "//eexpmap, >> llogfile) # PRE-SCALING AND DEFAULT SCALING FACTORS FILE CREATION if(pprescale){ # Prevent imcombine from scaling twice sscaling="none" # If stacking, and image already exists, do not bother # if(sstack && access(sstackimage//".fits")){ # print("Not bothering to pre-scale... stacked image already exists.") # } else { print("===> Multiplying by additional scaling factors...") # In case of scalings taken from header keyword, make file_of_scales if(checkscale=="!"){ file_of_scales=mktemp(".fos") hsel("@"//ccomblist1,wwordscale,yes, >> file_of_scales) } # In case of scalings taken from file... if(checkscale=="@"){ # # ...create file of DEFAULT SCALING FACTORS if it doesn't exist... # if(!access(sscalename)){ file_of_air=mktemp(".foa") # get airmasses hsel("@"//ccomblist1,"AIRMASS",yes, >> file_of_air) # turn airmasses into scales list=file_of_air while (fscan (list,air) != EOF) { sf=10**(0.4*eextcoeff*(air-aairzero)) print(sf, >> sscalename) } del(file_of_air,ver-) # If combining default scales with other pre-existing scales... if(sscalecombine){ file_of_more=mktemp(".fom") if(checkmore=="@"){ copy(substr(mmorescalename,2,strlen(mmorescalename)),file_of_more,ver-) } if(checkmore=="!"){ hsel("@"//ccomblist1,substr(mmorescalename,2,strlen(mmorescalename)),yes, >> file_of_more) } # join files of default and additional scales del("tmp_."//sscalename,ver-,>&"dev$null") join(sscalename,file_of_more,output="tmp_."//sscalename) del(sscalename,ver-,>&"dev$null") del(file_of_more,ver-,>&"dev$null") list="" list="tmp_."//sscalename # create new scales & put into scale file while(fscan (list,air,sf) != EOF) { print(air*sf, >> sscalename) } del("tmp_."//sscalename,ver-,>&"dev$null") } # Finished with creation of default scalings file } list="" file_of_scales=sscalename # End of taking scales from list subroutine } list="" # Allow imcombine to do sigscaling as requested even when pre-scaling if(s_sigscale!=0.){ del ("_avg.file.tmp", ver-, >& "dev$null") type (file_of_scales | average opt="new_sample", >> "_avg.file.tmp") sfavg=average.mean sfmin=1.E20 sfmax=-1.E20 list=file_of_scales while (fscan (list,sf) != EOF) { sfmin=min(sfmin,sf) sfmax=max(sfmax,sf) } if((sfavg-sfmin/sfavg)>=s_sigscale || (sfmax-sfavg/sfavg)>=s_sigscale)s_sigscale=0. del ("_avg.file.tmp", ver-, >& "dev$null") list="" } # Do multiplicative scaling unless it has already been done list_of_scales=mktemp(".los") join(ccomblist1,file_of_scales,output=list_of_scales) if(checkscale=="!")del(file_of_scales,ver-) list=list_of_scales while (fscan (list,img,sf) != EOF) { imgets(img,"PRESCALE",>&"dev$null") if(imgets.value=="0"){ imar(img,"*",sf,img,pixt="real",calct="real",ver-) hedit(img,"PRESCALE",sf,add+,ver-,show-,update+,>&"dev$null") if(ddefscale){ imgets(img,"AIRMASS",>&"dev$null") hedit(img,"AIRMOLD",imgets.value,add+,ver-,show-,update+,>&"dev$null") hedit(img,"AIRMASS",aairzero,add+,ver-,show-,update+,>&"dev$null") } } else { print("No action -- image "//img//" already pre-scaled by factor "//imgets.value) } } # } } list="" # put scale factors into image headers if desired if(checkscale=="@"){ if(pputscale){ del("_tmp.sscaling",ver-,>&"dev$null") join(ccomblist1,sscalename,out="_tmp.sscaling") list="_tmp.sscaling" while(fscan (list, img, sf) != EOF) { hedit(img,wwordscale,sf,add+,ver-,show-,update+,>&"dev$null") } del("_tmp.sscaling",ver-,>&"dev$null") } } list="" # DETERMINE ZERO-LEVEL OFFSETS IF NEEDED AND INSERT INTO HEADERS IF DESIRED if(checkzero=="@"){ if(!access(zzeroname)){ print("===) Finding iterative median zero offsets for the images...") del ("_zero.file.tmp?", ver-, >& "dev$null") del ("_avg.file.tmp", ver-, >& "dev$null") # first find iterative median of each image if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_zero.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_zero.file.tmp1", sstatfile, ver-) } else { iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_zero.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_zero.file.tmp1", sstatfile, ver-) } } else { if(sstatfile!="_nonexistentFILEname_")print("Using statistics from"//sstatfile) copy(sstatfile, "_zero.file.tmp1", ver-) } # next find the overall average of the means fields ("_zero.file.tmp1", 5, >> "_zero.file.tmp2") type ("_zero.file.tmp2" | average opt="new_sample", >> "_avg.file.tmp") # now compute the offset of each image from the overall average mean list="_avg.file.tmp" while (fscan (list, avg, sig, num) !=EOF) { lintran("_zero.file.tmp2",min=2,x2=avg,yfield=1,angle=180, >> zzeroname) } del ("_zero.file.tmp?", ver-) del ("_avg.file.tmp", ver-) } # now insert into image headers if desired if(pputzero) { if(access("_tmp.zzeroing"))del("_tmp.zzeroing",ver-) join(ccomblist1,zzeroname,out="_tmp.zzeroing") list="" list="_tmp.zzeroing" while (fscan (list, img, zf) !=EOF) { hedit(img,wwordzero,zf,add+,ver-,show-,update+) } del("_tmp.zzeroing",ver-,>&"dev$null") } } list="" # DETERMINE WEIGHTS IF NEEDED AND ADD TO IMAGE HEADERS IF DESIRED if(checkweight=="@"){ if(!access(wweightname)){ print("===) Creating file of optimal exptime/rms**2 weights for the images...") del ("_weight.file.tmp?", ver-, >& "dev$null") del ("_avg.file.tmp", ver-, >& "dev$null") # first find iterative rms of each image #hsel("@"//ccomblist1,"PRESCALE",yes, >> "_weight.file.tmp9") #count("_weight.file.tmp9") | scan (i,j,k) #if(j!=0){ #beep #print("WARNING! At least one image in "//ccomblist//" was pre-scaled;") #print("thus, the image weights being calculated will be erroneous.") #} if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 if(!access("_weight.file.tmp1"))maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_weight.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_weight.file.tmp1", sstatfile, ver-) } else { if(!access("_weight.file.tmp1"))iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_weight.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_weight.file.tmp1", sstatfile, ver-) } } else { copy (sstatfile, "_weight.file.tmp1", ver-) } fields ("_weight.file.tmp1", 3, >> "_weight.file.tmp2") # get the exptimes for the images hsel("@"//ccomblist1,eexpname,yes, >> "_weight.file.tmp0") join("_weight.file.tmp2","_weight.file.tmp0",out="_weight.file.tmp3") # compute the weights = exptime./(rms**2.) #filecalc ("_weight.file.tmp3", "$2/($1*$1)", calctype="real", >> "_weight.file.tmp4") !/scrs1/pathall/irtfcoadd_1.p _weight.file.tmp3 > _weight.file.tmp4 # find the sum of the weights type ("_weight.file.tmp4" | average opt="new_sample",>> "_avg.file.tmp") # normalize by the sum of the weights #filecalc ("_weight.file.tmp4", "$1/"//average.sum, calctype="real", >> wweightname) !/scrs1/pathall/irtfcoadd_2.p _avg.file.tmp _weight.file.tmp4 > _weight.file.tmp5 rename ("_weight.file.tmp5", wweightname) del ("_weight.file.tmp?", ver-) del ("_avg.file.tmp", ver-) } if(pputweight){ if(access("_tmp.wweighting"))del("_tmp.wweighting",ver-) join(ccomblist1,wweightname,out="_tmp.wweighting") list="_tmp.wweighting" while (fscan (list, img, wt) !=EOF) { hedit(img,wwordweight,wt,add+,ver-,show-,update+) } del("_tmp.wweighting",ver-) } } list="" # IF DESIRED, DETERMINE NORMALIZATION FACTORS AND ADD TO IMAGE HEADERS if(getnorm){ print("===) Finding normalization factors (variances) and putting into image headers...") del ("_norm.file.tmp?", ver-, >& "dev$null") # first find iterative rms of each image if(!access(sstatfile)){ if(maskedstat){ iterstat.nsigrej=5. iterstat.maxiter=10 if(!access("_norm.file.tmp1"))maskstat("@"//ccomblist1,"!BPM",1,lower=INDEF,upper=INDEF,iterstat+,ver-,printit+, >> "_norm.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_norm.file.tmp1", sstatfile, ver-) } else { if(!access("_norm.file.tmp1"))iterstat("@"//ccomblist1,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-, >> "_norm.file.tmp1") if(sstatfile!="_nonexistentFILEname_")copy("_norm.file.tmp1", sstatfile, ver-) } } else { copy (sstatfile, "_norm.file.tmp1", ver-) } # compute the normalization factor = (rms**2.) #fields ("_norm.file.tmp1", 3, >> "_norm.file.tmp2") #filecalc ("_norm.file.tmp2", "$1*$1", calctype="real", >> "_norm.file.tmp4") fields ("_norm.file.tmp1", "3,3", >> "_norm.file.tmp2") !/scrs1/pathall/irtfcoadd_5.p _norm.file.tmp2 > _norm.file.tmp4 if(access("_tmp.norm"))del("_tmp.norm",ver-) join(ccomblist1,"_norm.file.tmp4",out="_tmp.norm") list="_tmp.norm" while (fscan (list, img, wt) !=EOF) { hedit(img,nnormname,wt,add+,ver-,show-,update+) } del("_tmp.norm",ver-) del ("_norm.file.tmp?", ver-) } list="" # SUBPIXEL SHIFTING noappend=no # First expand images if subpixel shifting is desired if (mag!=1){ if(!sspshift)sshiftintlist=sshiftexactlist//blk # If output image list already exists, do not append to it if (access(ccomblist2)){ noappend=yes print("WARNING! Output image list "//ccomblist2//" already exists.") print("Any images listed therein will be created if they do not exist,") print("but no image names will be appended to this preexisting file.") } print("===) Expanding images by factor "//mag//" in both directions...") list=ccomblist1 # Go through image list while (fscan (list, img) !=EOF) { fileroot(img,validim+) image=fileroot.root # Do the magnification as long as the image does not already exist or has not # already been rotated/magnified if(!access(image//blk//".fits")){ imgets(image,"ROTATED",>&"dev$null") if(imgets.value=="0"){ # Divide by mag squared to conserve total number of counts in input image. imar(image,"/",mag2,"_"//blk//image,pixt="real",calc="real",ver-) blkrep("_"//blk//image,image//blk,mag,mag) imdel("_"//blk//image,ver-) if(!noappend)print (image//blk, >> ccomblist2) # Now replicate the bad pixel mask, if not already done. imgets(image//blk,"BPMASK",>&"dev$null") if(imgets.value=="0")imgets(image//blk,"BPM",>&"dev$null") oldbp=imgets.value newbp=blk//oldbp if(!access(newbp)){ blkrep(oldbp,newbp,mag,mag) print(newbp//".pl", >> bprotlist) } # Insert the replicated bad pixel mask in the image header hedit(image//blk,"BPMASK",newbp,add+,ver-,show-,update+) hedit(image//blk,"BPM",newbp,add+,ver-,show-,update+) } else { # If input image already rotated, only print a warning. print("WARNING! "//image//".fits already rotated; not rotated again") } } else { # If output image already exists, only print a warning. print("WARNING! "//image//blk//".fits already exists; not overwritten") } # Next image } # # If output subpixel shifts file doesn't exist, create it if(!access(sshiftintlist)) { print("===> Calculating shifts for expanded images...") if (access("tmp"//sshiftintlist))del("tmp"//sshiftintlist,ver-) list="" list=sshiftexactlist # Convert old shifts to new while (fscan (list,xold,yold) != EOF) { xnew=mag*xold ynew=mag*yold print (xnew, ynew, >> "tmp"//sshiftintlist) } # Round off to integer shifts (in units of new pixels, natch). #filecalc("tmp"//sshiftintlist,"$1;$2",format="%4.0f %4.0f", >> sshiftintlist) del("tmp?.sshiftintlist",ver-) copy ("tmp"//sshiftintlist, "tmp1.sshiftintlist") !/scrs1/pathall/irtfcoadd_3.p tmp1.sshiftintlist > tmp2.sshiftintlist rename ("tmp2.sshiftintlist", sshiftintlist) del("tmp?.sshiftintlist",ver-) del("tmp"//sshiftintlist,ver-) # If output subpixel shifts file does exist, just print warning } else { if(sshiftintlist==sshiftexactlist//blk)print("WARNING! "//sshiftintlist//" already exists; not overwritten") } # Correction of zero offsets for lower flux/pixel in blkrep'd images, if needed if(!sspscale) { # Zero offsets from list if(checkzero=="@") { if(!access(zzeroname//blk)) { #filecalc(zzeroname,"$1/"//mag2,format="%9.7f", >> zzeroname//blk) del ("_tmpmag2", ver-, >& "dev$null") del ("_zzeroname*", ver-, >& "dev$null") print (mag2, >> "_tmpmag2") copy (zzeroname, "_zzeroname", ver-) !/scrs1/pathall/irtfcoadd_4.p _tmpmag2 _zzeroname > _zzeronameblk rename ("_zzeronameblk", zzeroname//blk) del ("_zzeroname*", ver-, >& "dev$null") del ("_tmpmag2", ver-, >& "dev$null") newzzeroname=zzeroname//blk zzeroname=newzzeroname zzeroing="@"//newzzeroname } } # Zero offsets from header keyword if(checkzero=="!"){ oldzs=mktemp(".oz") newzs=mktemp(".nz") hsel("@"//ccomblist1,wwordzero,yes, >> oldzs) #filecalc(oldzs,"$1/"//mag2,format="%9.7f", >> newzs) del ("_???zs", ver-, >& "dev$null") del ("_tmpmag2", ver-, >& "dev$null") print (mag2, >> "_tmpmag2") copy (oldzs, "_oldzs", ver-) !/scrs1/pathall/irtfcoadd_4.p _tmpmag2 _oldzs > _newzs rename ("_newzs", newzs, ver-) del ("_???zs", ver-, >& "dev$null") del ("_tmpmag2", ver-, >& "dev$null") join(ccomblist2,oldzs,output=newzs) list="" list=newzs while (fscan (list,img,levelzero) != EOF) { hedit(img,wwordzero,levelzero,add+,ver-,show-,update+) } del(oldzs,ver-) del(newzs,ver-) } } # End of subpixel shift option } list="" # INSERT NEW ZERO OFFSETS INTO REPLICATED IMAGE HEADERS IF DESIRED. if(access(ccomblist2) && checkzero=="@"){ if(pputzero) { if(!sspscale && access(zzeroname//blk))zzeroname=zzeroname//blk del("_tmp.zzeroing",ver-,>&"dev$null") join(ccomblist2,zzeroname,out="_tmp.zzeroing") list="_tmp.zzeroing" while (fscan (list, img, zf) !=EOF) { hedit(img,wwordzero,zf,add+,ver-,show-,update+) } del("_tmp.zzeroing",ver-,>&"dev$null") } } list="" # PRE-ZEROING: INCORPORATE ZERO OFFSETS BEFORE IMCOMBINE IF DESIRED if(pprezero){ print("===> Doing zero offsetting prior to imcombine...") # Prevent imcombine from zeroing twice zzeroing="none" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) # In case of zero offsets taken from header keyword, make file_of_zeros if(checkzero=="!"){ file_of_zeros=mktemp(".foz") hsel("@"//ccomblist2,wwordzero,yes, >> file_of_zeros) } if(checkzero=="@")file_of_zeros=zzeroname list_of_zeros=mktemp(".loz") join(ccomblist2,file_of_zeros,output=list_of_zeros) if(checkzero=="!")del(file_of_zeros,ver-) # If stacking, and image already exists, do not bother if(sstack && access(sstackimage//".fits")){ print("Not bothering to pre-zero... stacked image already exists.") } else { # Do zero offsetting unless it has already been done list=list_of_zeros while (fscan (list,img,levelzero) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value=="0"){ imar(img,"+",levelzero,img,pixt="real",calc="real",ver-) hedit(img,"PREZERO",levelzero,add+,ve-,sho-,updat+,>&"dev$null") } else { print("No action -- image "//img//" already zero-offset by "//imgets.value) } } } } list="" # COADD images # If output coadded image doesn't exist, create it! if (!access(ooutimage//"."//oextimage)){ # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) if (sstack){ # If output stacked image doesn't exist, create it! if (!access(sstackimage//"."//oextimage)){ print("===) Stacking the images...") imstack("@"//ccomblist2,sstackimage,title="Stacked images listed in "//ccomblist2) } if(nnewmask) { hedit(sstackimage,"BPM",bbadmask,add+,ver-,show-,update+) } print("===) Combining the images...") if (makeavg){ imcombine(sstackimage, ooutimage, sigma=s_sigma, plfile=s_plfile, combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } else{ if (stdpars) { imcombine(sstackimage, ooutimage, sigma="", plfile="", combine="average", reject="ccdclip", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale=sscaling, zero=zzeroing, weight=wweighting, statsec="", expname=eexpname, lthresh=INDEF, hthresh=INDEF, nlow=1., nhigh=1., nkeep=1., mclip+, lsigma=5., hsigma=5., rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { imcombine(sstackimage, ooutimage, sigma=s_sigma, plfile=s_plfile, combine=s_combine, reject=s_reject, project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise=s_snoise, sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } } # Stacked images only: compute correct UNWEIGHTED average exposure time del("tmp_"//ccomblist2,ver-,>&"dev$null") hsel ("@"//ccomblist2,eexpname,yes, >> "tmp_"//ccomblist2) type ("tmp_"//ccomblist2) | average (opt="new_sample") | scan (eexptime,p,b) hedit(ooutimage,eexpname,eexptime,add+,ver-,show-,update+) del("tmp_"//ccomblist2,ver-,>&"dev$null") # if(uunstack)imdel(sstackimage,ver-) } else{ if(nnewmask) { list=ccomblist2 while (fscan (list, img) !=EOF) { imgets(img,"BPMASK",>&"dev$null") if(imgets.value=="0") { imgets(img,"BPM",>&"dev$null") hedit(img,"BPMASK",imgets.value,add+,ver-,show-,update+) hedit(img,"BPM",bbadmask,add+,ver-,show-,update+) } else { hedit(img,"BPM",bbadmask,add+,ver-,show-,update+) } } } print("===) Combining the images...") if (makeavg){ imcombine("@"//ccomblist2, ooutimage, sigma=s_sigma, plfile=s_plfile, combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise=s_snoise, sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } else{ if (stdpars) { imcombine("@"//ccomblist2, ooutimage, sigma="", plfile="", combine="average", reject="ccdclip", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale=sscaling, zero=zzeroing, weight=wweighting, statsec="", expname=eexpname, lthresh=INDEF, hthresh=INDEF, nlow=1., nhigh=1., nkeep=1., mclip+, lsigma=5., hsigma=5., rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=0.1, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { imcombine("@"//ccomblist2, ooutimage, sigma=s_sigma, plfile=s_plfile, combine=s_combine, reject=s_reject, project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale=sscaling, zero=zzeroing, weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=s_lthresh, hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=s_rdnoise, gain=s_gain, snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } } } list="" # Put original BPM back if necessary if(nnewmask) { list=ccomblist2 while (fscan (list, img) !=EOF) { imgets(img,"BPMASK",>&"dev$null") hedit(img,"BPM",imgets.value,add+,ver-,show-,update+) } } list="" # Header parameters for the coadded image hedit(ooutimage,"title","Coadded image from "//ccomblist2//" and "//sshiftintlist,ver-,show-,update+) time | scan (theadline) addcomment(ooutimage,"phat.optcoadd: "//theadline,ver-) addcomment(ooutimage,"Coadded from "//ccomblist2//" and "//sshiftintlist,ver-) addcomment(ooutimage,"makeavg="/makeavg//", zero shifts from "//zzeroing,ver-) addcomment(ooutimage,"scaling factors from "//sscaling//", and stdpars="//stdpars,ver-) # AIRMASS # Set airmass of coadded image to effective airmass if default scaling !used if(!ddefscale){ del("_airmass.tmp?",ver-,>&"dev$null") hsel("@"//ccomblist2, "airmass", yes, >> "_airmass.tmp1") type("_airmass.tmp1" | average opt="new_sample", >> "_airmass.tmp2") effairmass=real(average.mean) hedit(ooutimage,"airmass",(effairmass),add+,ver-,show-,update+) del("_airmass.tmp?",ver-,>&"dev$null") # Set airmass of coadded image to reference airmass if default scaling was used } else { hedit(ooutimage,"airmass",(aairzero),add+,ver-,show-,update+) } # EXPOSURE NORMALIZATION -- normalize coadded image to total exposure time. # If weighting was done w/a stacked image, first find correct WEIGHTED exptime del ("_exptime.tmp?", ver-, >& "dev$null") if(sstack && wweighting!="none"){ # First get individual image exposure times del ("_exptime.tmp?", ver-, >& "dev$null") hsel("@"//ccomblist2,eexpname,yes, >> "_exptime.tmp1") # Join individual image exptimes with weights join("_exptime.tmp1", wweightname, output="_exptime.tmp3") # Calculate individual image weighted exposure times #filecalc ("_exptime.tmp3", "$1*$2", calctype="real", >> "_exptime.tmp4") !/scrs1/pathall/irtfcoadd_5.p _exptime.tmp3 > _exptime.tmp4 # Calculate correct weighted exposure time type ("_exptime.tmp4" | average opt="new_sample",>> "_exptime.tmp5") # Insert correct weighted exposure time into image header hedit(ooutimage,eexpname,average.sum,add+,ver-,show-,update+) } # First find total exposure time of input images hsel("@"//ccomblist2,eexpname,yes, >> "_exptime.tmp6") type("_exptime.tmp6" | average opt="new_sample", >> "_exptime.tmp7") del ("_exptime.tmp?", ver-, >& "dev$null") unwt_avg_exptime=real(average.mean) eexptime=real(average.sum) # Get output exposure time of coadded image imgets(ooutimage,eexpname) wt_avg_exptime=real(imgets.value) # Insert total exposure time into coadded image header hedit(ooutimage,eexpname,eexptime,add+,ver-,show-,update+) # Multiply coadded image by (total_exposure_time/output_exposure_time) imar(ooutimage, "*", eexptime/wt_avg_exptime, ooutimage) print("", >> llogfile) print("Coadded image multiplied by "//eexptime/wt_avg_exptime//" to bring its flux", >> llogfile) print("in line with the total exposure time of "//eexptime//" s.", >> llogfile) # CREATE WEIGHTED EXPOSURE MAP # Create exposure maps if the output coadded-image exposure map does not exist. # Routine allows for images of different exposure times, sizes, and BPMs, while # creating as few images as possible consistent with meeting those criteria. explist="" if(!access(eexpmap//"."//oextimage)){ # Don't recreate exposure maps to be stacked if stacked expmap image exists if(!sstack || (sstack && !access("exp"//sstackimage//"."//oextimage))) { print("===) Creating exposure maps...") subimgold="_oops" testold=0. test1old=0 test2old=0 expmaskold="" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) list=ccomblist2 explist=ccomblist2//"exp" if(access(explist))del(explist,ver-,>&"dev$null") while (fscan (list, img) !=EOF) { # get image parameters: xsize, ysize, exptime, badpixelmask fileroot(img,validim+) imgets(img,"i_naxis1") test1=int(imgets.value) imgets(img,"i_naxis2") test2=int(imgets.value) imgets(img,eexpname) exposure=real(imgets.value) imgets(img,"BPMASK") expmask=str(imgets.value) # if any of those parameters differ from the previous image, need to create a # new exposure map for eventual coadding. if(test1!=test1old || test2!=test2old || exposure!=testold || expmask!=expmaskold) { subimg = mktemp(fileroot.root) print (subimg, >> explist) # imcalc(img,subimg,"im1*0+"//exposure,ver-) imcopy(img,subimg,ver-) imreplace(subimg,exposure,lower=-10000.,upper=INDEF) if(nnewmask)hedit(subimg,"BPM",bbadmask,add+,ver-,show-,update+) test1old=test1 test2old=test2 testold=exposure expmaskold=expmask subimgold=subimg } else { print (subimgold, >> explist) } } } # Create coadded-image exposure map print("===> Creating coadded-image exposure map...") if(sstack) { if(!access("exp"//sstackimage//"."//oextimage)) { print("===> Stacking exposure maps...") imstack("@"//explist,"exp"//sstackimage,title="Stacked exposure maps listed in "//explist) } else { print("Stacked exposure map image already exists-- not overwritten.") } if(nnewmask) { hedit("exp"//sstackimage,"BPM",bbadmask,add+,ver-,show-,update+) } imcombine("exp"//sstackimage, eexpmap, sigma="", plfile="", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale="none", zero="none", weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask) { imgets("exp"//sstackimage,"BPMASK",>&"dev$null") hedit("exp"//sstackimage,"BPM",imgets.value,add+,ve-,sho-,upda+) } if(uunstack)imdel("exp"//sstackimage,ver-) } else { imcombine("@"//explist, eexpmap, sigma="", plfile="", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=s_blank, scale="none", zero="none", weight=wweighting, statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } # following line had been commented out; replaced with 2nd line following # imreplace(eexpmap, -99999., lower=INDEF, upper=-10000.) imreplace(eexpmap, -99999., lower=INDEF, upper=-1.) hedit(eexpmap,"title","Weighted exposure map for "//ooutimage,add+,ve-,sho-,updat+) imgets(eexpmap,"ncombine") nncombine=int(imgets.value) if(explist!=""){ imdel("@"//explist, ver-, >& "dev$null") del(explist, ver-, >& "dev$null") } } else { print("Output exposure map already exists-- new one not created.") print("Output exposure map already exists-- new one not created.", >> llogfile) } # SUBTRACT constant background from image and DIVIDE by normalized # WEIGHTED EXPOSURE MAP to get image with globally constant exposure time if(!access(ooutimage//"mask.pl")){ # create mask image with border pixels = 0 whether originally 0 or -99999 imar(eexpmap, "+", "99999.", "j1"//eexpmap, noact-, ver-) imreplace("j1"//eexpmap, 1., lower=0.1, upper=INDEF) imar(eexpmap, "*", "j1"//eexpmap, "j2"//eexpmap, noact-, ver-) imreplace("j2"//eexpmap, 1., lower=0.1, upper=INDEF) imcopy("j2"//eexpmap, ooutimage//"mask.pl", ver-) imdel("j?"//eexpmap//"."//oextimage,ver-) } maskstat(ooutimage, ooutimage//"mask.pl", 1, lower=INDEF, upper=INDEF, iterstat+, ver-, printit+, >> llogfile) imar(ooutimage, "-", iterstat.mean, ooutimage, ver-, noact-) # imar(eexpmap,"/",wt_avg_exptime,"j1"//eexpmap,ver-,noact-) imar("j1"//eexpmap,"/",ooutimage//"mask.pl","j2"//eexpmap,ver-,noact-,divze=-99999.) imar(ooutimage,"/","j2"//eexpmap//"."//oextimage,ooutimage,ver-,noact-,divze=-99999.) imdel("j?"//eexpmap//"."//oextimage,ver-) # print("Weighted exposure map normalized by "//wt_avg_exptime, >> llogfile) print("and divided into output coadded image.", >> llogfile) # FLIP image over to correct orientation if necessary (N is up, E is left) if(flip){ imcopy(ooutimage//"[-*,*]", ooutimage, ver-) addcomment(ooutimage,"Image has been flipped L-R from orig. orientation",ver-) print("WARNING! Image has been flipped L-R! (i.e. imcopy orig[-*,*] new)") } } else { print("Output coadded image already exists-- coadding not done.") print("Output coadded image already exists-- coadding not done.", >> llogfile) } # NORMALIZATION MAPS # Create normalization maps if the output normalization map does not exist. # Routine allows for images of different exposure times, sizes, and BPMs, while # creating as few images as possible consistent with meeting those criteria. explist="" wtlist="" if(!access(nnormmap//"."//oextimage)){ # Don't recreate normalization maps to be stacked if stacked norm. image exists if(!sstack || (sstack && !access("norm"//sstackimage//"."//oextimage))) { print("===) Creating normalization maps...") subimgold="_oops" wtimgold="_oops" waitold=0. testold=0. test1old=0 test2old=0 expmaskold="" tplimgold="" # If list of images to coadd doesn't exist, create it! if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) list=ccomblist2 explist=ccomblist2//"norm" wtlist=ccomblist2//"wt" if(access(explist))del(explist,ver-,>&"dev$null") if(access(wtlist))del(wtlist,ver-,>&"dev$null") while (fscan (list, img) !=EOF) { # get image parameters: xsize, ysize, weight, norm.factor, badpixelmask fileroot(img,validim+) imgets(img,"i_naxis1") test1=int(imgets.value) imgets(img,"i_naxis2") test2=int(imgets.value) imgets(img,wwordweight) wait=real(imgets.value) imgets(img,nnormname) exposure=real(imgets.value) imgets(img,"BPMASK") expmask=str(imgets.value) imgets(img,"TPLIMG",>&"dev$null") tplimg=str(imgets.value) # if any of those parameters differ from the previous image, need to create a # new normalization map for eventual coadding. if(test1!=test1old || test2!=test2old || wait!=waitold || exposure!=testold || expmask!=expmaskold || tplimg!=tplimgold) { tmpimg = mktemp("_tmp") tmpimg2 = mktemp("_tmp2") subimg = mktemp("_nm") wtimg = mktemp("_wt") print (subimg, >> explist) print (wtimg, >> wtlist) # want to end up with wtimg = wait or -99999.; # subimg = exposure * (tpl**2.) * wait**2. or -99999.; # make tmpimg -99999 where img < -10000, 0 elsewhere imcopy(img,tmpimg,ver-) imreplace(tmpimg,0.,lower=-10000.,upper=INDEF) imreplace(tmpimg,-99999.,lower=INDEF,upper=-9999.) # make wtimg 0 where img < -10000, "wait" elsewhere imar(tmpimg,"+",99999.,wtimg,ver-) imreplace(wtimg,wait,lower=10000.,upper=INDEF) # tpl if(ttpl && access(tplimg)) { tpltmp=mktemp("tpltmp") imgets(tplimg,"i_naxis1") tpl1=int(imgets.value) imgets(tplimg,"i_naxis2") tpl2=int(imgets.value) # if tpl image is not same size as actual image, assume the image has been # copied to subsection of bigger image starting at (1,1), and that the rest of # the image is -99999 (thus no imar(img,"-",img,subimg) needed. (ie 61"+90") if(tpl1!=test1 || tpl2!=test2) { imcopy(img,subimg,ver-) # tpltmp = tmpimg + exposure * (wtimg / tplimg)**2. #imcalc(tmpimg//","//wtimg//","//tplimg,tpltmp,"im1+"//str(exposure)//"*(im2/im3)**2.",ver-) imcalc(wtimg//","//tplimg,tmpimg2,str(exposure)//"*(im1/im2)**2.",ver-) imar(tmpimg, "+", tmpimg2, tpltmp, ver-, noact-) imcopy(tpltmp, subimg//"[1:"//str(tpl1)//",1:"//str(tpl2)//"]", ver-) imdel(tmpimg2, ver-) imdel(tpltmp, ver-) } else { # subimg = tmpimg + exposure * (wtimg / tplimg)**2. #imcalc(tmpimg//","//wtimg//","//tplimg,subimg,"im1+"//str(exposure)//"*(im2/im3)**2.",ver-) imcalc(wtimg//","//tplimg,tmpimg2,str(exposure)//"*(im1/im2)**2.",ver-) imar(tmpimg,"+",tmpimg2,subimg,ver-,noact-) imdel(tmpimg2,ver-) } # no tpl } else { # subimg = tmpimg + exposure * wtimg**2. (exposure=exptime or variance) #imcalc(wtimg,tmpimg2,"(im1**2.)*"//str(exposure),ver-) imar (wtimg,"*",wtimg,tmpimg2,ver-,noact-) imar (tmpimg2,"*",str(exposure),tmpimg2,ver-,noact-) imar(tmpimg,"+",tmpimg2,subimg,ver-,noact-) imdel(tmpimg2,ver-) } # now make wtimg -99999 where img < -10000, "wait" elsewhere # tmpimg2 = mktemp("_tmp2") imren(wtimg,tmpimg2,ver-) imar(tmpimg2,"+",tmpimg,wtimg,ver-) imdel(tmpimg2,ver-) imdel(tmpimg,ver-) if(nnewmask)hedit(wtimg,"BPM",bbadmask,add+,ver-,show-,update+) if(nnewmask)hedit(subimg,"BPM",bbadmask,add+,ver-,show-,update+) test1old=test1 test2old=test2 tplimgold=tplimg waitold=wait testold=exposure expmaskold=expmask subimgold=subimg wtimgold=wtimg } else { print (subimgold, >> explist) print (wtimgold, >> wtlist) } } } # Create coadded-image normalization map # First create variance map print("===> Creating coadded-image normalization map...") if(sstack) { if(!access("norm"//sstackimage//"."//oextimage)) { print("===> Stacking variance maps...") imstack("@"//explist,"norm"//sstackimage,title="Stacked normalization maps listed in "//explist) } else { print("Stacked variance map image already exists-- not overwritten.") } if(nnewmask) { hedit("norm"//sstackimage,"BPM",bbadmask,add+,ver-,show-,updat+) } if(access("junknorm."//oextimage))imdel("junknorm."//oextimage,ver-) if(access(nnormmap//"pl.pl"))imdel(nnormmap//"pl.pl",ver-) imcombine("norm"//sstackimage, "junknorm", sigma="", plfile=nnormmap//"pl", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask){ imgets("norm"//sstackimage,"BPMASK",>&"dev$null") hedit("norm"//sstackimage,"BPM",imgets.value,ad+,ve-,sho-,upda+) } if(uunstack)imdel("norm"//sstackimage,ver-) } else { if(access("junknorm."//oextimage))imdel("junknorm."//oextimage,ver-) if(access(nnormmap//"pl.pl"))imdel(nnormmap//"pl.pl",ver-) imcombine("@"//explist, "junknorm", sigma="", plfile=nnormmap//"pl", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } if(explist!=""){ imdel("@"//explist, ver-, >& "dev$null") del(explist, ver-, >& "dev$null") } # Now create weight map if(sstack) { if(!access("wt"//sstackimage//"."//oextimage)) { print("===> Stacking weight maps...") imstack("@"//wtlist,"wt"//sstackimage,title="Stacked weight maps listed in "//wtlist) } else { print("Stacked weight map image already exists-- not overwritten.") } if(nnewmask) { hedit("wt"//sstackimage,"BPM",bbadmask,add+,ver-,show-,updat+) } if(access("junkweight."//oextimage))imdel("junkweight."//oextimage,ver-) imcombine("wt"//sstackimage, "junkweight", sigma="", plfile="", combine="average", reject="none", project+, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) if(nnewmask){ imgets("wt"//sstackimage,"BPMASK",>&"dev$null") hedit("wt"//sstackimage,"BPM",imgets.value,add+,ve-,sho-,upda+) } if(uunstack)imdel("wt"//sstackimage,ver-) } else { if(access("junkweight."//oextimage))imdel("junkweight."//oextimage,ver-) imcombine("@"//wtlist, "junkweight", sigma="", plfile="", combine="average", reject="none", project-, offsets=sshiftintlist, masktype=s_masktyp, maskvalue=s_maskval, blank=0., scale="none", zero="none", weight="none", statsec=s_statsec, expname=s_expname, lthresh=0., hthresh=s_hthresh, nlow=s_nlow, nhigh=s_nhigh, nkeep=s_nkeep, mclip+, lsigma=s_lsigma, hsigma=s_hsigma, rdnoise=0., gain=1., snoise="0.", sigscale=s_sigscale, pclip=s_pclip, grow=s_grow, logfile='STDOUT', >> llogfile) } if(wtlist!=""){ imdel("@"//wtlist, ver-, >& "dev$null") del(wtlist, ver-, >& "dev$null") } # Final steps to create normalization image imgets("junknorm","ncombine") nncombine=int(imgets.value) if(access(nnormmap//"num."//oextimage))imdel(nnormmap//"num."//oextimage,ver-) imar(nnormmap//"pl","-",nncombine,nnormmap//"num.fits") imar(nnormmap//"num.fits","*",-1.,nnormmap//"num.fits") imar("junknorm","*",nnormmap//"num.fits","junknorm",ver-,noact-) imar("junkweight","*",nnormmap//"num.fits","junkweight",ver-,noact-) #imcalc("junkweight,"//eexpmap//",junknorm",nnormmap,"((im1*im2)**2.)/im3",nullval=0.,ver-) imar("junkweight","*",eexpmap,"junkweight",ver-,noact-) imar("junkweight","*","junkweight","junkweight",ver-,noact-) imar("junkweight","/","junknorm",nnormmap,ver-,noact-) minmax(nnormmap,force+,update+,ver-) imar(nnormmap,"/",minmax.maxval,nnormmap,ver-,noact-) hedit(nnormmap,"title","Normalization map for "//ooutimage,add+,ve-,sho-,updat+) imdel("junkweight."//oextimage,ver-) imdel("junknorm."//oextimage,ver-) imdel(nnormmap//"num.fits",ver-) imdel(nnormmap//"pl.pl",ver-) if(flip){ imcopy(nnormmap//"[-*,*]", nnormmap, ver-) addcomment(nnormmap,"Image has been flipped L-R from orig. orientation",ver-) } } else { print("Output normalization map already exists-- new one not created.") print("Output normalization map already exists-- new one not created.", >> llogfile) } # UNDO PRE-ZEROING: if zeroing was done before imcombine, undo it if desired if(pprezero && uunzero){ # If block-replication was done, skip step if those images are to be deleted if(mag!=1 && ccleanup && !noappend){ print("", >> llogfile) } else { print("===> Undoing zero offsetting...") list=list_of_zeros while (fscan (list,img,levelzero) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value!="0"){ tmpzero=abs((real(imgets.value)-levelzero)/levelzero) if(tmpzero>=0.01){ print("WARNING! "//img//" pre-zeroing doesn't match list to 1%; unzeroing not done") } else { levelzero=real(imgets.value) imar(img,"-",levelzero,img,pixt="real",calc="real",ver-) hedit(img,"PREZERO","",del+,ver-,show-,updat+,>&"dev$null") } } else { print("No action -- "//img//" not pre-zeroed in the first place!") } } } } if(pprezero){ if(sstack && access(sstackimage//"."//oextimage)){print("", >> llogfile)} else{del(list_of_zeros,ver-,>&"dev$null")} } list="" # UNDO PRE-SCALING: if scaling was done before imcombine, undo it if desired if(pprescale && uunscale){ # If block-replication was done, skip step if those images are to be deleted if(mag!=1 && ccleanup && !noappend){ print("", >> llogfile) } else { print("===> Undoing scaling factors...") list=list_of_scales while (fscan (list,img,sf) != EOF) { imgets(img,"PREZERO",>&"dev$null") if(imgets.value!="0"){ print("WARNING! "//img//" still pre-scaled: pre-zeroing not undone first") } else { imgets(img,"PRESCALE",>&"dev$null") if(imgets.value!="0"){ tmpscale=abs((real(imgets.value)-sf)/sf) if(tmpscale>=0.01){ print("WARNING! "//img//" pre-scaling doesn't match list to 1%; unscaling not done") } else { imar(img,"/",sf,img,pixt="real",calct="real",ver-) hedit(img,"PRESCALE","",del+,ver-,sho-,updat+,>&"dev$null") if(ddefscale){ imgets(img,"AIRMOLD",>&"dev$null") hedit(img,"AIRMASS",imgets.value,add+,del-,ver-,sho-,updat+,>&"dev$null") hedit(img,"AIRMOLD","",del+,ver-,sho-,updat+,>&"dev$null") } } } else { print("No action -- "//img//" not pre-scaled in the first place!") } } } } } if(pprescale)del(list_of_scales,ver-,>&"dev$null") list="" # IMSHIFTS FILE # Create *.imshifts file, listing images & offsets used by masklet & photcheck if (!access(ooutimage//".imshifts")) { print("===> Creating output imshifts file...") if (!access(ccomblist2))copy(ccomblist1,ccomblist2,ver-) join(ccomblist2,sshiftintlist,output=ooutimage//".imshifts_tmp") # Find minimum x and y shift values and subtract them from output offsets listimshift=ooutimage//".imshifts_tmp" list="" list=listimshift xmin=100000 ymin=100000 while (fscan (list,img,newx,newy) != EOF) { if (newx < xmin) { xmin = newx } if (newy < ymin) { ymin = newy } } newx=0 newy=0 list="" list=listimshift while (fscan (list,img,oldx,oldy) != EOF) { newx = oldx - xmin newy = oldy - ymin print(img, " ", newx, newy, >> ooutimage//".imshifts") } del(ooutimage//".imshifts_tmp",ver-) } else { print("Output imshifts file already exists-- not overwritten.") } # Clean up. if(mag!=1){ if(ccleanup && !noappend){ if(access(bprotlist)){ imdel("@"//bprotlist,ver-,>&"dev$null") del(bprotlist,ver-,>&"dev$null") } if(access(ccomblist2))imdel("@"//ccomblist2,ver-,>&"dev$null") del(ccomblist2,ver-,>&"dev$null") del(sshiftexactlist//blk,ver-,>&"dev$null") del(zzeroname//blk,ver-,>&"dev$null") } } else { del(ccomblist2,ver-,>&"dev$null") } print(" ") print(ooutimage//", "//eexpmap//" (exposure map), imshifts file,") print("and "//nnormmap//" (normalization map) have been created.") #print("Next task is `mkobjmask' or `photcheck'.") } else { print("WARNING: tasks addcomment, fileroot, and/or iterstat are not loaded!") print("Please load the appropriate package(s) and restart this task.") } list="" print(" ") if(echog)beep end ./src/scab_old.cl0100644000151400000240000002245607145001210013035 0ustar phallgamesprocedure scab(imlist) # scab -- scab over bleeding columns # 980807: created # 980809: fixed so that no pixel subscripts should ever be out of bounds # 980923: added imexam option # 990608: added CLOTDONE header card # 000811: renamed scab.cl from clot.cl ; changed header card name to SCABDONE # (but maintained compatibility with CLOTDONE) string imlist {prompt="Images on which to work (im1,im2,im3)"} string prefix="scab_" {prompt="Prefix for bleeding star lists for images"} int strip_width=9 {prompt="Default width of strip around bleeding stars"} real uplimit=4000 {prompt="Minimum value above mean for bleeding columns"} real bleedlimit {prompt="Minimum value found in bleeding columns",mode="q"} bool dodisp=yes {prompt="Display images for imexam?"} bool doimexam=yes {prompt="Interactively mark bleeding stars w/imexam?"} bool doscab=yes {prompt="Do interpolation (scabbing) step?"} bool interact=no {prompt="Interactively select bleeding limits?"} bool findisp=yes {prompt="Display before & after images when done?"} bool echog=yes {prompt="Beep when task is done?"} struct *list struct *list2 begin string img, sat_list, im_age, pre_fix, im_list, image, satlist, oldsatlist int n, nn, x, y, xleft, xright, m, mm, xstar, ystar, xcen, ymin, ymax, xstep, i int xmin, xmax, stripwidth, xlimleft, xlimright, xtmp, ytmp, xhitmp, xlotmp, l int frame real leftval, rightval, bleed_limit, pixval, scabval, mean, sig, val_z1, val_z2 real up_limit bool fin_disp, inter_act, do_imexam, do_disp, do_scab im_list = mktemp("imlist") sections (imlist, >> im_list) pre_fix = prefix stripwidth = strip_width up_limit = uplimit do_disp = dodisp do_imexam = doimexam do_scab = doscab inter_act = interact fin_disp = findisp if (do_disp) { list=im_list frame=1 while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root imgets (im_age, "itermean") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (im_age, "itersig") if ((imgets.value)!="0") { sig=real(imgets.value) val_z1=mean-4*sig val_z2=mean+up_limit displ(im_age,frame,zr-,zs-,z1=val_z1,z2=val_z2) } else { beep print ("ITERSIG not found for "//im_age) display(im_age,frame) } } else { beep print ("ITERMEAN not found for "//im_age) display(im_age,frame) } frame=frame+1 } } if (do_imexam) { list=im_list; satlist=""; oldsatlist="" while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root satlist=pre_fix//im_age if (access(oldsatlist)) { type (oldsatlist, >> satlist) type (oldsatlist) } imexam (im_age, keeplog+, logf=satlist) vi ("-c ':g/$/s// "//stripwidth//"/g'", satlist) oldsatlist=satlist } } if (do_scab) { # do each saturated star list list=im_list while (fscan (list,image) != EOF) { imgets (image, "CLOTDONE", >& "dev$null") if (imgets.value=="yes") { hedit(img, "SCABDONE", "yes", add+, ver-, show-, upd-) } imgets (image, "SCABDONE", >& "dev$null") if (imgets.value=="yes" || !imaccess("_orig"//image)) { print("Now scabbing image "//image) fileroot(image,validim+) im_age=fileroot.root satlist=pre_fix//im_age img = "_tmp"//image # get approx coords of saturated stars (x align more impt than y align) list2=satlist l=0 while (fscan (list2,xstar,ystar,stripwidth) != EOF) { m = stripwidth; mm=(m-1)/2 l = l+1 if (stripwidth != 0) { # imhistogram m-pixel-wide strip centered on star's x position print("Working on strip for star #"//l//" ("//xstar//","//ystar//")") if (l==1) { xmin=1; ymin=1 imgets (image, "i_naxis1") xmax=real(imgets.value) imgets (image, "i_naxis2") ymax=real(imgets.value) mean=0 imgets (image, "itermean") if ((imgets.value)!="0") mean=real(imgets.value) } if (l==1 || inter_act) { xlotmp=max(xstar-mm,xmin); xhitmp=min(xstar+mm,xmax) imhistogram (image//"["//xlotmp//":"//xhitmp//",*]", z1=INDEF, z2=INDEF, binwidth=INDEF, nbins=512, autoscale+, top_closed-, hist_type="normal", listout-, plot_type="line", logy+, device="stdgraph") # select lower bleedcol cutoff (= bleed_limit) if (inter_act) { beep bleed_limit=bleedlimit } else { bleed_limit=mean+up_limit print("Minimum bleeding column value is "//bleed_limit) } } if (l==1) { print ("Copying to temporary working image...") imdel (img, ver-, >& "dev$null"); imcopy (image, img, ver-) } # consider m-pixel-wide strip centered on star, working upwards for (y=ystar; y<=ymax; y+=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymax } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } # now work downwards ytmp=max(ystar-1,ymin) for (y=ytmp; y>=ymin; y-=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymin } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } } # **also repeat using min_sky instead of bleed_limit for oversubtracted regions # in SNe images, reversing the sign so to speak # repeat for next star in satlist } hedit(img, "SCABDONE", "yes", add+, ver-, show+, upd+) if (fin_disp) { if(imaccess(img)){ display (image, 1) display (img, 2) } } if(imaccess(img)){ imren (image, "_orig"//image, ver+) imren (img, image, ver+) } } else { print("SCABDONE header card and/or _orig"//image//" already exist;") print("scabbing already done on "//image//" -- not redone.") } # repeat for next satlist } } del (im_list, ver-) if (echog) beep end ./src/ptv.cl0100644000151400000240000000225206704670634012116 0ustar phallgamesprocedure ptv(image,frame) # ptv -- display image in range determined from iterative mean & sigma # # 950808: created # 981216: negative lsig/hsig values use the absolute value of lsig/hsig # for that limit # 990222: now uses plain old display if iterstat hasn't been done on image string image {prompt="Image to display"} int frame {prompt="Frame to use"} real lsig=3 {prompt="Number of sigma below mean for display lower limit"} real hsig=10 {prompt="Number of sigma above mean for display upper limit"} begin string img real h_sig, l_sig, mean, sig, val_z1, val_z2 img = image l_sig = lsig h_sig = hsig imgets (img, "itermean") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (img, "itersig") if ((imgets.value)!="0") { sig=real(imgets.value) if (l_sig<0) { val_z1=-1*l_sig } else { val_z1=mean-l_sig*sig } if (h_sig<0) { val_z2=-1*h_sig } else { val_z2=mean+h_sig*sig } display (image, frame, zr-, zs-, z1=val_z1, z2=val_z2) } else { beep print ("ITERSIG not found in image header; using display") display (image, frame) } } else { beep print ("ITERMEAN not found in image header; using display") display (image, frame) } end ./src/mysetcatg.gz0100744000151400000240000000013706560142201013310 0ustar phallgamesg.mysetcatgSVTOO.*N-IN,QP1TSOI-+QqwB\\\\*F ʃBr;X./src/autodefringe.cl0100644000151400000240000000751306561403306013755 0ustar phallgames# autodefringe.cl -- automatically defringe using RMS-minimizing scalings # 980730: created from testfringe.cl procedure autodefringe(fiximage,fringe,outname) string fiximage {prompt="Name of (original) image to be defringed"} string fringe {prompt="Fringe image to scale and subtract"} string outname {prompt="Name of final defringed image to create"} string logfile {"STDOUT",prompt="Log file (either STDOUT or a filename)"} real startscale {1.,min=0.,prompt="Scaling to start with on fringe image"} real stepscale {0.01,min=0.,prompt="Step between scaling values"} string imsect {"",prompt="[Image section] to use for statistics & display"} bool addhead {no,prompt="Add iterstat output to image header?"} bool display {no,prompt="Display original & final images when done?"} bool echog {yes,prompt="Beep when task is done?"} begin string llogfile, rrootname, ooutname, ffunc string wweighting, fiximg, ffringe, titlestring, statsec real max, nncols, nnlines, sscale, minrms real sc_start, sc_step, itermed, oldrms, newrms, sc_final, ll, ul, mn, sig int x, y, zz, xxord, yyord, xx, steps, w, nx, npx, m, v bool go, ffit, xxterms, ddisplay, hadd, disfinal fiximg=fiximage ffringe=fringe ooutname=outname llogfile=logfile sc_start=startscale if(sc_start==0.)sc_start=1 sc_step=stepscale if(sc_step==0.)sc_step=0.01 statsec=imsect hadd=addhead ddisplay=display # check for imcalc & addcomment; if not defined abort task. go=yes if(!deftask("addcomment")) {go=no} if(!deftask("imcalc")) {go=no} if(go) { # Get initial RMS print("", >> llogfile) print("===> Iterstating original image section...", >> llogfile) iterstat (fiximg//statsec,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print+,ver-,addh=hadd, >> llogfile) oldrms=iterstat.sigma minrms=iterstat.sigma sc_final=0. # First, increase scalings in positive steps until RMS starts going up; # then decrease them in negative steps until same thing happens for (v=1; v>=-1; v+=-2) { sscale=sc_start sc_step=sc_step*v print ("===> Subtracting fringe images scaled from "//sscale//" in "//sc_step//" steps.", >> llogfile) # Loop over requested scalings, 100 steps maximum for (w=1; w<=100; w+=1) { # if new image... if(w!=1){ # ...get new scaling sscale=sscale+sc_step } # subtract & iterstat the scaled fringe image imcalc(fiximg//statsec//","//ffringe//statsec,ooutname//"_"//str(sscale),"im1-im2*"//sscale,ver-) hedit(ooutname//"_"//str(sscale),"title","Defringed image using scale="//sscale,ver-,add+,update+,show-) imstat (ooutname//"_"//str(sscale),fields="mean,stddev,npix",lower=INDEF,upper=INDEF,for-) | scan(mn,sig,npx) m = 1 while (m <= 10) { ll = mn-5*sig ul = mn+5*sig imstat (ooutname//"_"//str(sscale),fields="mean,stddev,npix",lower=ll,upper=ul,for-) | scan(mn,sig,nx) if (nx == npx) break npx = nx m = m + 1 } print ("RMS of "//ooutname//"_"//str(sscale)//" is "//sig, >> llogfile) imdel (ooutname//"_"//str(sscale),ver-) newrms=sig if(newrms<=minrms){ minrms=newrms sc_final=sscale } if(newrms>=oldrms){ w=101 } oldrms=newrms } } # create full-size final image if(sc_final!=0){ print("Creating final image with scale "//sc_final, >> llogfile) imcalc(fiximg//","//ffringe,ooutname,"im1-im2*"//sc_final,ver-) hedit(ooutname,"FRINGMED",sc_final,add+,ver-,show-,update+) addcomment(ooutname,"Defringed using FRINGMED-scaled copy of "//ffringe,ve-) if(ddisplay){ print("===> Displaying original and defringed images...") displ(fiximg, 1) displ(ooutname, 2) } } else { beep print ("No defringed image had RMS lower than original! Wrong fringe image used?", >> llogfile) } } else{ print("Tasks stsdas.toolbox.imgtools.imcalc & phiirs.addcomment aren't loaded,") print("and this task needs them to run. Please load them and start again.") } if(echog)beep end ./src/btc_coadd.cl0100644000151400000240000000730207144614371013203 0ustar phallgamesprocedure btc_coadd(inlist, outimg, outplf, offfile, logname) # btc_coadd -- coadd BTC images using standard parameters # 980805: created string inlist {prompt="List of images to coadd"} string outimg {prompt="Output coadded image name"} string outplf {prompt="Output pixel list file name"} string offfile {prompt="File with image offsets for coadding"} string logname {"STDOUT",prompt="Log file"} string imsect {"[950:1100,950:1100]",prompt="Section of image to use for makeobjmask statistics"} bool delold {no,prompt="Delete preexisting copies of intermediate files?"} bool cleanup {yes,prompt="Delete intermediate images when done?"} bool echog {yes,prompt="Beep when task is done?"} begin string in_list, outimage, off_file, log_name, plfimage, im_sect, extn int nlines1, nlines2 bool clean_up, del_old in_list = inlist fileroot(outimg,validim+) outimage = fileroot.root extn = fileroot.extension if(extn=="")extn="fits" fileroot(outplf,validim+) plfimage = fileroot.root off_file = offfile log_name = logname if (log_name=="") log_name="STDOUT" im_sect = imsect clean_up = cleanup del_old = delold count (in_list) | scan (nlines1) count (off_file) | scan (nlines2) if (nlines1!=nlines2) { beep print ("Task aborted -- number of images & shifts don't match!") } else { # make plf file print("", >> log_name) if (delold) { imdel (plfimage, ver-, >& "dev$null") } if (!access(plfimage//".pl")) { print("===> Making PLF image...", >> log_name) imcombine ("@"//in_list, outimage//"avgtmp", plf=plfimage, logf=log_name, offsets=off_file, rej="none", scale="none", zero="mode", weight="exposure", maskt="none") imdel (outimage//"avgtmp", ver-) } # make average coadd if (delold) { imdel (outimage//"avg", ver-, >& "dev$null") } if (!access(outimage//"avg."//extn)) { print("===> Making average coadd...", >> log_name) imcombine ("@"//in_list, outimage//"avg", plf="", logf=log_name, offsets=off_file, rej="none", scale="none", zero="mode", weight="exposure") } # make spurious-object-cleaned coadd if (delold) { imdel (outimage//"rej", ver-, >& "dev$null") } if (!access(outimage//"rej."//extn)) { print("===> Making average coadd...", >> log_name) imcombine ("@"//in_list, outimage//"rej", plf="", logf=log_name, offsets=off_file, rej="ccdclip", hsig=4, lsig=10, grow=2, scale="none", zero="mode", weight="exposure", nkeep=1) } # make spurious-object-cleaned coadd object mask (objects=1) if (delold) { imdel (outimage//"rejominv.pl", ver-, >& "dev$null") } if (!access(outimage//"rejominv.pl")) { makeobjmask (outimage//"rej", subsam=3, filtsize=10, suffix="om", nsmoo=3, statsec=im_sect, ngrow=2, inv-) imren (outimage//"rejom.pl", outimage//"rejominv.pl") } # create image of objects only if (delold) { imdel (outimage, ver-, >& "dev$null") } if (!access(outimage//"."//extn)) { imar (outimage//"avg", "*", outimage//"rejominv.pl", outimage, noact-) } # invert spurious-object-cleaned coadd object mask so objects=0 if (delold) { imdel (outimage, ver-, >& "dev$null") } if (!access(outimage//"rejom.pl")) { minv (outimage//"rejominv.pl", outimage//"rejom.pl") } # create image of sky only if (delold) { imdel (outimage//"rejobjn."//extn, ver-, >& "dev$null") } if (!access(outimage//"rejobjn."//extn)) { imar (outimage//"rej", "*", outimage//"rejom.pl", outimage//"rejobjn", noact-) } # add sky-only and object-only images imar (outimage, "+", outimage//"rejobjn", outimage, noact-) # add exposure image hedit (outimage, "PLFMASK", plfimage, add+, ver-, show+, update+) # clean up imdel (outimage//"rejobjn", ver-) if (clean_up) { imdel (outimage//"rej", ver-) imdel (outimage//"avg", ver-) } if(echog)beep } end ./src/btc_dochipscales.cl0100644000151400000240000001127007144614371014571 0ustar phallgamesprocedure btc_dochipscales(basename,divone,divtwo,divthree,divfour) # apply chip-to-chip photometric scalings to btc image sets # redoing of iterstat is not done by default because it may have been done in # the focasflat step # 990723: skips over missing images string basename {prompt="Full base name of image set to normalize"} real divone {prompt="Scaling factor to divide into chip #1"} real divtwo {prompt="Scaling factor to divide into chip #2"} real divthree {prompt="Scaling factor to divide into chip #3"} real divfour {prompt="Scaling factor to divide into chip #4"} bool doiterstat {no,prompt="Rerun iterstat on the final scaled images?"} string imextn="fits" {prompt="Extension of images (imh, fits, etc.)"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string base, image, scales, im_extn real avgmean, chipscale, dvone, dvtwo, dvthree, dvfour, divisor bool redoiterstat # -- cycle through images base = basename dvone = divone dvtwo = divtwo dvthree = divthree dvfour = divfour redoiterstat = doiterstat im_extn = imextn # -- do the scaling for (i=1; i<=4; i+=1) { image = base//"_"//i//"."//im_extn if(!access(image)) { print ("WARNING! Cannot access "//image) } else { if(i==1){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvone) imar (image, "/", dvone, image, ver-, noact-) hedit(image,"chipscal",dvone,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvone//"*"//dvone//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==2){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvtwo) imar (image, "/", dvtwo, image, ver-, noact-) hedit(image,"chipscal",dvtwo,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvtwo//"*"//dvtwo//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==3){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvthree) imar (image, "/", dvthree, image, ver-, noact-) hedit(image,"chipscal",dvthree,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvthree//")",ad+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvthree//")",ad+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvthree//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvthree//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvthree//"*"//dvthree//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==4){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvfour) imar (image, "/", dvfour, image, ver-, noact-) hedit(image,"chipscal",dvfour,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvfour//"*"//dvfour//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } } } if(echog)beep end ./src/patrename.cl0100644000151400000240000000255106704670632013261 0ustar phallgames# 990320: changed field in individual rename from "root" to "all" procedure patrename(oldlist,newlist) string oldlist {prompt="List of old file names"} string newlist {prompt="List of new file names"} bool verb {yes,prompt="Print names of files as they are copied?"} struct *list begin string ooldlist, nnewlist, errstring, oldname, newname, ooldtemp, nnewtemp, y real x int errflag bool vverb ooldtemp=oldlist nnewtemp=newlist ooldlist=oldlist nnewlist=newlist vverb=verb x=strlen(ooldlist) y=substr(ooldlist,1,1) if(y=="@")ooldlist=substr(ooldlist,2,x) x=strlen(nnewlist) y=substr(nnewlist,1,1) if(y=="@")nnewlist=substr(nnewlist,2,x) del ("tmp.err", ver-, >& "dev$null") del ("tmp.renamelist", ver-, >& "dev$null") join (ooldlist, nnewlist, output="tmp.renamelist", >& "tmp.err") errflag=0 list="tmp.err" while (fscan (list, errstring) !=EOF) { if (errstring=="WARNING:") errflag=1 } if (errflag==0) { list="tmp.renamelist" if(vverb){ while (fscan (list, oldname, newname) !=EOF) { rename (oldname, newname, field="all") print (oldname//" --> "//newname) } } else{ while (fscan (list, oldname, newname) !=EOF) { rename (oldname, newname, field="all") } } } else { print("WARNING! Number of input files does not match number of output files.") print("No renaming done.") } del ("tmp.err", ver-) del ("tmp.renamelist", ver-) end ./src/mkfringe.cl0100644000151400000240000001673307000651123013076 0ustar phallgames# mkfringe.cl -- create fringe frame & optionally subtract it from images # # Calls routines iterstat, addcomment, noao.imred.ccdred.mkskycor, # and possibly stsdas.toolbox.imgtools.imcalc # # CHANGES: # 98/09/14: created from defringe.cl procedure mkfringe(rootname,imagelist,logfile,defstring,biasimage) string rootname {prompt="Rootname for output images and image list"} string imagelist {prompt="List of images to process (do not use an `@')"} string logfile {prompt="Name of log file"} string defstring {prompt="String to be appended to output images"} string biasimage {prompt="Zero level calibration image for ccdproc"} bool getfringe {yes,prompt="Do fringe creation step?"} bool imdisplay {yes,prompt="Display sky+fringe image?"} bool dofringe {yes,prompt="Do fringe removal step?"} real gain {prompt="Gain of CCD (for ccdclip in imcombine)"} real rdnoise {prompt="Read noise of CCD (for ccdclip in imcombine)"} bool forcescale {no,prompt="Force recalculation of image scales?"} bool goon=yes {prompt="Continue with task using this sky+fringe image?",mode="q"} bool ssave=no {prompt="Save sky+fringe image?",mode="q"} bool echog {yes,prompt="Beep when task is done?"} struct *list struct *list2 struct *list3 struct *datelist begin string ddefstring, ffringename, outlist, sskyfringename, sskyname, biasimg string rrootname, ddark, llogfile, bbadmask, eextension, normfile, img string flatlist, flat, flatbase, meanfile, currentflat, base, mmaskname string iimagelist, FlatImageList, fflatstr, check, ttplname, templist, flatdiv string datefile, thedate, ickinfo, name, tempstring, otherstring, tempfile real mean, nnumber, flatnorm, valmed, fringmed, ggain, rrdnoise, scale, scale2 real indiv_exptime, avg_exptime, sum_exptime int sstartno, eendno, i, j, numpix, x, y, z bool zzeroout, ttpl, sstdpars, go, fflatsave, force, ggoon rrootname = rootname iimagelist = imagelist llogfile = logfile ddefstring = defstring biasimg = biasimage ggain = gain rrdnoise = rdnoise force = forcescale outlist = iimagelist//ddefstring if(access(outlist) && ddefstring!="")del(outlist,ver-) sskyfringename=rrootname//".skyfringe.fits" # sky+fringe image ffringename=rrootname//".fringe.fits" # fringe image sskyname=rrootname//".sky.fits" # sky-flat image #The "go" parameter won't let the task run if you haven't loaded ccdred. go=yes if(!defpac("ccdred")) {go=no} if(!deftask("imcalc")) {go=no} if(!deftask("iterstat")) {go=no} if(!deftask("addcomment")) {go=no} if(go) { #Set up log file, appending if it already exists if(llogfile == "") llogfile=rrootname//".log" print(" ", >> llogfile) # Create fringe image step if(getfringe){ # Do iterstat to find each image's "true" median for use in scaling print("===> Finding image scales and weights...") list = iimagelist sum_exptime = 0. scale = 1 i = 0 while (fscan(list,img) !=EOF) { fileroot(img,validim+) flat=fileroot.root//ddefstring//".fits" if(ddefstring!="")print(flat, >> outlist) i = i + 1 force = forcescale imgets (img, "exptime") sum_exptime=sum_exptime+real(imgets.value) if (!force) { imgets (img,"SKYFRING",>&"dev$null") mean=real(imgets.value) if (mean == 0) { imgets (img,"ITERMED",>&"dev$null") valmed=real(imgets.value) if (valmed == 0) { force = yes } else { valmed = 1./valmed hedit(img,"SKYFRING",valmed,ad+,ve-,sho-,updat+) scale = scale + real(imgets.value) } } else { scale = scale + 1./real(imgets.value) } } if (force) { iterstat.nsigrej=5 iterstat.maxiter=10 iterstat(img,nsigrej=5.,maxiter=10,lower=INDEF,upper=INDEF,print-,ver-) valmed = 1./iterstat.median hedit (img,"SKYFRING",valmed,add+,ver-,show-,update+) scale = scale + (1./valmed) } } sum_exptime=sum_exptime/i # Use this list of images to make the sky+fringe frame print("===> Creating template sky + fringe frame...") if(!imaccess(sskyfringename)){ imcombine("@"//iimagelist, sskyfringename, sigma="", plfile="", combine="median", reject="ccdclip", project-, offsets="none", blank=0., scale="!SKYFRING", zero="none", weight="!SKYFRING", statsec="", lthresh=-100000, hthresh=100000, nlow=1, nhigh=1, nkeep=1, mclip+, lsigma=3, hsigma=3, rdnoise=rrdnoise, gain=ggain, snoise="0.", sigscale=0.1, pclip=-0.5, grow=0., logfile='STDOUT', >> llogfile) } else { beep; print (sskyfringename//" already exists... not overwritten.") } hedit(sskyfringename,"exptime",sum_exptime,add+,ver-,show-,update+) print("===> Displaying sky+fringe image for inspection. If object residuals") print("===> are present, you may wish to stop, create object masks, and rerun") print("===> the task. You can use makeobjmask on the non-defringed images to") print("===> create object masks for them directly, or you can use shiftnadd on") print("===> the non-defringed images, run mkobjmask on the skysubbed output,") print("===> insert the object mask names into the non-defringed image headers,") print("===> and then rerun this task so that the objects are masked out during") print("===> the creation of the sky+fringe image.") if(imdisplay)displ(sskyfringename,1) print("===> Displaying image histogram...") imhistog(sskyfringename,hist_type="normal",listout-,logy+) ggoon=goon if(!ggoon){ print("Task aborted-- illumination correction & defringing not done.") if(!ssave)imdel(sskyfringename,ver-) if(ddefstring!="")del(outlist,ver-) return } # "scale" is set equal to the average median of the input images. # It is multiplied into the sky+fringe frame to keep fringe counts accurate. scale = scale / i imgets (sskyfringename,"SCALE",>&"dev$null") scale2 = real(imgets.value) if (scale2 == 0) { imar (sskyfringename, "*", scale, sskyfringename) hedit (sskyfringename, "scale", scale, add+, ver-, show-, update+) iterstat (sskyfringename, print+, ver-, addh+) } else { beep print(sskyfringename//" untouched -- already scaled by factor "//scale2) } # Insert title into fringe image header hedit (sskyfringename, "title", "Sky+fringe image for "//iimagelist, add+,ver-,show-,update+) # Create sky illumination correction image mkskycor(sskyfringename,sskyname,xboxmin=5.,xboxmax=0.25,yboxmin=5.,yboxmax=0.25) hedit (sskyname, "title", "Sky illumination correction image for "//iimagelist, add+,ver-,show-,update+) # Do illumination correction *on output images only* # imcopy("@"//iimagelist, "@"//outlist, ver-) # ccdproc("@"//outlist, illumcor+, illum=sskyname, zero=biasimg) # Create fringe image imcopy(sskyfringename, ffringename, ver-) imar (ffringename, "-", sskyname, ffringename) hedit (ffringename, "title", "Fringe image for "//iimagelist,add+,ver-,show-,update+) } # Subtract accurately scaled fringe image from each input image, if desired if(dofringe){ print("===> Subtracting UNSCALED fringe image from each input image...") list = iimagelist while (fscan (list, name) !=EOF) { fileroot(name,validim+) flat=fileroot.root//ddefstring//".fits" if(!access(outlist))print(flat, >> outlist) imar (name,"-",ffringename,flat,ver-,noact-,pixt="1",calct="real") hedit(flat,"FRINGMED","1.",add+,ver-,show-,update+) addcomment(flat,"Defringed using unscaled copy of "//ffringename,ver-) print(flat//" was defringed using "//ffringename) } } print("===> Wrapping up... ") datefile = mktemp("date") date(>>datefile) datelist = datefile print("finished at "//datelist, >> llogfile) datelist = "" del(datefile, ver-) } else { beep print("WARNING: one or more of the packages `noao.imred.ccdred' or") print("`stsdas.toolbox.imgtools' or `PHIIRS' are not loaded!") print("Please load them and restart this task.") } if(echog)beep end ./src/btc_chipscales.cl0100644000151400000240000001635607144614371014260 0ustar phallgamesprocedure btc_chipscales(filename,scalename) # btc_chipscales -- find and/or apply BTC chip-to-chip photometric scalings # This program will fail if the ITERMEAN keyword is not in all image headers! # 981113: created from btc_getchipscales and btc_dochipscales string filename {prompt="File of root names of BTC image sets"} string scalename {prompt="Root name for output scaling files"} string extension="fits" {prompt="Image extension"} bool getscales {yes,prompt="Get individual image set scalings?"} bool avgscales {yes,prompt="Average lots of scalings together?"} bool savescales {yes,prompt="Accept and save average scaling?",mode="q"} bool applyscales {yes,prompt="Apply scalings to the images?"} bool doiterstat {no,prompt="Rerun iterstat on the final scaled images?"} bool echog {yes,prompt="Beep when task is done?"} struct *name begin string root, image, scales, extn, scale_name, base, scale_file real avgmean, chipscale, dvone, dvtwo, dvthree, dvfour, divisor bool get_scales, avg_scales, save_scales, apply_scales, redoiterstat name = filename scale_name = scalename extn = extension get_scales = getscales avg_scales = avgscales apply_scales = applyscales redoiterstat = doiterstat # -- cycle through images if (get_scales) { print ("Output to "//scale_name//"_chipscales:") while (fscan (name, root) != EOF) { # -- find average itermean hsel (root//"_?."//extn, "itermean", yes) | average | scan (avgmean) # -- get itermean for all 4 images in the set and divide by average itermean scales="" for (i=1; i<=4; i+=1) { image = root//"_"//i//"."//extn hsel (image, "itermean", yes) | scan (chipscale) chipscale=chipscale/avgmean scales = (scales//" "//chipscale) } # -- output print (root//scales) print (root//scales, >> scale_name//"_chipscales") } } # -- average lots of image set scalings together chip-by-chip while (avg_scales) { print ("Average scalings, RMS uncertainty and # of images used for chips 1-4:") fields (scale_name//"_chipscales",2) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",3) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",4) | iteravg >> scale_name//"_chipscalesavg") fields (scale_name//"_chipscales",5) | iteravg >> scale_name//"_chipscalesavg") type (scale_name//"_chipscalesavg") print (" ") print ("If the above is unacceptable, answer `n' and the "//scale_name//"_chipscales") print ("file will be displayed for editing and the iterative average re-run.") save_scales=savescales if(save_scales){ print ("Saving to file "//scale_name//"_chipscalesavg.") print ("Additions to this file should ONLY be as comments at the end of it!") print ("#--> Any additions to this file MUST be placed after this line! <--", >> scale_name//"_chipscalesavg") avg_scales=no } else { avg_scales=yes del (scale_name//"_chipscalesavg", ver-) vi (scale_name//"_chipscales") } } # -- apply chip-to-chip photometric scalings to btc image sets if (apply_scales) { scale_file = scale_name//"_chipscalesavg" if(access(scale_file)) { dvone=0.; dvtwo=0.; dvthree=0.; dvfour=0. fields (scale_file, "1", lines="1") | scan (dvone) fields (scale_file, "1", lines="2") | scan (dvtwo) fields (scale_file, "1", lines="3") | scan (dvthree) fields (scale_file, "1", lines="4") | scan (dvfour) if ((dvone==0.) || (dvtwo==0.) || (dvthree==0.) || (dvfour==0.)) { beep print ("Problem reading file "//scale_file//" -- no images scaled!") } } else { beep print ("File "//scale_file//" not found -- no images scaled!") apply_scales=no } } if (apply_scales) { # -- cycle through images name = filename while (fscan (name, base) != EOF) { # -- do the scaling for (i=1; i<=4; i+=1) { image = base//"_"//i if(i==1){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvone) imar (image, "/", dvone, image, ver-, noact-) hedit(image,"chipscal",dvone,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvone//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvone//"*"//dvone//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==2){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvtwo) imar (image, "/", dvtwo, image, ver-, noact-) hedit(image,"chipscal",dvtwo,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvtwo//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvtwo//"*"//dvtwo//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==3){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvthree) imar (image, "/", dvthree, image, ver-, noact-) hedit(image,"chipscal",dvthree,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvthree//")",ad+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvthree//")",ad+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvthree//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvthree//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvthree//"*"//dvthree//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } if(i==4){ imgets (image, "chipscal", >& "dev$null") if ((imgets.value)=="0") { print ("Dividing "//image//" by "//dvfour) imar (image, "/", dvfour, image, ver-, noact-) hedit(image,"chipscal",dvfour,add+,ver-,show+,update+) # -- update the iterstat parameters in the image headers if (redoiterstat) { print ("Rerunning iterstat on "//image) iterstat (image, print+, ver-, addh+) } else { hedit(image,"itermean","(itermean/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itermode","(itermode/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itersig","(itersig/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"itermed","(itermed/"//dvfour//")",add+,ve-,sho-,updat+) hedit(image,"variance","(variance/("//dvfour//"*"//dvfour//"))",add+,ve-,sho-,updat+) } } else { print (image//" already divided by "//imgets.value) } } } } } if(echog)beep end ./src/xypreserve.cl0100644000151400000240000000775406607240202013517 0ustar phallgames #in all of this, 1234 are done in parallel but separately, individually. #x,y coords are first generated using irshift (BRI separate) #coadding shifts the x,y (BRI separate) #maskaligntrim shifts them again (BRI should end up on approx. same system) #irshift #btc_coadd.cl #btc_maskaligntrim.cl procedure btc_coadd(inlist, outimg, outplf, offfile, logname) # btc_coadd -- coadd BTC images using standard parameters # 980805: created string inlist {prompt="List of images to coadd"} string outimg {prompt="Output coadded image name"} string outplf {prompt="Output pixel list file name"} string offfile {prompt="File with image offsets for coadding"} string logname {"STDOUT",prompt="Log file"} string imsect {"[950:1100,950:1100]",prompt="Section of image to use for makeobjmask statistics"} bool delold {no,prompt="Delete preexisting copies of intermediate files?"} bool cleanup {yes,prompt="Delete intermediate images when done?"} bool echog {yes,prompt="Beep when task is done?"} begin string in_list, outimage, off_file, log_name, plfimage, im_sect, extn int nlines1, nlines2 bool clean_up, del_old in_list = inlist fileroot(outimg,validim+) outimage = fileroot.root extn = fileroot.extension if(extn=="")extn="fits" fileroot(outplf,validim+) plfimage = fileroot.root off_file = offfile log_name = logname if (log_name=="") log_name="STDOUT" im_sect = imsect clean_up = cleanup del_old = delold count (in_list) | scan (nlines1) count (off_file) | scan (nlines2) if (nlines1!=nlines2) { beep print ("Task aborted -- number of images & shifts don't match!") } else { # make plf file print("", >> log_name) if (delold) { imdel (plfimage, ver-, >& "dev$null") } if (!access(plfimage//".pl")) { print("===> Making PLF image...", >> log_name) imcombine ("@"//in_list, outimage//"avgtmp", plf=plfimage, logf=log_name, offsets=off_file, rej="none", scale="none", zero="mode", weight="exposure", maskt="none") imdel (outimage//"avgtmp", ver-) } # make average coadd if (delold) { imdel (outimage//"avg", ver-, >& "dev$null") } if (!access(outimage//"avg."//extn)) { print("===> Making average coadd...", >> log_name) imcombine ("@"//in_list, outimage//"avg", plf="", logf=log_name, offsets=off_file, rej="none", scale="none", zero="mode", weight="exposure") } # make spurious-object-cleaned coadd if (delold) { imdel (outimage//"rej", ver-, >& "dev$null") } if (!access(outimage//"rej."//extn)) { print("===> Making average coadd...", >> log_name) imcombine ("@"//in_list, outimage//"rej", plf="", logf=log_name, offsets=off_file, rej="ccdclip", hsig=4, lsig=10, grow=2, scale="none", zero="mode", weight="exposure", nkeep=1) } # make spurious-object-cleaned coadd object mask (objects=1) if (delold) { imdel (outimage//"rejominv.pl", ver-, >& "dev$null") } if (!access(outimage//"rejominv.pl")) { makeobjmask (outimage//"rej", subsam=3, filtsize=10, suffix="om", nsmoo=3, statsec=im_sect, ngrow=2, inv-) imren (outimage//"rejom.pl", outimage//"rejominv.pl") } # create image of objects only if (delold) { imdel (outimage, ver-, >& "dev$null") } if (!access(outimage//"."//extn)) { imar (outimage//"avg", "*", outimage//"rejominv.pl", outimage, noact-) } # invert spurious-object-cleaned coadd object mask so objects=0 if (delold) { imdel (outimage, ver-, >& "dev$null") } if (!access(outimage//"rejom.pl")) { minv (outimage//"rejominv.pl", outimage//"rejom.pl") } # create image of sky only if (delold) { imdel (outimage//"rejobjn."//extn, ver-, >& "dev$null") } if (!access(outimage//"rejobjn."//extn)) { imar (outimage//"rej", "*", outimage//"rejom.pl", outimage//"rejobjn", noact-) } # add sky-only and object-only images imar (outimage, "+", outimage//"rejobjn", outimage, noact-) # add exposure image hedit (outimage, "PLFMASK", plfimage, add+, ver-, show+, update+) # clean up imdel (outimage//"rejobjn", ver-) if (clean_up) { imdel (outimage//"rej", ver-) imdel (outimage//"avg", ver-) } if(echog)beep } end ./src/scab_chooyu.cl0100644000151400000240000002553307145001210013564 0ustar phallgamesprocedure scab(imlist) # scab -- scab over bleeding columns # 980807: created # 980809: fixed so that no pixel subscripts should ever be out of bounds # 980923: added imexam option string imlist {prompt="Images on which to work (im1,im2,im3)"} string prefix="scab_" {prompt="Prefix for bleeding star lists for images"} int strip_width=9 {prompt="Default width of strip around bleeding stars"} real uplimit=4000 {prompt="Minimum value above mean for bleeding columns"} real bleedlimit {prompt="Minimum value found in bleeding columns",mode="q"} bool dodisp=yes {prompt="Display images for imexam?"} bool doimexam=yes {prompt="Interactively mark bleeding stars w/imexam?"} bool doscab=yes {prompt="Do interpolation (scabbing) step?"} bool interact=no {prompt="Interactively select bleeding limits?"} bool findisp=yes {prompt="Display before & after images when done?"} bool echog=yes {prompt="Beep when task is done?"} struct *list struct *list2 begin string img, sat_list, im_age, pre_fix, im_list, image, satlist, oldsatlist int n, nn, x, y, xleft, xright, m, mm, xstar, ystar, xcen, ymin, ymax, xstep, i int xmin, xmax, stripwidth, xlimleft, xlimright, xtmp, ytmp, xhitmp, xlotmp, l int frame, xoldleft, xoldright real leftval, rightval, bleed_limit, pixval, scabval, mean, sig, val_z1, val_z2 real up_limit bool fin_disp, inter_act, do_imexam, do_disp, do_scab im_list = mktemp("imlist") sections (imlist, >> im_list) pre_fix = prefix stripwidth = strip_width up_limit = uplimit do_disp = dodisp do_imexam = doimexam do_scab = doscab inter_act = interact fin_disp = findisp if (do_disp) { list=im_list frame=1 while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root imgets (im_age, "itermean") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (im_age, "itersig") if ((imgets.value)!="0") { sig=real(imgets.value) val_z1=mean-4*sig val_z2=mean+up_limit displ(im_age,frame,zr-,zs-,z1=val_z1,z2=val_z2) } else { beep print ("ITERSIG not found for "//im_age) display(im_age,frame) } } else { beep print ("ITERMEAN not found for "//im_age) display(im_age,frame) } frame=frame+1 } } if (do_imexam) { list=im_list; satlist=""; oldsatlist="" while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root satlist=pre_fix//im_age if (access(oldsatlist)) { type (oldsatlist, >> satlist) type (oldsatlist) } imexam (im_age, keeplog+, logf=satlist) vi ("-c ':g/$/s// "//stripwidth//"/g'", satlist) oldsatlist=satlist } } if (do_scab) { # do each saturated star list list=im_list while (fscan (list,image) != EOF) { if (!imaccess("_orig"//image)) { print("Now scabbing over image "//image) fileroot(image,validim+) im_age=fileroot.root satlist=pre_fix//im_age img = "_tmp"//image # get approx coords of saturated stars (x align more impt than y align) list2=satlist l=0 while (fscan (list2,xstar,ystar,stripwidth) != EOF) { m = stripwidth; mm=(m-1)/2 l = l+1 if (stripwidth != 0) { # imhistogram m-pixel-wide strip centered on star's x position print("Working on strip for star #"//l//" ("//xstar//","//ystar//")") if (l==1) { xmin=1; ymin=1 imgets (image, "i_naxis1") xmax=real(imgets.value) imgets (image, "i_naxis2") ymax=real(imgets.value) mean=0 imgets (image, "itermean") if ((imgets.value)!="0") mean=real(imgets.value) } if (l==1 || inter_act) { xlotmp=max(xstar-mm,xmin); xhitmp=min(xstar+mm,xmax) imhistogram (image//"["//xlotmp//":"//xhitmp//",*]", z1=INDEF, z2=INDEF, binwidth=INDEF, nbins=512, autoscale+, top_closed-, hist_type="normal", listout-, plot_type="line", logy+, device="stdgraph") # select lower bleedcol cutoff (= bleed_limit) if (inter_act) { beep bleed_limit=bleedlimit } else { bleed_limit=mean+up_limit print("Minimum bleeding column value is "//bleed_limit) } } if (l==1) { print ("Copying to temporary working image...") imdel (img, ver-, >& "dev$null"); imcopy (image, img, ver-) } # **consider m-pixel-wide strip centered on star x,y for (y=ystar; y<=ymax; y+=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymax } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } # **now work upwards along the edge of the replacement region for (y=ystar+1; y<=ymax; y+=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymax } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } # **now work downwards along the edge of the replacement region ytmp=max(ystar-1,ymin) for (y=ytmp; y>=ymin; y-=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymin } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } } # **also repeat using min_sky instead of bleed_limit for oversubtracted regions # in SNe images, reversing the sign so to speak # repeat for next star in satlist } if (fin_disp) { display (image, 1) if(imaccess(img))display (img, 2) } if(imaccess(img)){ imren (image, "_orig"//image, ver+) imren (img, image, ver+) } } else { print("_orig"//image//" already exists; scabbing already done!") } # repeat for next satlist } } del (im_list, ver-) if (echog) beep end ./src/offone.cl0100644000151400000240000000477607102330660012557 0ustar phallgames# offone.cl -- find the first object within some radius of another on the sky # # Input format for both lists is: # 1 2 3 # ra dec id# # # Output is: # 1 2 3 4 5 6 7 # id1 ra1 dec1 id2 ra2 dec2 distance # # ...for the first object closer than "limit" if procedure offone(list1,list2,outlist,limit) string list1 {prompt = "First list of coordinates"} string list2 {prompt = "Second list of coordinates"} string outlist {prompt = "Output file"} real limit {prompt = "Max separation, in arcmin, to save"} #bool all {prompt = "List all objects closer than limit?"} struct *el1 struct *el2 begin real dist, cdist, sdist, tdist, rn1, rn2, dn1, dn2, rt1, rt2, sigdig, distold real pa, cpa, spa, tpa, rd, dd, rds, dds, dt1, dt2, r1, r2, d1, d2, lim real pi=3.141592653585 int ipa string ir1, ir2, id1, id2, num1, num2, ooutlist, el3 string ir1old, ir2old, id1old, id2old, num1old, num2old bool aall, go el1=list1 el2=list2 el3=list2 ooutlist=outlist lim=limit distold=lim+1. #aall=all go=no while(fscan(el1,ir1,id1,num1) !=EOF) { while(fscan(el2,ir2,id2,num2) !=EOF) { # print (num1//" "//num2) r1=real(ir1) d1=real(id1) r2=real(ir2) d2=real(id2) #convert input RA to degrees rt1=15.0*r1 rt2=15.0*r2 #convert input RA,dec to radians rn1=rt1*pi/180.0 rn2=rt2*pi/180.0 dn1=d1*pi/180.0 dn2=d2*pi/180.0 #compute the distance using the formula: #cosine(distance) = sin(dn1)*sin(dn2) + cos(dn1)cos(dn2)cos(rn2-rn1) cdist = sin(dn1)*sin(dn2) + cos(dn1)*cos(dn2)*cos(rn2-rn1) if(cdist**2>=1.00)cdist=1.00 #fixes roundoff prob sdist = sqrt(1.00 - cdist**2) tdist = atan2(sdist,cdist) #theta=atan2(y,x) dist = tdist*180.00/pi ##compute the position angle using the formula: ##cos(pa)=(cos(dn1)sin(dn2) - sin(dn1)cos(dn2)cos(rn2-rn1))/(sin(tdist)) # #cpa = (cos(dn1)*sin(dn2) - sin(dn1)*cos(dn2)*cos(rn2-rn1))/(sdist) # cpa = cos(dn1)*sin(dn2) - sin(dn1)*cos(dn2)*cos(rn2-rn1) # if(sdist==0.0){ # pa = 360.0 # } else { # cpa = cpa/sdist # if(cpa**2>=1.00)cpa=1.00 #fixes roundoff prob # spa = sqrt(1.00 - cpa**2) # tpa = atan2(spa,cpa) #theta=atan2(y,x) # pa = tpa*180.00/pi # } #is this the closest match found so far for this object? if(dist*60<=lim){ go=yes distold=dist #output closest match print(num1//" "//ir1//" "//id1//" "//num2//" "//ir2//" "//id2//" "//dist*60, >> ooutlist) } #end el2 loop if match found if(go==yes)break #end el2 loop } distold=lim+1. go=no el2=el3 #end el1 loop } end ./src/scab_exam.cl.gz0100644000151400000240000000123107145001211013615 0ustar phallgames@# 6scab_exam.cln0@미Rq۔$t:Pj+ \-ԑcKXYcp&$&V+(3̊s+*+Ɍr!gp/K`"$c$&w2*g)̛ Y+UF+6JhAcb!ʞ0*{ɪbZ%4bAscf W731b0WζB+OFjLv^0 EuMc$BFkӀzGӄFp $w9_)M WZ_<+2AӘuKύqq:eKuB63z픶/jS8'7~١iktɃJ;4}ֺJ!3&91H#n L,1B-}| e& s.Ao8W;zfSʽMmM$&A :I&AolWba%Uٕw%JU9+1/vh]$$AIE_V⇕xW%nWޕ+qW%J$Mmtm&~%qXIV]]IxWJ®$\+h7IENIЛ[$d{քrr+ ./src/scab_chomsky.cl0100644000151400000240000002713407145001210013732 0ustar phallgamesprocedure scab(imlist) # scab -- scab over bleeding columns # 980807: created # 980809: fixed so that no pixel subscripts should ever be out of bounds # 980923: added imexam option # **add mask # **speed up # **below-sky? string imlist {prompt="Images on which to work (im1,im2,im3)"} string prefix="scab_" {prompt="Prefix for bleeding star lists for images"} int strip_width=9 {prompt="Default width of strip around bleeding stars"} real uplimit=4000 {prompt="Minimum value above mean for bleeding columns"} real bleedlimit {prompt="Minimum value found in bleeding columns",mode="q"} bool dodisp=yes {prompt="Display images for imexam?"} bool doimexam=yes {prompt="Interactively mark bleeding stars w/imexam?"} bool doscab=yes {prompt="Do interpolation (scabbing) step?"} bool interact=no {prompt="Interactively select bleeding limits?"} bool findisp=yes {prompt="Display before & after images when done?"} bool echog=yes {prompt="Beep when task is done?"} struct *list struct *list2 begin string img, sat_list, im_age, pre_fix, im_list, image, satlist, oldsatlist int n, nn, x, y, xleft, xright, m, mm, xstar, ystar, xcen, ymin, ymax, xstep, i int xmin, xmax, stripwidth, xlimleft, xlimright, xtmp, ytmp, xhitmp, xlotmp, l int frame, xoldleft, xoldright real leftval, rightval, bleed_limit, pixval, scabval, mean, sig, val_z1, val_z2 real up_limit bool fin_disp, inter_act, do_imexam, do_disp, do_scab im_list = mktemp("imlist") sections (imlist, >> im_list) pre_fix = prefix stripwidth = strip_width up_limit = uplimit do_disp = dodisp do_imexam = doimexam do_scab = doscab inter_act = interact fin_disp = findisp if (do_disp) { list=im_list frame=1 while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root imgets (im_age, "itermean") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (im_age, "itersig") if ((imgets.value)!="0") { sig=real(imgets.value) val_z1=mean-4*sig val_z2=mean+up_limit displ(im_age,frame,zr-,zs-,z1=val_z1,z2=val_z2) } else { beep print ("ITERSIG not found for "//im_age) display(im_age,frame) } } else { beep print ("ITERMEAN not found for "//im_age) display(im_age,frame) } frame=frame+1 } } if (do_imexam) { list=im_list; satlist=""; oldsatlist="" while (fscan (list,img) != EOF) { fileroot(img,validim+) im_age=fileroot.root satlist=pre_fix//im_age if (access(oldsatlist)) { type (oldsatlist, >> satlist) type (oldsatlist) } imexam (im_age, keeplog+, logf=satlist) vi ("-c ':g/$/s// "//stripwidth//"/g'", satlist) oldsatlist=satlist } } if (do_scab) { # do each saturated star list list=im_list while (fscan (list,image) != EOF) { if (!imaccess("_orig"//image)) { print("Now scabbing over image "//image) fileroot(image,validim+) im_age=fileroot.root satlist=pre_fix//im_age img = "_tmp"//image # get approx coords of saturated stars (x align more impt than y align) list2=satlist l=0 while (fscan (list2,xstar,ystar,stripwidth) != EOF) { m = stripwidth; mm=(m-1)/2 l = l+1 if (stripwidth != 0) { # imhistogram m-pixel-wide strip centered on star's x position print("Working on strip for star #"//l//" ("//xstar//","//ystar//")") if (l==1) { xmin=1; ymin=1 imgets (image, "i_naxis1") xmax=real(imgets.value) imgets (image, "i_naxis2") ymax=real(imgets.value) mean=0 imgets (image, "itermean") if ((imgets.value)!="0") mean=real(imgets.value) } if (l==1 || inter_act) { xlotmp=max(xstar-mm,xmin); xhitmp=min(xstar+mm,xmax) imhistogram (image//"["//xlotmp//":"//xhitmp//",*]", z1=INDEF, z2=INDEF, binwidth=INDEF, nbins=512, autoscale+, top_closed-, hist_type="normal", listout-, plot_type="line", logy+, device="stdgraph") # select lower bleedcol cutoff (= bleed_limit) if (inter_act) { beep bleed_limit=bleedlimit } else { bleed_limit=mean+up_limit print("Minimum bleeding column value is "//bleed_limit) } } if (l==1) { print ("Copying to temporary working image...") imdel (img, ver-, >& "dev$null"); imcopy (image, img, ver-) } # **alt1: problem: need leftval & rightval for each line # find x extent of sat. region at central y value of star # for leftmost x, go up in y until < bleed_limit # move to next x and keep going up # **alt2: # --n=1: start with m-pixel-wide strip centered on star x,y # --n=1: check central pixel and find xleft & xright # --n>1: if xleft=xright check for > bleed_limit & you're done # check xleft: if < bleedlimit keep checking right to xright; # if xleft < xright then do same going left from xright # save xleft & xright for previous iteration # **int xleftstart, xrightstart, xleftold, xrightold, xleftlim, xrightlim # **int oldleftval, oldrightval # --consider m-pixel-wide strip centered on star x,y for (y=ystar; y<=ymax; y+=1) { # --n=1: start with m-pixel-wide strip centered on star x,y if (y=ystar) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # --check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymax } } # --if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # --repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } xrightstart=xright ; xleftstart=xleft xrightold=xright ; xleftold=xleft # --n>1: } else { # check xleft: if < bleedlimit keep checking right to xright; # if xleft < xright then do same going left from xright # save xleft & xright for previous iteration # --now work upwards along the edge of the replacement region # for (y=ystar+1; y<=ymax; y+=1) { # xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 xcen=xstar; xleft=xleftold; xright=xrightold; leftval=0; rightval=0 # --start at old rightmost pixel + 1 & work leftwards until > bleed_limit for (x=xright+1; x>=xleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { oldleftval = bleed_limit # stay within image boundaries xlimleft=max(xleft-1,xmin); xlotmp=max(xright+1,xmax) for (x=xlotmp; x>=xlimleft; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if > bleed_limit, ** if (pixval > bleed_limit) { leftval = oldleftval; xleft = x+1 } if (pixval > bleed_limit) break oldleftval = pixval if (x==xlimleft) { leftval = bleed_limit; xleft = xmin } if (x==xlimleft) break } # --if central pix > bleed_limit check pixels to the right until < bleed_limit; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # --replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } # --next row } # --now work downwards along the edge of the replacement region ytmp=max(ystar-1,ymin) for (y=ytmp; y>=ymin; y-=1) { xcen=xstar; xleft=xcen-mm; xright=xcen+mm; leftval=0; rightval=0 # check central pixel imstat(img//"["//xcen//":"//xcen//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) # if < bleed_limit check the pixels immediately to the left & right; # if either of them are > bleed_limit; go to "> bleed_limit" section # if neither are > bleed_limit, this half of the star is finished if (pixval < bleed_limit) { xlotmp=max(xcen-1,xmin); xhitmp=min(xcen+1,xmax) xstep=xhitmp-xlotmp for (x=xlotmp; x<=xhitmp; x+=xstep) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval > bleed_limit) xcen=x if (pixval > bleed_limit) break if (x==xhitmp) y=ymin } } # if > bleed_limit check pixels to the left until < bleed_limit; if (pixval >= bleed_limit) { xlimleft=max(xcen-mm,xmin); xlotmp=max(xcen-1,xmin) for (x=xlotmp; x>=xlimleft-1; x-=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { leftval = pixval; xleft = x+1 } if (pixval < bleed_limit) break if (x==xmin) { leftval = bleed_limit; xleft = xmin } if (x==xmin) break } # repeat with pixels to the right; xlimright=min(xcen+mm,xmax); xhitmp=min(xcen+1,xmax) for (x=xhitmp; x<=xlimright+1; x+=1) { imstat(img//"["//x//":"//x//","//y//":"//y//"]", fields="mean", format-) | scan (pixval) if (pixval < bleed_limit) { rightval = pixval; xright = x-1 } if (pixval < bleed_limit) break if (x==xmax) { rightval = bleed_limit; xright = xmax } if (x==xmax) break } } # replace all pixels in the row's bleed region with 0.5*(leftval+rightval) if ((leftval != 0) && (rightval != 0)) { scabval=0.5*(leftval+rightval) imreplace(img//"["//xleft//":"//xright//","//y//":"//y//"]", scabval, lower=INDEF, upper=INDEF) } } } # **also repeat using min_sky instead of bleed_limit for oversubtracted regions # in SNe images, reversing the sign so to speak # repeat for next star in satlist } if (fin_disp) { display (image, 1) if(imaccess(img))display (img, 2) } if(imaccess(img)){ imren (image, "_orig"//image, ver+) imren (img, image, ver+) } } else { print("_orig"//image//" already exists; scabbing already done!") } # repeat for next satlist } } del (im_list, ver-) if (echog) beep end ./oldir/0040777000151400000240000000000007215457701011311 5ustar phallgames./oldir/btc_saulflip.980702.gz0100644000151400000240000000145606547152267015077 0ustar phallgamesԜ5btc_saulflip.980702Un0 =_J~z:NP(U,ò]},Il/ISe[—,{ ɲ4PBB~Ϟҽz#TmEkZ2 z0][w-HAI0KctRhUW;{pcM/}ծh.2vm: NvZvmzX"%*MX*ʚHއrh9,`/w\ dl׭ؖ=@14Iy|Ⱥ }SGhK9 H_n`|O8I_e&kKÞ!Llj%I㨞D׻9BwEaȅA~&qf`:'sv<8'@5JՎzl~fsg,r=s̯ej^Mfs cJ6 ı}iQ.] NA2~祌NJ:ɇ 0n_|v vfPh􌺗|5`6˙οQa!ɍۥ4_|>gǵY$ 8h= ۏ*A.L})Q2azW֋ލaD-Z,344np!=oj~U[ӱ %v*ۛIHW>V2/'R./oldir/testfringe.980728.gz0100644000151400000240000000356706560132421014600 0ustar phallgames5testfringe.980728Xm6l|H[ܠ@"5=4v(El$Q` I-"IpNJc7*r <`NY_JF :iNqeMo^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3~S  ,Azʇmt6hDWM '"wj\Wvv>䓗 1aN58شDDDIe{@mympų Oc8ZrThD"vY Sq;`MA(h+Ʊvi8 \LCƎp}&zE,U0vL%kF:EN|*񸴯2R:*}R>z>Kxd \镟s53/_?3k>s xƗxy'7|9rrA gcB͗IPO\0{<#W-߇$?pyU慫,{:ܮfRMTRy,l^ W5fS6 z'=C[Z3^y>XV)'Jt'Iw N./oldir/focasflat.980923.gz0100644000151400000240000000303306561403670014361 0ustar phallgames5focasflat.980923Wn6}b*Z+g{q /)<CQ.R퍛~{gHfa98"k\sV01Z[JэTF +j =+0H &^xz6;%[!'J?7ഴԖae=0ĂamT+nK2#9h#WRDiHdxd"F?F,)V},պ|܊:8>Bٶ5ke=AÿP75[:Mww?nހW y7VkA=GR\Dh:]-R5e.#9Ÿ>~FcnT*#8d3Ku(73PH%:&\KJhܛZJv?un9T·m+25ՍRdѤF~T`8a`+"1Jhd1lM wch0Sd{8l0ACf+|1und $4@tYUmag Nt,n#Ľ'~/Q^֋h":) &^-eE#`}2LWdYr6~j=r`22zMEAWW,[p+<2.OI?NLy\N~(0 'v E|‚a]61e& 06gTOW!3jCu\PP<*2A-,ni—Y<0t_==TQb~E&쮿dx)$ò & l^/޼]$/ɳtC/Z$Ft$ܑ(D?{d {:r=a PU~xAGؚ8 J4]v㼓}|uOtuum`WfHg~xFFt"~fn:w_s{ lFtL n\}pp GZG<`HؚҧkP,R\R㨱ަNgNkDŽȃ %얶w-Rd8x7 'T/ZKj D(\wm?.nt rv >3@S`>9< m5!"خPaQLؑuM}ŗ/8(vQtwSYs6gm`- 3݆wDӯVC>2_-/.H9>s$}i!WN9Q!;QL2E;fxx(珖پNjy^>hC=7D|޺ߵa(Tf./oldir/focasflat.981108.gz0100644000151400000240000000337006621426572014364 0ustar phallgamesz-F6focasflat.981108Xk۶,~xo 6qmSPmŖ(DoR?ę3gjʬ%&M^KE)cM랦aljQ5zVj M~lv=#U Rʆ*Y%1+lLu= QH Y^DɌҭLwp&[Lک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ؼD?i$9-V. $d m^=۰[ @y t)kp~ٯ@60Xp\,b%Fvٺ &)(14LN(4PG&jE/|brk ^.PjzNOܒ,%NnCם B綉SVl S%x Q|b&[',Ԥ=n)ak͉5 f3y{h~w[ǃcy?0-Tqdd!-y|H._`Izn^a 0ƴ>~ul}?\gOL܍òhO I틩>Nd3sߐ}*ADY *,k͓zѸ0NUsC:Nr> <7<->iVzYǀB!sw 2|r8X•($UBPKXP[]&YoVPPP rս% ݼ /: uL{c#]`r|sU,_);|F%\ "oޖ8r2GX+囗qbW|tX^Wg6*o2Ob7$g~ŬP#8BBq6Nؑ춪vHM#gh5BUȵe;Rg/kZX9Fw-شR 옘Q*ˮZ0+ދLN3`5݊=Vnkݷ~Lǵ7d Vv**Q%m,J>`EBڃP$nd)9@"ˣ)/~!!z;JD+`χqVrQ. h|9'E5yRNBqxP 9]Yd(L[+RH \>T-\ Y\Aw ķ;_..cEj<_@v@O: 9(zy:;\Jr-Ů- !G[jZ *Qn?gfHB (./oldir/ptv.cl0100644000151400000240000000231006665365653012443 0ustar phallgamesprocedure ptv(image,frame) # ptv -- display image in range determined from iterative mean & sigma # # 950808: created # 981216: negative lsig/hsig values use the absolute value of lsig/hsig # for that limit # 990222: now uses plain old display if iterstat hasn't been done on image string image {prompt="Image to display"} int frame {prompt="Frame to use"} real lsig=3 {prompt="Number of sigma below mean for display lower limit"} real hsig=10 {prompt="Number of sigma above mean for display upper limit"} begin string img real h_sig, l_sig, mean, sig, val_z1, val_z2 img = image l_sig = lsig h_sig = hsig imgets (img, "itermean", >& "dev$null") if ((imgets.value)!="0") { mean=real(imgets.value) imgets (img, "itersig", >& "dev$null") if ((imgets.value)!="0") { sig=real(imgets.value) if (l_sig<0) { val_z1=-1*l_sig } else { val_z1=mean-l_sig*sig } if (h_sig<0) { val_z2=-1*h_sig } else { val_z2=mean+h_sig*sig } display (image, frame, zr-, zs-, z1=val_z1, z2=val_z2) } else { beep print ("ITERSIG not found in image header; using display") display (image, frame) } } else { beep print ("ITERMEAN not found in image header; using display") display (image, frame) } end ./oldir/ptv.cl.gz0100600000151400000240000000067106564643671013057 0ustar phallgamesG5ptv.clMO0 ͯ0EBlh! Pm#iC߱ !C;o6ϘuHղInec!)d5| J6:ҘAnҩ5BR%af-JJE.+w/]٪dU")YEEJNNB Ūy YT@*4i3A :oCD Taav-yA7 ^M)< ] nĈ̌B0cbv8KYq~EM} s?r?B>7;_˿y2 V-\RDC;ūt:!.Qfh/Q3u#ۥ.Q@MO5cj./oldir/scab.bkup.gz0100644000151400000240000000250006564417574013523 0ustar phallgames|5scab.bkupX[o6~~řlv,7q [eú>aYm"h"HRr,A3 x9xX5 W˱FdJ:?I0LY|QR fCU6B?pK*kQxJkHh|>YC[Yn[ui7[56#v (GҶr m5ums#BK# OaPIC `_/BQXp.((v8I#uP5+èM3mW"OZ5nY \ Cp$?EBLH3d$K&#ͨ%Znxki*W[ wJ ( pp*نAI5(#ɠ z'H ڃ1~99K4K쬃qsqn?-H+1{s[*/A%maÓ=Jx y(\D*;N۬ۂ }ӫ_O#zvSt*:3P# kMz^!Û}稥:5h.IGzriˡ; p3<W:ZKib0}2*o _]:eĪ][Bɳl08\0g70VFu~sUtIH(oCAPk~6IF{.;V]J!Z< SE lȯmM@PESzp7´E$;#%/=Or-ҵ#_Q5^CJ=q4WjiDv*Sݙc1%ފ`Qev!ѹM |BTI"*I(~./oldir/scab.bkup2.gz0100644000151400000240000000257706564417575013624 0ustar phallgames}5scab.bkup2XKoF>bJdQE.6rhZ  r4̒zn\maVռg)5<\$;3hK$PY_:ZSeP(g u,QQ`e`9vz7I_Ku.CF .=lGm7\^OP+WtQW0Pý>K|Y#RoAd9'LqۅD[P@?=?v6+omڶH[gBp tPSUd H^P.0%Ar߰RCs]Ww' h:I]@P;$;wcNO8AQ8YH MooPyg`IY,*vK-D6_)UE*QZSB./oldir/scab.bkup3.gz0100644000151400000240000000300406564417575013607 0ustar phallgames}5scab.bkup3XQo6~~M:+c;@:`[ a݀=aYm"tc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