Commit 24229219 by Pierre Cazenave

### Update the documentation for the latest release.

parent 9ab7705d
 ... ... @@ -59,6 +59,6 @@ This function is called by: 0007 % Revision history 0008 % 0009 %==============================================================================
Generated on Wed 10-Aug-2016 16:44:39 by m2html © 2005

Generated on Thu 01-Feb-2018 09:49:00 by m2html © 2005
\ No newline at end of file
 Description of do_residual
Home > fvcom_postproc > do_residual.m

do_residual

PURPOSE

DO_RESIDUAL Takes the u and v vectors of a model output and calculates

SYNOPSIS

function [rDir,rMag,uRes,vRes]=do_residual(u,v,dt)

DESCRIPTION

DO_RESIDUAL Takes the u and v vectors of a model output and calculates
the long-term direction and magnitude for that data.

[RDIR,RMAG,URES,VRES]=DO_RESIDUAL(U,V,DT) takes the residual direction
(RDIR) and magnitude RMAG) of the data in U and V sampled at interval
DT. URES and UDIR are the summed U and V positions (the raw data for a
progresive vector diagram). Direction output is in degrees, vector
magnitude in units/s.

Pierre Cazenave PML 20/03/2012.

CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:
• do_residual_plot Take the output of do_residual and plot as a vector figure. Summarises a

SOURCE CODE

0001 function [rDir,rMag,uRes,vRes]=do_residual(u,v,dt)
0002 % DO_RESIDUAL Takes the u and v vectors of a model output and calculates
0003 % the long-term direction and magnitude for that data.
0004 %
0005 %   [RDIR,RMAG,URES,VRES]=DO_RESIDUAL(U,V,DT) takes the residual direction
0006 %   (RDIR) and magnitude RMAG) of the data in U and V sampled at interval
0007 %   DT. URES and UDIR are the summed U and V positions (the raw data for a
0008 %   progresive vector diagram). Direction output is in degrees, vector
0009 %   magnitude in units/s.
0010 %
0011 % Pierre Cazenave PML 20/03/2012.
0012 %
0013
0014 % Loosely based on my original dfsuResidual.m and processResidual function
0015 % for DHI's MIKE21 software, which in turn were based on Dave Lambkin's
0016 % residual analysis scripts.
0017 %
0018 % TODO: Make it possible to specify the average for all layers (i.e. NZ is
0019 % all layers).
0020
0021 % Let's do it...
0022
0023 toSecFactor=24*60*60;
0024
0025 nElements=size(u,1);
0026 nLayers=size(u,2);
0027 nTimeSteps=size(u,3);
0028
0029 % Some tidal assumptions. This will need to change in areas in which the
0030 % diurnal tide dominates over the semidiurnal.
0031 tideCycle=(12+(25/60))/24;
0032 tideWindow=ceil(tideCycle/dt);
0033 tideDuration=(mean((dt*nTimeSteps)-tideCycle)-mean(tideCycle))*toSecFactor;
0034
0035 % Preallocate outputs.
0036 uRes=zeros(nElements,nLayers,nTimeSteps);
0037 vRes=zeros(nElements,nLayers,nTimeSteps);
0038 uSum=nan(nElements,nTimeSteps,nLayers);
0039 vSum=nan(nElements,nTimeSteps,nLayers);
0040 uStart=nan(nElements,nLayers);
0041 vStart=nan(nElements,nLayers);
0042 uEnd=nan(nElements,nLayers);
0043 vEnd=nan(nElements,nLayers);
0044
0045 for hh=1:nLayers
0046     uSum(:,:,hh)=cumsum(squeeze(u(:,hh,:)),2);
0047     vSum(:,:,hh)=cumsum(squeeze(v(:,hh,:)),2);
0048     for ii=1:nTimeSteps;
0049         uRes(:,hh,ii)=uRes(:,hh,ii)+(uSum(:,ii,hh).*(dt*toSecFactor));
0050         vRes(:,hh,ii)=vRes(:,hh,ii)+(vSum(:,ii,hh).*(dt*toSecFactor));
0051     end
0052     uStart(:,hh)=mean(squeeze(uRes(:,hh,1:tideWindow)),2);
0053     vStart(:,hh)=mean(squeeze(vRes(:,hh,1:tideWindow)),2);
0054     uEnd(:,hh)=mean(squeeze(uRes(:,hh,end-tideWindow:end)),2);
0055     vEnd(:,hh)=mean(squeeze(vRes(:,hh,end-tideWindow:end)),2);
0056 end
0057
0058 uDiff=uEnd-uStart;
0059 vDiff=vEnd-vStart;
0060
0061 % Calculate direction and magnitude.
0062 rDir=atan2(uDiff,vDiff)*(180/pi); % in degrees.
0063 rMag=sqrt(uDiff.^2+vDiff.^2)/tideDuration; % in units/s.

