function sgt_range,index,spatial=spatial,spectral=spectral

;; reference pixel
refpix = (sgt_refpix(index))(0,*)
len      = strlen(index.gen.filename)
data_ext = strupcase(strmid(index.gen.filename,len-3,3))

;; dimensions of data array
dims = sgt_dims(index)
dy   = dims(1,0)
dw   = dims(0,0)

;; slit location
center = 180
if data_ext eq 'FTS' then begin
   up     = 60 
   down   = 300
endif else begin
   up     = 300 
   down   = 60
endelse

slit   = sgt_slit(index)
case slit of
  1: SlitLoc = center
  2: SlitLoc = center
  3: SlitLoc = up
  4: SlitLoc = center
  5: SlitLoc = down
  6: SlitLoc = up
  7: SlitLoc = center
  8: SlitLoc = down
  9: SlitLoc = center
  
  else: message,'Problem with slit'
endcase

for n=0,n_elements(refpix)-1 do begin

  ;; spatial direction 
  if dy eq 360 then yrange = [0,359] else yrange = slitloc+[-dy/2,dy/2-1]
  
  ;; spectral direction
  if dw eq 1024 then wrange = [0,1023] else begin
    if dw mod 2 eq 0 then wrange = refpix(n)-1+[-dw/2+1,dw/2] $
    else wrange = refpix(n)-1+[-dw/2,dw/2]
  endelse
  
  if keyword_set(SPATIAL) then d = yrange else d = wrange

  boost_array,d_out,d

endfor
  
return,d_out
end