pro goes_pitch_angles, H_values, Htotal, prefix = prefix, suffix = suffix
compile_opt idl2
if undefined(prefix) then prefix = ''
if undefined(suffix) then suffix = ''
s35 = sin(35.0d0*!dtor)
c35 = cos(35.0d0*!dtor)
s70 = sin(70.0d0*!dtor)
c70 = cos(70.0d0*!dtor)
get_data, H_values, data=Hdata
get_data, Htotal, data=Htstruct
if ~is_struct(Hdata) || ~is_struct(Htstruct) then begin
dprint, dlevel = 1, 'Error calculating pitch angles, possibly due to invalid tplot variables.'
return
endif
Ht = Htstruct.Y[*]
He = Hdata.Y[*,0]
Hp = Hdata.Y[*,1]
Hn = Hdata.Y[*,2]
pitch_angles = fltarr(n_elements(Hn), 9)
pitch_angles[*,0] = acos(He/Ht)*!radeg
pitch_angles[*,1] = acos(( s35*Hn + c35*He)/Ht)*!radeg
pitch_angles[*,2] = acos((-s70*Hn + c70*He)/Ht)*!radeg
pitch_angles[*,3] = acos((-s35*Hn + c35*He)/Ht)*!radeg
pitch_angles[*,4] = acos(( s70*Hn + c70*He)/Ht)*!radeg
pitch_angles[*,5] = acos((-s35*Hp + c35*He)/Ht)*!radeg
pitch_angles[*,6] = acos(( s70*Hp + c70*He)/Ht)*!radeg
pitch_angles[*,7] = acos(( s35*Hp + c35*He)/Ht)*!radeg
pitch_angles[*,8] = acos((-s70*Hp + c70*He)/Ht)*!radeg
store_data, prefix + '_pitch_angles', data={x:Hdata.X, y:pitch_angles}
end
pro goes_remove_ifcs, b_sc, Htotal, btsc_num_pts, ht_num_pts
compile_opt idl2
get_data, b_sc, data=b_sc_data, dlimits=b_sc_dlimits
get_data, Htotal, data=Htotal_data, dlimits=Htotal_dlimits
if (~is_struct(b_sc_data) || ~is_struct(b_sc_dlimits) $
|| ~is_struct(Htotal_data) || ~is_struct(Htotal_dlimits)) then begin
dprint, dlevel = 1, 'Error removing IFCs, possibly due to invalid tplot variables.'
return
endif
Ht_fillvalue = Htotal_dlimits.cdf.vatt.fillval
ht_ifc = where(Htotal_data.Y eq Ht_fillvalue, htifc_count)
if htifc_count gt 0 then begin
newbscvar = b_sc_data.Y
newbscvar[ht_ifc,0] = Ht_fillvalue
newbscvar[ht_ifc,1] = Ht_fillvalue
newbscvar[ht_ifc,2] = Ht_fillvalue
endif
npdiff = where(btsc_num_pts ne ht_num_pts, numptscount)
if numptscount gt 0 then begin
if undefined(newbscvar) then begin
newbscvar = b_sc_data.Y
newhtvar = Htotal_data.Y
endif
newbscvar[npdiff,0] = Ht_fillvalue
newbscvar[npdiff,1] = Ht_fillvalue
newbscvar[npdiff,2] = Ht_fillvalue
newhtvar[npdiff] = Ht_fillvalue
endif
htspike = where(Htotal_data.Y gt 512.0, spikecount)
if spikecount gt 0 then begin
if undefined(newbscvar) then begin
newbscvar = b_sc_data.Y
newhtvar = Htotal_data.Y
endif
newbscvar[npdiff,0] = Ht_fillvalue
newbscvar[npdiff,1] = Ht_fillvalue
newbscvar[npdiff,2] = Ht_fillvalue
newhtvar[npdiff] = Ht_fillvalue
endif
if ~undefined(newbscvar) then store_data, b_sc + '_ifcs_removed', data = {x: b_sc_data.X, y: newbscvar}, dlimits = b_sc_dlimits
if ~undefined(newhtvar) then store_data, Htotal + '_ifcs_removed', data = {x: Htotal_data.X, y: newhtvar}, dlimits = Htotal_dlimits
end
pro goes_ht_quadrature, b_sc
compile_opt idl2
get_data, b_sc, data=b_sc_data, dlimits=b_sc_dlimits
if ~is_struct(b_sc_data) || ~is_struct(b_sc_dlimits) then begin
dprint, dlevel = 1, 'Error calculating total field from the quadrature sum of the components, possibly due to invalid tplot variables.'
return
endif
bscfillvalue = b_sc_dlimits.cdf.vatt.fillval
bscfill = where(b_sc_data.Y[*,0] eq bscfillvalue or b_sc_data.Y[*,1] eq bscfillvalue or b_sc_data.Y[*,2] eq bscfillvalue, fillcount)
htcorr = sqrt((b_sc_data.Y[*,0])^2+(b_sc_data.Y[*,1])^2+(b_sc_data.Y[*,2])^2)
if fillcount gt 0 then htcorr[bscfill] = bscfillvalue
store_data, 'ht_corr_quad', data = {x: b_sc_data.X, y: htcorr}, dlimits = b_sc_dlimits
end
pro goes_epead_center_pitch_angles, Bsc, Bt
compile_opt idl2
get_data, Bsc, data = bsc_data, dlimits = bsc_dlimits
get_data, Bt, data = bt_data, dlimits = bt_dlimits
if (~is_struct(bsc_data) || ~is_struct(bsc_dlimits) || ~is_struct(bt_data) || ~is_struct(bt_dlimits)) then begin
dprint, dlevel = 1, 'Error calculating EPEAD center pitch angles, possibly due to invalid tplot variables.'
return
endif
bscfillvalue = bsc_dlimits.cdf.vatt.fillval
w_pitch_angle = acos(bsc_data.Y[*,0]/bt_data.Y)*!radeg
e_pitch_angle = acos(-bsc_data.Y[*,0]/bt_data.Y)*!radeg
bscfill = where(bsc_data.Y[*,0] eq bscfillvalue or bt_data.Y eq bscfillvalue, fillcount)
if fillcount gt 0 then begin
w_pitch_angle[bscfill] = bscfillvalue
e_pitch_angle[bscfill] = bscfillvalue
endif
newpad = fltarr(n_elements(w_pitch_angle), 2)
newpad[*,0] = e_pitch_angle
newpad[*,1] = w_pitch_angle
labels = ['E pitch angles', 'W pitch angles']
str_element, bsc_dlimits, 'labels', labels, /add
store_data, 'goes_epead_center_pitch_angles', data = {x:bsc_data.X, y:newpad}, dlimits = bsc_dlimits
end
pro goes_epead_contam_cor, e_uncor, p_uncor
compile_opt idl2
e1coeff = [0.07, 1.40, 3.90, 30.0]
e2coeff = [0.30, 9.00, 18.0, 96.0]
e1g = 0.75
e2g = 0.05
mincr = 6.67e-3
mine1flux = mincr/e1g
mine2flux = mincr/e2g
for e_uncor_idx = 0, n_elements(e_uncor)-1 do begin
e_uncor_tname = e_uncor[e_uncor_idx]
if e_uncor_idx eq 0 then begin
get_data, e_uncor_tname, data=e_uncor_data, dlimits = e_uncor_dlimits
if ~is_struct(e_uncor_data) || ~is_struct(e_uncor_dlimits) then begin
dprint, dlevel = 1, 'Error calculating EPEAD contamination corrections, possibly due to invalid tplot variables.'
return
endif
newe_uncor_data = fltarr(e_uncor_data.Y, 2)
newe_uncor_data[*,0] = e_uncor_data.Y
e_fillvalue = e_uncor_dlimits.cdf.vatt.fillval
endif else begin
get_data, e_uncor_tname, data=e_uncor_data, dlimits = e_uncor_dlimits
if ~is_struct(e_uncor_data) || ~is_struct(e_uncor_dlimits) then begin
dprint, dlevel = 1, 'Error calculating EPEAD contamination corrections, possibly due to invalid tplot variables.'
return
endif
newe_uncor_data[*,1] = e_uncor_data.Y
endelse
endfor
for p_uncor_idx = 0, n_elements(p_uncor)-1 do begin
p_uncor_tname = p_uncor[p_uncor_idx]
if p_uncor_idx eq 0 then begin
get_data, p_uncor_tname, data = p_uncor_data, dlimits = p_uncor_dlimits
if ~is_struct(p_uncor_data) || ~is_struct(p_uncor_dlimits) then begin
dprint, dlevel = 1, 'Error calculating EPEAD contamination corrections, possibly due to invalid tplot variables.'
return
endif
newp_uncor_data = fltarr(p_uncor_data.Y,4)
newp_uncor_data[*,0] = p_uncor_data.Y
p_fillvalue = p_uncor_dlimits.cdf.vatt.fillval
endif else begin
get_data, p_uncor_tname, data = p_uncor_data, dlimits = p_uncor_dlimits
if ~is_struct(p_uncor_data) || ~is_struct(p_uncor_dlimits) then begin
dprint, dlevel = 1, 'Error calculating EPEAD contamination corrections, possibly due to invalid tplot variables.'
return
endif
newp_uncor_data[*,p_uncor_idx] = p_uncor_data.Y
endelse
endfor
e1_fill = where(newe_uncor_data[*,0] eq e_fillvalue or newp_uncor_data[*,0] eq p_fillvalue or newp_uncor_data[*,1] $
eq p_fillvalue or newp_uncor_data[*,2] eq p_fillvalue or newp_uncor_data[*,3] eq p_fillvalue, e1fillcount)
e2_fill = where(newe_uncor_data[*,1] eq e_fillvalue or newp_uncor_data[*,0] eq p_fillvalue or newp_uncor_data[*,1] $
eq p_fillvalue or newp_uncor_data[*,2] eq p_fillvalue or newp_uncor_data[*,3] eq p_fillvalue, e2fillcount)
de1 = (e1coeff[0]*newp_uncor_data[*,0] + e1coeff[1]*newp_uncor_data[*,1] + e1coeff[2]*newp_uncor_data[*,2] + $
e1coeff[3]*newp_uncor_data[*,3])/e1g
de2 = (e2coeff[0]*newp_uncor_data[*,0] + e2coeff[1]*newp_uncor_data[*,1] + e2coeff[2]*newp_uncor_data[*,2] + $
e2coeff[3]*newp_uncor_data[*,3])/e2g
e1_cor = newe_uncor_data[*,0] - de1
e2_cor = newe_uncor_data[*,1] - de2
e1low = where(e1_cor lt mine1flux, e1lowcount)
e2low = where(e2_cor lt mine2flux, e2lowcount)
if e1lowcount gt 0 then e1_cor[e1low] = mine1flux
if e2lowcount gt 0 then e2_cor[e2low] = mine2flux
if e1fillcount gt 0 then e1_cor[e1_fill] = e_fillvalue
if e2fillcount gt 0 then e2_cor[e2_fill] = e_fillvalue
store_data, 'e1_cor', data = e1_cor, dlimits = e_uncor_dlimits
store_data, 'e2_cor', data = e2_cor, dlimits = e_uncor_dlimits
end
pro goes_part_omni_flux, particle_tvar
get_data, particle_tvar, data=particle_data, dlimits=particle_dlimits
if ~is_struct(particle_data) || ~is_struct(particle_dlimits) then begin
dprint, dlevel = 1, 'Error calculating omni-directional flux, possibly due to an invalid tplot variable'
return
endif
frac_total_sa = 18.*!pi*(1-cos(15*!dtor))/(4*!pi)
omni_flux = total(particle_data.Y, 2, /double)/frac_total_sa
store_data, particle_tvar+'_omni', data={x: particle_data.X, y: omni_flux}, dlimits=particle_dlimits
end
pro goes_maged_omni_flux, prefix, suffix
energies = fltarr(5,2)
energies[0,0] = 30.
energies[0,1] = 50.
energies[1,0] = 50.
energies[1,1] = 100.
energies[2,0] = 100.
energies[2,1] = 200.
energies[3,0] = 200.
energies[3,1] = 350.
energies[4,0] = 350.
energies[4,1] = 600.
centered_energies = intarr(5)
tvar_names = strarr(5)
for i = 0, 4 do begin
centered_energies[i] = round((energies[i,1]-energies[i,0])/2.+energies[i,0])
maged_tvar = prefix + '_maged_'+strcompress(string(centered_energies[i]), /rem)+'keV_dtc_cor_flux'+suffix
goes_part_omni_flux, maged_tvar
tvar_names[i] = maged_tvar+'_omni'
endfor
join_vec, tvar_names, prefix + '_maged_dtc_cor_omni_flux'+suffix
options, /def, prefix + '_maged_dtc_cor_omni_flux'+suffix, 'ylog', 1
options, /def, prefix + '_maged_dtc_cor_omni_flux'+suffix, 'labflag', 1
options, /def, prefix + '_maged_dtc_cor_omni_flux'+suffix, 'labels', strcompress(string(centered_energies)+' keV', /rem)
options, /def, prefix + '_maged_dtc_cor_omni_flux'+suffix, 'ytitle', 'Electrons!C [e/(cm!U2!N-s-sr-keV)]'
options, /def, prefix + '_maged_dtc_cor_omni_flux'+suffix, 'ysubtitle', ''
end
pro goes_magpd_omni_flux, prefix, suffix
energies = fltarr(5,2)
energies[0,0] = 80.
energies[0,1] = 110.
energies[1,0] = 110.
energies[1,1] = 170.
energies[2,0] = 170.
energies[2,1] = 250.
energies[3,0] = 250.
energies[3,1] = 350.
energies[4,0] = 350.
energies[4,1] = 800.
centered_energies = intarr(5)
tvar_names = strarr(5)
for i = 0, 4 do begin
centered_energies[i] = round((energies[i,1]-energies[i,0])/2.+energies[i,0])
magpd_tvar = prefix + '_magpd_'+strcompress(string(centered_energies[i]), /rem)+'keV_dtc_cor_flux'+suffix
goes_part_omni_flux, magpd_tvar
tvar_names[i] = magpd_tvar+'_omni'
endfor
join_vec, tvar_names, prefix + '_magpd_dtc_cor_omni_flux'+suffix
options, /def, prefix + '_magpd_dtc_cor_omni_flux'+suffix, 'ylog', 1
options, /def, prefix + '_magpd_dtc_cor_omni_flux'+suffix, 'labels', strcompress(string(centered_energies)+' keV', /rem)
options, /def, prefix + '_magpd_dtc_cor_omni_flux'+suffix, 'labflag', 1
options, /def, prefix + '_magpd_dtc_cor_omni_flux'+suffix, 'ytitle', 'Protons!C [p/(cm!U2!N-s-sr-keV)]'
options, /def, prefix + '_magpd_dtc_cor_omni_flux'+suffix, 'ysubtitle', ''
end
pro goes_epead_comb_electron_flux, prefix, suffix
energies = strarr(3)
tvarnames = strarr(3)
energies[0] = '0.6'
energies[1] = '2'
energies[2] = '4'
for i = 0, 2 do begin
get_data, prefix+'_elec_'+energies[i]+'MeV_uncor_flux'+suffix, data=elec_data, dlimits=elec_dlimits
if (is_struct(elec_data) && is_struct(elec_dlimits)) then begin
total_values = (elec_data.Y[*,0]+elec_data.Y[*,1])/2.
store_data, prefix+'_elec_'+energies[i]+'MeV_uncor_flux_comb'+suffix, data={x: elec_data.X, y: total_values}, dlimits=elec_dlimits
tvarnames[i] = prefix+'_elec_'+energies[i]+'MeV_uncor_flux_comb'+suffix
endif else begin
dprint, dlevel = 1, 'Error combining EPEAD electron flux - no valid data?'
return
endelse
endfor
join_vec, tvarnames, prefix+'_elec_uncor_comb_flux'+suffix
options, /def, prefix+'_elec_uncor_comb_flux'+suffix, 'ylog', 1
options, /def, prefix+'_elec_uncor_comb_flux'+suffix, 'labflag', 1
options, /def, prefix+'_elec_uncor_comb_flux'+suffix, 'ytitle', 'Electrons!C [e/(cm!U2!N-s-sr)]'
options, /def, prefix+'_elec_uncor_comb_flux'+suffix, 'labels', energies+' MeV'
options, /def, prefix+'_elec_uncor_comb_flux'+suffix, 'ysubtitle', ''
end
pro goes_eps_comb_proton_flux, prefix, suffix
telescope_energies = strarr(3)
dome_energies = strarr(4)
telescope_energies[0] = '2.4'
telescope_energies[1] = '6.5'
telescope_energies[2] = '12'
dome_energies[0] = '27.5'
dome_energies[1] = '60'
dome_energies[2] = '122.5'
dome_energies[3] = '332.5'
join_vec, prefix+'_prot_'+telescope_energies+'MeV_flux'+suffix, prefix+'_eps_tele_protons'+suffix
join_vec, prefix+'_prot_'+dome_energies+'MeV_flux'+suffix, prefix+'_eps_dome_protons'+suffix
options, /def, prefix+'_eps_dome_protons'+suffix, 'ylog', 1
options, /def, prefix+'_eps_dome_protons'+suffix, 'ytitle', 'Protons!C [p/(cm!U2!N-s-sr-MeV)]'
options, /def, prefix+'_eps_dome_protons'+suffix, 'labels', dome_energies+' MeV'
options, /def, prefix+'_eps_dome_protons'+suffix, 'labflag', 1
options, /def, prefix+'_eps_dome_protons'+suffix, 'ysubtitle', ''
options, /def, prefix+'_eps_tele_protons'+suffix, 'ylog', 1
options, /def, prefix+'_eps_tele_protons'+suffix, 'ytitle', 'Protons!C [p/(cm!U2!N-s-sr-MeV)]'
options, /def, prefix+'_eps_tele_protons'+suffix, 'labels', telescope_energies+' MeV'
options, /def, prefix+'_eps_tele_protons'+suffix, 'labflag', 1
options, /def, prefix+'_eps_tele_protons'+suffix, 'ysubtitle', ''
end
pro goes_eps_comb_electron_flux, prefix, suffix
dome_energies = strarr(3)
dome_energies[0] = '0.6'
dome_energies[1] = '2.0'
dome_energies[2] = '4.0'
join_vec, prefix+'_elec_'+dome_energies+'MeV_iflux'+suffix, prefix+'_eps_dome_electrons'+suffix
options, /def, prefix+'_eps_dome_electrons'+suffix, 'ylog', 1
options, /def, prefix+'_eps_dome_electrons'+suffix, 'labels', dome_energies+' MeV'
options, /def, prefix+'_eps_dome_electrons'+suffix, 'ytitle', 'Electrons!C [e/(cm!U2!N-s-sr)]'
options, /def, prefix+'_eps_dome_electrons'+suffix, 'labflag', 1
options, /def, prefix+'_eps_dome_electrons'+suffix, 'ysubtitle', ''
end
pro goes_epead_comb_proton_flux, prefix, suffix
energies = strarr(7)
tvarnames = strarr(7)
energies[0] = '2.5'
energies[1] = '6.5'
energies[2] = '11.6'
energies[3] = '30.6'
energies[4] = '63.1'
energies[5] = '165'
energies[6] = '433'
for i = 0, 6 do begin
get_data, prefix+'_prot_'+energies[i]+'MeV_uncor_flux'+suffix, data=prot_data, dlimits=prot_dlimits
if (is_struct(prot_data) && is_struct(prot_dlimits)) then begin
total_values = (prot_data.Y[*,0]+prot_data.Y[*,1])/2.
store_data, prefix+'_prot_'+energies[i]+'MeV_uncor_flux_comb'+suffix, data={x: prot_data.X, y: total_values}, dlimits=prot_dlimits
tvarnames[i] = prefix+'_prot_'+energies[i]+'MeV_uncor_flux_comb'+suffix
endif else begin
dprint, dlevel = 1, 'Error combining the EPEAD proton flux - no valid data?'
return
endelse
endfor
join_vec, tvarnames, prefix+'_prot_uncor_comb_flux'+suffix
options, /def, prefix+'_prot_uncor_comb_flux'+suffix, 'ylog', 1
options, /def, prefix+'_prot_uncor_comb_flux'+suffix, 'labels', energies+' MeV'
options, /def, prefix+'_prot_uncor_comb_flux'+suffix, 'labflag', 1
options, /def, prefix+'_prot_uncor_comb_flux'+suffix, 'ytitle', 'Protons!C [p/(cm!U2!N-s-sr-keV)]'
options, /def, prefix+'_prot_uncor_comb_flux'+suffix, 'ysubtitle', ''
end
pro goes_lib
end