


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

0001 function [Plots]=do_vector_plot_MatlabMapC(plotOPTS,FVCOM,tt) 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 0086 %------------------------------------------------------------------------ 0087 % Select how many layers to plot 0088 %------------------------------------------------------------------------ 0089 ND=ndims(FVCOM.(plotOPTS.var_plotu)) 0090 switch ND 0091 case 2 0092 nLayers=1; 0093 colourSpec=[0 0 0]; 0094 0095 case 3 0096 if isfield(plotOPTS,'nz_plot_vec') 0097 nLayers=size(plotOPTS.nz_plot_vec,2); 0098 nLayersRange=plotOPTS.nz_plot_vec; 0099 else 0100 nLayers=size(plotOPTS.nz_plot,2); 0101 nLayersRange=plotOPTS.nz_plot; 0102 end 0103 % choose colors for vectors 0104 if nLayers==1 0105 colourSpec=[0 0 0]; 0106 else 0107 colourSpec=colormap(hsv(nLayers)); 0108 end 0109 end 0110 0111 % Preallocate outputs 0112 u=nan(size(igood,1),nLayers,1); 0113 v=nan(size(igood,1),nLayers,1); 0114 0115 % Check if we're running 0116 % for aa=1:length(plotOPTS.Time_record) 0117 aa=tt; 0118 fprintf('Time step %i of %i\n',aa,length(FVCOM.Time_record)); 0119 0120 0121 % Mesh goes underneath vectors. 0122 % if plotOPTS.do_mesh 0123 % % plot vertices 0124 % Plots(plotOPTS.figure).mesh=patch('Vertices',[double(plotOPTS.mesh.lat),double(plotOPTS.mesh.lon)],'Faces',plotOPTS.mesh.tri,... 0125 % 'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on 0126 % end 0127 0128 switch ND 0129 case 2 0130 u(:,1)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,(aa))); 0131 v(:,1)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,(aa))); 0132 case 3 0133 for ii=1:nLayers 0134 u(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotu)(igood,nLayersRange(ii),(aa))); 0135 v(:,ii)=squeeze(FVCOM.(plotOPTS.var_plotv)(igood,nLayersRange(ii),(aa))); 0136 end 0137 end 0138 for jj=1:nLayers 0139 % [Plots(plotOPTS.figure).handles{jj}]=quiver(double(plotOPTS.mesh.lonc(igood)),double(plotOPTS.mesh.latc(igood)),u,v,plotOPTS.vel_sca,'k','filled'); 0140 [Plots(plotOPTS.figure).handles{jj}]=quiverwcolorbar(double(plotOPTS.mesh.lonc(igood)),double(plotOPTS.mesh.latc(igood)),u,v,... 0141 plotOPTS.vel_sca,'bounds',plotOPTS.clims) 0142 % [Plots(plotOPTS.figure).handles{jj}]=quiverm(double(FVCOM.latc(igood)),double(FVCOM.lonc(igood)),u./100,v./100,'k',0,'filled'), 0143 % [Plots(plotOPTS.figure).handles(jj),~]=m_vec(plotOPTS.vel_sca,x(igood),y(igood),... 0144 % u(:,jj),v(:,jj),colourSpec(jj,:),... 0145 % 'shaftwidth',1,'headwidth',2); 0146 % hold on 0147 end 0148 pause(plotOPTS.pause) 0149 % if aa~=length(plotOPTS.Time_record) 0150 % delete(Plots(plotOPTS.figure).handles(:)) 0151 % end 0152 % end