pro thm_load_efi_l2, probe = probe, datatype = datatype, trange = trange, $
level = level, verbose = verbose, downloadonly = downloadonly, $
no_download = no_download, coord = coord, varformat = varformat, $
cdf_data = cdf_data, varnames = varnames, valid_names = valid_names, $
files = files, relpathnames_all = relpathnames_all, $
suffix = suffix, progobj = progobj, test = test, $
no_time_clip = no_time_clip, msg_out=msg_out, _extra = _extra
thm_init
vb = size(verbose, /type) ne 0 ? verbose : !themis.verbose
if not keyword_set(suffix) then suffix=''
if arg_present(relpathnames_all) then begin
downloadonly=1
no_download=1
end
thm_load_proc_arg, sname = probe, datatype = datatype, $
level = 'l2', verbose = verbose, no_download = no_download, $
valid_names = valid_names, $
vsnames = 'a b c d e', $
type_sname = 'probe', $
vdatatypes = 'eff_dot0 efs_dot0 eff_q_mag eff_q_pha efs_q_mag efs_q_pha eff_e12_efs eff_e34_efs', $
vtypes = 'calibrated', $
vlevels = 'l2', $
vL2datatypes = 'eff_dot0 efs_dot0 eff_q_mag eff_q_pha efs_q_mag efs_q_pha eff_e12_efs eff_e34_efs', $
file_vL2datatypes = 'efi', $
deflevel = 'l2', $
osname = probes, odt = dts, olvl = lvls, $
oft = fts, ofdt = fdts, otyp = typ, $
load_params = !themis, $
my_themis = my_themis
lvls = 'l2'
ndts = n_elements(dts)
nfts = n_elements(fts)
nprobes = n_elements(probes)
if keyword_set(valid_names) then return
if ndts*nfts*nprobes le 0 then return
if arg_present(cdf_data) && ndts*nprobes gt 1 then begin
dprint, 'can only get cdf_data for a single datatype'
return
endif
if ~keyword_set(trange) then begin
trange = timerange()
endif
for j = 0, nfts-1 do $
for i = 0, nprobes-1 do begin
probei = probes[i]
ftj = fts[j]
lvlk = 'l2'
relpath = 'th'+probei+'/'+lvlk+'/'+ ftj+'/'
prefix = 'th'+probei+'_'+lvlk+'_'+ftj+'_'
dir = 'YYYY/'
ending = '_v01.cdf'
relpathnames = file_dailynames(relpath, prefix, ending, dir = dir, trange = trange, addmaster = addmaster)
if vb ge 7 then dprint, 'relpathnames : ', relpathnames
if arg_present(relpathnames_all) then begin
if i+j eq 0 then relpathnames_all = relpathnames else relpathnames_all = [relpathnames_all, relpathnames]
endif
files = file_retrieve(relpathnames, _extra = my_themis, progobj = progobj)
if keyword_set(downloadonly) then continue
if arg_present(cdf_data) then begin
cdf_data = cdf_load_vars(files, varnames = varnames, verbose = vb, /all)
return
endif
if ~keyword_set(varformat) then begin
varformat = 'th?_'+dts
If(keyword_set(coord)) Then Begin
crd = thm_check_valid_name(strlowcase(coord), ['dsl', 'gse', 'gsm'], /include_all, $
invalid=msg_coord, type='coordinates')
Endif Else crd = 'dsl'
For vv = 0, n_elements(crd)-1 Do Begin
varformat = [varformat, ' th?_'+dts+'_'+crd[vv]]
Endfor
If(n_elements(varformat) Gt 1) Then varformat = strjoin(varformat, ' ')
endif
if keyword_set(vb) then dprint, transpose(['Loading...', files])
If(is_string(file_search(files)) Eq 0) Then Begin
dprint, 'Files: '+files+' not found'
Return
Endif
cdf2tplot, file = files, all = all, verbose = vb, varformat = varformat, tplotnames = tplotnames
if ~keyword_set(no_time_clip) && keyword_set(trange) then begin
for l = 0, n_elements(tplotnames)-1 do begin
if tplotnames[l] eq '' then continue
dprint, 'Clipping '+tplotnames[l]
time_clip, tplotnames[l], trange[0], trange[1], /replace, error = clip_err
if clip_err then begin
dprint, 'Unable to clip '+tplotnames[l]+' to requested time range. Data may be out of range.'
store_data, tplotnames[l], /del
filtered_tplotnames = tplotnames[l]
endif
endfor
if keyword_set(filtered_tplotnames) then tplotnames = filtered_tplotnames
endif
for l = 0, n_elements(tplotnames)-1 do begin
tplot_var = tplotnames[l]
etype = strmid(tplot_var, 0, 5)
qflag = strpos(tplot_var, '_q_')
get_data, tplot_var, data = d_str, limit = l_str, dlimit = dl_str
if is_struct(dl_str) then begin
if qflag[0] eq -1 then begin
thm_new_units, tplot_var
thm_new_coords, tplot_var
get_data, tplot_var, dlimits = dl_str
unit = dl_str.data_att.units
u1 = strsplit(unit, ' ', /extract)
dl_str.data_att.units = u1[0]
if etype Eq 'th'+probei+'_v' then begin
colors = [1, 2, 3, 4, 5, 6]
labels = ['V1', 'V2', 'V3', 'V4', 'V5', 'V6']
endif
if etype eq 'th'+probei+'_e' then begin
colors = [2, 4, 6]
labels = [ 'Ex', 'Ey', 'Ez']
endif
str_element, dl_str, 'colors', colors, /add
str_element, dl_str, 'labels', labels, /add
str_element, dl_str, 'labflag', 1, /add
store_data, tplot_var, data = d_str, limit = l_str, dlimit = dl_str
endif else begin
str_element, dl_str, 'ytitle', tplot_var, /add
store_data, tplot_var, data = d_str, limit = l_str, dlimit = dl_str
ylim, tplot_var, 0, 0, 1
endelse
endif
if n_elements(suffix) eq 1 && strlen(suffix) gt 0 then begin
tplot_var_suf = tplot_var+suffix[0]
copy_data, tplot_var, tplot_var_suf
endif
endfor
endfor
msg_out = keyword_set(msg_coord) ? msg_coord:''
end