1 |
gforget |
1.1 |
function [secX,secY,secFLD]=gcmfaces_section(lons,lats,fld); |
2 |
|
|
%purpose: extract a great circle section (defined by two points) from a field |
3 |
|
|
% |
4 |
|
|
%inputs: lons/lats are the longitude/latitude vector |
5 |
|
|
% fld is the gcmfaces field (can incl. depth/time dimensions) |
6 |
|
|
%outputs: secX/secY is the vector of grid points longitude/latitude |
7 |
|
|
% secFLD is the vector/matrix of grid point values (from fld) |
8 |
|
|
|
9 |
|
|
global mygrid; |
10 |
|
|
|
11 |
|
|
line_cur=line_greatC_TUV_mask(lons,lats); |
12 |
|
|
secP=find(~isnan(line_cur.mmtIn)); |
13 |
|
|
secN=sum(~isnan(line_cur.mmtIn)); |
14 |
|
|
|
15 |
|
|
%lon/lat vectors: |
16 |
|
|
secX=zeros(secN,1); secY=zeros(secN,1); |
17 |
|
|
%sections: |
18 |
|
|
n3=max(size(fld{1},3),1); n4=max(size(fld{4},4),1); secFLD=zeros(secN,n3,n4); |
19 |
|
|
%counter: |
20 |
|
|
ii0=0; |
21 |
|
|
for ff=1:secP.nFaces; |
22 |
|
|
tmp0=secP{ff}; [tmpI,tmpJ]=ind2sub(size(mygrid.XC{ff}),tmp0); |
23 |
|
|
tmp1=mygrid.XC{ff}; for ii=1:length(tmpI); secX(ii+ii0)=tmp1(tmpI(ii),tmpJ(ii)); end; |
24 |
|
|
tmp1=mygrid.YC{ff}; for ii=1:length(tmpI); secY(ii+ii0)=tmp1(tmpI(ii),tmpJ(ii)); end; |
25 |
|
|
tmp1=fld{ff}; for ii=1:length(tmpI); secFLD(ii+ii0,:,:)=squeeze(tmp1(tmpI(ii),tmpJ(ii),:,:)); end; |
26 |
|
|
ii0=ii0+length(tmpI); |
27 |
|
|
end; |
28 |
|
|
|
29 |
|
|
%sort according to increasing latitude: |
30 |
|
|
[tmp1,ii]=sort(secY); %sort according to increasing latitude |
31 |
|
|
secX=secX(ii); secY=secY(ii); secFLD=secFLD(ii,:,:); |
32 |
|
|
|