!!! What does eis_prep do?

The eis_prep routine in Solarsoft takes the EIS level-0 FITS files and produces as output a level-1 FITS file. In addition to converting
the measured CCD signal into calibrated intensity units,
a key part of EIS PREP is to flag bad data points. These
can arise through pixel saturation, cosmic ray hits, or simply
defective pixels on the CCD.  The bad points are referred to as ''missing pixels''. The central outputs of EIS PREP are two
level-1 FITS files, one containing calibrated intensities at
each pixel, and the other containing error bars on these
intensities. Note that the missing pixels are assigned a value of -100 in the error file, ''not'' the intensity file. The bad points in the intensity file are replaced with the median of the neighbouring pixels.

The standard way of calling eis_prep is:

IDL> eis_prep, filename, /default, /save

which will create the level-1 FITS file and associated error FITS file in the working directory. Additional keywords that you may want to use are:

/quiet - eis_prep runs without popping up information widgets

/retain - see Step 2 discussion below

/noabs - calibration is not performed (Step 6 below), so the final units are DN

/photons - instead of erg/cm2/s/sr/Angstrom, the final units will be photons/cm2/s/sr/Angstrom

The full list of keywords is given in the header of the eis_prep routine.

The sequential steps performed by eis_prep are as follows.

!! Step 1: flagging saturated data

The first step of EIS PREP is to flag any saturated data.
The EIS CCDs have a 14 bit dynamic range and so saturation occurs at 16,383 data numbers (DN). All such pixels
are flagged as missing as described above.

!! Step 2: dark current and pedestal subtraction

In the raw data, the spectra are found to sit on a background
of around 500 DN that arises principally from the
CCD bias, and secondly from the CCD dark current. It is
not possible to estimate the CCD bias level directly for EIS
data, so the bias and dark current levels are estimated directly
from the science data as follows. For each 3D data
window 2 % of the detector pixels are isolated that have the
lowest DN values. The median DN value of these 2 % pixels
is then set to be the background level and it is subtracted
from the DN values of each pixel.

For full CCD spectra, a different approach is used. Sections of the CCD have been identified where there are no (or very weak) emission lines and so it can be assumed that the background here represents a measure of the CCD background. The regions are then averaged to yield the background level which is subtracted from the spectra.

It is to be noted that both of these methods will yield some pixels with negative DN values. For window data it will only be 1 % of pixels because of the method used, but for full CCD spectra it can be up to 50 % of pixels if the raster contains very weak emission (e.g., coronal holes or off-limb spectra). ''The default mode for eis_prep sets pixels with zero or negative DN values to be missing data.''  This is because it is not possible to assign a photon noise error to the data points.

By setting the /RETAIN keyword in eis_prep, pixels with zero or negative DN values will not be flagged as missing. The errors for the pixels will be set to the dark current error estimate (see Step 6).

!! Step 3: cosmic rays removal

Anomalously bright pixels are found on the EIS CCD
images that arise from 'hot pixels', 'warm pixels' and cosmic
rays. The cosmic ray removal is performed by EIS DESPIKE, 
a wrapper routine that calls NEW SPIKE, a routine developed
for removing cosmic rays from SOHO/Coronal Diagnostic
Spectrometer (CDS) data-sets (Thompson et al., 1998; Pike
& Harrison, 2000). For CDS data processing it was typical
for not only the identified CCD pixels to be flagged,
but also the nearest-neighbour pixels on the CCD. This
is because there is often residual signal from the cosmic
ray next to the brightest pixels. EIS sees significantly less
cosmic rays than CDS apart from during the approximately 5 minute
passes through the South Atlantic Anomaly. As the most
useful function of EIS DESPIKE was actually to flag warm
pixels, and since warm pixels are only single pixel events, then
the nearest-neighbour option is usually switched off for EIS. It is to
be noted that the NEW SPIKE routine was designed to be
cautious when removing cosmic rays from line profiles, thus
possibly artificially enhancing the emission line intensities
at these locations. 

!! Step 4: flagging hot and warm pixels

Both hot pixels and warm pixels are single pixels
that have anomalously high DN values. A hot pixel is defined to be one 
that yields 25,000 electrons pixel-1 s-1 at
room temperature (a specification from the CCD manufacturer).
Pixels that fall below this threshold but are still
clearly identified as being anomalous when inspecting the
data are referred to as 'warm' pixels. Separate maps of the locations
of hot and warm pixels are generated by the EIS team every 2-4 weeks 
following inspection of 100 s dark exposures and they are
stored in Solarsoft. The pixel maps that are closest in
time to the science observation are used by EIS PREP to
mark the hot and warm pixels as missing data. \\
Please also check the post [Top and bottom of hot/warm pixels maps|TopBottomHotWarmMaps] for more details.

!! Step 5: flagging dusty pixels

The next step for EIS PREP is to flag the pixels affected by dust on
the CCD. Several small pieces of dust accumulated on the
CCD before launch and are found to completely block the
solar signal on the CCD at their locations. They are fixed
in position and cover less than 0.1 % of the CCD, however
two of the pieces do affect the strong lines Fe XI 188.23,
188.30 and Fe XII 193.51 such that the lines can not be
used over 15-30" spatial ranges in solar-Y.

!! Step 6: radiometric calibration

The final step of EIS PREP is to convert DN values into
intensities in units erg cm-2 s-1 sr-1 A-1. The errors on
the intensities are computed assuming photon statistics together
with an error estimate of the dark current of 2.5 DN.