1 |
function [P]=regrid_dblres(P,pType,nDblRes); |
2 |
%object : double the resolution (only along 3rd dimension for now) |
3 |
% for a variable P (extensive or intensive) a number of times. |
4 |
%input : P is the variable of interest |
5 |
% pType is 'extensive' or 'intensive' |
6 |
% nDblRes is the number of resolution doublings. |
7 |
%output : P is the input variable but with 2^nDblRes resolution |
8 |
|
9 |
gcmfaces_global; |
10 |
|
11 |
for ii=1:nDblRes; |
12 |
%start with repmat |
13 |
tmp1=repmat(P,[1 1 2]); |
14 |
nn=size(P{1},3); |
15 |
tmp1(:,:,1:2:2*nn)=P; |
16 |
tmp1(:,:,2:2:2*nn)=P; |
17 |
%interpolate (in grid point space) |
18 |
tmp2=NaN*tmp1; |
19 |
tmp2(:,:,2:2:2*nn-2)=3/4*P(:,:,1:nn-1)+1/4*P(:,:,2:nn); |
20 |
tmp2(:,:,3:2:2*nn-1)=1/4*P(:,:,1:nn-1)+3/4*P(:,:,2:nn); |
21 |
tmp1(~isnan(tmp2))=tmp2(~isnan(tmp2)); |
22 |
%if extensive then we want to conserve the sum over grid points |
23 |
if strcmp(pType,'extensive'); tmp1=tmp1/2; end; |
24 |
%overwite P |
25 |
P=tmp1; |
26 |
end; |
27 |
|