1 |
gforget |
1.1 |
%author : Gael Forget |
2 |
|
|
%date : 07/25/2005 |
3 |
|
|
%object : test if there are enough vertical sampling to justify an interpolated value |
4 |
|
|
% |
5 |
|
|
%inputs : |
6 |
|
|
% profile_std standardized profile |
7 |
|
|
% z_std standard depths |
8 |
|
|
% z_in originally observed depths |
9 |
|
|
% fill_value_output fill value of the output files |
10 |
|
|
function [profile_std2]=test_interp(profile_std,z_std,z_in,fill_value_output); |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
profile_std2=profile_std; |
15 |
|
|
|
16 |
|
|
dz=(z_std(2:end)-z_std(1:end-1)); |
17 |
|
|
dz=[dz(1) (dz(2:end)+dz(1:end-1))/2 dz(end)]; |
18 |
|
|
|
19 |
|
|
%1) define upper and lower limits of the cells : |
20 |
|
|
zinf0=z_std-dz/2; zsup0=z_std+dz/2; |
21 |
|
|
zinf1=z_std-dz; zsup1=z_std+dz; |
22 |
|
|
zinf2=max(z_std-3*dz,z_std-500); |
23 |
|
|
zsup2=min(z_std+3*dz,z_std+500); |
24 |
|
|
|
25 |
|
|
%2) make the test itself : |
26 |
|
|
for kkk=1:length(z_std) |
27 |
|
|
tmp0=~isempty( find((z_in>=zinf0(kkk))&(z_in<=zsup0(kkk))) ); |
28 |
|
|
tmp1_1=~isempty( find((z_in>zinf1(kkk))&(z_in<=z_std(kkk))) ); |
29 |
|
|
tmp2_1=~isempty( find((z_in>=z_std(kkk))&(z_in<zsup1(kkk))) ); |
30 |
|
|
tmp1_2=~isempty( find((z_in>zinf2(kkk))&(z_in<=z_std(kkk))) ); |
31 |
|
|
tmp2_2=~isempty( find((z_in>=z_std(kkk))&(z_in<zsup2(kkk))) ); |
32 |
|
|
|
33 |
|
|
if ~( (tmp1_1&tmp2_2)|(tmp2_1&tmp1_2)|tmp0 ); profile_std2(kkk)=fill_value_output; end; |
34 |
|
|
end |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|