
A Modicum of Help in Using Reduce
---------------------------------
updated 2 October 1995 prme, updates flagged by ***
***One of the main goals of the modifications has been to make the
different reduce switches more independent, so that one can do the
interactive parts in one session, and fire off
a bunch of batch noninteractive reductions when you leave for the day.
The main changes involve xzap, badpixupdate, and interactive mask
checking. *** in the comments to a parameter is just my attempt to
make the comments more accurate.

The three inputs to reduce are a list of images, a reference image within this list,
and the base name for the output image.  The input images should have been 
linearized and flattened, and a good choice for the ref image is the 2nd or 3rd image
in the list.  The parameters are listed in the order in which the reductions are
usually performed.  You can set it up to do partial reductions, like through the
firstpass stage (just turn off everything after fp_registar), and then start up
reduce again later to finish it off by turning off everything that has been done
and turning on what needs to be done). Here is the parameter list with some comments -

img_lst	- a text file giving the list of input images

out_img - base name for output firstpass and maskpass images

*** kpchking - See the "chk" parameter below.  If chk is yes, you will be
	given the chance to continue modifying the mask files
        until you set kpchking to no.

ref_img	- name of the reference alignment image in this list

prefix  - a prefix for sky-subtracted images which will default to "ss_";
	the firstpass sky-sub images will be deleted but the maskpass
	versions will remain at the end of reduce

*** chk     - Do you want chances to check shifts and masks?  answering yes
	allows you to edit intermediate files in the process of making
	the shiftlist (you always get to edit the actual shiftlist since
	you might want to zero out some bad frames [by setting the last
	number 1 on that image line to 0]) and to prompt you to look at
	the masks. *** Mask checking now puts you in a loop until
	you answer no the "Keep checking mask?" question.

fp_xslm  - set to yes to make sky-sub images the first time (no masks)

fp_fixpix- set to yes to interpolate over bad pixels, as defined in the 
	bpimage; acts on the sky-sub images only in the first pass

*** fp_xzap  - set to yes to remove cosmic rays in the sky-sub images in the
	first pass; uses a set of default parameters which work well for
	256x256 IR array data with fwhm=2 pixels.  Creates set of 
	crmask* files, one per frame, which get used in later steps so
	that turning on xzap in the mask pass stage is not necessary.
	*** xzap now writes the crmask file name in the image header,
	and acts different in the mask pass, so you may want to leave 
	it on there.
	
*** fp_badpixupd- set to yes to add frequently zapped pixels from xzap 
	to the bpimage.  *** Modified to work with an unlimited number
	of input images to avoid the crash that occurs when too many
	files are open.

mk_shifts- set to yes to create shiftlist by first centering the same star
	in all sky-sub images, then centering several stars in the ref
	image, and finally editing the shiftlist to zero any bad frames

fp_register- set to yes to make a registered image in the first pass through 
	with no masking

masking	- set to yes to make an object mask from the firstpass image.  A little
	trick is employed here to prevent objects from getting cosmic ray zapped
	by mistake.

maskdereg- almost always set this to yes if you are doing the maskpass, it creates
	object masks for each frame from the master mask

mp_xslm - set to yes to do sky-subtraction the second time through with masking

mp_fixpix- set to yes to fixpix the new sky-sub images using the bpimage

*** mp_xzap - set to no to avoid repeating *running* xzap; 
	cosmic rays will still be
	taken care of by use of the crmask files created the first time xzap was
	run (assuming you did this in the firstpass through the data)
	*** However here xzap can use the object masks to avoid zapping
	objects.

*** mp_badpixupd- set to yes to add frequently zapped pixels from xzap 
	to the bpimage *** Modified to fix crash when more than 100 input 
	images created too many open files.

mp_registar - finally register the masked sky-sub images - this creates the final 
	image

nmed    - number of neighboring frames used to create a sky image; 6 or 8 works well

bpimage - the bad pixel mask image (with 0 for the good pixels and 1 for the bad pix)

mfac    - the pixels are replicated by this number in the maskpass stage when the
	sky-sub frames are registered so that no interpolation is necessary when 
	doing the shifting.  2 or 4 are a good numbers.

secpexp - the exposure time of the frame

ncoavg  - Number of internal coaverages per frame, so the total integration time is
	secpexp * ncoavg for a given input image

rjct    - Number of pixels for minmax reject when making the sky frame, 
	usually use 1 or 2

nskymin - Minimum number of frames to use for sky at beginning or end of list;
	usually set at 2 or 4

forcescale - Force recalculation of image medians in sky scaling after masking, 
	usually set to yes

premask - Mask working sky images in maskpass, usually set to yes

pixin   -  set to yes if input coords are measured pixels of a ref object
	*** This is the case if you set mk_shifts to yes.

*** the "historical" parameters allow for registration in the case where
you can't (or don't want to) use a reference object. We have used
commanded arcsecond offsets and guide probe readouts in such cases.
The parameters allow for two coordinate systems: the xy pixel coordinate
system of the array, and the ab coordinate system of the offsets or
guide probes.

scale_x - historical, automatically set to 1 if pixin=yes. 
	(i.e. if you are using measured reference objects for shifts)
	*** if you were using arcsecond offsets and the pixel size was 0.25
	arcsec in the x direction, you would enter 4 here

scale_y - ditto

ang_a2x - *** Automatically set to 0 if pixin = yes. 
	It is the angle in degrees from a CCW to x where a,b can
	be a different coord system than the x,y coordinate system of your frame

senseab - *** Is a through b counterclockwise?  Automatically set to yes if pixin is yes
	
ang_y2N - *** dimsum will output your registered image within 
	45 degrees of N up and E left if you set ang_y2N and rotation 
	correctly. ang_y2N is the angle in degrees from pixel y to celestial 
	north, in the direction N through E for a displayed input frame.  

rotation - For a displayed input frame, is N through E counterclockwise (yes or no)?

nsig_obj_msk - factor times suggested threshold for object masking, try 1.0; during
	the masking stage the task will automatically find a masking level.  
	*** If chk=yes you probably need to type in the suggested threshold 
	value again, however.  If you
	usually like the result of this procedure then set to 1.0; if you want 
	fewer pixels masked set the level higher (e.g. 2) and vice versa.

nsig_cr_msk - factor times suggested threshold for cr masking, try 1.5; the first
	part of the masking stage makes an object mask which is used to correct
	cosmic ray masks for any real objects which were zapped.  
	*** generally this might the core of a star, hence the higher threshold.

