function rbsp_load_emfisis_quicklook_urls, sc, date
compile_opt idl2, hidden
emfisis_root_dir = 'http://emfisis.physics.uiowa.edu/Flight/'
scdir = strupcase('rbsp-' + sc[0]) + '/Quick-Look/'
dstr = strmid(time_string(time_double(date)), 0, 10)
year = strmid(dstr, 0, 4)
mm = strmid(dstr, 5, 2)
dd = strmid(dstr, 8, 2)
date_dir = year + '/' + mm + '/' + dd + '/'
remote_dir = emfisis_root_dir + scdir + date_dir
urls = jbt_fileurls(remote_dir, verbose = 0)
return, urls
end
function rbsp_load_emfisis_quicklook_fname_filter, dtype
compile_opt idl2, hidden
case dtype of
'1sec-gse': filter = '*_magnetometer_1sec-gse_*'
'4sec-gse': filter = '*_magnetometer_4sec-gse_*'
'hires-gse': filter = '*_magnetometer_hires-gse_*'
'uvw': filter = '*_magnetometer_uvw_*'
'hfr': filter = '*_HFR-spectra_*'
'hfr-waveform': filter = '*_HFR-waveform_*'
'hfr-burst': filter = '*_HFR-spectra-burst_*'
'wfr-BuBu': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-BvBv': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-BwBw': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-EuEu': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-EvEv': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-EwEw': filter = '*_WFR-spectral-matrix-diagonal_*'
'wfr-burst': filter = '*_WFR-spectral-matrix-burst-diagonal_*'
else: begin
dprint, 'Invalid data type. Returning a filter of "InvalidFilter".'
return, 'InvalidFilter'
end
endcase
return, filter
end
function rbsp_load_emfisis_quicklook_fname, dtype, urls
compile_opt idl2, hidden
fnames = file_basename(urls)
filter = rbsp_load_emfisis_quicklook_fname_filter(dtype)
if strcmp(filter, 'InvalidFilter') then return, ''
ind = where(strmatch(fnames, filter), nind)
if nind gt 0 then return, fnames[ind[0]] else return, ''
end
pro rbsp_load_emfisis_quicklook_meta, dtype, sc, tvar, dlim
compile_opt idl2, hidden
rbx = 'rbsp' + strlowcase(sc) + '_'
case dtype of
'1sec-gse': begin
tvar = rbx + 'mag_gse_1sec'
coord = 'gse'
units = 'nT'
lbl_suf = strupcase(' ' + coord)
labels = ['Bx'+lbl_suf, 'By'+lbl_suf, 'Bz'+lbl_suf]
ysub = '[' + units + ']'
dlim = {ysubtitle:ysub, colors:[2,4,6], labels:labels, labflag:1}
end
'4sec-gse': begin
tvar = rbx + 'mag_gse_4sec'
coord = 'gse'
units = 'nT'
lbl_suf = strupcase(' ' + coord)
labels = ['Bx'+lbl_suf, 'By'+lbl_suf, 'Bz'+lbl_suf]
ysub = '[' + units + ']'
dlim = {ysubtitle:ysub, colors:[2,4,6], labels:labels, labflag:1}
end
'hires-gse': begin
tvar = rbx + 'mag_gse_hires'
coord = 'gse'
units = 'nT'
lbl_suf = strupcase(' ' + coord)
labels = ['Bx'+lbl_suf, 'By'+lbl_suf, 'Bz'+lbl_suf]
ysub = '[' + units + ']'
dlim = {ysubtitle:ysub, colors:[2,4,6], labels:labels, labflag:1}
end
'uvw': begin
tvar = rbx + 'mag_uvw'
coord = 'uvw'
units = 'nT'
lbl_suf = strupcase(' ' + coord)
labels = ['Bx'+lbl_suf, 'By'+lbl_suf, 'Bz'+lbl_suf]
ysub = '[' + units + ']'
dlim = {ysubtitle:ysub, colors:[2,4,6], labels:labels, labflag:1}
end
'hfr': begin
tvar = rbx + 'hfr'
coord = ''
units = 'V^2/m^2/Hz'
ztitle = '[V!U2!N/m!U2!N/Hz]'
ysub = '[Hz]'
dlim = {ysubtitle:ysub, spec:1, ylog:1, zlog:1, ztitle:ztitle, $
yrange:[1e4, 486.97e3], ystyle:1}
end
'wfr-BuBu': begin
tvar = rbx + 'wfr_BuBu'
coord = ''
units = 'nT^2/Hz'
ztitle = '[nT!U2!N/Hz]'
ysub = '[Hz]'
dlim = {ysubtitle:ysub, spec:1, ylog:1, zlog:1, ztitle:ztitle, $
yrange:[4, 12e3], ystyle:1}
end
'wfr-EuEu': begin
tvar = rbx + 'wfr_EuEu'
coord = ''
units = 'V^2/m^2/Hz'
ztitle = '[V!U2!N/m!U2!N/Hz]'
ysub = '[Hz]'
dlim = {ysubtitle:ysub, spec:1, ylog:1, zlog:1, ztitle:ztitle, $
yrange:[4, 12e3], ystyle:1}
end
else: begin
dprint, 'Invalid data type. '
return
end
endcase
att = {coord_sys:coord, units:units}
str_element, dlim, 'data_att', att, /add
end
function rbsp_load_emfisis_quicklook_spec, dtype
compile_opt idl2, hidden
case dtype of
'1sec-gse': return, -1
'4sec-gse': return, -1
'hires-gse': return, -1
'uvw': return, -1
'hfr': return, 1
'wfr-BuBu': return, 1
'wfr-BvBv': return, 1
'wfr-BwBw': return, 1
'wfr-EuEu': return, 1
'wfr-EvEv': return, 1
'wfr-EwEw': return, 1
else: begin
dprint, 'Invalid data type. '
return, !values.f_nan
end
endcase
end
function rbsp_load_emfisis_quicklook_spec_name, dtype
compile_opt idl2, hidden
case dtype of
'1sec-gse': return, ''
'4sec-gse': return, ''
'hires-gse': return, ''
'uvw': return, ''
'hfr': return, 'HFR_Spectra'
'wfr-BuBu': return, 'BuBu'
'wfr-BvBv': return, 'BvBv'
'wfr-BwBw': return, 'BwBw'
'wfr-EuEu': return, 'EuEu'
'wfr-EvEv': return, 'EvEv'
'wfr-EwEw': return, 'EwEw'
else: begin
dprint, 'Invalid data type. '
return, !values.f_nan
end
endcase
end
pro rbsp_load_emfisis_quicklook_download, sc, date, dtype, urls $
, _extra = _extra
compile_opt idl2, hidden
fname = rbsp_load_emfisis_quicklook_fname(dtype, urls)
sep = '/'
scdir = strupcase('rbsp-' + sc[0]) + sep + 'Quick-Look' + sep
dstr = strmid(time_string(time_double(date)), 0, 10)
year = strmid(dstr, 0, 4)
mm = strmid(dstr, 5, 2)
dd = strmid(dstr, 8, 2)
date_dir = year + sep + mm + sep + dd + sep
emfisis_root_dir = 'http://emfisis.physics.uiowa.edu/Flight/'
serverdir = emfisis_root_dir
localdir = !rbsp_efw.local_data_dir + 'emfisis' + sep
pathname = scdir + date_dir + fname
file_http_copy, pathname $
, serverdir=serverdir $
, localdir=localdir $
, _extra = _extra
end
function rbsp_load_emfisis_quicklook_file, sc, date, dtype, urls, $
use_local = use_local
compile_opt idl2, hidden
sep = path_sep()
scdir = strupcase('rbsp-' + sc[0]) + sep + 'Quick-Look' + sep
dstr = strmid(time_string(time_double(date)), 0, 10)
year = strmid(dstr, 0, 4)
mm = strmid(dstr, 5, 2)
dd = strmid(dstr, 8, 2)
date_dir = year + sep + mm + sep + dd + sep
localdir = !rbsp_efw.local_data_dir + 'emfisis' + sep
if ~keyword_set(use_local) then begin
fname = rbsp_load_emfisis_quicklook_fname(dtype, urls)
if strlen(fname) eq 0 then return, ''
endif else begin
tmpdir = localdir + scdir + date_dir
files = file_search(tmpdir, '*.cdf')
fnames = file_basename(files)
filter = rbsp_load_emfisis_quicklook_fname_filter(dtype)
if strcmp(filter, 'InvalidFilter') then return, ''
ind = where(strmatch(fnames, filter), nind)
if nind gt 0 then return, files[ind[0]] else return, ''
endelse
pathname = scdir + date_dir + fname
file = localdir + pathname
return, file
end
pro rbsp_load_emfisis_quicklook, probe = probe, datatype = datatype $
, _extra = _extra, use_local = use_local, downloadonly = downloadonly
compile_opt idl2
if ~keyword_set(datatype) then datatype = ['1sec-gse', 'hfr', 'wfr-BuBu', $
'wfr-EuEu']
if ~keyword_set(probe) then probe = ['a', 'b']
if n_elements(downloadonly) eq 0 then downloadonly = !rbsp_efw.downloadonly
rbsp_efw_init
tspan = timerange()
dsta = strmid(time_string(tspan[0]+10.), 0, 10)
dend = strmid(time_string(tspan[1]-10.), 0, 10)
days = (time_double(dend) - time_double(dsta) )/(24d * 3600d) + 1
tsta = time_double(dsta)
cdf_leap_second_init
ntype = n_elements(datatype)
nsc = n_elements(probe)
for itype = 0, ntype - 1 do begin
dtype = datatype[itype]
for ip = 0, nsc-1 do begin
sc = probe[ip]
rbx = 'rbsp' + sc + '_'
for i = 0L, days-1 do begin
t0 = tsta + i * 24d * 3600d
tmptr = t0 + [0d, 24d*3600d]
date = strmid(time_string(t0), 0, 10)
if ~keyword_set(use_local) then begin
urls = rbsp_load_emfisis_quicklook_urls(sc, date)
rbsp_load_emfisis_quicklook_download, sc, date, dtype, urls $
, _extra = _extra
if keyword_set(downloadonly) then continue
endif
file = rbsp_load_emfisis_quicklook_file(sc, date, dtype, urls, $
use_local = use_local)
if strlen(file) gt 0 then cdf2tplot, file = file else begin
dprint, dtype, ' data not available for RBSP ', strupcase(sc), '.'
continue
endelse
if rbsp_load_emfisis_quicklook_spec(dtype) gt 0 then begin
spec_name = rbsp_load_emfisis_quicklook_spec_name(dtype)
get_data, spec_name, data = data
ind = where(data.x ge tmptr[0] and data.x lt tmptr[1], nind)
if nind eq 0 then begin
dprint, 'Something is off.'
stop
endif
tarr = data.x[ind]
spec_y = data.y[ind, *]
v_tmp = reform(data.v)
dim = size(v_tmp, /dim)
if n_elements(dim) eq 1 then begin
nv = dim[0]
spec_v = transpose(rebin(v_tmp, nv, nind))
endif else spec_v = v_tmp
if n_elements(x_tplot) eq 0 then begin
x_tplot = tarr
spec_y_tplot = spec_y
spec_v_tplot = spec_v
endif else begin
x_tplot = [x_tplot , tarr]
spec_y_tplot = [spec_y_tplot, spec_y]
spec_v_tplot = [spec_v_tplot, spec_v]
endelse
endif else begin
get_data, 'Mag', data = data
ind = where(data.x ge tmptr[0] and data.x lt tmptr[1], nind)
if nind eq 0 then begin
dprint, 'Something is off.'
stop
endif
bx = data.y[ind,0]
by = data.y[ind,1]
bz = data.y[ind,2]
tarr = data.x[ind]
if n_elements(x_tplot) eq 0 then begin
x_tplot = tarr
bx_tplot = bx
by_tplot = by
bz_tplot = bz
endif else begin
x_tplot = [x_tplot , tarr]
bx_tplot = [bx_tplot , bx]
by_tplot = [by_tplot , by]
bz_tplot = [bz_tplot , bz]
endelse
endelse
endfor
if keyword_set(downloadonly) then continue
nt = n_elements(x_tplot)
if nt eq 0 then continue else begin
rbsp_load_emfisis_quicklook_meta, dtype, sc, tvar, dlim
ind = where(x_tplot ge tspan[0] and x_tplot le tspan[1], nind)
if nind eq 0 then begin
dprint, 'Something is off.'
stop
endif
if rbsp_load_emfisis_quicklook_spec(dtype) gt 0 then begin
data = {x:x_tplot[ind], y:spec_y_tplot[ind, *], $
v:spec_v_tplot[ind, *]}
undefine, x_tplot
endif else begin
data = {x:x_tplot[ind], y:[$
[bx_tplot[ind]] $
, [by_tplot[ind]] $
, [bz_tplot[ind]] $
]}
undefine, x_tplot
endelse
store_data, tvar, data = data, dlim = dlim
if strmatch(dtype, '*hires*') or $
strmatch(dtype, '*uvw*') $
then begin
get_data, tvar, data = data, dlim = dlim, lim = lim
btot = sqrt(total(data.y^2,2))
bsm = thm_lsp_median_smooth(btot, 20)
bdiff = abs(btot - bsm)
ind = where(bdiff gt 100)
data.y[ind, *] = !values.d_nan
data.y[*,0] = interp(data.y[*,0], data.x, data.x, /ignore_nan)
data.y[*,1] = interp(data.y[*,1], data.x, data.x, /ignore_nan)
data.y[*,2] = interp(data.y[*,2], data.x, data.x, /ignore_nan)
store_data, tvar, data = data, dlim = dlim, lim = lim
endif
endelse
endfor
endfor
if keyword_set(downloadonly) then return
store_data, ['Mag', 'Magnitude', 'delta', 'lambda', 'rms', 'coordinates'], $
/del, verbose = 0
store_data, ['HFR_Spectra', 'BuBu', 'BvBv', 'BwBw', 'EuEu', 'EvEv', 'EwEw'], $
/del, verbose = 0
end