This file describes further details and differences between the ISR
STIS 96-019 and the implementation.

The input file itself is modified, rather than copying the input to an
output file.  The modification is just to write values to two keywords,
SHIFTA1 and SHIFTA2, in the SCI extension header; the data values are
not changed.

SHIFTA1 and SHIFTA2 give the shifts for the first and second axes
respectively if DISPAXIS is one, but they apply to the second and first
axes if DISPAXIS is two.  Perhaps it would be better to write the shifts
to keywords identified with the respective axes, rather than with the
dispersion and spatial directions.

The offset of the slit from the nominal position is added when finding
the shift.  It's not obvious to me that this is appropriate.

When summing data in either rows or columns, the entire row or column is
added, except that pixels flagged as bad are excluded.  The header keyword
SDQFLAGS is used to determine which bits are significant when checking
data quality.  Since pixels may have been excluded, the sum is then
divided by the number of good pixels; that is, the 1-D array is an average
rather than a sum.  When taking the sum, it might be better to include
only the middle portion, so that the geometric distortion will be well
determined, and there will be less variation in dispersion.

Each group in the input image is processed independently.  This will
probably not work in the case of echelle data, since different orders will
have been written by calstis7 to different groups, and some orders may not
have sufficient signal to noise to make it possible to determine the shift.
A value of -9999. is written to SHIFTA1 or SHIFTA2 if the shift could not
be measured in the spatial or dispersion direction.

Rebinning the reference spectrum to match the resolution of the observed
wavecal is done using Aitken's quadratic interpolation.  The shift in
wavelength between the reference spectrum and observed wavecal is found
by locating the peak in the cross correlation between the two spectra.

For finding the shift in the spatial direction, cross correlation with
a rectangular template is used for short echelle slits (0.2 arcsec or
shorter), and edge location is used for the medium echelle slit (six
arcsec) and long slits.  For the medium length slit the edges are the
ends of the slit, while for long slits the edges of the occulting bars
are used.  The shift is computed as the average of the differences
between observed and expected locations.

The cross correlations are done over a range of offsets, and the range
depends on which shift is being found and the size of the input data.
When determining the shift in the dispersion direction, the number of
pixels in the 1-D average is divided by 16 to get the range, but with a
minimum of seven.  For the spatial direction, the size of the 1-D array
is divided by two to get the range, again with a minimum of seven.  The
range must be an odd number, so one is added if necessary.  The range
just described is the full range from negative offset to positive, with
zero offset in the middle.

To determine the location of an edge, the data are cross correlated with
the kernel {-1, 0, +1}.  The cross correlation will be a minimum at the
location of an edge going from bright to faint, and it will be a maximum
at an edge going from faint to bright.

Note that in every case the 1-D data are cross correlated in order to find
a location, either with a template or with an edge-finding kernel.  The
maximum (or minimum) in the cross correlation is the actual location which
is compared with the nominal location to get the shift.  The location of
the extremum is found by fitting a quadratic to the three pixels centered
on the brightest (or faintest) value in the cross correlation.

The nominal location of the center of the slit is given by CRPIX1 and
CRPIX2 in the SCI extension header.

One significant unresolved issue is that the shifts are in units of pixels
in the output of calstis7 (2-D extracted and rectified), but what we need
is the pixel shift in the raw image.
