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

root/gliderproc/trunk/MATLAB/opnml/mat4/isophase.m

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

Initial import of Stark code.

Line 
1 %ISOPHASE contour a vector of scalar (phase) values on a FEM grid.
2 %   ISOPHASE accepts a vector of values to be contoured
3 %   over the provided mesh.  ISOPHASE expects the element file to
4 %   be either 3 or 4 columns wide.  If elems is 4 columns wide, ISOPHASE
5 %   assumes the first column is the element number and strips
6 %   it away.
7 %
8 % Input:    elems - list of nodes per element
9 %           x,y - xy locations of nodes; each must be 1-D
10 %           Q - scalar to be contoured upon; must be 1-D
11 %           cval - vector of values to contour
12 %
13 %           The parameter/value pairs currently allowed in the isophase 
14 %           function are as follows ( default values appear in {} ) :
15 %
16 %                Color       {'r' = red}
17 %                LineStyle   {'-' = solid}
18 %                LineWidth   {0.5 points; 1 point = 1/72 inches}
19 %                MarkerSize  {6 points}
20 %
21 %           See the Matlab Reference Guide entry on the LINE command for
22 %           a complete description of parameter/value pair specification.
23 %
24 %           The idea and some of the constructs used in pv decoding
25 %           in this routine come from an unreleased MathWorks function
26 %           called polar2.m written by John L. Galenski III 
27 %           and provided by Jeff Faneuff.
28 %
29 % Output:  isophase returns the handle to the contour line drawn
30 %
31 % Call as: h=isophase(elems,x,y,Q,cval,p1,v1,p2,v2,...)
32 %
33 % Written by : Brian O. Blanton
34 %
35 function chandle=isophase(elems,x,y,Q,cval,p1,v1,p2,v2,p3,v3,p4,v4,...
36                                             p5,v5,p6,v6,p7,v7,p8,v8)                                           
37 % DEFINE ERROR STRINGS
38 err1=['matrix of elements must be either 3 or 4 columns wide' ];
39 err2=['node coordinate vectors must be the same length'];
40 err3=['length of scalar must be the same length as coordinate vectors'];
41 err4=['scalar to be contoured must be 1-D'];
42 err5=['insufficient number of parameters or values'];
43
44 % check number of arguments
45 N=nargin;
46 msg=nargchk(1,21,N);
47 if ~isempty(msg)
48    disp(msg);
49    disp('Routine: isophase');
50    return
51 end
52
53 % check array sizes
54 [nelems,s]=size(elems);   % m = number of elements
55 if s<3 | s>4
56    error(err1);
57 end
58 if s==4,elems=elems(:,2:4);,end
59
60 if length(x) ~= length(y)
61    error(err2);
62 end
63
64 [nrowQ,ncolQ]=size(Q);
65 if nrowQ*ncolQ~=length(Q),error(err4),end
66
67 % columnate Q
68 Q=Q(:);
69 [nrowQ,ncolQ]=size(Q);
70
71 if nrowQ ~= length(x)
72    error(err3);
73 end   
74
75 % determine number of pv pairs input
76 npv = N-5;
77 if rem(npv,2)==1,error(err5);,end
78  
79 % process parameter/value pair argument list, if needed
80 PropFlag = zeros(1,4);
81 limt=npv/2;
82 for X = 1:limt
83   p = eval(['p',int2str(X)]);
84   v = eval(['v',int2str(X)]);
85   if X == 1
86     Property_Names = p;
87     Property_Value = v;
88   else
89     Property_Names = str2mat(Property_Names,p);
90     Property_Value = str2mat(Property_Value,v);
91   end
92   if strcmp(lower(p),'color')
93     PropFlag(1) = 1;
94     color = v;
95   elseif strcmp(lower(p),'linestyle')
96     PropFlag(2) = 1;
97     linestyle = v;
98   elseif strcmp(lower(p),'linewidth')
99     PropFlag(3) = 1;
100     linewidth = v;
101   elseif strcmp(lower(p),'markersize')
102     PropFlag(4) = 1;
103     markersize = v;
104   end
105 end
106
107 % Determine which properties have not been set by
108 % the user
109 Set    = find(PropFlag == 1);
110 NotSet = find(PropFlag == 0);
111  
112 % Define property names and assign default values
113 Default_Settings = ['''r''   ';
114                     '''- ''  ';
115                     '0.5   ';
116                     '6     '];
117 Property_Names =   ['color     ';
118                     'linestyle ';
119                     'linewidth ';
120                     'markersize'];
121 for I = 1:length(NotSet)
122   eval([Property_Names(NotSet(I),:),'=',Default_Settings(NotSet(I),:),';'])
123 end
124  
125 % range of scalar quantity to be contoured; columnate cval
126 Qmax=max(Q);
127 Qmin=min(Q);
128 cval=cval(:);
129  
130 for kk=1:length(cval)
131    if cval(kk) > Qmax | cval(kk) < Qmin
132       disp([num2str(cval(kk)),' not within range of specified scalar field']);
133       chandle(kk)=0;
134   else 
135  
136 % Call cmex function isopnex
137 %
138       C=isopmex5(x,y,elems,Q,cval(kk));
139       if ~isempty(C)
140          chandle(kk)=line(C(:,1),C(:,2),...
141                           'Color',color,...
142                           'Linestyle',linestyle,...
143                           'LineWidth',linewidth,...
144                           'MarkerSize',markersize);
145          set(chandle(kk),'UserData',cval(kk));
146          set(chandle(kk),'Tag','contour');
147          drawnow
148       else
149          disp([num2str(cval(kk)) ' not found.']);
150          chandle(kk)=0;
151       end
152    end
153 end
154
155 return
156 %
157 %        Brian O. Blanton
158 %        Department of Marine Sciences
159 %        15-1A Venable Hall
160 %        CB# 3300
161 %        Uni. of North Carolina
162 %        Chapel Hill, NC
163 %                 27599-3300
164 %
165 %        919-962-4466
166 %        blanton@marine.unc.edu
167
168    
169
170
171
172
173
174  
Note: See TracBrowser for help on using the browser.