track


 TRACK   -- measures and fits the X position of the spectrum as a 
 function of Y. The result is needed when you wish to cope with 
 significant tilt on the spectrum. It is assumed that the spectrum
 runs more-or-less vertically.

 TRACK works by first locating the spectrum in a block of rows. It then steps
 up and down from this point looking for the spectrum in a window centred on
 the previous position. The positions are measured by cross-correlation with 
 a gaussian. The positions are fitted with B-splines and optionally the
 whole process is repeated for stability with the windows centred on 
 positions defined by the previous fit. Plots of the fit can be overlaid a 
 greyscale image or over the measured positions.

 If an old track file is used, then the spline is kept fixed, and the residuals relative
 to the spline are fitted with a polynomial whose order is stored in the PAMELA.TRACK
 extension as NPOLY. This is set to zero for a new spline-only fit. If non zero then the
 data values are the polynomial coefficients. If NPOLY=0, the data value (only 1 of them) is
 meaningless. The polynomial is scaled to run from -1 to 1 between the end spline knots which 
 mark the edge of the data

 TRACK checks for bad pixels and eliminates points too badly affected by them. This allows
 the user to specifically remove points if he/she thinks TRACK is failing because of them.


 Parameters:

  IMAGE  -- Data frame to track

  FLAT   -- Balance frame

  OLD    -- TRUE to update an old fit. In this case the spline from the old fit
            will be read in and preserved and you will be prompted for the number 
            coefficients of a polynomial correction to this.

  TRACK  -- Name of file in which fit will be stored. Should already exist
            if OLD=TRUE.

 If OLD

    NPOLY  -- Order of polynomial fit. This will only be prompted for if OLD=TRUE.
              It is the number of poly coefficients after the existing spline fit 
              has first been subtracted. 
 else

    NSPLINE - number of splines to use if OLD=FALSE. 

    ORDER   - order of the spline (4=cubic)



 NFPOLY  -- Order of plot polynomial. A poly of order NFPOLY will be
            removed before plotting in order to show the residuals more
            clearly.

 XSTART, XEND -- valid X region. Useful for isolating an order.

 YSTART, YEND -- Valid Y region, sometimes should crop down if track is
                 having trouble finding the spectrum if it fades near ends.

 If OLD

   TWEAK  -- TRUE to tweak spectrum as opposed to completely relocating it.
           This means that the old spectrum will be used to find the new one
           as opposed to finding the entire spectrum from scratch. The current 
           spectrum should be close to the old one (within a FWHM or two).

 PICK   -- TRUE to pick spectrum automatically. Normally this works, but
           every so often you have to do it by hand.

 If PICK

    NOBJ  -- Number of objects. The routine will identify the NOBJ highest
             peaks. If your target spectrum is the third highest then you
             should either define XSTART and XEND to isolate it or put
             NOBJ = 3. Beware variability which may demote your target even
             lower. If so increase NOBJ.


    IOBJ -- Which object counting from the left of the frame.

    IBLOCK -- Number of rows to average for start position.

    YPOS   -- Initial Y position to start at.

 If TWEAK

    OFFSET  --  Offset to add to old fit to locate new spectrum. Most
               useful if there are two stars on the slit.

    FCHANGE --  If a position shifts by more than FCHANGE on the first position
                check that point is rejected. This is similar to CHANGE but allows
                more slop for TWEAK cases where one cannot be too accurate to start
                with. CHANGE (see below) applies on later cycles.

 PLOT   -- TRUE if you want plots.

 HARDCOPY   -- TRUE if you want the plots to be hardcopy

 AUTO   -- TRUE for automatic scaling of greyscale plot

 If .NOT.AUTO

    LOW, HIGH -- Limits for greyscale plot

 WIDTH -- The width of the window which should cover the object and some more.
          (Preferably should be several times both ESIG and FWHM).

 ESIG  -- FWHM of gaussian used to measure position by cross-correlation.
          Should be similar to FWHM of spectrum.

 FWHM  -- FWHM of profile. This need only be an estimate and is used to 
          attempt to correct for undersampling. This can be seen if the
          positions tend to stick to the middle of pixels. Beware of making
          it too large because it can actually add discontinuities to the 
          measured positions. Set = 0 to ignore.

 READOUT -- RMS readout noise, ADU

 PHOTON  -- electrons/ADU

 CLIP  -- Sigma rejection threshold during poly fit.

 NBLOCK -- The spectrum can be taken in blocks of NBLOCK rows at a time to
           improve signal-to-noise.

 If NBLOCK.GT.2

    PSIG   -- The blocks can be improved by kicking out discrepant rows.
              PSIG is a threshold for doing just this. 

 TCYCLE  -- The number of additional cycles following the first fit to
            clean it up and make sure that it is stable.

 CHANGE  -- If a position shifts by more than CHANGE during a tweak cycle
            that point is rejected. Typically the positions should shift
            by much less than a pixel.



This command belongs to the classes: tilted , fitting


Tom Marsh, Warwick