; script for quick reduction of pt. source: ; ; 1. bias subtraction ("nb") ; 2. linearity correction ("lin") ; 3. flatfielding with twiflat ("linfl") ; 4. 1st pass sky subtraction using super-sky frame ("sub1") ; (scaled median-averaged, median combined all the frames) ; 5. mask out stars in frames interactively ("skymask") ; 6. 2nd pass sky subtraction using AUTOGAL: ("sub2") ; uses masks and make a local sky frame for each image ; 7. registration via centroiding (interactive) ; 8. mask mosaic ; 9. save final reduced frames and their sky frames ; ; I believe the masking convention is entirely ; consistent in this routine (after extensive debugging) ; ; assembled from: NBLIN.IDL, FLSUB.IDL, SAVE.IDL ; 4/20/96 MCL ; ; added some user prompting, overwrite checks ; 8/20/96 MCL ; ; fixed one small error in propagating BADVAL during 1st pass sky sub, ; helps to make displaying the masked sky frames easier ; 10/17/96 MCL ;-------------------------------------------------- ; please set these to the appropriate strings: ; (need to global replace in the script) ; ; object name: fs29j ; set of frames: _n2-1 ; bias frame: bias5274 ; bad pixel image: badpix ; twiflat: jtflat2 ; ISTART = 5300 ; 1st image NC = 1 ; number of coadds/image NF = 6 ; number of images ; ;-------------------------------------------------- BADVAL = -1e6 MASKRAD = 20 ; radius for masks dlim = 50 ; for sensible displaying ; check for relevant calibration frames if (n_elements(bias5274) eq 0) or (n_elements(badpix) eq 0) or $ (n_elements(jtflat2) eq 0) then begin print, '** calibration frames not loaded !! **' retall endif ; check file numbers print, '-- ISTART = ', strc(ISTART), ', NCOADD = ', strc(NC), ', ' + $ 'NFILES = ', strc(NF), ' --' goto, STARTHERE ;STARTHERE: ; make image list listims, istart, istart+nc*(nf-1), step = nc, $ out = 'fs29j_n2-1.lst', fname = 'fits/d', /lick ; get images loadimf,'fs29j_n2-1.lst',fs29j,/lick ; subtract bias print, '========================================' print, '=== subtracting bias frame: bias5274 ===' print, '========================================' skysub,fs29j,bias5274,fs29j_nb fs29j = 0 ; linearize ans = '' ;read, 'apply linearity correction? (y|n) ', ans ;if (ans eq 'y') then $ if getyn('apply linearity correction?') then $ lincorr, fs29j_nb, fs29j_lin, lincoeff, satmap $ else $ lincorr, fs29j_nb, fs29j_lin, lincoeff, satmap, /nocorrect fs29j_nb = 0 ; check to see which are sky loadct, 15 win,0,title='IDL (0): scan mode' print, '==============================================================' print, '=== look at bias-sub., linearized images (self-subtracted) ===' print, '==============================================================' scan,fs29j_lin>0,/sub ; flatten print, '=======================================' print, '=== flattening frames with: jtflat2 ===' print, '=======================================' w = where(fs29j_lin le BADVAL) flatdiv, fs29j_lin, jtflat2, fs29j_linfl, badpix = (jtflat2 gt 0) fs29j_linfl(w) = BADVAL fs29j_lin = 0 ;; make skyflat and sky flatten ;avgmed,fs29j_skyflat,fs29j_linfl ;fs29j_skyflat = fs29j_skyflat / median(fs29j_skyflat) ;flatdiv,fs29j_nb,fs29j_skyflat,fs29j_nbfl ; examine the results print, '==================================' print, '=== look at flatfielded images ===' print, '==================================' scan, fs29j_linfl > 0 ; do 1st pass sky subtraction print, '======================================' print, '=== doing 1st pass sky subtraction ===' print, '======================================' avgmed, sky_avg, fs29j_linfl skysub, fs29j_linfl, sky_avg, fs29j_sub1, /scale w = where(fs29j_linfl eq BADVAL, nw) if (nw gt 0) then fs29j_sub1(w) = BADVAL sky_avg = 0 ; mask stars from the sky frames ; and combine mask with the saturated pixel mask print, '=========================================' print, '=== please mask stars from sky frames ===' print, '=========================================' ans = '' ans2 = 'y' if n_elements(fs29j_skymasks) ne 0 then begin read, 'masks already defined - reinitialize them? (y|n) ', ans if (ans ne 'y') then $ read, 'masks already defined - add objects to them? (y|n) ', ans2 endif if (ans eq 'y') then begin imask, fs29j_sub1, fs29j_skymasks, $ badpix = badpix, radius = MASKRAD, $ lscl = -dlim, uscl = dlim, /new endif else if (ans2 eq 'y') then begin imask, fs29j_sub1, fs29j_skymasks, $ badpix = badpix, radius = MASKRAD, $ lscl = -dlim, uscl = dlim endif STARTHERE: print, '=============================' print, '=== look at masked images ===' print, '=============================' scan, fs29j_sub1 * fs29j_skymasks > (-dlim) < dlim while getyn('do you want to do more masking?') do begin imask, fs29j_sub1, fs29j_skymasks, $ radius = MASKRAD, badpix = badpix ; lscl = -dlim/2., uscl = dlim/2. print, '=================================' print, '=== look at masked sky images ===' print, '=================================' scan, fs29j_sub1 * fs29j_skymasks > (-dlim) < dlim endwhile fs29j_sub1 = 0 ; do 2nd pass sky subtraction, using masks ; note that pixels in the subtracted images which had ; no good pixels in the sky frame are set to BADVAL print, '================================================' print, '=== doing 2nd pass sky subtraction (w/masks) ===' print, '================================================' autogal, fs29j_linfl, fs29j_sub2, fs29j_sky, $ nsky = 2, mask = fs29j_skymasks * (fs29j_linfl gt BADVAL), $ badpix = badpix ;; cross correlate & mosaic ;print, '===============================================' ;print, '=== cross correlating images to find shifts === ;print, '===============================================' ;imgcor, fs29j_sub2(*, *, objlist), fs29j_dx, fs29j_dy, mask = $ ; (fs29j_masks* (fs29j_sub2 gt BADVAL))(*, *, objlist), badpix = badpix ; register frames interactively and mosaic print, '========================================' print, '=== interactively registering frames === print, '========================================' ireg, fs29j_sub2, junk, junk2, fs29j_dx, fs29j_dy, $ badpix = badpix, masks = (fs29j_sub2 gt BADVAL), $ /nomos, lscl = -dlim, uscl = dlim print, '======================' print, '=== making mosaic ===' print, '======================' mosf, fs29j_sub2, fs29j_dx, fs29j_dy, $ fs29j_mos, fs29j_mosexp, fs29j_mossky, $ badpix = badpix, $ mask = (fs29j_sub2 gt BADVAL),/setsky ; show resulting mosaic window,4,xs=450,ys=450 loadct,15 wset,4 display2,alog10(fs29j_mos>1) ; write results from reduction scripts (PTSOURCE.IDL or GALAXY.IDL) ans = '' ;read, 'do you want to save the files? ', ans ;if (ans ne 'y') then stop if not(getyn('do you want to save the files?')) then stop ; save stuff ans = '' read, 'did you remember to change ISTART = '+strc(istart)+' ??? ', ans if (ans ne 'y') then read, 'enter value for ISTART: ', istart writeims, fs29j_sub2, numlist = indgen(NF)*NC + istart, $ fname = 'fs29j_', ext = '.fits', /lick writeims, fs29j_sky, numlist = indgen(NF)*NC + istart, $ fname = 'fs29j_', ext = 'sky.fits', /lick print, '=== writing mosaic files for ===' writefits, 'fs29j_n2-1_skymasks.fits', fs29j_skymasks writefits, 'fs29j_n2-1_mos.fits', fs29j_mos writefits, 'fs29j_n2-1_mosexp.fits', fs29j_mosexp spawn,'date',date openw, unit0, 'fs29j_n2-1_shifts.dat', /get_lun printf,unit0, '# fs29j_n2-1_shifts.dat' printf,unit0, '# image offsets for fs29j_n2-1' printf,unit0, '#' printf,unit0, '# ', date printf,unit0, '# ' printf,unit0, '# dx dy' printf,unit0, ' ' free_lun, unit0 printarray, [[fs29j_dx], [fs29j_dy]], out = 'fs29j_n2-1_shifts.dat', /silent openw, unit0, 'fs29j_n2-1_mossky.dat', /get_lun printf,unit0, '# fs29j_n2-1_mossky.dat' printf,unit0, '# sky offsets for fs29j_n2-1 frames from mosaicing routine' printf,unit0, '#' printf,unit0, '# ', date printf,unit0, '# ' printf,unit0, '# frame number sky offset' printf,unit0, ' ' free_lun, unit0 printarray, [[indgen(n_elements(fs29j_mossky))], [fs29j_mossky]], $ out = 'fs29j_n2-1_mossky.dat', /silent end