pro thm_scpot2dens_opt_n, probe = probe, datatype_esa = datatype_esa, trange = trange, no_data_load = no_data_load, _extra = _extra
if (keyword_set(probe)) then sc = probe[0] Else sc = 'a'
if not (keyword_set(datatype_esa)) then datatype_esa = 'peer'
If(Not keyword_set(trange)) Then get_timespan, t Else t = trange
If(Not keyword_set(no_data_load)) Then Begin
if(datatype_esa eq 'peef' or datatype_esa eq 'peer' or datatype_esa eq 'peeb' or datatype_esa eq 'peem') then begin
thm_load_esa, probe = sc, level = 2, datatype = datatype_esa+'_'+['density', 'vthermal', 'sc_pot'], trange = t
endif
Endif
thm_load_state, probe = sc, coord = 'sm', trange = t, suffix = '_sm_coordinates'
get_data, strjoin('th'+sc+'_state_pos_sm_coordinates'), data = tmp
If(is_struct(tmp) Eq 0) Then Begin
dprint, 'Missing: '+'th'+sc+'_state_pos_sm_coordinates'
return
Endif
store_data, 'th'+sc+'_R', data = {x:tmp.x, y:sqrt(tmp.y[*, 0]^2+tmp.y[*, 1]^2+tmp.y[*, 2]^2)/6371.}, $
dlim = {colors:[0], labels:['R'], ysubtitle:'[km]', labflag:1, constant:0, ytitle:'th'+sc+'_R'}
MLT = atan(tmp.y[*, 1]/tmp.y[*, 0])*180/!pi/15.+12
if(n_elements(where(tmp.y[*, 0] lt 0)) gt 1) then MLT[where(tmp.y[*, 0] lt 0)] = $
(atan(tmp.y[where(tmp.y[*, 0] lt 0), 1]/tmp.y[where(tmp.y[*, 0] lt 0), 0])+!pi)*180/!pi/15.+12
if(n_elements(where(MLT[*] gt 24)) gt 1) then MLT[where(MLT[*] ge 24)] = MLT[where(MLT[*] ge 24)]-24
store_data, 'th'+sc+'_MLT', data = {x:tmp.x, y:MLT}, $
dlim = {colors:[0], labels:['R'], ysubtitle:'[km]', labflag:1, constant:0, ytitle:'th'+sc+'_MLT'}
MLAT = atan(tmp.y[*, 2]/sqrt(tmp.y[*, 0]^2+tmp.y[*, 1]^2))*180/!pi
store_data, 'th'+sc+'_MLAT', data = {x:tmp.x, y:MLAT}, $
dlim = {colors:[0], labels:['MLAT'], ysubtitle:'[deg]', labflag:1, constant:0, ytitle:'th'+sc+'_MLAT'}
get_data, 'th'+sc+'_'+datatype_esa+'_sc_pot', data = Vdata, index = index
if(index eq 0) then begin
dprint, 'Missing: '+'th'+sc+'_'+datatype_esa+'_sc_pot'
return
endif
Vdata.y[*] = -Vdata.y[*]
store_data, 'th'+sc+'_'+datatype_esa+'_-sc_pot', data = Vdata
get_data, 'th'+sc+'_'+datatype_esa+'_density', data = Nedata, index = index
if(index eq 0) then begin
dprint, 'Missing: '+'th'+sc+'_'+datatype_esa+'_density'
return
endif
get_data, 'th'+sc+'_'+datatype_esa+'_vthermal', data = Vthdata, index = index
if(index eq 0) then begin
dprint, 'Missing: '+'th'+sc+'_'+datatype_esa+'_vthermal'
return
endif
tinterpol_mxn, 'th'+sc+'_R', 'th'+sc+'_'+datatype_esa+'_sc_pot', newname = 'th'+sc+'_R_int'
tinterpol_mxn, 'th'+sc+'_MLT', 'th'+sc+'_'+datatype_esa+'_sc_pot', newname = 'th'+sc+'_MLT_int'
get_data, 'th'+sc+'_R_int', data = R, index = index1
get_data, 'th'+sc+'_MLT_int', data = MLT, index = index2
if(index1 eq 0) then begin
dprint, 'Missing: '+'th'+sc+'_R_int'
return
endif
if(index2 eq 0) then begin
dprint, 'Missing: '+'th'+sc+'_MLT_int'
return
endif
Vthdata.y = Vthdata.y*(1-(-1/(1+exp(-2*(R.y-4)))+1))+10^4*(-1/(1+exp(-2*(R.y-4)))+1)
store_data, 'th'+sc+'_vthermal2', data = Vthdata
Case sc Of
'a': Ne_scpot = (10^(Vdata.y/22.0)*20000.+10^(Vdata.y/ 5.0)*160000.+10^(Vdata.y/2.0)*15000000.0+10^(Vdata.y/0.4)*1500000000000.0)/Vthdata.y
'b': Ne_scpot = (10^(Vdata.y/25.5)*16500. +10^(Vdata.y/2.0)*3000000.0+10^(Vdata.y/0.4)*1500000000000.0)/Vthdata.y
'c': Ne_scpot = (10^(Vdata.y/26.0)*22000. +10^(Vdata.y/2.0)*3000000.0+10^(Vdata.y/0.25)*1e14)/Vthdata.y
'd': Ne_scpot = (10^(Vdata.y/25.5)*20000.+10^(Vdata.y/ 5.0)*30000.+10^(Vdata.y/2.0)*10000000.0+10^(Vdata.y/0.2)*5000000000000000.0)/Vthdata.y
'e': Ne_scpot = (10^(Vdata.y/25.5)*20000.+10^(Vdata.y/ 5.0)*30000.+10^(Vdata.y/2.0)*10000000.0+10^(Vdata.y/0.2)*3000000000000000.0)/Vthdata.y
Endcase
store_data, 'th'+sc+'_'+datatype_esa+'_en_eflux_pot', data = ['th'+sc+'_'+datatype_esa+'_en_eflux', 'th'+sc+'_'+datatype_esa+'_scpot']
ylim, 'th'+sc+'_'+datatype_esa+'_en_eflux_pot', 5e0, 2.3e4, style = 1
Ne_Sheeley_PSph = 1390*(3/R.y)^4.8
Ne_Sheeley_PSsh = 124*(3/R.y)^4.0+36*(3/R.y)^3.5*cos((MLT.y-(7.7*(3/R.y)^2+12))*!pi/12)
insert_nan = where(R.y[*] lt 2 or R.y[*] gt 7)
If(insert_nan[0] Ne -1) Then Begin
Ne_Sheeley_PSph[insert_nan] = 'NaN'
Ne_Sheeley_PSsh[insert_nan] = 'NaN'
Endif
store_data, 'th'+sc+'_'+datatype_esa+'_density_npot', data = {x:Vdata.x, y:[Ne_scpot]}, $
dlim = {colors:[0], labels:['Ne_scpot'], ysubtitle:'[cm-3]', labflag:1, constant:0, ylog:1}
store_data, 'th'+sc+'_'+datatype_esa+'_density_Sheeley', data = {x:Vdata.x, y:[Ne_Sheeley_PSph]}, $
dlim = {colors:[0], labels:['Ne_Sheeley_PSph'], ysubtitle:'[cm-3]', labflag:1, constant:0, ylog:1}
If(n_elements(nedata.x) Eq n_elements(vdata.x)) Then Begin
store_data, 'th'+sc+'_'+datatype_esa+'_density_comparison', $
data = {x:Vdata.x, y:[[Nedata.y], [Ne_scpot], [Ne_Sheeley_PSph]]}, $
dlim = {colors:[0, 2, 6], labels:['Ne_pxxm', 'Ne_scpot', 'Ne_Sheeley_PSph'], $
ysubtitle:'[cm-3]', labflag:-1, constant:0, ylog:1}
options, 'th'+sc+'_'+datatype_esa+'_density_comparison'
Endif
end