
;	(26-mar-91)
FUNCTION GET_SDA, FILE=FILE, TIMES, SUBSET=SUBSET, $
  IMAGE_VECT = IMAGE_VECT
;+
; NAME:
;	GET_SDA
;	
; PURPOSE:
;	Read image data from an SDA file and return as a data cube
;
; CALLING SEQUENCE:
;	DATA = GET_SDA(FILE=FILE, TIMES, SUBSET=SUBSET, $
;	       IMAGE_VECT = IMAGE_VECT
;
; INPUTS:
;	FILE = String containing SDA file name
;
; OPTIONAL KEYWORDS:
;	SUBSET = If nonzero, user will be prompted for a subset of
;		 all images in the SDA file
;
; OUTPUTS:
;	DATA = Data cube of images extracted from SDA file
;
; OPTIONAL OUTPUTS:
;	TIMES = Vector of times at which the extracted images were
;		taken
;	IMAGE_VECT = Vector of indices of image extracted from SDA
;		     file
;
; MODIFICATION HISTORY:
;	Version 1.0 - Mar, 1991, S. L. Freeland, LPARL
;	Version 1.1 - Apr, 1991, G. L. Slater, LPARL
;-

!path = !path + $					; rf access routines
	',dsk1:[morrison.soft.solara_db.idl]' + $
	',dsk1:[morrison.soft.solara_db.reformat]'
if not keyword_set(file)  then $			; default file
    file='dsk1:[sxtimages.reformat]sgb901011.0907'	; STIII
gen_struct						; define structures
obs_struct
sxt_struct
rd_sdarmap,file,rmap,ndsets				; road map
if n_elements(subset) eq 0 then $			; default, all images
  image_vect=indgen(ndsets)+1 $
else begin						; select image subset 
  print,' There are ' + string(ndsets,'(i3)') + $
        ' images in this file.'
  n0 = '' & read,' Enter first image number desired (def is 1): ',n0
  if n0 eq '' then n0 = 1 else n0 = fix(n0)
  n1 = ''
  read,' Enter last image number desired (def is last image): ',n1
  if n1 eq '' then n1 = ndsets-1 else n1 = fix(n1)
  n_subset = n1 - n0 + 1
  eoa = ''
  read,' Do you want even, odd, or all images (e,o, or a, def is a)? ',eoa
  eoa = strupcase(strmid(eoa,0,1))
  if eoa eq '' then eoa = 'A'
  case eoa of
    'E': image_vect = n0 + n0 mod 2 + $
	   indgen(((n1 - n1 mod 2) - (n0 + n0 mod 2))/2+1)*2
    'O': image_vect = n0 + (n0+1) mod 2 + $
	   indgen(((n1 - (n1+1) mod 2) - (n0 + (n0+1) mod 2))/2+1)*2
    'A': image_vect = n0 + indgen(n1-n0+1)
  endcase
;print,image_vect
endelse
int2ex,rmap(*).time,rmap(*).day,timbuf			; image times
times=timbuf(*,image_vect-1)				; offset
rd_sda,file,image_vect,index,data,rmap			; get data

return,data						
end

