Commit 10eac3a5 authored by Pierre Cazenave's avatar Pierre Cazenave

Add Riqui's upstream changes

parent 64067650
function [Plots]=do_surface_plot(plotOPTS,FVCOM)
% reads image and plots tracks or stations
%
% 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
%
% OUTPUT:
% Plots = structure array with figure handles
%
% EXAMPLE USAGE
% [Plots]=do_surface_plot(plotOPTS,FVCOM)
%
% Author(s):
% Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory)
%
% Revision history
%
%==============================================================================
%
m_mappath;
% adds m_map to matlab paths. file is in utilities directory.
% amend according to your m_map installation paths
figure(plotOPTS.figure); clf
m_proj('UTM','lon',[plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',plotOPTS.zone,'ell','grs80')
figure(plotOPTS.figure);clf
% generate figure with correct projection lat and lon range ellipsoid and
% zone.
m_proj('UTM','lon',[ plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',plotOPTS.zone,'ell',plotOPTS.ell)
m_grid('box','fancy')
%m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
%[X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
X=plotOPTS.mesh.x;
Y=plotOPTS.mesh.y;
% add coastline if present
if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
end
[X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
%------------------------------------------------------------------------------
% Generate maps at a give level
%------------------------------------------------------------------------------
for aa=1:length(plotOPTS.Time_record)
% plot map with plotOPTS.var_plot
fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record));
%plot map
hold on
try
% 3D data (i.e. DYE, pH etc.)
Plots(1).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),...
'edgecolor','interp','facecolor','interp');
catch
% 2D data only (i.e. zeta etc.)
Plots(1).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,aa)),...
'edgecolor','interp','facecolor','interp');
end
fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),'edgecolor','interp','facecolor','interp');
caxis(plotOPTS.clims)
colorbar
set(get(colorbar,'YLabel'),'String',plotOPTS.var_plot)
% check if mesh elements are required
if plotOPTS.do_mesh
% plot vertices
%plot vertices
[X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
'EdgeColor',[0.6 0.6 0.6],'FaceColor','none'); hold on
Plots(plotOPTS.figure).mesh=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
end
%----------------------------------------------------------------------
% Only in my case it needs adding 6 because proj automatically
% determines a reference long in strides of 6deg while m_map doesn't
%----------------------------------------------------------------------
pause(plotOPTS.pause)
%-----------------------------------------------------------------------
% Only in my case it needs adding 6 because proj automatically determines a
% reference long in strides of 6deg while m_map doesn't
%------------------------------------------------------------------------
pause(.2)
if aa~=length(plotOPTS.Time_record)
delete(Plots(1).handles)
delete(Plots(plotOPTS.figure).handles(:))
end
end
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment