;+
;PROCEDURE:	load_stb_l1_sept
;PURPOSE:	
;   loads STEREO/IMPACT SEPT high resolution data for "tplot".
;
;INPUTS:	none, but will call "timespan" if time
;		range is not already set.
;KEYWORDS:
;  TIME_RANGE:  2 element vector specifying the time range
;  DATA:        Data returned in this named variable.
;  NODATA:	Returns 0 if data exists for time range, otherwise returns 1.
;  PREFIX:	(string) prefix for tplot variables.  Default is 'sta_'
;  NAME:	(string) name for tplot variables. Default is 'sta_let'
;  MASTERFILE:	(string) full filename of master file.
;SEE ALSO: 
;  "make_cdf_index","loadcdf","loadcdfstr","loadallcdf"
;
;CREATED BY:	Peter Schroeder
;LAST MODIFIED:	11/27/06
;-


pro load_stb_l1_sept,time_range=trange,data=d,  $
  nodata=nodat, $
  prefix = prefix, $
  name = bname, $
  masterfile=masterfile, novardata=nvd
  
if not keyword_set(masterfile) then masterfile = 'STB_L1U'
;cdfnames = ['B_HGRTN']
ppx = 'B'
myformat = '/disks/stereodata/l1/behind/sept/????/??/STB_L1_SEPT_*.cdf'

d=0
nodat = 0

novarznames = ['Spec_E_Mean_Energy','Spec_I_Mean_Energy']
cdfnames = ['Spec_0_E','Spec_1_E','Spec_2_E','Spec_3_E']

loadallcdf,myformat,time_range=trange, novarnames=novarnames, $
    cdfnames=cdfnames,data=d_e,res =res, $
    novarznames = novarznames, novardata = nvd

cdfnames = ['Spec_0_NS','Spec_1_NS','Spec_2_NS','Spec_3_NS']

loadallcdf,myformat,time_range=trange, novarnames=novarnames, $
    cdfnames=cdfnames,data=d_ns,res =res

store_data,'STB_SEPT_Spec_E_antisun',data={x: d_e.time, y: transpose(d_e.spec_0_e), $
   v: nvd.spec_e_mean_energy}
store_data,'STB_SEPT_Spec_I_sun',data={x: d_e.time, y: transpose(d_e.spec_1_e), $
   v: nvd.spec_i_mean_energy}
store_data,'STB_SEPT_Spec_E_sun',data={x: d_e.time, y: transpose(d_e.spec_2_e), $
   v: nvd.spec_e_mean_energy}
store_data,'STB_SEPT_Spec_I_antisun',data={x: d_e.time, y: transpose(d_e.spec_3_e), $
   v: nvd.spec_i_mean_energy}
store_data,'STB_SEPT_Spec_E_north',data={x: d_ns.time, y: transpose(d_ns.spec_0_ns), $
   v: nvd.spec_e_mean_energy}
store_data,'STB_SEPT_Spec_I_south',data={x: d_ns.time, y: transpose(d_ns.spec_1_ns), $
   v: nvd.spec_i_mean_energy}
store_data,'STB_SEPT_Spec_E_south',data={x: d_ns.time, y: transpose(d_ns.spec_2_ns), $
   v: nvd.spec_e_mean_energy}
store_data,'STB_SEPT_Spec_I_north',data={x: d_ns.time, y: transpose(d_ns.spec_3_ns), $
   v: nvd.spec_i_mean_energy}
   
if keyword_set(d_e) eq 0 then begin
   message,'No STB SEPT data during this time.',/info
   nodat = 1
  return
endif

;H_energies = [2., 2.45, 2.95, 3.4, 3.8, 4.25, 4.75, 5.5, 7., 9., 11., 13.5]

;store_data,'sta_let_H_UNSEC_FLUX',data={x: d.time, y: transpose(d.H_UNSEC_FLUX), $
;   v: H_energies}, dlim={ylog: 1, spec: 1}
end