Home > fvcom_postproc > 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 try delete(plotOPTS.PlotoutV(plotOPTS.figure).handles{1})
0051 catch 
0052         clf
0053 end
0054 % generate figure with correct projection lat and lon range ellipsoid and
0055 % zone.
0056 if isfield(plotOPTS,'Lontick')
0057     MerTick = plotOPTS.Lontick;
0058 else
0059     MerTick = 0.5;
0060 end
0061 if isfield(plotOPTS,'Lattick')
0062     ParTick = plotOPTS.Lattick;
0063 else
0064     ParTick = 0.5;
0065 end
0066 
0067 
0068 
0069 H=axesm('mercator','MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon],'MeridianLabel','on',...
0070     'ParallelLabel','on','MLineLocation',MerTick,'PLineLocation',ParTick,'LabelUnits','dm')
0071 
0072 % add coastline if present
0073 if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
0074     if isfield (plotOPTS,'PlotoutV') && ~isempty(plotOPTS.PlotoutV(plotOPTS.figure).handles)
0075     else
0076 %     coast=load(plotOPTS.coastline_file);
0077     geoshow(plotOPTS.coastline_file,'Color','black','LineWidth',2)
0078     setm (H,'MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon])    
0079     end
0080 end
0081 %-----------------------------------------------------------------------
0082 % Convert element positions from FVCOM to lat and lon using m_ll2ll.m from
0083 % utilities directory. This accesses m_map functions.
0084 % In my case it needs adding 6 because of discrepancies between proj and m_map.
0085 % Proj automatically determines a
0086 % reference long in strides of 6deg while m_map doesn't
0087 %------------------------------------------------------------------------
0088 
0089 % only plot vectors inside lat and lon range and ...
0090 if ~isfield(plotOPTS.mesh,'latc')
0091     try 
0092         plotOPTS.mesh.latc = nodes2elems(plotOPTS.mesh.lat,plotOPTS.mesh);
0093         plotOPTS.mesh.lonc = nodes2elems(plotOPTS.mesh.lon,plotOPTS.mesh);
0094     catch
0095         disp(['We have no access to nodes2elems in the fvcom_prepro directory'])
0096     end
0097 end
0098 igood = find ( plotOPTS.mesh.lonc < plotOPTS.range_lon(2) &  plotOPTS.mesh.lonc > plotOPTS.range_lon(1) &...
0099      plotOPTS.mesh.latc < plotOPTS.range_lat(2) &   plotOPTS.mesh.latc > plotOPTS.range_lat(1));
0100 % decimate positions. Plot every plotOPTS.data_dec position.
0101 igood=igood(1:plotOPTS.data_dec:end);
0102 %------------------------------------------------------------------------
0103 % Select how many layers to plot
0104 %------------------------------------------------------------------------
0105 ND=ndims(FVCOM.(plotOPTS.var_plotu))
0106 switch ND
0107     case 2
0108         nLayers=1;
0109         colourSpec=[0 0 0];
0110         
0111     case 3
0112         if isfield(plotOPTS,'nz_plot_vec')
0113             nLayers=size(plotOPTS.nz_plot_vec,2);
0114             nLayersRange=plotOPTS.nz_plot_vec;
0115         else
0116             nLayers=size(plotOPTS.nz_plot,2);
0117             nLayersRange=plotOPTS.nz_plot;
0118         end
0119         % choose colors for vectors
0120         if nLayers==1
0121             colourSpec=[0 0 0];
0122         else
0123             colourSpec=colormap(hsv(nLayers));
0124         end
0125 end
0126 
0127 % Preallocate outputs
0128 u=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0129 v=nan(size(igood,1),nLayers,length(plotOPTS.Time_record));
0130 
0131 % Check if we're running
0132 % for aa=1:length(plotOPTS.Time_record)
0133 aa=plotOPTS.Time_record;
0134 fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
0135 
0136 
0137 % Mesh goes underneath vectors.
0138 % if plotOPTS.do_mesh
0139 %     % plot vertices
0140 %     Plots(plotOPTS.figure).mesh=patch('Vertices',[double(plotOPTS.mesh.lat),double(plotOPTS.mesh.lon)],'Faces',plotOPTS.mesh.tri,...
0141 %         'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0142 % end
0143 
0144 switch ND
0145     case 2
0146         u(:,1)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,(aa)));
0147         v(:,1)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,(aa)));
0148     case 3
0149         for ii=1:nLayers
0150             u(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,nLayersRange(ii),(aa)));
0151             v(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,nLayersRange(ii),(aa)));
0152         end
0153 end
0154 for jj=1:nLayers
0155     [Plots(plotOPTS.figure).handles{jj}]=quiverm(double(plotOPTS.mesh.latc(igood)),double(plotOPTS.mesh.lonc(igood)),u,v,'k',plotOPTS.vel_sca,'filled'),
0156 %     [Plots(plotOPTS.figure).handles{jj}]=quiverm(double(FVCOM.latc(igood)),double(FVCOM.lonc(igood)),u./100,v./100,'k',0,'filled'),
0157 %     [Plots(plotOPTS.figure).handles(jj),~]=m_vec(plotOPTS.vel_sca,x(igood),y(igood),...
0158 %         u(:,jj),v(:,jj),colourSpec(jj,:),...
0159 %         'shaftwidth',1,'headwidth',2);
0160     %         hold on
0161 end
0162 pause(plotOPTS.pause)
0163 %     if aa~=length(plotOPTS.Time_record)
0164 %         delete(Plots(plotOPTS.figure).handles(:))
0165 %     end
0166 % end

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