Home > utilities > do_vector_plot.m

do_vector_plot

PURPOSE ^

SYNOPSIS ^

function [Plots]=do_vector_plot(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(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 m_mappath;
0048 % adds m_map to matlab paths. file is in utilities directory.
0049 % ammend according to your m_map installation paths
0050 figure(plotOPTS.figure);
0051 % generate figure with correct projection lat and lon range ellipsoid and
0052 % zone.
0053 m_proj('UTM','lon',[plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',plotOPTS.zone,'ell',plotOPTS.ell)
0054 m_grid('box','fancy')
0055 % add coastline if present
0056 if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
0057     m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
0058 end
0059 %-----------------------------------------------------------------------
0060 % Convert element positions from FVCOM to lat and lon using m_ll2ll.m from
0061 % utilities directory. This accesses m_map functions.
0062 % In my case it needs adding 6 because of discrepancies between proj and m_map.
0063 % Proj automatically determines a
0064 % reference long in strides of 6deg while m_map doesn't
0065 %------------------------------------------------------------------------
0066 
0067 [x,y]=m_ll2ll(FVCOM.xc,FVCOM.yc); x=x+6;
0068 
0069 % only plot vectors inside lat and lon range and ...
0070 igood = find (x < plotOPTS.range_lon(2) & x > plotOPTS.range_lon(1) &...
0071     y < plotOPTS.range_lat(2) & y > plotOPTS.range_lat(1));
0072 % decimate positions. Plot every plotOPTS.data_dec position.
0073 igood=igood(1:plotOPTS.data_dec:end);
0074 %------------------------------------------------------------------------
0075 % Select how many layers to plot
0076 %------------------------------------------------------------------------
0077 if isfield(plotOPTS,'nz_plot_vec')
0078     nLayers=size(plotOPTS.nz_plot_vec,2);
0079     nLayersRange=plotOPTS.nz_plot_vec;
0080 else
0081     nLayers=size(plotOPTS.nz_plot,2);
0082     nLayersRange=plotOPTS.nz_plot;
0083 end
0084 % choose colors for vectors
0085 if nLayers==1
0086     colourSpec=[0 0 0];
0087 else
0088     colourSpec=colormap(hsv(nLayers));
0089 end
0090 
0091 % Preallocate outputs
0092 u=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0093 v=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0094 
0095 % Check if we're running
0096 for aa=1:length(plotOPTS.Time_record)
0097     fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
0098 
0099 
0100     % Mesh goes underneath vectors.
0101     if plotOPTS.do_mesh
0102         % plot vertices
0103         [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0104         Plots(plotOPTS.figure).mesh=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0105             'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0106     end
0107 
0108     for ii=1:nLayers
0109         u(:,ii)=squeeze(FVCOM.u(igood,nLayersRange(ii),(aa)));
0110         v(:,ii)=squeeze(FVCOM.v(igood,nLayersRange(ii),(aa)));
0111     end
0112     for jj=1:nLayers
0113         [Plots(plotOPTS.figure).handles(jj),~]=m_vec(plotOPTS.vel_sca,x(igood),y(igood),...
0114             u(:,jj),v(:,jj),colourSpec(jj,:),...
0115             'shaftwidth',1,'headwidth',2);
0116         hold on
0117     end
0118     pause(plotOPTS.pause)
0119     if aa~=length(plotOPTS.Time_record)
0120         delete(Plots(plotOPTS.figure).handles(:))
0121     end
0122 end

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