%% modmclie.m calculates the new scaling factor for the E5D McIllwain
%% model as set out by Liemohn et al. JGR June 2001 eqn 12, and based 
%% on fits between E0 and Kp data provided by Mike Liemohn. This 
%% scaling factor can be used to replace the 1+0.3Kr scaling factor 
%% (denoted by G2 in my thesis and in (most) the MATLAB code).
%%
  
function sf=modmclie(kp);

re=6371;                 %Earth radii (km)
e0=kp2e0(kp);            %calculate required cross tail electric field (mV/m)
e0=e0*(1e-3*re);         %convert e0 from mV/m to kV/RE

ex=0.2;                  %x-component of Mcillwain E field (kV/RE)
ey=0.8;                  %y-component of Mcillwain E field (kV/RE)
emax=sqrt(ex^2+ey^2);    %maximum Mcillwain E field (kV/RE)

sf=e0/emax;              %calculate scaling factor
