pro ace_mag_swepam_load, datatype=datatype, trange=trange, downloadonly=downloadonly, $
addmaster=addmaster, verbose=verbose, tplotnames=tn, source_options=source
ace_init
if not keyword_set(source) then source = !ace
if not keyword_set(datatype) then datatype = 'all'
if keyword_set(datatype) then Begin
if datatype ne 'mag' and datatype ne 'swepam' and datatype ne 'all' then Begin
print, 'Incorrect datatype specified.'
print, "Valid datatypes for ACE ascii data include: ('mag', 'swepam', 'all')"
if obj_valid(progobj) then progobj -> update, 0.0, $
text = string("Incorrect datatype specified - valid datatypes are ('mag', 'swepam', 'all')")
return
endif
endif
datatype = strlowcase(datatype)
if not keyword_set(trange) then trange = timerange(/current)
if datatype ne 'all' then Begin
pathformat = 'ace/'+datatype+'/k0/YYYY/YYYYMMDD_ace_'+datatype+'_1m.txt'
relpathnames = file_dailynames(file_format=pathformat,trange=trange,addmaster=addmaster)
endif else Begin
pathformat = 'ace/mag/k0/YYYY/YYYYMMDD_ace_mag_1m.txt'
magpathnames = file_dailynames(file_format=pathformat,trange=trange,addmaster=addmaster)
pathformat = 'ace/swepam/k0/YYYY/YYYYMMDD_ace_swepam_1m.txt'
swepathnames = file_dailynames(file_format=pathformat,trange=trange,addmaster=addmaster)
relpathnames = [magpathnames, swepathnames]
endelse
files = file_retrieve(relpathnames, local_data_dir=!ace.local_data_dir, $
remote_data_dir=!ace.remote_data_dir)
if keyword_set(downloadonly) then return
n_files=n_elements(files)
for i=0, n_files-1 do Begin
if file_test(files(i)) eq 0 then Begin
dprint,dlevel=1, verbose=verbose, string('ACE file not found: '+files(i))
if obj_valid(progobj) then progobj -> update, 0.0, $
text = string('ACE file not found: '+files(i))
print, 'ACE file not found: '+files(i)
endif else Begin
print, 'ACE file '+files(i)+' retrieved.'
if obj_valid(progobj) then progobj -> update, 0.0, $
text = string('ACE file '+files(i)+' retrieved.')
if (strpos(files(i), 'mag') ne -1) then Begin
filetype='mag'
data_start=20
endif else Begin
filetype='swepam'
data_start=18
endelse
data=read_ascii(files(i), data_start=data_start)
print, 'Loading ACE file '+files(i)
if obj_valid(progobj) then progobj -> update, 0.0, $
text = string('Loading ACE file '+files(i))
ace2tplot, data, filetype
endelse
endfor
print, 'Done loading ACE files.'
if obj_valid(progobj) then progobj -> update, 0.0, $
text = string('Done loading ACE files.')
end