%% ap2kp.m converts from Ap solar magnetic activity index to
%% kp solar magnetic index.
%%

function kp=ap2kp(ap);

% ap = Ap index of points of interest
% kp = Kp index of points of interest

apv=[0 3 7 15 27 48 80 140 240 400];    %Ap vector
kpv=0:9;                                %Kp vector
aps=size(ap);                           %size of input 
ap=ap(:);                               %reshape to a column vector
kp=interp1(apv,kpv,ap,'spline');        %determine the corresponding kp values
kp=reshape(kp,aps);                     %reshape to orignal input size
