;       (28-jul-92)
  pro get_ssx_slice, data, index, slice, t_width=t_width, $
    pdata=pdata, type=type, x0=x0
;+
; NAME:
;	GET_SSX_SLICE
; PURPOSE:
; CATEGORY:
; CALLING SEQUENCE:
; INPUTS:
;   POSITIONAL PARAMETERS:
;   KEYWORDS PARAMETERS:
; OUTPUTS:
;   POSITIONAL PARAMETERS:
;   KEYWORDS PARAMETERS:
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; PROCEDURE:
; EXAMPLE:
; MODIFICATION HISTORY:
;       July, 1992. - Written by GLS, LMSC.
;	4-Dec-92 (GLS) - Modifications to correct for errors when extracting
;			 SSE and SSW
;	10-Dec-92 (MDM) - Perform the out of range correction properly
;	19-Jun-93 (MDM) - Modified to add keyword output X0
;-

  if n_elements(t_width) eq 0 then t_width = [.5,.5]*1.2*86400.

  sec_per_pix = 2.453
  twopi = 2*!pi
  omega = dr_carr(/rad)*1e-6	; Equatorial Carrington rotation
				;   rate in radians/sec
IF TYPE NE 1 THEN OMEGA=OMEGA*COS(45/!RADEG)
  res = gt_res(index)
  rb0p = makvec(get_rb0p(index))
  r_pix = rb0p(0)/sec_per_pix
  tilt = rb0p(1)*!radeg

  xoff = r_pix/sec_per_pix*cos(45/!radeg)	;4-Dec-92
  case type of
    0: xoff = - xoff
    1: xoff =   0
    2: xoff =   xoff
    else: stop,' Unacceptable value for keyword TYPE.'
  endcase

  if keyword_set(pdata) eq 0 then get_pnt,index,pdata,offset=offset
  roll = pdata.sc_pntg(0)/36000.	; TODO: Use roll to re-orient image
					;  prior to extracting slice.
  img_siz = gt_shape_cmd(index)
  sxt_cen = gt_hxa(pdata,/sxtpix)/(2^res)
  q_pntg_fix = ( (int2secarr(index, '9-apr-92  15:31:18') gt 0) and $
    (int2secarr(index, '14-apr-92  12:35:15') lt 0))
  if q_pntg_fix then sxt_cen = [500.,563.]/(2^res)
  xcen = sxt_cen(0) & ycen = sxt_cen(1)

  pix_width = r_pix*omega*t_width/2^res
; x0 = (xcen+(xoff/2^res)-pix_width(0))>0<(img_siz(0)*2^(res-1)-1)	;4-Dec-92
; x1 = (xcen+(xoff/2^res)+pix_width(1))>0<(img_siz(0)*2^(res-1)-1)
  x0 = (xcen+(xoff/2^res)-pix_width(0))>0<(img_siz(0)/(2^res)-1)	;10-Dec-92 img_siz in FR pix 0-1024, 2^res=1,2,4
  x1 = (xcen+(xoff/2^res)+pix_width(1))>0<(img_siz(0)/(2^res)-1)
  slice = data(x0:x1,*)

  end

