Home > utilities > do_vector_plot_MatlabMap.m

do_vector_plot_MatlabMap

PURPOSE ^

SYNOPSIS ^

function [Plots]=do_vector_plot_MatlabMap(plotOPTS,FVCOM)

DESCRIPTION ^

 Function to display vector maps of FVCOM currents (i.e. U,V)

  [Plots]=do_vector_plot(plotOPTS,FVCOM)

 DESCRIPTION:
    Generates vector maps of currents using m_map toolbox

 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_vector_plot_MatlabMap(plotOPTS,FVCOM)
0002 %
0003 % Function to display vector maps of FVCOM currents (i.e. U,V)
0004 %
0005 %  [Plots]=do_vector_plot(plotOPTS,FVCOM)
0006 %
0007 % DESCRIPTION:
0008 %    Generates vector maps of currents using m_map toolbox
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_vector_plot(plotOPTS,FVCOM)
0040 %
0041 % Author(s):
0042 %    Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory)
0043 %
0044 % Revision history
0045 %
0046 %==============================================================================
0047 % adds m_map to matlab paths. file is in utilities directory.
0048 % ammend according to your m_map installation paths
0049 figure(plotOPTS.figure);
0050 % generate figure with correct projection lat and lon range ellipsoid and
0051 % zone.
0052 
0053 axesm('mercator','MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon],'MeridianLabel','on',...
0054     'ParallelLabel','on','MLineLocation',[0.1],'PLineLocation',[0.1],'LabelUnits','dm')
0055 
0056 
0057 % add coastline if present
0058 if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
0059     coast=load(plotOPTS.coastline_file);
0060     geoshow([coast.ncst(:,2)],[coast.ncst(:,1)],'Color','black')
0061 
0062 end
0063 %-----------------------------------------------------------------------
0064 % Convert element positions from FVCOM to lat and lon using m_ll2ll.m from
0065 % utilities directory. This accesses m_map functions.
0066 % In my case it needs adding 6 because of discrepancies between proj and m_map.
0067 % Proj automatically determines a
0068 % reference long in strides of 6deg while m_map doesn't
0069 %------------------------------------------------------------------------
0070 
0071 % only plot vectors inside lat and lon range and ...
0072 if ~isfield(plotOPTS.mesh,'latc')
0073     try 
0074         plotOPTS.mesh.latc = nodes2elems(plotOPTS.mesh.lat,plotOPTS.mesh);
0075         plotOPTS.mesh.lonc = nodes2elems(plotOPTS.mesh.lon,plotOPTS.mesh);
0076     catch
0077         disp(['We have no access to nodes2elems in the fvcom_prepro directory'])
0078     end
0079 end
0080 igood = find ( plotOPTS.mesh.lonc < plotOPTS.range_lon(2) &  plotOPTS.mesh.lonc > plotOPTS.range_lon(1) &...
0081      plotOPTS.mesh.latc < plotOPTS.range_lat(2) &   plotOPTS.mesh.latc > plotOPTS.range_lat(1));
0082 % decimate positions. Plot every plotOPTS.data_dec position.
0083 igood=igood(1:plotOPTS.data_dec:end);
0084 %------------------------------------------------------------------------
0085 % Select how many layers to plot
0086 %------------------------------------------------------------------------
0087 ND=ndims(FVCOM.(plotOPTS.var_plotu))
0088 switch ND
0089     case 2
0090         nLayers=1;
0091         colourSpec=[0 0 0];
0092         
0093     case 3
0094         if isfield(plotOPTS,'nz_plot_vec')
0095             nLayers=size(plotOPTS.nz_plot_vec,2);
0096             nLayersRange=plotOPTS.nz_plot_vec;
0097         else
0098             nLayers=size(plotOPTS.nz_plot,2);
0099             nLayersRange=plotOPTS.nz_plot;
0100         end
0101         % choose colors for vectors
0102         if nLayers==1
0103             colourSpec=[0 0 0];
0104         else
0105             colourSpec=colormap(hsv(nLayers));
0106         end
0107 end
0108 
0109 % Preallocate outputs
0110 u=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0111 v=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0112 
0113 % Check if we're running
0114 % for aa=1:length(plotOPTS.Time_record)
0115 aa=plotOPTS.Time_record;
0116 fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
0117 
0118 
0119 % Mesh goes underneath vectors.
0120 % if plotOPTS.do_mesh
0121 %     % plot vertices
0122 %     Plots(plotOPTS.figure).mesh=patch('Vertices',[double(plotOPTS.mesh.lat),double(plotOPTS.mesh.lon)],'Faces',plotOPTS.mesh.tri,...
0123 %         'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0124 % end
0125 
0126 switch ND
0127     case 2
0128         u(:,1)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,(aa)));
0129         v(:,1)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,(aa)));
0130     case 3
0131         for ii=1:nLayers
0132             u(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,nLayersRange(ii),(aa)));
0133             v(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,nLayersRange(ii),(aa)));
0134         end
0135 end
0136 for jj=1:nLayers
0137     [Plots(plotOPTS.figure).handles{jj}]=quiverm(double(plotOPTS.mesh.latc(igood)),double(plotOPTS.mesh.lonc(igood)),u,v,'k',plotOPTS.vel_sca,'filled'),
0138 %     [Plots(plotOPTS.figure).handles{jj}]=quiverm(double(FVCOM.latc(igood)),double(FVCOM.lonc(igood)),u./100,v./100,'k',0,'filled'),
0139 %     [Plots(plotOPTS.figure).handles(jj),~]=m_vec(plotOPTS.vel_sca,x(igood),y(igood),...
0140 %         u(:,jj),v(:,jj),colourSpec(jj,:),...
0141 %         'shaftwidth',1,'headwidth',2);
0142     %         hold on
0143 end
0144 pause(plotOPTS.pause)
0145 %     if aa~=length(plotOPTS.Time_record)
0146 %         delete(Plots(plotOPTS.figure).handles(:))
0147 %     end
0148 % end

Generated on Wed 10-Aug-2016 16:44:39 by m2html © 2005