Home > fvcom_prepro > plot_field.m

plot_field

PURPOSE ^

Plot the mesh, user defined field, open boundary nodes, and river points

SYNOPSIS ^

function plot_field(Mobj,PlotField,varargin)

DESCRIPTION ^

 Plot the mesh, user defined field, open boundary nodes, and river points 

 function plot_field(Mobj,field,varargin)

 DESCRIPTION:
    Plot a field from the Mesh structure

 INPUT 
   Mobj                    = matlab mesh object 
   PlotField               = vertex-based field to plot
   [optional] coordinate   = coordinate system 
                             'cartesian'(default)
                             'spherical'  
   [optional] showgrid     = show the grid
                             [true ; false (default)] 
   [optional] withextra    = display river nodes and obc nodes
                             [true ; false (default)]

 OUTPUT:
    Figure Plot to Screen

 EXAMPLE USAGE
    plot_field(Mobj,Mobj.h,'coordinate','spherical')
    plot_field(Mobj,Mobj.ts,'showgrid',true)

 Author(s):  
    Geoff Cowles (University of Massachusetts Dartmouth)

 Revision history
 2013-08-22 optional function to pass the axes id to the function added.
 Rory O'Hara Murray, MSS

==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plot_field(Mobj,PlotField,varargin) 
0002 
0003 % Plot the mesh, user defined field, open boundary nodes, and river points
0004 %
0005 % function plot_field(Mobj,field,varargin)
0006 %
0007 % DESCRIPTION:
0008 %    Plot a field from the Mesh structure
0009 %
0010 % INPUT
0011 %   Mobj                    = matlab mesh object
0012 %   PlotField               = vertex-based field to plot
0013 %   [optional] coordinate   = coordinate system
0014 %                             'cartesian'(default)
0015 %                             'spherical'
0016 %   [optional] showgrid     = show the grid
0017 %                             [true ; false (default)]
0018 %   [optional] withextra    = display river nodes and obc nodes
0019 %                             [true ; false (default)]
0020 %
0021 % OUTPUT:
0022 %    Figure Plot to Screen
0023 %
0024 % EXAMPLE USAGE
0025 %    plot_field(Mobj,Mobj.h,'coordinate','spherical')
0026 %    plot_field(Mobj,Mobj.ts,'showgrid',true)
0027 %
0028 % Author(s):
0029 %    Geoff Cowles (University of Massachusetts Dartmouth)
0030 %
0031 % Revision history
0032 % 2013-08-22 optional function to pass the axes id to the function added.
0033 % Rory O'Hara Murray, MSS
0034 %
0035 %==============================================================================
0036 
0037 subname = 'plot_field';
0038 global ftbverbose
0039 if(ftbverbose);
0040   fprintf('\n'); fprintf(['begin : ' subname '\n'])
0041 end;
0042 
0043 %------------------------------------------------------------------------------
0044 % Parse input arguments
0045 %------------------------------------------------------------------------------
0046 PlotCartesian = 'cartesian';
0047 ShowGrid = false;
0048 HaveTitle = false;
0049 PlotExtra = false;
0050 HaveAxes = false;
0051 
0052 nArgs = length(varargin);
0053 if(mod(nArgs,2) ~= 0)
0054     error('incorrect usage of plot_mesh')
0055 end;
0056 
0057 
0058 for i=1:2:length(varargin)-1
0059     keyword  = lower(varargin{i});
0060     if( ~ischar(keyword) )
0061         error('incorrect usage of plot_mesh')
0062     end;
0063     
0064     switch(keyword(1:3))
0065     
0066     case'coo'
0067         coord = lower(varargin{i+1});
0068         if(coord(1:3) == 'car')
0069             PlotCartesian = true;
0070         else
0071             PlotCartesian = false;
0072         end;
0073     case'sho'
0074         showg = lower(varargin{i+1});
0075         if(showg)
0076             ShowGrid = true;
0077         else
0078             ShowGrid = false;
0079         end;
0080     case'tit'
0081         MyTitle = varargin{i+1};
0082         HaveTitle = true;
0083     case'wit'
0084         showg = lower(varargin{i+1});
0085         if(showg)
0086             PlotExtra = true;
0087         else
0088             PlotExtra = false;
0089         end;
0090     case 'aid'
0091         aid = varargin{i+1};
0092         HaveAxes = true;
0093     otherwise
0094         error(['Can''t understand value for:' keyword]);
0095     end; %switch keyword
0096 end;
0097 
0098 %------------------------------------------------------------------------------
0099 % Plot the mesh and bathymetry
0100 %------------------------------------------------------------------------------
0101 
0102 if(ShowGrid)
0103     edgecolor = 'k';
0104 else
0105     edgecolor = 'interp';
0106 end;
0107 
0108 field = PlotField;
0109 
0110 if(PlotCartesian)
0111     if(~Mobj.have_xy)
0112         error('no (x,y) coordinates available for Mesh structure')
0113     end;
0114     x = Mobj.x;
0115     y = Mobj.y;
0116 else
0117     if(~Mobj.have_lonlat)
0118         error('no (lon,lat) coordinates available for Mesh structure')
0119     end;
0120     x = Mobj.lon;
0121     y = Mobj.lat;
0122 end;
0123 
0124 if HaveAxes
0125     axes(aid)
0126 else
0127     figure
0128 end
0129     
0130 patch('Vertices',[x,y],'Faces',Mobj.tri,...
0131           'Cdata',field,'edgecolor',edgecolor,'facecolor','interp');
0132 colorbar
0133 hold on;
0134 
0135 if(HaveTitle)
0136     title(MyTitle)
0137 end;
0138 
0139 %------------------------------------------------------------------------------
0140 % Plot the mesh and bathymetry
0141 %------------------------------------------------------------------------------
0142 if(PlotExtra)
0143     for i=1:Mobj.nRivers
0144         nodes = Mobj.riv_nodes(i,1:Mobj.nRivNodes(i));
0145         plot(x(nodes),y(nodes),'go','MarkerFaceColor','g');
0146     end;
0147     for i=1:Mobj.nObs
0148         nodes = Mobj.obc_nodes(i,1:Mobj.nObcNodes(i));
0149         plot(x(nodes),y(nodes),'ks','MarkerFaceColor','k');
0150     end;
0151     for i=1:Mobj.nSponge
0152         nodes = Mobj.sponge_nodes(i,1:Mobj.nSpongeNodes(i));
0153         plot(x(nodes),y(nodes),'rd','MarkerSize',5,'MarkerFaceColor','k');
0154     end;
0155 end;
0156 
0157 
0158 if(ftbverbose);
0159   fprintf(['end   : ' subname '\n'])
0160 end;
0161 
0162

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005