Rough outline of CIRSI data reduction
20 March 2000


1) Make flatfield / gain map

  a) Median combine domeflat observations taken with dome lamp on
  b) Median combine domeflat observations taken with dome lamp off
  c) Subtract combined lamp off from combined lamp on to make flatfield image
  d) Divide flatfield by its mode to make gain map
  e) Identify bad pixels and set to 0.0 in gain map
       A pixel is bad if gain < 0.7 or gain > 1.3 or > 5 sigma deviant from 
       local background in gain map
  f) Apply flatfield correction to data (multiply by inverse of gain map)

2) Combine loops
  
  a) Apply zero offset to images using image modes
  b) Calculate unweighted mean image (rejection is based on robust standard
     deviation if 5 or more loops, otherwise standard deviation estimated
     from median signal level and assumption of photon noise)

3) First pass sky subtraction (using loop-combined images)

  a) Calculate sky image from median of four nearest frames in
     time sequence and subtract sky image
  b) Apply reset anomaly correction by subtracting the row mode from each
     row and column mode from each column, working quadrant by quadrant

4) Determine offsets between dither frames in each dither set

  a) Obtain first guess of dither offsets from RA, DEC keywords in image header
  b) Threshold images - set pixels below the object detection threshold
     (a few sigma above sky) to zero (used SExtractor program)
  c) Cross correlate the non-zero pixels (object pixels) and determine
     dither offset from peak of cross-correlation image

5) First pass dither set coaddition

  a) Create weight maps for image coaddition from:
     gain_map * number_of_loops * exposure_time / image_variance
  b) Register images and weight maps using modified bilinear interpolation
     that accounts for bad pixels
  c) Coadd registered frames using a weighted, clipped mean (the rejection
     method used depends on the number of valid pixels at that position 
     in the stack as described in step 2) above)

6) Produce object masks from coadded dither sets to use in second pass analysis

  a) Threshold images to identify objects (used SExtractor program)
  b) Grow object region by multiplicative scaling (eg, doubling) of
     detection isophote
  c) Unregister dither set object mask to obtain masks for the individual
     dither frames

7) Second pass sky subtraction (process each loop separately)

  a) Calculate sky frame from weighted, clipped mean of 10 nearest frames 
     in time sequence (with object masking) and subtract sky frame
  b) Apply reset correction, this time with object masking to improve
     mode calculations
  c) Combine loops of second-pass sky-subtracted images as described above
     for first-pass loop coaddition

8) Second pass dither set coaddition 

  a) Coadd dither frames as done in first pass analysis, but this time
     using second-pass sky-subtracted frames

9) Astrometry

  a) Set rough WCS in FITS header from telescope RA, DEC, and chip number
  b) Match objects in coadded dither frames to the APM catalog using a
     triangle matching program and calculate 6 coefficient linear coordinate 
     transformation 
  c) Update WCS in FITS header
  d) Alternative approach is interactive astrometry using Skycat GAIA program

10) Make tile image (13' x 13' for du Pont data)

  a) Drizzle coadded dither frames onto tile image (used ESO drizzle program)
     producing a tile image and associated map of effective exposure time


Possible improvement in pipeline:

Instead of coadding dither sets and drizzling coadded dither frames onto a
tile image, just do a single coaddition step: coadd all individual dither
frames directly to form the tile image.
