function rbsp_load_state_get_attitude_filelist, remote_dir, localdir = localdir
compile_opt idl2, HIDDEN
urls = jbt_fileurls(remote_dir, verbose = 0, localdir = localdir)
fnames = file_basename(urls)
years = long(strmid(fnames, 6, 4))
doys = long(strmid(fnames, 11, 3))
versions = long(strmid(fnames, 15, 2))
jdays = julday(1, 1, years) + doys - 1L
order = sort(jdays)
jdays = jdays[order]
fnames = fnames[order]
versions = versions[order]
tspan = timerange()
jday_sta = jbt_date2jday(strmid(time_string(tspan[0]+10),0,10)) - 3L
jday_end = jbt_date2jday(strmid(time_string(tspan[1]-10),0,10)) + 3L
ind = where(jdays ge jday_sta and jdays le jday_end, nind)
jdays = jdays[ind]
fnames = fnames[ind]
versions = versions[ind]
ind_uniq = uniq(jdays)
nfile = n_elements(fnames)
nversions = ind_uniq[1:*] - ind_uniq
nversions = [ind_uniq[0], nversions]
n = n_elements(nversions)
klist = ['']
for i = 0L, n-1 do begin
iend = ind_uniq[i]
if i eq 0 then ista = 0 else ista = ind_uniq[i-1]+1
v = versions[ista:iend]
f = fnames[ista:iend]
dum = max(v, imax)
klist = [klist, f[imax]]
endfor
ind = where(strlen(klist) gt 0)
return, klist[ind]
end
pro rbsp_load_state_download_spice_probe_attitude, probe = probe
compile_opt idl2, HIDDEN
if ~keyword_set(probe) then probe = ['a', 'b']
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
serverdir = !rbsp_efw.remote_data_dir
localdir = datadir
nsc = n_elements(probe)
scdirs = ['']
moc = 'MOC_data_products/'
for ip = 0, nsc - 1 do begin
sc = probe[ip]
scdirs = [scdirs, moc + strupcase('rbsp' + sc) + '/']
endfor
ind = where(strlen(scdirs) gt 0)
scdirs = scdirs[ind]
for ip = 0, nsc-1 do begin
mocdir = scdirs[ip]
remote_dir = serverdir + mocdir + 'attitude_history/'
tmpdir = datadir + mocdir
fnames = rbsp_load_state_get_attitude_filelist(remote_dir, localdir = tmpdir)
nfile = n_elements(fnames)
for i = 0L, nfile-1 do begin
fname = fnames[i]
pathname = mocdir + 'attitude_history/' + fname
file_http_copy,pathname $
, serverdir=serverdir $
, localdir=localdir
endfor
endfor
end
pro rbsp_load_state_download_spice_probe, probe = probe
compile_opt idl2, HIDDEN
if ~keyword_set(probe) then probe = ['a', 'b']
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
serverdir = !rbsp_efw.remote_data_dir
localdir = datadir
nsc = n_elements(probe)
scdirs = ['']
moc = 'MOC_data_products/'
for ip = 0, nsc - 1 do begin
sc = probe[ip]
scdirs = [scdirs, moc + strupcase('rbsp' + sc) + '/']
endfor
ind = where(strlen(scdirs) gt 0)
scdirs = scdirs[ind]
rbsp_load_state_download_spice_probe_attitude, probe = probe
subdirs = ['ephemerides' $
, 'eclipse_predict' $
, 'frame_kernel' $
, 'leap_second_kernel' $
, 'operations_sclk_kernel' $
, 'planetary_ephemeris' $
] + '/'
nsub = n_elements(subdirs)
for ip = 0, nsc-1 do begin
mocdir = scdirs[ip]
for k = 0, nsub - 1 do begin
subdir = subdirs[k]
remote_dir = serverdir + mocdir + subdir
tmpdir = datadir + mocdir
urls = jbt_fileurls(remote_dir, verbose = 0, localdir = tmpdir)
fnames = file_basename(urls)
nfile = n_elements(fnames)
for i = 0L, nfile-1 do begin
fname = fnames[i]
pathname = mocdir + subdir + fname
file_http_copy,pathname $
, serverdir=serverdir $
, localdir=localdir
endfor
endfor
endfor
end
pro rbsp_load_state_download_spice_general
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
serverdir = !rbsp_efw.remote_data_dir
localdir = datadir
spicedir = 'teams/spice/'
subdirs = ['fk/', 'ik/', 'pck/']
nsub = n_elements(subdirs)
for k = 0, nsub - 1 do begin
subdir = subdirs[k]
remote_dir = serverdir + spicedir + subdir
tmpdir = datadir + spicedir
urls = jbt_fileurls(remote_dir, verbose = 0, localdir = tmpdir)
fnames = file_basename(urls)
nfile = n_elements(fnames)
for i = 0L, nfile-1 do begin
fname = fnames[i]
pathname = spicedir + subdir + fname
file_http_copy,pathname $
, serverdir=serverdir $
, localdir=localdir
endfor
endfor
end
function rbsp_load_state_lsk_kernel, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = 'MOC_data_products' + sep
LSK = 'leap_second_kernel' + sep
dir = datadir + moc + strupcase('rbsp' + sc) + sep + LSK
flist = file_search(dir, 'naif*')
fnames = file_basename(flist)
day_number = long(strmid(fnames, 4, 4))
dum = max(day_number, imax)
return, flist[imax]
end
function rbsp_load_state_general_kernels, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = datadir + 'MOC_data_products' + sep
spice = datadir + 'teams' + sep + 'spice' + sep
fk_dir = spice + 'fk' + sep
ik_dir = spice + 'ik' + sep
pck_dir = spice + 'pck' + sep
frame = moc + strupcase('rbsp' + sc) + sep + 'frame_kernel' + sep
planet = moc + strupcase('rbsp' + sc) + sep + 'planetary_ephemeris' + sep
klist = ['']
dir = fk_dir
flist = file_search(dir, 'rbsp*')
fnames = file_basename(flist)
versions = long(strmid(fnames, 12, 3))
dum = max(versions, imax)
klist = [klist, flist[imax]]
klist = [klist, ik_dir + 'rbsp' + strlowcase(sc) + '_rps_v000.ti']
klist = [klist, jbt_file_latest(pck_dir)]
klist = [klist, jbt_file_latest(frame)]
klist = [klist, jbt_file_latest(planet)]
ind = where(strlen(klist) gt 0)
return, klist[ind]
end
function rbsp_load_state_eph_kernel, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = datadir + 'MOC_data_products' + sep
eph_dir = moc + strupcase('rbsp' + sc) + sep + 'ephemerides' + sep
flist = file_search(eph_dir, 'rbsp*')
fnames = file_basename(flist)
years = long(strmid(fnames, 15, 4))
doys = long(strmid(fnames, 20, 3))
versions = long(strmid(fnames, 24, 2))
jdays = julday(1, 1, years) + doys - 1L
jday_max = max(jdays)
ind = where(jdays eq jday_max, nind)
v = versions[ind]
f = flist[ind]
dum = max(v, imax)
return, f[imax]
end
function rbsp_load_state_eph_predict_kernel, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = datadir + 'MOC_data_products' + sep
eph_dir = moc + strupcase('rbsp' + sc) + sep + 'ephemeris_predict' + sep
flist = file_search(eph_dir, 'rbsp*')
fnames = file_basename(flist)
years = long(strmid(fnames, 15, 4))
doys = long(strmid(fnames, 20, 3))
versions = long(strmid(fnames, 24, 2))
jdays = julday(1, 1, years) + doys - 1L
jday_max = max(jdays)
ind = where(jdays eq jday_max, nind)
v = versions[ind]
f = flist[ind]
dum = max(v, imax)
return, f[imax]
end
function rbsp_load_state_att_kernels, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = datadir + 'MOC_data_products' + sep
att_dir = moc + strupcase('rbsp' + sc) + sep + 'attitude_history' + sep
flist = file_search(att_dir, 'rbsp*')
fnames = file_basename(flist)
years = long(strmid(fnames, 6, 4))
doys = long(strmid(fnames, 11, 3))
versions = long(strmid(fnames, 15, 2))
jdays = julday(1, 1, years) + doys - 1L
order = sort(jdays)
jdays = jdays[order]
flist = flist[order]
versions = versions[order]
tspan = timerange()
jday_sta = jbt_date2jday(strmid(time_string(tspan[0]+10),0,10)) - 3L
jday_end = jbt_date2jday(strmid(time_string(tspan[1]-10),0,10)) + 3L
ind = where(jdays ge jday_sta and jdays le jday_end, nind)
jdays = jdays[ind]
flist = flist[ind]
versions = versions[ind]
ind_uniq = uniq(jdays)
nfile = n_elements(flist)
nversions = ind_uniq[1:*] - ind_uniq
nversions = [ind_uniq[0], nversions]
n = n_elements(nversions)
klist = ['']
for i = 0L, n-1 do begin
iend = ind_uniq[i]
if i eq 0 then ista = 0 else ista = ind_uniq[i-1]+1
v = versions[ista:iend]
f = flist[ista:iend]
dum = max(v, imax)
klist = [klist, f[imax]]
endfor
ind = where(strlen(klist) gt 0)
return, klist[ind]
end
function rbsp_load_state_sclk_kernel, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = 'MOC_data_products' + sep
SCLK = 'operations_sclk_kernel' + sep
dir = datadir + moc + strupcase('rbsp' + sc) + sep + SCLK
flist = file_search(dir, 'rbsp*')
fnames = file_basename(flist)
day_number = long(strmid(fnames, 11, 4))
dum = max(day_number, imax)
return, flist[imax]
end
function rbsp_load_state_spice_kernel_list, probe = probe, $
use_eph_predict = use_eph_predict
compile_opt idl2, HIDDEN
if ~keyword_set(probe) then probe = ['a', 'b']
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = 'MOC_data_products' + sep
spice = 'teams' + sep + 'spice' + sep
nsc = n_elements(probe)
klist = ['']
for ip = 0, nsc - 1 do begin
sc = probe[ip]
if ~keyword_set(use_eph_predict) then begin
klist = [klist $
, rbsp_load_state_lsk_kernel(sc) $
, rbsp_load_state_sclk_kernel(sc) $
, rbsp_load_state_general_kernels(sc) $
, rbsp_load_state_att_kernels(sc) $
, rbsp_load_state_eph_kernel(sc) $
]
endif else begin
klist = [klist $
, rbsp_load_state_lsk_kernel(sc) $
, rbsp_load_state_sclk_kernel(sc) $
, rbsp_load_state_general_kernels(sc) $
, rbsp_load_state_att_kernels(sc) $
, rbsp_load_state_eph_predict_kernel(sc) $
]
endelse
endfor
ind = where(strlen(klist) gt 0, nind)
klist = klist[ind]
nk = n_elements(klist)
for i = 0L, nk - 1 do klist[i] = file_expand_path(klist[i])
return, klist
end
pro rbsp_load_state_load_spice, probe = probe, no_update = no_update, $
klist = klist, downloadonly = downloadonly, $
use_eph_predict = use_eph_predict
compile_opt idl2, HIDDEN
if ~keyword_set(probe) then probe = ['a','b']
if ~keyword_set(no_update) then begin
rbsp_load_state_download_spice_general
rbsp_load_state_download_spice_probe, probe = probe
endif
if keyword_set(downloadonly) then return
klist = rbsp_load_state_spice_kernel_list(probe = probe, $
use_eph_predict = use_eph_predict)
cspice_furnsh, klist
end
function rbsp_load_state_eclipse_time_files, sc
compile_opt idl2, HIDDEN
datadir = !rbsp_efw.local_data_dir
datadir = expand_tilde(datadir)
sep = path_sep()
moc = datadir + 'MOC_data_products' + sep
ecl_dir = moc + strupcase('rbsp' + sc) + sep + 'eclipse_predict' + sep
all_ecl_files = file_basename(file_search(ecl_dir, 'rbsp*'))
reg = '^rbsp' + strlowcase(sc) + '_201[0-9]{1}_[0-9]{3}_[0-9]{2}'
ind = where(stregex(all_ecl_files, reg, /bool))
all_ecl_files = all_ecl_files[ind]
tmp = stregex(all_ecl_files, '201[0-9]{1}_[0-9]{3}_[0-9]{2}', /extract)
years = long(strmid(tmp, 0, 4))
doys = long(strmid(tmp, 5, 3))
versions = long(strmid(tmp, 9, 2))
jdays = julday(1, 1, years) + doys - 1
tspan = timerange() + [10, -10.]
days = (tspan[1] - tspan[0])/(24d * 3600d) + 1
files = ['']
for i = 0L, days - 1 do begin
time = tspan[0] + i * 24d * 3600d
date = strmid(time_string(time), 0, 10)
jday = jbt_date2jday(date)
ind = where(jdays lt jday, nind)
if nind eq 0 then begin
dprint, 'No file available. Something is off.'
stop
endif
itmp = ind[nind-1]
doy = doys[itmp]
ind = where(doys eq doy, nind)
if nind gt 1 then begin
v = versions[ind]
dum = max(v, imax)
file = all_ecl_files[ind[imax]]
endif else file = all_ecl_files[ind[0]]
files = [files, file]
endfor
ind = where(strlen(files) gt 0)
files = files[ind]
ind = uniq(files)
files = files[ind]
return, ecl_dir + files
end
function rbsp_load_state_eclipse_str2time, subitems
compile_opt idl2, HIDDEN
day = subitems[0]
month = subitems[1]
year = subitems[2]
time_str = subitems[3]
if strcmp(strmid(month, 0, 3), 'Jan', /fold) then mm = '01'
if strcmp(strmid(month, 0, 3), 'Feb', /fold) then mm = '02'
if strcmp(strmid(month, 0, 3), 'Mar', /fold) then mm = '03'
if strcmp(strmid(month, 0, 3), 'Apr', /fold) then mm = '04'
if strcmp(strmid(month, 0, 3), 'May', /fold) then mm = '05'
if strcmp(strmid(month, 0, 3), 'Jun', /fold) then mm = '06'
if strcmp(strmid(month, 0, 3), 'Jul', /fold) then mm = '07'
if strcmp(strmid(month, 0, 3), 'Aug', /fold) then mm = '08'
if strcmp(strmid(month, 0, 3), 'Sep', /fold) then mm = '09'
if strcmp(strmid(month, 0, 3), 'Oct', /fold) then mm = '10'
if strcmp(strmid(month, 0, 3), 'Nov', /fold) then mm = '11'
if strcmp(strmid(month, 0, 3), 'Dec', /fold) then mm = '12'
str = year + '-' + mm + '-' + day + '/' + time_str
return, time_double(str)
end
pro rbsp_load_state_parse_eclipse_time_file, file, sc, $
umbra_sta, umbra_end, in_penumbra_len, out_penumbra_len, $
no_eclipse = no_eclipse
compile_opt idl2, HIDDEN
no_eclipse = 0
lines = jbt_get_lines(file)
nline = n_elements(lines)
ind = where(strmatch(lines, '*------------------------*'))
ista = ind[0] + 1
iline = ista
nitem = 13
while iline lt nline do begin
line = lines[iline]
items = strsplit(line, /extract)
if n_elements(items) ne 13 then begin
iline++
continue
endif
if n_elements(orbit_ids) eq 0 then begin
orbit_ids = long(items[0])
start_times = rbsp_load_state_eclipse_str2time(items[1:4])
end_times = rbsp_load_state_eclipse_str2time(items[5:8])
tlens = double(items[9])
types = items[11]
endif else begin
orbit_ids = [orbit_ids, long(items[0])]
start_times = [start_times, rbsp_load_state_eclipse_str2time(items[1:4])]
end_times = [end_times, rbsp_load_state_eclipse_str2time(items[5:8])]
tlens = [tlens, double(items[9])]
types = [types, items[11]]
endelse
iline++
endwhile
if n_elements(types) eq 0 then begin
no_eclipse = 1
dprint, 'No eclipse in the current time span.'
return
endif
ind_umbra = where(strcmp(types, 'Umbra', /fold), nind)
if nind eq 0 then begin
no_eclipse = 1
dprint, 'No umbra in the current time span.'
return
endif
n_type = n_elements(types)
umbra_sta = start_times[ind_umbra]
umbra_end = end_times[ind_umbra]
in_penumbra_len = umbra_sta
out_penumbra_len = umbra_sta
ind = ind_umbra
for i = 0, nind -1 do begin
if ind[i] eq 0 then in_penumbra_len[i] = !values.f_nan $
else in_penumbra_len[i] = tlens[ind[i]-1]
if ind[i] eq n_type-1 then out_penumbra_len[i] = !values.f_nan $
else out_penumbra_len[i] = tlens[ind[i]+1]
endfor
in_penumbra_len = interp(in_penumbra_len, dindgen(nind), $
dindgen(nind), /ignore_nan)
out_penumbra_len = interp(out_penumbra_len, dindgen(nind), $
dindgen(nind), /ignore_nan)
in_penumbra_len = thm_lsp_median_smooth(in_penumbra_len, 7)
out_penumbra_len = thm_lsp_median_smooth(out_penumbra_len, 7)
umbra_len = umbra_end - umbra_sta
end
pro rbsp_load_state_load_eclipse_time, probe = probe, $
no_eclipse = no_eclipse
compile_opt idl2, HIDDEN
tspan = timerange()
nsc = n_elements(probe)
for ip = 0, nsc-1 do begin
sc = strlowcase(probe[ip])
rbx = 'rbsp' + sc + '_'
files = rbsp_load_state_eclipse_time_files(sc)
nfile = n_elements(files)
for i = 0, nfile-1 do begin
file = files[i]
rbsp_load_state_parse_eclipse_time_file, file, sc, $
umbra_sta, umbra_end, in_penumbra_len, out_penumbra_len, $
no_eclipse = no_eclipse
if no_eclipse gt 0 then continue
if n_elements(umbra_sta_all) eq 0 then begin
umbra_sta_all = umbra_sta
umbra_end_all = umbra_end
in_penumbra_len_all = in_penumbra_len
out_penumbra_len_all = out_penumbra_len
endif else begin
umbra_sta_all = [umbra_sta_all , umbra_sta]
umbra_end_all = [umbra_end_all , umbra_end]
in_penumbra_len_all = [in_penumbra_len_all , in_penumbra_len]
out_penumbra_len_all = [out_penumbra_len_all , out_penumbra_len]
endelse
endfor
if n_elements(umbra_end_all) eq 0 or n_elements(umbra_sta_all) eq 0 then $
continue
ind = where(umbra_end_all gt tspan[0] and umbra_sta_all lt tspan[1], nind)
if nind eq 0 then continue
umbra_sta = umbra_sta_all[ind]
umbra_end = umbra_end_all[ind]
in_penumbra_len = in_penumbra_len_all[ind]
out_penumbra_len = out_penumbra_len_all[ind]
att = {units:'s'}
dl = {data_att:att, ysubtitle:'[s]', psym:1}
store_data, rbx + 'umbra_sta', data = {x:umbra_sta, y:in_penumbra_len}, $
dlim = dl
options, rbx + 'umbra_sta', colors = [2], labels=['sta']
store_data, rbx + 'umbra_end', data = {x:umbra_end, y:out_penumbra_len}, $
dlim = dl
options, rbx + 'umbra_end', colors = [6], labels=['end']
store_data, rbx + 'umbra', data = rbx + 'umbra_' + ['end', 'sta']
options, rbx + 'umbra', labflag = 1
endfor
end
function rbsp_load_state_smooth_mat_dsc, mat_dsc
compile_opt idl2, hidden
nsm = 1000
for i = 0, 2 do $
for j = 0, 2 do $
mat_dsc[*,i,j] = smooth(mat_dsc[*,i,j], nsm, /edge_truncate)
return, mat_dsc
end
pro rbsp_load_state, probe = probe, datatype = datatype, dt = dt, $
no_update = no_update, klist = klist, unload = unload, $
spice_only = spice_only, get_support_data = get_support_data, $
verbose = verbose, downloadonly = downloadonly, $
no_eclipse = no_eclipse, $
use_eph_predict = use_eph_predict, $
no_spice_load = no_spice_load
compile_opt idl2
if ~keyword_set(datatype) then datatype = ['pos', 'vel', 'spinper', $
'spinphase', 'mat_dsc', 'umbra', 'Lvec']
if ~keyword_set(probe) then probe = ['a', 'b']
if n_elements(dt) ne 1 then dt = 5.
if n_elements(unload) eq 0 then unload = 1
rbsp_efw_init
if n_elements(no_update) eq 0 then no_update = !rbsp_efw.no_download
if n_elements(downloadonly) eq 0 then downloadonly = !rbsp_efw.downloadonly
if dt lt 0.1 then begin
dprint, 'dt is small. You can now have a long cup of coffee, take a walk, '
print, " and don't be surprised if the loading is not over yet " + $
'when you come back.'
endif
tspan = timerange()
tlen = tspan[1] - tspan[0]
ntimes = ceil(tlen / dt)
time = tspan[0] + dindgen(ntimes) * dt
if ~keyword_set(no_spice_load) then begin
dprint, verbose = verbose, 'Loading SPICE...'
rbsp_load_state_load_spice, probe = probe, no_update = no_update, $
klist = klist, downloadonly = downloadonly, $
use_eph_predict = use_eph_predict
if keyword_set(downloadonly) then return
endif
if keyword_set(spice_only) then return
time_str=time_string(time, prec=3)
strput,time_str,'T',10
cspice_str2et,time_str,et
ntype = n_elements(datatype)
nsc = n_elements(probe)
for ip = 0, nsc-1 do begin
sc = probe[ip]
rbx = 'rbsp' + sc + '_'
spice_str_id = 'RBSP_' + strupcase(sc)
spice_str_id =spice_str_id[0]
spice_num_id = -long(byte(strlowcase(sc))) - 265
spice_num_id = spice_num_id[0]
inst = spice_num_id * 1000L
cspice_spkezr, spice_str_id, et,'GSE', 'NONE','EARTH', posvel, ltime
pgse=transpose(posvel[0:2,*])
vgse=transpose(posvel[3:5,*])
cspice_sce2c, spice_num_id[0], et, sclkdp
xs = 149598261d + time * 0d
ys = time * 0d
zs = time * 0d
store_data, 'slp_*', /del, verbose = 0
x2 = pgse[*,0]
y2 = pgse[*,1]
z2 = pgse[*,2]
us = [[xs-x2], [ys-y2], [zs-z2]]
absus = sqrt(total(us^2,2))
us[*,0] = us[*,0] / absus
us[*,1] = us[*,1] / absus
us[*,2] = us[*,2] / absus
mat_dsc = fltarr(ntimes, 3, 3)
mat_xyz = fltarr(ntimes, 3, 3)
xdsc = fltarr(ntimes, 3)
per = dblarr(ntimes)
Lvec = dblarr(ntimes, 3)
for i = 0L, ntimes - 1 do begin
cspice_ckgpav, inst, sclkdp[i], 0d, 'GSE', cmat, av, clkout, found
if found le 0 then begin
dprint, 'Spacecraft pointing matrix not found. Abort.'
return
endif
mat_xyz[i,*,*] = cmat
per[i] = 2d * !dpi / sqrt(total(av^2))
Lvec[i, *] = av / sqrt(total(av^2))
u_sun = reform(us[i, *])
u_axb = reform(cmat[*,2])
tmp = crossp(u_axb, u_sun)
tmp = tmp / sqrt(total(tmp^2))
u_ss = crossp(tmp, u_axb)
xdsc[i,*] = cmat ## transpose(u_ss)
ydsc_gse = crossp(u_axb, u_ss)
mat_dsc[i,*,*] = [[u_ss], [ydsc_gse], [u_axb]]
endfor
x = xdsc[*,0]
y = xdsc[*,1]
phase = -atan(y, x) * !radeg + 360. - 45.
phase = phase mod 360
if total(strcmp(datatype, 'pos', /fold)) gt 0 then begin
tvar = rbx + 'pos_gse'
data = {x:time, y:pgse}
att = {units:'[km]', coord_sys:'gse'}
dl ={data_att:att, ysubtitle:'[km]'}
store_data, tvar, data = data, dlim = dl, verbose = verbose
options, tvar, colors = [2, 4, 6], $
labels = ['x GSE', 'y GSE', 'z GSE'], $
labflag = 1
if keyword_set(get_support_data) then begin
newtvar = rbx + 'pos_gsm'
cotrans, tvar, newtvar, /gse2gsm
options, newtvar, colors = [2, 4, 6], $
labels = ['x GSM', 'y GSM', 'z GSM'], $
labflag = 1
endif
endif
if total(strcmp(datatype, 'vel', /fold)) gt 0 then begin
tvar = rbx + 'vel_gse'
data = {x:time, y:vgse}
att = {units:'[km/s]', coord_sys:'gse'}
dl ={data_att:att, ysubtitle:'[km/s]'}
store_data, tvar, data = data, dlim = dl, verbose = verbose
options, tvar, colors = [2, 4, 6], $
labels = ['Vx GSE', 'Vy GSE', 'Vz GSE'], $
labflag = 1
if keyword_set(get_support_data) then begin
newtvar = rbx + 'vel_gsm'
cotrans, tvar, newtvar, /gse2gsm
options, newtvar, colors = [2, 4, 6], $
labels = ['Vx GSM', 'Vy GSM', 'Vz GSM'], $
labflag = 1
endif
endif
if total(strcmp(datatype, 'Lvec', /fold)) gt 0 then begin
tvar = rbx + 'Lvec'
data = {x:time, y:Lvec}
att = {units:'', coord_sys:'gse'}
dl ={data_att:att}
store_data, tvar, data = data, dlim = dl, verbose = verbose
options, tvar, colors = [0], $
labels = ['spin!C L vector'], $
labflag = 1
endif
if total(strcmp(datatype, 'spinper', /fold)) gt 0 then begin
tvar = rbx + 'spinper'
data = {x:time, y:per}
att = {units:'[s]', coord_sys:''}
dl ={data_att:att, ysubtitle:'[s]', yrange:minmax(per)+[-0.001,0.001], $
ystyle:1}
store_data, tvar, data = data, dlim = dl, verbose = verbose
options, tvar, colors = [0], $
labels = ['spin!C period'], $
labflag = 1
endif
if total(strcmp(datatype, 'spinphase', /fold)) gt 0 then begin
tvar = rbx + 'spinphase'
data = {x:time, y:phase}
att = {units:'[degree]', coord_sys:''}
dl ={data_att:att, ysubtitle:'[degree]'}
store_data, tvar, data = data, dlim = dl, verbose = verbose
options, tvar, colors = [0], $
labels = ['spin!C phase'], $
labflag = 1
endif
if total(strcmp(datatype, 'mat_dsc', /fold)) gt 0 then begin
tvar = rbx + 'mat_dsc'
mat_dsc = rbsp_load_state_smooth_mat_dsc(temporary(mat_dsc))
data = {x:time, y:mat_dsc}
att = {units:'', coord_sys:''}
dl ={data_att:att, ysubtitle:''}
store_data, tvar, data = data, dlim = dl
if keyword_set(get_support_data) then begin
get_data, tvar, data = d
xgse_in_dsc = reform(d.y[*,0,*])
ygse_in_dsc = reform(d.y[*,1,*])
zgse_in_dsc = reform(d.y[*,2,*])
att = {units:'', coord_sys:'dsc'}
dl ={data_att:att, ysubtitle:''}
store_data, rbx + 'xgse_dsc', data = {x:d.x, y:xgse_in_dsc}, dlim=dl, $
verbose = verbose
options, rbx + 'xgse_dsc', colors = [2, 4, 6], $
labels = ['X', 'Y', 'Z'], $
labflag = 1
store_data, rbx + 'ygse_dsc', data = {x:d.x, y:ygse_in_dsc}, dlim=dl, $
verbose = verbose
options, rbx + 'ygse_dsc', colors = [2, 4, 6], $
labels = ['X', 'Y', 'Z'], $
labflag = 1
store_data, rbx + 'zgse_dsc', data = {x:d.x, y:zgse_in_dsc}, dlim=dl, $
verbose = verbose
options, rbx + 'zgse_dsc', colors = [2, 4, 6], $
labels = ['X', 'Y', 'Z'], $
labflag = 1
endif
if total(strcmp(datatype, 'umbra', /fold)) gt 0 then begin
rbsp_load_state_load_eclipse_time, probe = sc, no_eclipse = no_eclipse
endif
endif
endfor
if keyword_set(no_spice_load) then return
if keyword_set(unload) then begin
dprint, verbose = verbose, 'Unloading SPICE kernels...'
cspice_unload, klist
endif else $
dprint, verbose = verbose, 'SPICE not unloaded. !!!Keep this in mind!!!'
end