pro thm_pgs_tplot_rename,in_names,probe,datatype,units,suffix,an_tnames=an_tnames,en_tnames=en_tnames
compile_opt idl2,hidden
prefix = 'th'+probe+'_'+datatype+'_'
new_name = prefix+strlowcase(units)+'_energy'+suffix
idx = where(strmatch(in_names,new_name,/fold_case),c)
if c ge 1 then begin
old_name = prefix+'en_'+strlowcase(units)+suffix
tplot_rename,new_name,old_name
en_tnames = array_concat(old_name,en_tnames)
endif
new_name = prefix+strlowcase(units)+'_phi'+suffix
idx = where(strmatch(in_names,prefix+strlowcase(units)+'_phi'+suffix,/fold_case),c)
if c ge 1 then begin
old_name=prefix+'an_'+strlowcase(units)+'_phi'+suffix
tplot_rename,new_name,old_name
an_tnames = array_concat(old_name,an_tnames)
endif
new_name = prefix+strlowcase(units)+'_theta'+suffix
idx = where(strmatch(in_names,prefix+strlowcase(units)+'_theta'+suffix,/fold_case),c)
if c ge 1 then begin
old_name = prefix+'an_'+strlowcase(units)+'_theta'+suffix
tplot_rename,new_name,old_name
an_tnames = array_concat(old_name,an_tnames)
endif
new_name = prefix+strlowcase(units)+'_pa'+suffix
idx = where(strmatch(in_names,prefix+strlowcase(units)+'_pa'+suffix,/fold_case),c)
if c ge 1 then begin
old_name = prefix+'an_'+strlowcase(units)+'_pa'+suffix
tplot_rename,new_name,old_name
an_tnames = array_concat(old_name,an_tnames)
endif
new_name = prefix+strlowcase(units)+'_gyro'+suffix
idx = where(strmatch(in_names,prefix+strlowcase(units)+'_gyro'+suffix,/fold_case),c)
if c ge 1 then begin
old_name = prefix+'an_'+strlowcase(units)+'_gyro'+suffix
tplot_rename,new_name,old_name
an_tnames = array_concat(old_name,an_tnames)
endif
end
pro thm_part_getspec,$
probes=probes,$
instrument_types=instruments,$
data_type=data_type,$
datatypes=datatypes,$
trange=trange,$
erange=erange,$
energy=energy,$
phi=phi_in,$
theta=theta,$
pitch=pitch,$
gyro=gyro_in,$
angle=angle,$
start_angle=start_angle, $
outputs=outputs,$
units=units,$
regrid=regrid, $
suffix=suffix, $
datagap=datagap, $
get_error=get_error, $
gui_statusBar=gui_statusBar, $
gui_historyWin=gui_historyWin, $
other_dim=other_dim,$
method_clean=method_clean,$
sun_bins=sun_bins,$
dist_array=dist_array, $
error=error,$
en_tnames=en_tnames,$
an_tnames=an_tnames,$
normalize=normalize,$
bins2mask=bins2mask,$
badbins2mask=badbins2mask,$
enoise_bins=enoise_bins,$
autoplot=autoplot, $ --automatically plot data(otherwise just produces output variables)
sst_cal=sst_cal,$
get_support_data=get_support_data,$
forceload=forceload, $ --force data load(otherwise will try to use previously loaded data), (not implemented in new wrapper)
mag_suffix=mag_suffix,$
_extra=ex
compile_opt idl2
twin = systime(/sec)
error=1
dprint,dlevel=0,"WARNING: This routine is now a wrapper. For new code, we recommend using the core routine thm_part_products.pro, see thm_crib_part_products.pro for examples."
if keyword_set(normalize) then begin
message,'ERROR: Keyword normalize is fully deprecated.'
endif
if keyword_set(bins2mask) then begin
message,'ERROR: Keyword bins2mask is fully deprecated. Use sun_bins for sst sun decontamination, and dist_array otherwise'
endif
if keyword_set(badbins2mask) then begin
message,'ERROR: Keyword badbins2mask is fully deprecated. Use sun_bins for sst sun decontamination, and dist_array otherwise'
endif
if keyword_set(enoise_bins) then begin
message,'ERROR: enoise_bins is fully deprecated. Use sun_bins for sst sun decontamination'
endif
if keyword_set(autoplot) then begin
message,'ERROR: Keyword autoplot is fully deprecated. Use an_tnames keyword & tplot to display data products'
endif
if keyword_set(method_clean) then begin
if strlowcase(method_clean) eq 'automatic' then begin
dprint,dlevel=1,'Automatic SST decontamination method no longer supported, Defaulting to manual with good default.'
endif
sst_method_clean='manual'
endif
if keyword_set(sun_bins) then begin
sst_sun_bins = where(~sun_bins)
endif
if ~keyword_set(suffix) then begin
suffix = ''
endif
valid_probes = ['a','b','c','d','e']
if is_string(probes) then begin
probes_lc = strfilter(valid_probes, probes, /fold_case, delimiter=' ')
probes_lc = strlowcase(probes_lc)
if probes_lc[0] eq '' then begin
dprint, dlevel=1, 'Input did not contain a valid probe designation.'
return
endif
endif else begin
dprint, dlevel=1, 'Input did not contain a valid probe designation.'
return
endelse
valid_datatypes = ['peif','peef','psif','psef','peir','peer', $
'psir','pser','peib','peeb','pseb']
if is_string(data_type) then datatypes = data_type
if is_string(instruments) then datatypes = instruments
if is_string(datatypes) then begin
datatypes_lc = strfilter(valid_datatypes, datatypes, /fold_case, delimiter=' ')
datatypes_lc = strlowcase(datatypes_lc)
if datatypes_lc[0] eq '' then begin
dprint, dlevel=1, 'Input did not include a valid data type.'
return
endif
endif else begin
dprint, dlevel=1, 'Input did not include a valid data type.'
return
endelse
if keyword_set(theta) then begin
if n_elements(theta) lt 2 then begin
dprint,'Error, theta keyword should have 2 elements.',dlevel=1
return
endif
if theta[1] lt theta[0] then begin
dprint,'Error: theta keyword max less than theta min',dlevel=1
return
endif
if theta[0] lt -90 || theta[1] gt 90 then begin
dprint,'Error: theta must be between -90 & 90',dlevel=1
return
endif
endif
if keyword_set(phi_in) then begin
if n_elements(phi_in) lt 2 then begin
dprint,'Error: phi keyword should have 2 elements.',dlevel=1
return
endif
if max(phi_in) - min(phi_in) gt 360. then begin
phi = [0,360]
if undefined(start_angle) then start_angle = min(phi_in)
endif else begin
phi = phi_in
endelse
endif
if keyword_set(pitch) then begin
if n_elements(pitch) lt 2 then begin
dprint,'Error, pitch keyword should have 2 elements.',dlevel=1
return
endif
if pitch[1] lt pitch[0] then begin
dprint,'Error: pitch keyword max less than pitch min',dlevel=1
return
endif
if pitch[0] lt 0 || pitch[1] gt 180 then begin
dprint,'Error: pitch must be between 0 & 180',dlevel=1
return
endif
endif
if keyword_set(gyro) then begin
if n_elements(gyro) lt 2 then begin
dprint,'Error: gyro keyword should have 2 elements.',dlevel=1
return
if max(gyro_in) - min(gyro_in) gt 360. then begin
gyro = [0,360]
if undefined(start_angle) then start_angle = min(gyro_in)
endif else begin
gyro = gyro_in
endelse
endif
endif
if ~keyword_set(trange) then begin
trange = timerange()
endif
if keyword_set(energy) then begin
outputs = array_concat('energy',outputs)
endif
if keyword_set(angle) then begin
outputs = array_concat(strsplit(angle,' ',/extract),outputs)
endif else if ~keyword_set(angle) then begin
outputs = array_concat('phi',outputs)
endif
if ~keyword_set(units) then begin
units_lc = 'eflux'
endif else begin
units_lc = strlowcase(units)
endelse
undefine,an_tnames
undefine,en_tnames
undefine,out_names
if keyword_set(dist_array) then begin
if n_elements(probes_lc) gt 1 then begin
message,'Error: dist_array keyword cannot be used with multiple probes
endif
if n_elements(datatypes_lc) gt 1 then begin
message,'Error: dist_array keyword cannot be used with multiple datatypes
endif
thm_part_products,probe=probes_lc[0],datatype=datatypes_lc[0],trange=trange,$
energy=erange,phi=phi,theta=theta,gyro=gyro,pitch=pitch,$
outputs=outputs,units=units_lc,regrid=regrid,suffix=suffix,$
datagap=datagap,get_error=get_error,gui_statusbar=gui_statusbar,$
gui_historywin=gui_historywin,fac_type=fac_type,$
mag_name='th'+probes_lc[0]+'_fgs',$
sst_sun_bins=sst_sun_bins,sst_method_clean=sst_method_clean,$
dist_array=dist_array,$
error=error_dev,$
start_angle=start_angle,$
tplotnames=tplotnames,$
sst_cal=sst_cal
if (error_dev) then begin
return
endif
thm_pgs_expand_yaxis, tplotnames
thm_pgs_tplot_rename,tplotnames,probes_lc[0],datatypes_lc[0],units_lc,suffix,an_tnames=an_tnames,en_tnames=en_tnames
endif else begin
for i = 0,n_elements(probes_lc)-1 do begin
for j = 0,n_elements(datatypes_lc)-1 do begin
thm_load_state, probe = probes_lc[i], trange = trange, /get_support_data
thm_load_fit, probe=probes_lc[i], trange=trange, datatype='fgs', level='l1', $
coord='dsl', /get_support_data
thm_part_load,probe=probes_lc[i],datatype=datatypes_lc[j],trange=trange,sst_cal=sst_cal,_extra=ex
thm_part_products,probe=probes_lc[i],datatype=datatypes_lc[j],trange=trange,$
energy=erange,phi=phi,theta=theta,gyro=gyro,pitch=pitch,$
outputs=outputs,units=units_lc,regrid=regrid,suffix=suffix,$
datagap=datagap,get_error=get_error,gui_statusbar=gui_statusbar,$
gui_historywin=gui_historywin,fac_type=fac_type,$
sst_sun_bins=sst_sun_bins,sst_method_clean=sst_method_clean,$
mag_name='th'+probes_lc[i]+'_fgs',$
dist_array=dist_array,$
error=error_dev,$
start_angle=start_angle,$
tplotnames=tplotnames,$
sst_cal=sst_cal,$
_extra=ex
if (error_dev) then begin
return
endif
thm_pgs_expand_yaxis, tplotnames
thm_pgs_tplot_rename,tplotnames,probes_lc[i],datatypes_lc[j],units_lc,suffix,an_tnames=an_tnames,en_tnames=en_tnames
endfor
endfor
endelse
dprint,'Runtime: ',systime(/sec) - twin,' secs'
error=0
end