# # Proccedure to cut out masks that correspond to individual images # and assing them in the headers of the sky images. # By Richard Elston 9/18/95 # procedure mkmask(skylist,maskimg,offsets) string skylist {prompt="Name of sky image list"} string maskimg {prompt="Mask image name"} string offsets {prompt="Name of offset file"} struct *imglist struct *offlist begin Int oxdim, oydim, ixdim, iydim, ix, iy, xe, ye Real xoff, yoff, xmin, xmax, ymin, ymax string img, msect # Get dimensions of mask image from image mosaic produced by shiftfix. imgets(maskimg,"i_naxis1") oxdim=int(imgets.value) imgets(maskimg,"i_naxis2") oydim=int(imgets.value) # Get dimensions of first input image. It is assumed that all the # input images have the same dimension -- no checking is done for this. imglist = skylist if (fscan(imglist,img) != EOF) { imgets(img,"i_naxis1") ixdim=int(imgets.value) imgets(img,"i_naxis2") iydim=int(imgets.value) } else { print ("ERROR reading image name from file ",skylist) return } # Rewind file list. imglist=skylist offlist=offsets # # Find Minimum X and Y offset in the offlist file # xmin=1000 ymin=1000 while (fscan(offlist, xoff, yoff) !=EOF) { if( xoff < xmin) {xmin=xoff} if( yoff < ymin) {ymin=yoff} } # # cut out subimages and set headers. # offlist=offsets while (fscan(imglist,img) != EOF) { if(fscan(offlist, xoff, yoff) !=EOF) {} print ("Making mask images for ",img) ix=xoff-xmin+1 iy=yoff-ymin+1 xe=ix + ixdim - 1 ye=iy + iydim - 1 msect = "["//ix//":"//xe//","//iy//":"//ye//"]" if (access("mask_"//img//".pl")) imdel ("mask_"//img//".pl",ver-) imcopy(maskimg//msect,"mask_"//img//".pl",ver-) hedit(img,fields="BPM",value="('mask_'//$I//'.pl')", add+,ver-,up+,sho-) } # Clean up. end