NAME: warpstack PURPOSE: (one line only) Stack a set of images on a given ROI warped to a master image DESCRIPTION: This tool is designed to build a reference image for a given image of the sky. The reference image is intended to be subtracted by a later tool to remove the fixed stellar background. The template is built by resampling the input reference images to precisely match the master image, which includes its scale, orientation and any optical distortions. The input list of reference images should be a reasonble list of images to be considered but not all of them are required to be useful for this purpose (ie., no overlap). However, it is up to the calling program to not propose reference images that contain the object of interest on or near the location of that object in the master image. The stack is built from those reference images that have overlap with the ROI on the master image. The software works to use only the best data from the reference image list to make the template. When complete, four files are saved. 1) a log file containg information about the stacking process, 2) the stacked image in FITS format, 3) the cube from which the stack was built, also in FITS format, and 4) a screen shot of the template image saved in .png format Construction of templates works best where there are lots of images to work with but this tool strives to make do if the number of files is small. With 5 or more images, it will do a robust average of the cube. With 4 or less a straight median is used. If there is only one relevant file you get that one file, resampled to match but it will still have all image blemishes, like cosmic ray strikes. CATEGORY: CCD data processing CALLING SEQUENCE: warpstack,fnim,fnref,error INPUTS: fnim - File name of the master image that the stack will be built to match fnref - List of files that may be useful for building a stack OPTIONAL INPUT PARAMETERS: KEYWORD INPUT PARAMETERS: FWHM - Vector of fwhm, in pixels for each image in fnref. If provided, this can speed up the program significantly. The default is to determine this on the images internally. GAIN - Gain of detector, default is 1e-/DN KEYFILE - Header keyword list (see loadkeys.pro) OUTPATH - Directory where output files are to be written to. Default is to write to the current directory. PATH - Directory where input images (master and reference) can be found. You can put paths on the inputs in which case use the default of '' for this keyword. ROI - Region of interest from master image that stack will be built to. The default is to do it for the entire image. Provide a 4-element vector [i0,j0,i1,j1] (lower left hand corner and upper right hand corner of region) to use this option. VERBOSE - Flag, if set will turn on a lot of printed output to see what the program is doing. MINAREA - minimum fraction of area overlap allowed to keep a template image. Default = 0.65 OUTPUTS: error - Flag, set to 1 in case of error. The KEYWORD OUTPUT PARAMETERS: COMMON BLOCKS: SIDE EFFECTS: RESTRICTIONS: This tool depends on the presence of WCS information in the image headers and expects to find my format information in there (see astinfo.pro). PROCEDURE: MODIFICATION HISTORY: 2016/04/12, Written by Marc W. Buie, Southwest Research Institute 2016/04/21, MWB, slight fixes to logic for output file names when input files contain their paths. 2016/09/29, MWB, added MINAREA keyword