profit


 PROFIT  -- Implements the fitting method described in 
            1989, PASP, 101, 1032 for fitting the fractions needed
            for optimal extraction when the spectrum is tilted or curved.

 There are circumstances when extopt behaves poorly because the spectra
 are too strongly tilted. This is when 'profit' followed by 'optext'
 should be used.

 In principle PROFIT should collapse with a dead-straight spectrum as the
 linear equations become ill-conditioned. However I have yet to have it do
 this and even on spectra tilted by less than a pixel it has been fine.
 However you should keep an eye out if you are trying to apply it very
 straight spectra. Use extopt if it does fail in such cases. 


 Parameters are:

  IMAGE   -- The data file under analysis.

  FLAT    -- balance frame.

  DLOAD   -- TRUE if dark frame is required.

  DARK    -- Dark frame representing counts unaffected by slit
             profile. This will be subtracted off data before applying
             the balance factors. 

  REGION  -- Contains the sky/object region limits (only the object
             limits matter in this case).

  SKY     -- Contains fits to the background sky in the region of
             the object.

  TRACK   -- Contains fit to position of spectrum.

  FRACT   -- Output file containing fit evaluated over region of
             extraction.

  YSTART, YEND -- The Y pixel limits of the extraction.

  READOUT -- The readout noise of the detector in RMS data units/pixel

  PHOTON  -- The number of photons per data number.

  NPOLY   -- Number of coefficients for profile polynomial fits.
             Should not be more than 3 or 4 normally.

  SIZEX   -- The separation in pixels between the polynomials.

  THRESH  -- Sigma threshold for poly fits.

  NSLOW   -- Number of bad pixels to reject one by one. Standardly profit
             rejects pixels in whole swathes. This parameter allows you to
             force the safe-but-slow reject the single worst pixel at each
             point. The larger you make it the safer it should be. For subtle
             reasons, the safest values of this parameter are either 0 (which
             gives standard old-style behaviour) or a large number like 100

  BADVAL  -- Value above which a pixel will automatically be ignored.
             Use as a way of avoiding horrendous cosmics which can
             upset 'profit'. Should obviously be way above any feasible
             data values.

  NBLOCK  -- Data will be taken in groups of NBLOCK rows.

  NMED   -- Low signals with large numbers of cosmic rays can go completely wrong
            owing to the profiles with cosmic rays in them being given EXTRA weight. e.g.
            if the total signal is typically 100 counts but a cosmic rays comes
            along with 10000 counts, that profile looks particularly good. To reduce
            this, this option median filters the profile sums before they are divided
            in to estimate fractions. Should not be too wide if target has lots of
            narrow line features. Must be odd. thsi number can be traded against NBLOCK
            to some extent.

  PLOT    -- TRUE to make plots.

  DEVICE  -- Plot device

This command belongs to the classes: extract , fitting , tilted


Tom Marsh, Warwick