pro goes_load_data, trange = trange, datatype = datatype, probes = probes, suffix = suffix, $
downloadonly = downloadonly, avg_1m = avg_1m, avg_5m = avg_5m, no_time_clip = no_time_clip, $
tplotnames = tplotnames, varformat = varformat, get_support_data = get_support_data, noephem = noephem
compile_opt idl2
goes_init
if undefined(suffix) then suffix = ''
catch, errstats
if errstats ne 0 then begin
dprint, dlevel=1, 'Error: ', !ERROR_STATE.MSG
catch, /cancel
return
endif
if not keyword_set(datatype) then datatype = 'fgm'
if not keyword_set(probes) then probes = ['13', '14', '15']
if not keyword_set(source) then source = !goes
if (keyword_set(trange) && n_elements(trange) eq 2) $
then tr = timerange(trange) $
else tr = timerange()
tn_list_before = tnames('*')
for idx_probes=0,n_elements(probes)-1 do begin
sc = 'g'+string(probes[idx_probes], format='(I02)')
prefix = sc + '_'
dprint,dlevel=2,verbose=source.verbose,'Loading GOES-',probes[idx_probes],' ',strupcase(datatype),' data'
fullavgpath = ['new_full', 'new_avg']
goes_path_dir = fullavgpath[~undefined(avg_1m) or ~undefined(avg_5m)]
remote_path = goes_path_dir + '/YYYY/MM/goes' + string(probes[idx_probes], format='(I02)') + '/netcdf/'
case datatype of
'fgm': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = remote_path + sc + '_magneto_512ms_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = remote_path + sc + '_magneto_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = remote_path + sc + '_magneto_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'eps': begin
if ~undefined(avg_1m) then begin
pathformat = remote_path + sc + '_eps_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = remote_path + sc + '_eps_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'epead': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = strarr(8)
pathformat[0] = remote_path + sc + '_epead_e1ew_4s_YYYYMMDD_YYYYMMDD.nc'
pathformat[1] = remote_path + sc + '_epead_e2ew_16s_YYYYMMDD_YYYYMMDD.nc'
pathformat[2] = remote_path + sc + '_epead_e3ew_16s_YYYYMMDD_YYYYMMDD.nc'
pathformat[3] = remote_path + sc + '_epead_p1ew_8s_YYYYMMDD_YYYYMMDD.nc'
pathformat[4] = remote_path + sc + '_epead_p27e_32s_YYYYMMDD_YYYYMMDD.nc'
pathformat[5] = remote_path + sc + '_epead_p27w_32s_YYYYMMDD_YYYYMMDD.nc'
pathformat[6] = remote_path + sc + '_epead_a16e_32s_YYYYMMDD_YYYYMMDD.nc'
pathformat[7] = remote_path + sc + '_epead_a16w_32s_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = strarr(3)
pathformat[0] = remote_path + sc + '_epead_e13ew_1m_YYYYMM01_YYYYMM??.nc'
pathformat[1] = remote_path + sc + '_epead_p17ew_1m_YYYYMM01_YYYYMM??.nc'
pathformat[2] = remote_path + sc + '_epead_a16ew_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = strarr(3)
pathformat[0] = remote_path + sc + '_epead_e13ew_5m_YYYYMM01_YYYYMM??.nc'
pathformat[1] = remote_path + sc + '_epead_p17ew_5m_YYYYMM01_YYYYMM??.nc'
pathformat[2] = remote_path + sc + '_epead_a16ew_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'maged': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = strarr(5)
channels = ['me1','me2','me3','me4','me5']
resolution = ['2','2','4','16','32']
for i = 0, n_elements(channels)-1 do pathformat[i] = $
remote_path + sc + '_maged_19'+channels[i]+'_'+resolution[i]+'s_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = remote_path + sc + '_maged_19me15_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = remote_path + sc + '_maged_19me15_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'magpd': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = strarr(5)
channels = ['mp1','mp2','mp3','mp4','mp5']
resolution = ['16','16','16','32','32']
for i = 0, n_elements(channels)-1 do pathformat[i] = $
remote_path + sc + '_magpd_19'+channels[i]+'_'+resolution[i]+'s_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = remote_path + sc + '_magpd_19mp15_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = remote_path + sc + '_magpd_19mp15_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'hepad': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = strarr(2)
pathformat[0] = remote_path + sc + '_hepad_ap_32s_YYYYMMDD_YYYYMMDD.nc'
pathformat[1] = remote_path + sc + '_hepad_s15_4s_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = strarr(2)
pathformat[0] = remote_path + sc + '_hepad_ap_1m_YYYYMM01_YYYYMM??.nc'
pathformat[1] = remote_path + sc + '_hepad_s15_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = strarr(2)
pathformat[0] = remote_path + sc + '_hepad_ap_5m_YYYYMM01_YYYYMM??.nc'
pathformat[1] = remote_path + sc + '_hepad_s15_5m_YYYYMM01_YYYYMM??.nc'
endif
end
'xrs': begin
if undefined(avg_1m) && undefined(avg_5m) then begin
pathformat = remote_path + sc + '_xrs_2s_YYYYMMDD_YYYYMMDD.nc'
endif else if ~undefined(avg_1m) then begin
pathformat = remote_path + sc + '_xrs_1m_YYYYMM01_YYYYMM??.nc'
endif else if ~undefined(avg_5m) then begin
pathformat = remote_path + sc + '_xrs_5m_YYYYMM01_YYYYMM??.nc'
endif
end
else: pathformat = ''
endcase
if not keyword_set(pathformat) then begin
dprint,'No data found. Try a different probe.'
return
endif
for j = 0, n_elements(pathformat)-1 do begin
relpathnames = file_dailynames(file_format=pathformat[j],trange=tr,addmaster=addmaster, /unique)
files = file_retrieve(relpathnames, _extra=source, /last_version)
if keyword_set(downloadonly) then continue
netcdf2tplot, files, prefix = prefix, suffix = suffix
endfor
tn_list_after = tnames('*')
new_tnames = ssl_set_complement([tn_list_before], [tn_list_after])
if undefined(noephem) && new_tnames[0] ne -1 then begin
ephem = goes_load_pos(trange = time_string(tr), probe = probes[idx_probes])
if is_struct(ephem) then begin
data_att = {project: 'GOES', observatory: (strsplit(prefix,'_', /extra))[0], $
instrument: 'ephem', units: 'km', coord_sys: 'gei', st_type: 'pos'}
dlimits = {data_att: data_att, colors: [2,4,6], labels: ['x','y','z']+'_gei', ysubtitle: '[km]'}
store_data, prefix + 'pos_gei' + suffix, data={x: ephem.time, y: ephem.pos_values}, dlimits=dlimits
endif else begin
dprint, dlevel=1, 'Error loading ephemeris data. No data returned from goes_load_pos()'
endelse
endif
if new_tnames[0] ne -1 then begin
goes_combine_tdata, datatype = datatype, probe = probes[idx_probes], prefix = prefix, suffix = suffix, $
get_support_data = get_support_data, tplotnames = tplotnames, noephem = noephem
endif
endfor
if ~undefined(tr) && ~undefined(tplotnames) then begin
if (n_elements(tr) eq 2) and (tplotnames[0] ne '') then begin
time_clip, tplotnames, tr[0], tr[1], replace=1, error=error
endif
endif
end