% Initial version: Magnus Billvik, Swedish Institute of Space Physics,
%Uppsala, June 2005

clear;
p=load('spenvis_trapped_protons.txt');
p=[p(:,19) p(:,22)]; % columns for 10 and 30 MeV resp.
e=load('spenvis_trapped_electrons.txt');
e=[e(:,12) e(:,28)]; % columns for 1 and 5 MeV resp.

% time vector (hours)
%t=[0:1/60:24-1/60];
t=[10+10/60 : 1/60 : 24+10+9/60];


figure(1)
% protons
subplot(2,1,1);
semilogy(t,p(:,1),'b-');
hold on;
semilogy(t,p(:,2),'r--');
%axis([0 24 0 10e6]);
axis([18 24 0 10e6]);
%xlabel('time (in hours) after 2005-03-04 10:10:00');
xlabel('time (hours) on 2005-03-04');
ylabel('proton flux (/cm2/s)')
legend('E >10 MeV', 'E >30 MeV',2);
% electrons
subplot(2,1,2);
semilogy(t,e(:,1),'b-');
hold on;
semilogy(t,e(:,2),'r--');
%axis([0 24 0 10e7]);
axis([18 24 0 10e7]);
%xlabel('time (in hours) after 2005-03-04 10:10:00');
xlabel('time (hours) on 2005-03-04');
ylabel('electron flux (/cm2/s)')
legend('E >1 MeV', 'E >5 MeV',2);

intp=cumsum(p)*60;
inte=cumsum(e)*60;

figure(2)
% protons 
subplot(2,1,1);
semilogy(t,intp(:,1),'b-');
hold on;
semilogy(t,intp(:,2),'r--');
%axis([0 24 0 10e9]);
axis([18 24 0 10e9]);
%xlabel('time (in hours) after 2005-03-04 10:10:00');
xlabel('time (hours) on 2005-03-04');
ylabel('protons (/cm2)')
legend('E >10 MeV', 'E >30 MeV',2);
% electrons 
subplot(2,1,2);
semilogy(t,inte(:,1),'b-');
hold on;
semilogy(t,inte(:,2),'r--');
%axis([0 24 0 10e11]);
axis([18 24 0 10e11]);
%xlabel('time (in hours) after 2005-03-04 10:10:00');
xlabel('time (hours) on 2005-03-04');
ylabel('electrons (/cm2)')
legend('E >1 MeV', 'E >5 MeV',2);
