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
   
==============================================================================

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 %
0033 %==============================================================================
0034 
0035 subname = 'plot_field';
0036 global ftbverbose
0037 if(ftbverbose);
0038   fprintf('\n'); fprintf(['begin : ' subname '\n'])
0039 end;
0040 
0041 %------------------------------------------------------------------------------
0042 % Parse input arguments
0043 %------------------------------------------------------------------------------
0044 PlotCartesian = 'cartesian';
0045 ShowGrid = false;
0046 HaveTitle = false;
0047 PlotExtra = false;
0048 
0049 nArgs = length(varargin);
0050 if(mod(nArgs,2) ~= 0)
0051     error('incorrect usage of plot_mesh')
0052 end;
0053 
0054 
0055 for i=1:2:length(varargin)-1
0056     keyword  = lower(varargin{i});
0057     if( ~ischar(keyword) )
0058         error('incorrect usage of plot_mesh')
0059     end;
0060     
0061     switch(keyword(1:3))
0062     
0063     case'coo'
0064         coord = lower(varargin{i+1});
0065         if(coord(1:3) == 'car')
0066             PlotCartesian = true;
0067         else
0068             PlotCartesian = false;
0069         end;
0070     case'sho'
0071         showg = lower(varargin{i+1});
0072         if(showg)
0073             ShowGrid = true;
0074         else
0075             ShowGrid = false;
0076         end;
0077     case'tit'
0078         MyTitle = varargin{i+1};
0079         HaveTitle = true;
0080     case'wit'
0081         showg = lower(varargin{i+1});
0082         if(showg)
0083             PlotExtra = true;
0084         else
0085             PlotExtra = false;
0086         end;
0087     otherwise
0088         error(['Can''t understand value for:' keyword]);
0089     end; %switch keyword
0090 end;
0091 
0092 %------------------------------------------------------------------------------
0093 % Plot the mesh and bathymetry
0094 %------------------------------------------------------------------------------
0095 
0096 if(ShowGrid)
0097     edgecolor = 'k';
0098 else
0099     edgecolor = 'interp';
0100 end;
0101 
0102 field = PlotField;
0103 
0104 if(PlotCartesian)
0105     if(~Mobj.have_xy)
0106         error('no (x,y) coordinates available for Mesh structure')
0107     end;
0108     x = Mobj.x;
0109     y = Mobj.y;
0110 else
0111     if(~Mobj.have_lonlat)
0112         error('no (lon,lat) coordinates available for Mesh structure')
0113     end;
0114     x = Mobj.lon;
0115     y = Mobj.lat;
0116 end;
0117 
0118 figure
0119 patch('Vertices',[x,y],'Faces',Mobj.tri,...
0120           'Cdata',field,'edgecolor',edgecolor,'facecolor','interp');
0121 colorbar
0122 hold on;
0123 
0124 if(HaveTitle)
0125     title(MyTitle)
0126 end;
0127 
0128 %------------------------------------------------------------------------------
0129 % Plot the mesh and bathymetry
0130 %------------------------------------------------------------------------------
0131 if(PlotExtra)
0132     for i=1:Mobj.nRivers
0133         nodes = Mobj.riv_nodes(i,1:Mobj.nRivNodes(i));
0134         plot(x(nodes),y(nodes),'go','MarkerFaceColor','g');
0135     end;
0136     for i=1:Mobj.nObs
0137         nodes = Mobj.obc_nodes(i,1:Mobj.nObcNodes(i));
0138         plot(x(nodes),y(nodes),'ks','MarkerFaceColor','k');
0139     end;
0140     for i=1:Mobj.nSponge
0141         nodes = Mobj.sponge_nodes(i,1:Mobj.nSpongeNodes(i));
0142         plot(x(nodes),y(nodes),'rd','MarkerSize',5,'MarkerFaceColor','k');
0143     end;
0144 end;
0145 
0146 
0147 if(ftbverbose);
0148   fprintf(['end   : ' subname '\n'])
0149 end;
0150 
0151

Generated on Tue 18-Dec-2012 12:37:31 by m2html © 2005