function gt_sxt_roll, index, sc=sc, corr=corr
;
;+
;NAME:
;	gt_sxt_roll
;PURPOSE:
;       To return the roll angle of the SXT image relative to solar
;       north in degrees counter clockwise.  Optionally return the
;	original S/C roll value, or the amount the image was rotated.
;METHOD:
;	It reads the index history file to see what roll correction
;	has been made and checks the S/C roll database and returns
;	the difference.  If SXT_PREP with /ROLL has been run, then
;	it should return the value 0.
;SAMPLE CALLING SEQUENCE:
;	solar_north = gt_sxt_roll(index)
;	sc_roll = gt_sxt_roll(index, /sc)
;INPUT:
;	index	- The SXT index
;OPTIONAL KEYWORD INPUT:
;	sc	- If set, just return the S/C roll value (including
;		  the fixed offset between SXT and S/C roll axes)
;	corr	- If set, return the size of the roll that has
;		  already been applied.
;		  In the case of SXT_PREP being used with /ROLL, this
;		  will be the same as the S/C roll value (the value 
;		  returned when "/SC" is used)
;HISTORY:
;	Written 5-Jan-94 by M.Morrison
;	23-Mar-94 (MDM) - Modified the header
;			- Modification so that /CORR option returned the
;			  proper value when the index does not have a 
;			  history record
;-
;
;if (his_exist(index) and keyword_set(corr)) then return, index.his.sun_center(2)
if (keyword_set(corr)) then begin
    if (his_exist(index)) then return, index.his.sun_center(2) $
			else return, fltarr(n_elements(index)>1)
end
;
out = get_roll(index)
if (keyword_set(sc)) then return, out
;
if (his_exist(index)) then begin
    ss = where(index.his.q_roll_corr ne 0)
    if (ss(0) ne -1) then begin		;found cases where roll correction was done
	out(ss) = out(ss) - index(ss).his.sun_center(2)
    end
end
;
return, out
end
