% heatmap_deployments
% 
% calculate the distribution of deployments needed after
% day 1000, when pseudo-steady state has been reached.
% 
% Note that N is number of deployments per month per *bin*

clear all;

load sim_global dep_lon dep_lat dep_t
lon2=dep_lon; lat2=dep_lat; t2=dep_t;

load sim_global_tpos_western10to10 dep_lon dep_lat dep_t
lon=dep_lon; lat=dep_lat; t=dep_t;
clear dep*

dL=1;
Lon=floor(min(lon)):dL:ceil(max(lon));
Lat=floor(min(lat)):dL:ceil(max(lat));

N=zeros(length(Lat),length(Lon),2); % number of deployments per month
for i=1:length(Lat);
    for j=1:length(Lon);
        q=find(lat>=Lat(i)-dL/2 & lat<Lat(i)+dL/2 & ...
            lon>=Lon(j)-dL/2 & lon<Lon(j)+dL/2 & t>=1000);
        if (length(q))
            N(i,j,1)=length(q)./(max(t)-1000)*365/12;
            lon(q)=[]; lat(q)=[]; t(q)=[];
        end;
        q=find(lat2>=Lat(i)-dL/2 & lat2<Lat(i)+dL/2 & ...
            lon2>=Lon(j)-dL/2 & lon2<Lon(j)+dL/2 & t2>=1000);
        if (length(q))
            N(i,j,2)=length(q)./(max(t2)-1000)*365/12;
            lon2(q)=[]; lat2(q)=[]; t2(q)=[];
        end;
    end;
end;

d=N(:,:,1)-N(:,:,2);

