PRO Dst_vs_NumMagStormIndex_fig7, inputfileTotalKE, dst_measured_file 

; Read inputfileTotalKE (simulation output)
; Read dst_measured_file (measured hourly equatorial Dst (Final) index)

t_simTotalKE = fltarr(1)
totalke_sim = fltarr(1)

restore,dst_measured_file

rhodim=5.*1.66054e-27*1.e6 ; [kg/m3]
vdim=3.5e-9/sqrt(4.e-7*!PI*rhodim) ; [m/s]
bdim=3.5e-9 ; [T]
tdim=6.378e6/vdim ; [s]

openr, lun, inputfileTotalKE, /get_lun

; Loop until EOF is found
while ~ eof(lun) do begin
   ; Read a line of text
   readf, lun, tsimTotalKE, totalkesim
   t_simTotalKE = [t_simTotalKE,tsimTotalKE]
   totalke_sim = [totalke_sim,totalkesim]
endwhile

; Close the file
close, lun

t_simTotalKE = t_simTotalKE(1:*)
totalke_sim = totalke_sim(1:*)

;t_simTotalKE = t_simTotalKE + (36.*60.+15.0336)/tdim
t_simTotalKE = t_simTotalKE + (9.*60.+21.0528)/tdim

wdef,0,800,400

;utplot,t*3600.,Dst_Final,background=255,color=0,yrange=[-300.,20.],title='Hourly Equatorial Dst (Final) & Numerical Magnetic Storm Index vs Time (06 April 2000 Storm)',ytitle='Dst (Final) (nT), total(delB_2.5RE_10RE(t)) (nT)'
utplot,t*3600.,Dst_Final,background=255,color=0,yrange=[-500.,20.],title='Hourly Equatorial Dst (Final) & Numerical Magnetic Storm Index vs Time (20 November 2003 Storm)',ytitle='Dst (Final) (nT), total(delB_2.5RE_10RE(t)) (nT)'

; Dessler-Parker relation
U = 4.*!dpi*8.e15*3.e-5/(3.*4.e-7*!dpi)
;delB_TotalKE = -2.*totalke_sim*90.*3.e4/(3.*U) ; PI*(100*RE^2.-6.25*RE^2.)*(0.3RE) for which the height of the ring current slab is a variable, in this case 0.3RE.
delB_TotalKE = -2.*totalke_sim*250.*3.e4/(3.*U) ; PI*(100*RE^2.-6.25*RE^2.)*(0.3RE) for which the height of the ring current slab is a variable, in this case 0.83RE.

oplot,t_simTotalKE*tdim,gauss_smooth(delB_TotalKE,2),color=0,linestyle=2

legend,['Dst (measured)','Numerical Magnetic Storm Index'],linestyle=[0,2],/top,/right,textcolor=0,color=0,box=0

;write_png,'Dst_06042000_Storm_Overlap.png',tvrd(/true)
write_png,'Dst_20112003_Storm_Overlap.png',tvrd(/true)

END