Home > fvcom_postproc > do_surface_plotMatlabMap.m

do_surface_plotMatlabMap

PURPOSE ^

SYNOPSIS ^

function [Plots]=do_surface_plotMatlabMap(plotOPTS,FVCOM)

DESCRIPTION ^

 Function to display color maps of FVCOM variables (i.e. temperature)

  [Plots]=do_surface_plot(plotOPTS,FVCOM)

 DESCRIPTION:
    Generates maps of variables using m_map toolbox (patch

 INPUT:
   plotOPTS   = structure array with predefined options for generating the
   maps
   FVCOM  = data extracted from FVCOM NC file. See read_netCDF_FVCOM for
   details

   plotOPTS.range_lat: [50.1000 50.4000]
   plotOPTS.range_lon: [-4.5000 -3.8500]
   plotOPTS.fig_name: 'co2_S5_slowleak'
   plotOPTS.mesh: [1x1 struct]
   plotOPTS.coastline_file: '../mat/tamar3_0coast.mat'
   plotOPTS.zone: 30
   plotOPTS.ell: 'grs80'
   plotOPTS.var_plot: 'PH'
   plotOPTS.clims: [6 8]
   plotOPTS.do_mesh: 0
   plotOPTS.nz_plot: 1
   plotOPTS.figure: 1
   plotOPTS.Time_record: 7.3271e+05
   plotOPTS.nz_plot_vec: 1
   plotOPTS.data_dec: 5
   plotOPTS.vel_sca: 5
   plotOPTS.pause: 0.5000

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Plots]=do_surface_plotMatlabMap(plotOPTS,FVCOM)
0002 %
0003 % Function to display color maps of FVCOM variables (i.e. temperature)
0004 %
0005 %  [Plots]=do_surface_plot(plotOPTS,FVCOM)
0006 %
0007 % DESCRIPTION:
0008 %    Generates maps of variables using m_map toolbox (patch
0009 %
0010 % INPUT:
0011 %   plotOPTS   = structure array with predefined options for generating the
0012 %   maps
0013 %   FVCOM  = data extracted from FVCOM NC file. See read_netCDF_FVCOM for
0014 %   details
0015 %
0016 %   plotOPTS.range_lat: [50.1000 50.4000]
0017 %   plotOPTS.range_lon: [-4.5000 -3.8500]
0018 %   plotOPTS.fig_name: 'co2_S5_slowleak'
0019 %   plotOPTS.mesh: [1x1 struct]
0020 %   plotOPTS.coastline_file: '../mat/tamar3_0coast.mat'
0021 %   plotOPTS.zone: 30
0022 %   plotOPTS.ell: 'grs80'
0023 %   plotOPTS.var_plot: 'PH'
0024 %   plotOPTS.clims: [6 8]
0025 %   plotOPTS.do_mesh: 0
0026 %   plotOPTS.nz_plot: 1
0027 %   plotOPTS.figure: 1
0028 %   plotOPTS.Time_record: 7.3271e+05
0029 %   plotOPTS.nz_plot_vec: 1
0030 %   plotOPTS.data_dec: 5
0031 %   plotOPTS.vel_sca: 5
0032 %   plotOPTS.pause: 0.5000
0033 
0034 %
0035 % OUTPUT:
0036 %   Plots = structure array with figure handles
0037 %
0038 % EXAMPLE USAGE
0039 %    [Plots]=do_surface_plot(plotOPTS,FVCOM)
0040 %
0041 % Author(s):
0042 %    Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory)
0043 %
0044 % Revision history
0045 %
0046 %==============================================================================
0047 %
0048 % adds m_map to matlab paths. file is in utilities directory.
0049 % amend according to your m_map installation paths
0050 
0051 figure(plotOPTS.figure);
0052 try delete(plotOPTS.PlotoutS(plotOPTS.figure).handles)
0053 catch 
0054         clf
0055 end
0056 
0057 % generate figure with correct projection lat and lon range ellipsoid and
0058 % zone.
0059 if isfield(plotOPTS,'Lontick')
0060     MerTick = plotOPTS.Lontick;
0061 else
0062     MerTick = floor(10*(diff(plotOPTS.range_lon)/5))/10;
0063 end
0064 if isfield(plotOPTS,'Lattick')
0065     ParTick = plotOPTS.Lattick;
0066 else
0067     ParTick = floor(10*(diff(plotOPTS.range_lat)/5))/10;
0068 end
0069 
0070 axesm('mercator','MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon],'MeridianLabel','on',...
0071     'ParallelLabel','on','MLineLocation',MerTick,'PLineLocation',ParTick,'LabelUnits','dm')
0072 
0073 
0074 % add coastline if present
0075 if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
0076     if isfield (plotOPTS,'PlotoutS') && ~isempty(plotOPTS.PlotoutS(plotOPTS.figure).handles)
0077     else
0078 %     coast=load(plotOPTS.coastline_file);
0079 geoshow(plotOPTS.coastline_file,'Facecolor',[0.7 .7 .7])        
0080     end
0081 
0082 end
0083 %------------------------------------------------------------------------------
0084 % Generate maps at a give level
0085 %------------------------------------------------------------------------------
0086     mstruct = gcm;
0087 
0088 
0089 [X, Y] = mfwdtran(mstruct,plotOPTS.mesh.lat, plotOPTS.mesh.lon);
0090 
0091  aa=plotOPTS.Time_record;
0092     fprintf('Time step %i of %i\n',aa,length(FVCOM.Time_record));
0093     %plot map
0094     hold on
0095     ND=ndims(FVCOM.(plotOPTS.var_plot))
0096     switch ND
0097         case 2
0098                 Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0099         'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,aa)),'edgecolor','interp','facecolor','interp');
0100 
0101         case 3
0102     Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0103         'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),'edgecolor','interp','facecolor','interp');
0104     end
0105     caxis(plotOPTS.clims)
0106     colorbar('peer',gca,'EastOutside')
0107     % check if mesh elements are required
0108     if plotOPTS.do_mesh
0109         %plot vertices
0110         Plots(plotOPTS.figure).mesh=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0111             'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0112 
0113     end
0114 %      setm(gca,'MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon])
0115      tightmap
0116     %-----------------------------------------------------------------------
0117     % Only in my case it needs adding 6 because proj automatically determines a
0118     % reference long in strides of 6deg while m_map doesn't
0119     %------------------------------------------------------------------------
0120     pause(plotOPTS.pause)
0121 %     if aa~=length(plotOPTS.Time_record)
0122 %         delete(Plots(plotOPTS.figure).handles(:))
0123 %     end
0124 
0125 %  end
0126 
0127  
0128  
0129  
0130  
0131  
0132  
0133 %  fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record));
0134 %     %plot map
0135 %     hold on
0136 %     Plots(plotOPTS.figure).handles=patch('Vertices',[lat,lon],'Faces',plotOPTS.mesh.tri,...
0137 %         'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),'edgecolor','interp','facecolor','interp');
0138 %
0139 %     caxis(plotOPTS.clims)
0140 %     colorbar
0141 %     % check if mesh elements are required
0142 %     if plotOPTS.do_mesh
0143 %         %plot vertices
0144 %         Plots(plotOPTS.figure).mesh=patch('Vertices',[lon,lat],'Faces',plotOPTS.mesh.tri,...
0145 %             'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0146 %
0147 %     end
0148 %     setm(gca,'MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon])
0149 %     %-----------------------------------------------------------------------
0150 %     % Only in my case it needs adding 6 because proj automatically determines a
0151 %     % reference long in strides of 6deg while m_map doesn't
0152 %     %------------------------------------------------------------------------
0153 %     pause(.2)
0154 %     if aa~=length(plotOPTS.Time_record)
0155 %         delete(Plots(plotOPTS.figure).handles(:))
0156 %     end
0157 %
0158 % end
0159 %
0160 return
0161

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