pro thm_load_xxx, sname = sname, datatype = datatype, trange = trange, $
level = level, coord = coord, proc_type = type, version = version, $
verbose = verbose, downloadonly = downloadonly, $
cdf_data = cdf_data, get_cdf_data = get_cdf_data, $
get_support_data = get_support_data, varformat = varformat, $
tplotnames = tplotnames, valid_names = valid_names, $
files = files, $
type_sname = type_sname, $
vsnames = vsnames, vdatatypes = vdatatypes, $
file_vdatatypes = file_vdatatypes, $
vtypes = vtypes, $
vlevels = vlevels, deflevel = deflevel, $
vL2datatypes = vL2datatypes, vL2coord = vL2coord, $
file_vL2datatypes = file_vL2datatypes, $
relpath_funct = relpath_funct, $
cdf_to_tplot = cdf_to_tplot, $
post_process_proc = post_process_proc, $
addmaster = addmaster, midfix = midfix, $
no_download = no_download, relpathnames_all = relpathnames_all, $
all_sites_in_one = all_sites_in_one, suffix = suffix, $
progobj = progobj, $
scm_cal = scm_cal, $
no_update = no_update, $
alternate_load_params=alternate_load_params, $
no_time_clip = no_time_clip, $
no_implicit_wildcard=no_implicit_wildcard, $
use_eclipse_corrections=use_eclipse_corrections, $
msg_out=msg_out, $
_ref_extra = _extra
compile_opt idl2
if keyword_set(alternate_load_params) then begin
dprint, 'Using alternate load parameters'
load_params=alternate_load_params
endif else begin
thm_init
load_params=!themis
endelse
thm_load_proc_arg, sname = sname, datatype = datatype, $
level = level, coord = coord, proc_type = type, $
verbose = verbose, $
varformat = varformat, valid_names = valid_names, $
type_sname = type_sname, $
vsnames = vsnames, vdatatypes = vdatatypes, $
file_vdatatypes = file_vdatatypes, $
vtypes = vtypes, $
vlevels = vlevels, deflevel = deflevel, $
vL2datatypes = vL2datatypes, vL2coord = vL2coord, $
file_vL2datatypes = file_vL2datatypes, $
no_download = no_download, $
progobj = progobj, $
osname = snames, odt = dts, olvl = lvls, my_themis = my_themis, $
oft = fts, ofdt = fdts, $
load_params=load_params, $
use_eclipse_corrections=use_eclipse_corrections, $
no_update = no_update, $
msg_out = msg_out
vb = size(verbose, /type) ne 0 ? verbose : load_params.verbose
nlvls = n_elements(lvls)
ndts = n_elements(dts)
nfts = n_elements(fts)
nsnames = n_elements(snames)
if nlvls*ndts*nfts*nsnames le 0 then return
if keyword_set(valid_names) then return
if get_cdf_data && nlvls*nfts*nsnames gt 1 then begin
dprint, 'can only get cdf_data for a single file type'
return
endif
if keyword_set(all_sites_in_one) then begin
nsnames = 1
endif
files_ptrarr = ptrarr(nsnames, nfts, nlvls)
for k = 0, nlvls-1 do $
for j = 0, nfts-1 do $
for i = 0, nsnames-1 do begin
snamei = snames[i]
ftj = fts[j]
lvlk = lvls[k]
if keyword_set(relpath_funct) then begin
relpathnames = call_function(relpath_funct, sname = snamei, $
filetype = ftj, level = lvlk, $
version = version, trange = trange, $
addmaster = addmaster, _extra = _extra)
endif else begin
if strcmp(strlowcase(type_sname), 'probe') then begin
relpath = 'th'+snamei+'/'+lvlk+'/'+ ftj+'/'
prefix = 'th'+snamei+'_'+lvlk+'_'+ftj+'_'
dir = 'YYYY/'
endif else if strcmp(strlowcase(type_sname), 'site') then begin
relpath = 'thg/'+lvlk+'/'+ftj+'/'+snamei + '/'
prefix = 'thg_'+lvlk+'_'+ftj+'_'+snamei + '_'
dir = 'YYYY/'
endif
If(version Eq '') Then Begin
ending = '.cdf'
Endif Else ending = '_'+version+'.cdf'
relpathnames = file_dailynames(relpath, prefix, ending, dir = dir, $
trange = trange, addmaster = addmaster)
endelse
my_themis.no_download = 1
files_ptrarr[i, j, k] = $
ptr_new(file_retrieve(relpathnames, _extra = my_themis))
if i+j+k eq 0 then relpathnames_all = relpathnames else $
relpathnames_all = [relpathnames_all, relpathnames]
if vb ge 7 then dprint, 'files', *files_ptrarr[i, j, k]
endfor
if ~load_params.no_download && ~keyword_set(no_download) then begin
if vb ge 7 then dprint, 'relpathnames', relpathnames_all
my_themis.no_download = 0
files = file_retrieve(relpathnames_all, _extra = my_themis)
endif
if keyword_set(downloadonly) then begin
ptr_free, files_ptrarr
return
endif
for k = 0, nlvls-1 do $
for j = 0, nfts-1 do $
for i = 0, nsnames-1 do begin
if keyword_set(all_sites_in_one) then begin
snamei = snames
endif else snamei = snames[i]
ftj = fts[j]
fdtj = fdts[j]
lvlk = lvls[k]
files = file_search(*files_ptrarr[i, j, k], count = filecount)
If(filecount Eq 0) Then Begin
dprint, 'Files Not Found:'
If(ptr_valid(files_ptrarr[i, j, k])) Then Begin
dprint, *files_ptrarr[i, j, k]
Endif Else dprint, 'Invalid files pointer'
Continue
Endif
star = keyword_set(get_support_data) ? '*' : ''
if keyword_set(no_implicit_wildcard) then begin
star = ''
endif
fdtj_arr = strsplit(fdtj, ' ', /extract)
if n_elements(fdtj_arr) eq 1 then fdtj_arr = fdtj_arr[0]
if keyword_set(varformat) then begin
varformatj = varformat
endif else if strcmp(strlowcase(type_sname), 'probe') then begin
varformatj = strjoin('*'+fdtj_arr+star, ' ')
endif else begin
varformatj = strjoin('*'+fdtj_arr+'_'+snamei+star, ' ')
endelse
if vb ge 6 then printdat, varformatj
if get_cdf_data then begin
if not keyword_set(varformat) then varformat = varformatj
cdf_data = cdf_load_vars(*files_ptrarr[0, 0, 0], varnames = varnames, $
verbose = vb, /all, varformat = varformat)
ptr_free, files_ptrarr
return
endif
if keyword_set(cdf_to_tplot) then begin
call_procedure, cdf_to_tplot, file = files, $
all = all, verbose = vb, tplotnames = tplotnames, $
varformat = varformatj, midfix = midfix, midpos = 4, $
suffix = suffix, varnames = varnames, _extra = _extra
endif else begin
if keyword_set(verbose) then dprint, transpose(['Loading...', files])
cdf2tplot, file = files, all = all, verbose = vb, $
tplotnames = tplotnames, suffix = suffix, $
midfix = midfix, midpos = 4, varformat = varformatj
endelse
tn_pre_proc = tnames()
If (keyword_set(trange) && n_elements(trange) Eq 2) $
Then tr = timerange(trange) $
else tr = timerange()
If(is_string(tplotnames)) Then Begin
for ivar = 0, n_elements(tplotnames)-1 do begin
if tnames(tplotnames[ivar]) eq '' then continue
if strmid(tplotnames[ivar], 16, 17, /reverse_offset) eq '_thm_cal_efi_priv' then continue
if strmid(tplotnames[ivar], 10, 11, /reverse_offset) eq '_state_temp' then continue
if strmid(tplotnames[ivar], 3, 3) eq '_sc' then continue
if ~keyword_set(no_time_clip) then begin
time_clip, tplotnames[ivar], min(tr), max(tr), /replace, error = tr_err
if tr_err then del_data, tplotnames[ivar]
endif
endfor
tn_post_clip = tnames()
if n_elements(tn_pre_proc) eq 1 then tn_pre_proc = [tn_pre_proc]
if n_elements(tn_post_clip) eq 1 then tn_post_clip = [tn_post_clip]
if n_elements(tplotnames) eq 1 then tplotnames = [tplotnames]
tn_for_cal = ssl_set_intersection(tplotnames, tn_post_clip)
if keyword_set(post_process_proc) then begin
if keyword_set(scm_cal) then Begin
call_procedure, post_process_proc, sname = snamei, filetype = ftj, $
datatype = fdtj, suffix = suffix, coord = coord, $
level = lvlk, verbose = vb, tplotnames = tplotnames, $
progobj = progobj, proc_type = type, trange = trange, $
scm_cal = scm_cal, get_support_data = get_support_data, $
use_eclipse_corrections = use_eclipse_corrections, _extra = _extra
endif else Begin
if ~array_equal(tn_for_cal, -1L,/no_type) then $
call_procedure, post_process_proc, sname = snamei, filetype = ftj, $
datatype = fdtj, suffix = suffix, coord = coord, $
level = lvlk, verbose = vb, tplotnames = tn_for_cal, $
progobj = progobj, files = files, proc_type = type, $
get_support_data = get_support_data, trange = trange, $
use_eclipse_corrections = use_eclipse_corrections, _extra = _extra
endelse
endif
tn_post_proc = tnames()
if n_elements(tn_post_proc) eq 1 then tn_post_proc = [tn_post_proc]
post_proc_names = ssl_set_complement(tn_pre_proc, tn_post_proc)
if size(post_proc_names, /type) eq 7 then tplotnames = [tplotnames, post_proc_names]
for ivar = 0, n_elements(tplotnames)-1 do begin
if tnames(tplotnames[ivar]) eq '' then continue
if strmid(tplotnames[ivar], 16, 17, /reverse_offset) eq '_thm_cal_efi_priv' then continue
if strmid(tplotnames[ivar], 10, 11, /reverse_offset) eq '_state_temp' then continue
if ~keyword_set(no_time_clip) then begin
time_clip, tplotnames[ivar], min(tr), max(tr), /replace, error = tr_err
if tr_err then del_data, tplotnames[ivar]
endif
endfor
Endif
endfor
ptr_free, files_ptrarr
end