pro sxt_prep2, input1, input2, index_out, data_out, unc_data, satpix, $
	;
	;------------------------- Calibration parameters
	nocorrections=nocorrections, $
	dc_scalar=dc_scalar, dc_interpolate=dc_interpolate, $
	upper_only=upper_only, $
	sfd_corr=sfd_corr, $
	;
	;------------------------- Alignment parameters
	register=register, $
	ref_image=ref_image, $
	helio=helio, date_helio=date_helio, $
	suncoord=suncoord, $
	ccdcoord=ccdcoord, $
	outres=outres, outsize=outsize, $
	st_en_lin = st_en_lin, $
	fill_gap=fill_gap, $
	;
	;------------------------- Secondary processing parameters
	exp_normalize=exp_normalize, normalize=normalize, $
	sum=sum, $
	;
	;------------------------- Miscellaneous
	force_read=force_read, outfile=outfil, append=append, $
	error=error, $
	run_time=run_time, $
	override=override, $
	qdebug=qdebug, qstop=qstop
;+
;NAME:
;	sxt_prep2
;SAMPLE CALLING SEQUENCE:
;	sxt_prep2, input1, input2, index_out, data_out
;	sxt_prep2, index, data, index_out, data_out
;	sxt_prep2, infil, dset_arr, index_out, data_out, $
;			helio=[-9.8,-20.3], date_helio='14-JUN-92  02:37:41')
;	sxt_prep2, index, data, index_out, data_out, /helio, ref_image=10)
;	sxt_prep2, index, data, index_out, data_out, ref_image=spr_index(0))
;PURPOSE:
;	This is a general purpose routine to prepare the SXT data for
;	analysis.  The steps performed are:
;		1. Flag the saturated pixels
;		2. Decompress the data
;		3. Subtract the dark current
;		4. Subtract the pin hole leak
;		5. Align the images and build the observing region.  The
;		   routine can extract subportions out of FFI images
;		6. Fill in the horizontal gaps in the observing region
;		7. Exposure normalize
;	It does not do the following items which the earlier version of
;	SXT_PREP did do:
;		*. Re-bin the data to a lower resolution
;		*. Temporal interpolation
;	In the future modifications (** NOT AVAILABLE RIGHT NOW **), it will:
;		*. De-spike the image
;		*. Perform leak subtraction with different reference image
;		   for images taken with ND filter
;		*. Perform leak subtraction with adjustments for S/C pointing
;		   changes
;INPUT:
;		  ** There are two methods for calling SXT_PREP2 **
;	input1	- A. The index structure for each of the input images
;		  B. The names of the input files
;	input2	- A. The input data array
;		  B. The dataset numbers to extract and process
;OUTPUTS:
;	data_out - The output data array
;	index_out- The index structure for each output image
;OPTIONAL KEYWORD INPUTS:
;		-------------------- Calibration Parameters --------------------
;	nocorrections- If set, then LEAK_SUB is not called
;	dc_scalar- If set, then a simple scalar value is used for dark current 
;		  subtraction. Default is to take the image closest in exposure.
;	dc_interpolate - If set, then perform interpolation on the dark frame
;		  images to get a better backround subtraction.  Deafult is to
;		  take the image closest in exposure.
;	upper_only - If set, only flag +1 pixels above (in a column) the
;		  saturated area (not the -1 pixels) [see call to sxt_satpix].
;	sfd_corr - If set, then the input image is an SFD image.  Use the
;		  SFD decompression, perform the registration, and recompress
;		  using the SFD compression.
;	
;		-------------------- Alignment Parameters --------------------
;	register - If set, then perform the registration and correct only for
;		the S/C jitter.
;
;	ref_image - A single roadmap or index structure which will be used 
;		to define the sun or heliocentric coordinates for alignment.  
;		It can be the image number (subscript) of the images being
;		extracted which should be used (not the absolute dataset 
;		number within the images listed in "infil") 
;
;	helio - the reference latitude and longitude for the alignment.
;		This should be the position of the active region at some 
;		time, preferably near the time it crossed closest to the 
;		center of the disk.  
;			helio(0) = longitude E/W (E is negative)
;			helio(1) = latitude N/S (S is negative)
;		It can be a non-zero scalar value if REF_IMAGE is passed in.
;		In this case, the heliocentric coordinates are derived
;		from "REF_IMAGE".
;	date_helio - the reference date/time for the heliocentric input.
;
;	suncoord - The coordinates of the center of the portion to extract
;		   in angular arcseconds relative to sun center.
;			suncoord(0) = E-W coordinate (E is negative)
;			suncoord(1) = N-S coordinate (S is negative)
;
;       ccdcoord - The FRE (full resolution CCD pixel equivalent) of the
;                  center of the portion to extract
;
;	outres- The resolution of the output image (0=FR, 1=HR, 2=QR).
;		If not set, then convert all to full res.  Only relevant if
;		registering the images.
;		** NOT AVAILABLE RIGHT NOW - ALWAY FULL RESOLUTION **
;	outsize- The dimention of the ouptut image [#col, #lin]
;		If it is a scalar value, it will make the #lin = #col
;		If not set, it will make it the largest size of the input
;		field of views.  If PFI and FFI are mixed, it will take
;		the largest PFI.
;
;	fill_gap - A gap can exist between two PFI strips for a single
;		   observing region because of a change in S/C pointing.
;		   If this variable is set, then the gap between the PFI
;		   strips is filled by interpolating the lines above and below
;			** NOT AVAILABLE RIGHT NOW **
;
;		-------------------- Secondary Processing Parameters ----------
;	sum	- Sum over SUM X SUM pixels.  It must be a scalar value.
;	exp_normalize- If set, perform exposure normalization
;	normalize- Same as EXP_NORM
;
;		-------------------- Miscellaneous Parameters ----------
;	force_read - If set, read all datasets at once even if input was 
;		  specified with INFIL/DSET.  This is available because doing 
;		  LEAK_SUB on all images at once if the input is PFI is more 
;		  efficient
;	outfil	- If specified, the data will not be passed back in INDEX_OUT and
;		  DATA_OUT.  Instead, it will be saved in an SDA file with the
;		  name specified by this parameter. 
;		  If "uncert" and "satpix" are included in the procedure call,
;		  they will be saved with the same file name with a "_unc"
;		  and a "_sat" appended to the file name.
;	qdebug	- If set, display some diagnostic messages
;	qstop	- If set, stop execution inside this subroutine (for debugging)
;OPTIONAL KEYWORD OUTPUTS:
;	error	- Error information.  
;			0 - No errors
;			1 - "index" and "data" input parameters are undefined
;			2 - "index" and "data" data types are incorrect
;	run_time - The number of minutes that SXT_PREP2 took
;	st_en_lin - The start/end line number where each PFI strip is inserted 
;		    into the output array.  It is 2 x # PFI Strips x # output 
;		    images.
;METHOD
;	When running YODAT, the user should NOT have the observing regions
;	assembled.  This routine will perform dark subtraction on each 
;	individual exposure and will align each PFI strip independently.
;
;	-------------------- Calibration Options --------------------
;	Decompression, dark_sub, leak_sub
;
;	-------------------- Alignment Option --------------------
;	To align the images.  User can specify
;		(1) heliocentric coordinates for a given time/date
;		    (corrects for solar differential rotation and S/C drift)
;		(2) the fixed coordinates relative to sun center in arcmin
;		    (corrects for S/C drift)
;		(3) simple CCD coordinates (probably only used when
;		    assembling observing regions, but want to do background
;		    subtraction first) (would not take out S/C drift)
;	The images are all changed to full resolution, and the signal is
;	scaled accordingly (an image converted from HR to FR has the signal
;	divided by 4 because there are 4 times more pixels now.  The total
;	signal is preserved)
;RESTRICTIONS:
;
;HISTORY:
;	Written 16-Aug-93 by M.Morrison using and merging:
;		ALIGN_PFI (which used  Metcalf ALIGN_AR as starting point)
;		SXT_PREP (JRL 20-Apr-93 version)
;V1.03	   Aug-93 (MDM)
;V1.04	31-Aug-93 (MDM) - Various patches
;			- Added RUN_TIME option
;V1.05	 3-Sep-93 (MDM) - Adjusted the documentation header some
;			- Changed the alignment code to always use ALIGN1IMG
;			  for all combinations of PFI/FFI
;			- Renamed keyword EXP_NORM to EXP_NORMALIZE
;	 8-Sep-93 (SLF) - add append keyword (for sav_sda call)
;V1.06	15-Sep-93 (MDM) - Added print statement on what version of SXT_PREP
;			  is being run
;			- Changed so that the sat pixel registration is
;			  done properly (sub pixel, sub-DN problem)
;			- Made the "uncert" data output type byte
;	16-Sep-93 (MDM)	- Added NORM_FACT switch to ALIGN1IMG call for
;			  satpix and uncert data.
;V1.07	22-Sep-93 (MDM) - Corrected error in the /NORM option (it was not
;			  working at all)
;			- Corrected error in the /FILL_GAP option
;V1.08	 1-Oct-93 (MDM) - Minor modification to recognize when registration
;			  is requested.
;V1.09	 6-Oct-93 (MDM) - Modified so that when not using the /REGISTER option
;			  the output size is determined in originally summed
;			  pixels (not Full res pixels)
;V1.10	11-Oct-93 (MDM) - Corrected for the case where an OR is assembled but
;			  /REGISTER is not used.  It was not saving the corner
;			  or new shape properly.
;V1.11	13-Oct-93 (MDM) - Enabled DC_INTERPOLATE and DC_SCALAR options
;V1.12	15-Oct-93 (MDM) - Corrected for problem when registering the BYTE
;			  uncertainty array
;	15-Nov-93 (MDM) - Modified the header information 
;V1.13	18-Nov-93 (MDM) - Patched an error in EXT_SUBIMG3 which was resulting in
;			  poorly aligned images.  Problem was in rounding off
;			  between integers and reals
;	19-Nov-93 (MDM) - Modified to make the output data type BYTE when using
;			  the /SFD_CORR option
;V1.14	24-Nov-93 (MDM) - Corrected error with OR assembly.  The problem was
;			  with EXT_SUBIMG3.  Added the /TRIM option inside
;			  the ALIGN1IMG call.
;			- Modified to record the actual percent of data present
;			  when doing the observing region assembly.
;	30-Nov-93 (MDM) - Renamed to SXT_PREP.  Put in call to SXT_PREP and
;			  DONT_USE_THIS.
;-
;
dont_use_this, 'SXT_PREP', 'SXT_PREP2', ['   ********* Calling SXT_PREP for you this time only **********']
;
sxt_prep, input1, input2, index_out, data_out, unc_data, satpix, $
	;
	;------------------------- Calibration parameters
	nocorrections=nocorrections, $
	dc_scalar=dc_scalar, dc_interpolate=dc_interpolate, $
	upper_only=upper_only, $
	sfd_corr=sfd_corr, $
	;
	;------------------------- Alignment parameters
	register=register, $
	ref_image=ref_image, $
	helio=helio, date_helio=date_helio, $
	suncoord=suncoord, $
	ccdcoord=ccdcoord, $
	outres=outres, outsize=outsize, $
	st_en_lin = st_en_lin, $
	fill_gap=fill_gap, $
	;
	;------------------------- Secondary processing parameters
	exp_normalize=exp_normalize, normalize=normalize, $
	sum=sum, $
	;
	;------------------------- Miscellaneous
	force_read=force_read, outfile=outfil, append=append, $
	error=error, $
	run_time=run_time, $
	override=override, $
	qdebug=qdebug, qstop=qstop
;
end
