1 |
gforget |
1.1 |
function [V,C]=ice_regularize(V,C,it); |
2 |
|
|
%object : get rid of negatives and small positives |
3 |
|
|
% that will be moved to other existing ice classes |
4 |
|
|
% if possible or to open water otherwise |
5 |
|
|
|
6 |
|
|
global nh nt nx; |
7 |
|
|
global reg2ice reg2ocn; |
8 |
|
|
if it==1; reg2ice=zeros(nt+1,2); reg2ocn=zeros(nt+1,2); end; |
9 |
|
|
|
10 |
|
|
tmp1=V(2:end,:); |
11 |
|
|
tmp2=C(2:end,:); |
12 |
|
|
%identify small pos: |
13 |
|
|
tmp3=1*(tmp1>=1e-6&tmp2>=1e-6); |
14 |
|
|
%compute the small pos and large pos reservoirs: |
15 |
|
|
tmp1_large=sum(tmp1.*tmp3,1); |
16 |
|
|
tmp1_small=sum(tmp1.*(1-tmp3),1); |
17 |
|
|
tmp2_large=sum(tmp2.*tmp3,1); |
18 |
|
|
tmp2_small=sum(tmp2.*(1-tmp3),1); |
19 |
|
|
%if possible then merge with other cats: |
20 |
|
|
ii=find(tmp1_large>100*abs(tmp1_small)&tmp2_large>100*abs(tmp2_small)); |
21 |
|
|
tmp11=(tmp1_large+tmp1_small)./tmp1_large; |
22 |
|
|
tmp11=ones(size(tmp1,1),1)*tmp11; |
23 |
|
|
V(2:end,ii)=(tmp1(:,ii).*tmp3(:,ii)).*tmp11(:,ii); |
24 |
|
|
tmp22=(tmp2_large+tmp2_small)./tmp2_large; |
25 |
|
|
tmp22=ones(size(tmp2,1),1)*tmp22; |
26 |
|
|
C(2:end,ii)=(tmp2(:,ii).*tmp3(:,ii)).*tmp22(:,ii); |
27 |
|
|
%otherwise dump in open water: |
28 |
|
|
ii=find(tmp1_large<=100*abs(tmp1_small)|tmp2_large<=100*abs(tmp2_small)); |
29 |
|
|
V(2:end,ii)=tmp1(:,ii).*tmp3(:,ii); |
30 |
|
|
C(2:end,ii)=tmp2(:,ii).*tmp3(:,ii); |
31 |
|
|
V(1,ii)=V(1,ii)+tmp1_small(ii);%dump in open water |
32 |
|
|
C(1,ii)=C(1,ii)+tmp2_small(ii);%dump in open water |
33 |
|
|
|
34 |
|
|
%keep track of what has been merged with other cats: |
35 |
|
|
ii=find(tmp1_large>100*abs(tmp1_small)&tmp2_large>100*abs(tmp2_small)); |
36 |
|
|
tmp1=nansum(tmp1_small(ii)); |
37 |
|
|
tmp2=nansum(tmp2_small(ii)); |
38 |
|
|
if tmp1~=0|tmp2~=0; |
39 |
|
|
% fprintf('%d pos merged %g %g\n',it,tmp1,tmp2); |
40 |
|
|
end; |
41 |
|
|
reg2ice(it,:)=reg2ice(it,:)+[tmp1 tmp2]; |
42 |
|
|
%keep track of what has been dumped to open water: |
43 |
|
|
ii=find(tmp1_large<=100*abs(tmp1_small)|tmp2_large<=100*abs(tmp2_small)); |
44 |
|
|
tmp1=nansum(tmp1_small(ii)); |
45 |
|
|
tmp2=nansum(tmp2_small(ii)); |
46 |
|
|
if tmp1~=0|tmp2~=0; |
47 |
|
|
% fprintf('%d pos removed %g %g\n',it,tmp1,tmp2); |
48 |
|
|
end; |
49 |
|
|
reg2ocn(it,:)=reg2ocn(it,:)+[tmp1 tmp2]; |
50 |
|
|
|