NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/searibbon.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function R=searibbon(ICQ4,mesh,xi,yi,interpint)
2 %SEARIBBON
3 %   SEARIBBON computes a transect given end-points, mesh, and .icq4
4 %   This is the transect 
5 % R=searibbon(ICQ4,mesh,x,y,interpint)
6 %
7 % R =    x: [nnv x npts]
8 %        y: [nnv x npts]
9 %        d: [nnv x npts]
10 %     ZMID: [nnv x npts]
11 %    UZMID: [nnv x npts]
12 %    VZMID: [nnv x npts]
13 %    WZMID: [nnv x npts]
14 %    Q2MID: [nnv x npts]
15 %   Q2LMID: [nnv x npts]
16 %   TMPMID: [nnv x npts]
17 %   SALMID: [nnv x npts]
18 %
19 % Check for existence of .icq4 file
20
21 flds{1}='ZMID';
22 flds{2}='UZMID';
23 flds{3}='VZMID';
24 flds{4}='WZMID';
25 flds{5}='Q2MID';
26 flds{6}='Q2LMID';
27 flds{7}='TMPMID';
28 flds{8}='SALMID';
29
30 Z=ICQ4.ZMID;
31
32 NNV=size(Z,2);
33 % OPNML Compliant 3-18-99 CVL
34 mesh=belint(mesh);
35 mesh=el_areas(mesh);
36
37 % INTERPOLATE X & Y ALONG TRACK IF REQUESTED
38
39 d=[0; cumsum(((diff(xi(:))).^2+(diff(yi(:))).^2).^0.5)];
40 xy=[xi(:),yi(:)];
41 if exist('interpint')
42         if ~isnan(interpint)
43                 xy=interp1(d,xy,...
44                         sort([d(:);[interpint:interpint:max(d)]']));
45                 d=sort([d(:);[interpint:interpint:max(d)]']);
46         end
47 end
48
49 % REMOVE NANS FOR NOW
50
51 ll=findelem(mesh,xy);
52 ind=find(~isnan(ll));
53 if isempty(ind)
54         error('section off grid!')
55 end
56
57 % BUILD BASIS FN LIST
58
59 ll=ll(ind);
60 xy=xy(ind,:);
61 [p]=basis2d(mesh,xy);
62
63 % FIRST PART OF STRUCTURE
64 R.x=nan*ones(length(d),NNV);
65 R.y=R.x;
66 R.d=d*ones(1,NNV);
67
68 R.x(ind,:)=meshgrid(xy(:,1),1:NNV)';
69 R.y(ind,:)=meshgrid(xy(:,2),1:NNV)';
70
71 % INTERPOLATE AT EACH SIGMA LEVEL
72
73 for iv=1:NNV
74         t=Z(:,iv);
75         v1(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
76        
77         t=ICQ4.UZMID(:,iv);
78         v2(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
79        
80         t=ICQ4.VZMID(:,iv);
81         v3(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
82        
83         t=ICQ4.WZMID(:,iv);
84         v4(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
85        
86         t=ICQ4.Q2MID(:,iv);
87         v5(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
88
89         t=ICQ4.Q2LMID(:,iv);
90         v6(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
91
92         t=ICQ4.TMPMID(:,iv);
93         v7(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
94
95         t=ICQ4.SALMID(:,iv);
96         v8(1:length(xy),iv)=sum((p.*t(mesh.e(ll,:)))')';
97 end
98
99 R=setfield(R,flds{1},v1);
100 R=setfield(R,flds{2},v2);
101 R=setfield(R,flds{3},v3);
102 R=setfield(R,flds{4},v4);
103 R=setfield(R,flds{5},v5);
104 R=setfield(R,flds{6},v6);
105 R=setfield(R,flds{7},v7);
106 R=setfield(R,flds{8},v8);
Note: See TracBrowser for help on using the browser.