Generated on Thu 01-Feb-2018 09:49:00 by m2html © 2005
\ No newline at end of file
 Description of do_residual_plot
Home > fvcom_postproc > do_residual_plot.m

do_residual_plot

PURPOSE

Take the output of do_residual and plot as a vector figure. Summarises a

SYNOPSIS

function [Plots]=do_residual_plot(plotOPTS,FVCOM,dt)

DESCRIPTION

Take the output of do_residual and plot as a vector figure. Summarises a
specified interval of time as a single long-term direction and magnitude.

CROSS-REFERENCE INFORMATION

This function calls:
• do_residual DO_RESIDUAL Takes the u and v vectors of a model output and calculates
This function is called by:

SOURCE CODE

0001 function [Plots]=do_residual_plot(plotOPTS,FVCOM,dt)
0002 % Take the output of do_residual and plot as a vector figure. Summarises a
0003 % specified interval of time as a single long-term direction and magnitude.
0004 m_mappath;
0005
0006 warning('on','FVCOM:Plot:ResidualAnalysis')
0007
0008 figure(plotOPTS.figure); clf
0009 m_proj('UTM','lon',[plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',30,'ell','grs80');
0010 m_grid('box','fancy');
0011 m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
0012 [x,y]=m_ll2ll(FVCOM.xc,FVCOM.yc); x=x+6;
0013
0014 igood = find (x < plotOPTS.range_lon(2) & x > plotOPTS.range_lon(1) &...
0015     y < plotOPTS.range_lat(2) & y > plotOPTS.range_lat(1));
0016 igood=igood(1:plotOPTS.data_dec:end);
0017
0018 if isfield(plotOPTS,'nz_plot_vec')
0019     nLayers=size(plotOPTS.nz_plot_vec,2);
0020     nLayersRange=plotOPTS.nz_plot_vec;
0021 else
0022     nLayers=size(plotOPTS.nz_plot,2);
0023     nLayersRange=plotOPTS.nz_plot;
0024 end
0025
0026 % Check we're not depth averaging values.
0027 if isfield(plotOPTS,'depth_average') && plotOPTS.depth_average
0028     if nLayers>1
0029         warning('FVCOM:Plot:ResidualAnalysis','Depth averaging has been set as well as a specific number of layers to extract. Usually one or the other is preferred.')
0030     end
0031     nLayers=1;
0032     nLayersRange=1;
0033     % Average through all depths. Don't squeeze() here as that's taken
0034     % care of in do_residual().
0035     uIn=mean(FVCOM.u,2);
0036     vIn=mean(FVCOM.v,2);
0037 else
0038     uIn=FVCOM.u(:,nLayersRange,:);
0039     vIn=FVCOM.v(:,nLayersRange,:);
0040 end
0041
0042 if nLayers==1
0043     colourSpec=[0 0 0];
0044 else
0045     colourSpec=colormap(hsv(nLayers));
0046     setColourMap=1;
0047 end
0048
0049 % We're not using uRes and vRes here, but if you wanted to do a PVD, then
0050 % you would use:
0051 %   plot(uRes(someElement,someLayer,:),vRes(someElement,someLayer,:),'.-'),
0052 % for example.
0053 [rDir,rMag,uRes,vRes]=do_residual(uIn,vIn,dt);
0054
0055 % Mesh goes underneath the vectors
0056 if plotOPTS.do_mesh
0057     % plot vertices
0058     [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0059     Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],...
0060         'Faces',plotOPTS.mesh.tri,'EdgeColor',[0.6 0.6 0.6],...
0061         'FaceColor','none'); hold on
0062 end
0063
0064 for ii=1:nLayers
0065     % Decompose to vector components for m_vec.
0066     uVec=rMag(:,ii,:).*sind(rDir(:,ii,:));
0067     vVec=rMag(:,ii,:).*cosd(rDir(:,ii,:));
0068     [Plots(plotOPTS.figure).handles(ii),~]=m_vec(plotOPTS.vel_sca,...
0069         x(igood),y(igood),squeeze(uVec(igood)),squeeze(vVec(igood)),...
0071     if exist('setColourMap','var')
0072         if setColourMap
0073             colorbar
0074             set(get(colorbar,'YLabel'),'String','Layer')
0075         end
0076     end
0077 end
0078

Generated on Thu 01-Feb-2018 09:49:00 by m2html © 2005
\ No newline at end of file
 Description of do_surface_plot
Home > fvcom_postproc > do_surface_plot.m

do_surface_plot

PURPOSE

SYNOPSIS

function [Plots]=do_surface_plot(plotOPTS,FVCOM)

DESCRIPTION

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

CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

SOURCE CODE

0001 function [Plots]=do_surface_plot(plotOPTS,FVCOM)
0002 %
0003 % Function to display color maps of FVCOM variables (i.e. temperature)
0004 %
0005 %  [Plots]=do_surface_plot(plotOPTS,FVCOM)
0006 %
0007 % DESCRIPTION:
0008 %    Generates maps of variables using m_map toolbox (patch
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_surface_plot(plotOPTS,FVCOM)
0040 %
0041 % Author(s):
0042 %    Ricardo Torres and Pierre Cazenave (Plymouth Marine Laboratory)
0043 %
0044 % Revision history
0045 %
0046 %==============================================================================
0047 %
0048 m_mappath;
0049 % adds m_map to matlab paths. file is in utilities directory.
0050 % amend according to your m_map installation paths
0051
0052 figure(plotOPTS.figure);clf
0053 % generate figure with correct projection lat and lon range ellipsoid and
0054 % zone.
0055 m_proj('UTM','lon',[ plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',plotOPTS.zone,'ell',plotOPTS.ell)
0056 m_grid('box','fancy')
0057 % add coastline if present
0058 if (isfield(plotOPTS,'coastline_file') && ~isempty(plotOPTS.coastline_file) )
0059     m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
0060 end
0061
0062 [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0063 %------------------------------------------------------------------------------
0064 % Generate maps at a give level
0065 %------------------------------------------------------------------------------
0066
0067 for aa=1:length(plotOPTS.Time_record)
0068     fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record));
0069     %plot map
0070     hold on
0071     Plots(plotOPTS.figure).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0072         'Cdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),'edgecolor','interp','facecolor','interp');
0073
0074     caxis(plotOPTS.clims)
0075     colorbar
0076     % check if mesh elements are required
0077     if plotOPTS.do_mesh
0078         %plot vertices
0079         [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0080         Plots(plotOPTS.figure).mesh=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0081             'EdgeColor',[0.6 0.6 0.6],'FaceColor','none');hold on
0082
0083     end
0084     %-----------------------------------------------------------------------
0085     % Only in my case it needs adding 6 because proj automatically determines a
0086     % reference long in strides of 6deg while m_map doesn't
0087     %------------------------------------------------------------------------
0088     pause(.2)
0089     if aa~=length(plotOPTS.Time_record)
0090         delete(Plots(plotOPTS.figure).handles(:))
0091     end
0092
0093 end
0094
0095 return
0096

Generated on Thu 01-Feb-2018 09:49:00 by m2html © 2005
\ No newline at end of file
This diff is collapsed.
 Description of do_surface_plotVel
Home > fvcom_postproc > do_surface_plotVel.m

do_surface_plotVel

PURPOSE

reads image and plots tracks or stations

SYNOPSIS

function [Plots]=do_surface_plotVel(plotOPTS,FVCOM)

DESCRIPTION

reads image and plots tracks or stations

CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

SOURCE CODE

0001 function [Plots]=do_surface_plotVel(plotOPTS,FVCOM)
0002 % reads image and plots tracks or stations
0003 m_mappath;
0004
0005 figure(plotOPTS.figure)
0006 % set(gcf,'units','normalized','outerposition',[0 0 0.5 0.5])
0007 clf
0008 m_proj('UTM','lon',[plotOPTS.range_lon],'lat',[plotOPTS.range_lat],'zon',plotOPTS.zone,'ell','grs80')
0009 m_grid('box','fancy')
0010 set(gca,'FontSize',18)
0011
0012 m_usercoast(plotOPTS.coastline_file,'Color','k','LineWidth',3);
0013 [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0014
0015
0016 if isfield(plotOPTS,'Time_record') & isfield(FVCOM,'mattime')
0017     if length(plotOPTS.Time_record)==1
0018         [dump,igoodT] = min(abs(plotOPTS.Time_record(1)-FVCOM.mattime));
0019     else
0020
0021         igoodT = find( plotOPTS.Time_record(1) <= FVCOM.mattime &   FVCOM.mattime <=  plotOPTS.Time_record(end) );
0022     end
0023 else
0024     igoodT=(1:length(FVCOM.(plotOPTS.var_plot)));
0025 end
0026
0027
0028 for aa=igoodT
0029     % plot map with plotOPTS.var_plot
0030     hold on
0031     try
0032         % 3D data (i.e. DYE, pH etc.)
0033         Plots(1).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0034             'FaceVertexCdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),...
0035             'CDataMapping','scaled','edgecolor','none','FaceColor','flat');
0036 %          Plots(1).handles=scatter(plotOPTS.mesh.xc,plotOPTS.mesh.yc,20,squeeze(FVCOM.(plotOPTS.var_plot)(:,plotOPTS.nz_plot,aa)),'filled')
0037     catch
0038         % 2D data only (i.e. zeta etc.)
0039         Plots(1).handles=patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0040             'FaceVertexCdata',squeeze(FVCOM.(plotOPTS.var_plot)(:,aa)),...
0041             'CDataMapping','scaled','edgecolor','none','FaceColor','flat');
0042 %          Plots(1).handles=scatter(plotOPTS.mesh.xc,plotOPTS.mesh.yc,20,squeeze(FVCOM.(plotOPTS.var_plot)(:,aa)),'filled')
0043     end
0044     fprintf('Time step %i of %i\n',aa,length(plotOPTS.Time_record))
0045     display(['Time ',datestr(FVCOM.mattime(aa))])
0046     caxis(plotOPTS.clims)
0047     colorbar
0048     set(get(colorbar,'YLabel'),'String',plotOPTS.var_plot,'FontSize',14)
0049     % check if mesh elements are required
0050     if plotOPTS.do_mesh
0051         % plot vertices
0052         [X,Y]=m_ll2xy(plotOPTS.mesh.lon,plotOPTS.mesh.lat,'clip','on');
0053         patch('Vertices',[X,Y],'Faces',plotOPTS.mesh.tri,...
0054             'EdgeColor',[0.6 0.6 0.6],'FaceColor','none'); hold on
0055     end
0056     %----------------------------------------------------------------------
0057     % Only in my case it needs adding 6 because proj automatically
0058     % determines a reference long in strides of 6deg while m_map doesn't
0059     %----------------------------------------------------------------------
0060    m_usercoast(plotOPTS.coastline_file,'patch',[0.6, 0.6, 0.6]);
0061    pause(plotOPTS.pause)
0062 %     if aa~=length(plotOPTS.Time_record)
0063 %         delete(Plots(1).handles)
0064 %     end
0065 end
0066
0067 return
0068

Generated on Thu 01-Feb-2018 09:49:00 by m2html © 2005
\ No newline at end of file