Due to a shift in policy, from 0900 GMT on Wednesday 14th July 2021, we will be disabling ssh access to the server for external users. External users who wish to continue to access code repositories on the server will need to switch to using https. This can be accomplished in the following way: 1) On the repo on gitlab, use the clone dialogue and select ‘Clone with HTTPS’ to get the address of the repo; 2) From within the checkout of your repo run: $ git remote set-url origin HTTPS_ADDRESS. Here, replace HTTPS_ADDRESS with the address you have just copied from GitLab. Pulls and pushes will now require you to enter a username and password rather than using a ssh key. If you would prefer not to enter a password each time, you might consider caching your login credentials.

Commit 40602d75 authored by Pierre Cazenave's avatar Pierre Cazenave

Add updated documentation for the newly added and amended function

parent 75844713
......@@ -24,8 +24,8 @@
<h2>Subsequent directories:</h2>
<ul style="list-style-image:url(../matlabicon.gif)">
<li>mat</li><li>plots</li><li>surface_plots</li><li>timeseries</li><li>transect_plots</li></ul>
<li>plots</li><li>surface_plots</li><li>transect_plots</li></ul>
<hr><address>Generated on Tue 18-Dec-2012 12:37:29 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
<hr><address>Generated on Mon 04-Feb-2013 14:22:26 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
......@@ -51,10 +51,12 @@
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Pierre Cazenave (Plymouth Marine Laboratory)
Karen Thurston (National Oceanography Centre, Liverpool)
Revision history
Modifed from add_sponge_nodes to read in nodes from a supplied list.
2012-11-26 Add ability to turn off the figures.
2013-01-18 Added support for variable sponge radius
==============================================================================</pre></div>
......@@ -97,69 +99,76 @@ This function is called by:
0024 <span class="comment">% Author(s):</span>
0025 <span class="comment">% Geoff Cowles (University of Massachusetts Dartmouth)</span>
0026 <span class="comment">% Pierre Cazenave (Plymouth Marine Laboratory)</span>
0027 <span class="comment">%</span>
0028 <span class="comment">% Revision history</span>
0029 <span class="comment">% Modifed from add_sponge_nodes to read in nodes from a supplied list.</span>
0030 <span class="comment">% 2012-11-26 Add ability to turn off the figures.</span>
0031 <span class="comment">%</span>
0032 <span class="comment">%==============================================================================</span>
0033 subname = <span class="string">'add_sponge_nodes'</span>;
0034
0035 <span class="keyword">global</span> ftbverbose
0036 <span class="keyword">if</span>(ftbverbose)
0037 fprintf(<span class="string">'\n'</span>)
0038 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0039 <span class="keyword">end</span>
0040
0041 <span class="comment">% Do we want a figure showing how we're getting along?</span>
0042 <span class="keyword">if</span> nargin == 5
0043 plotFig = 0;
0044 <span class="keyword">end</span>
0045
0046 <span class="comment">%------------------------------------------------------------------------------</span>
0047 <span class="comment">% Plot the mesh</span>
0027 <span class="comment">% Karen Thurston (National Oceanography Centre, Liverpool)</span>
0028 <span class="comment">%</span>
0029 <span class="comment">% Revision history</span>
0030 <span class="comment">% Modifed from add_sponge_nodes to read in nodes from a supplied list.</span>
0031 <span class="comment">% 2012-11-26 Add ability to turn off the figures.</span>
0032 <span class="comment">% 2013-01-18 Added support for variable sponge radius</span>
0033 <span class="comment">%</span>
0034 <span class="comment">%==============================================================================</span>
0035 subname = <span class="string">'add_sponge_nodes'</span>;
0036
0037 <span class="keyword">global</span> ftbverbose
0038 <span class="keyword">if</span>(ftbverbose)
0039 fprintf(<span class="string">'\n'</span>)
0040 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0041 <span class="keyword">end</span>
0042
0043 <span class="comment">% Do we want a figure showing how we're getting along?</span>
0044 <span class="keyword">if</span> nargin == 5
0045 plotFig = 0;
0046 <span class="keyword">end</span>
0047
0048 <span class="comment">%------------------------------------------------------------------------------</span>
0049 <span class="keyword">if</span> plotFig == 1
0050 <span class="keyword">if</span>(lower(Mobj.nativeCoords(1:3)) == <span class="string">'car'</span>)
0051 x = Mobj.x;
0052 y = Mobj.y;
0053 <span class="keyword">else</span>
0054 x = Mobj.lon;
0055 y = Mobj.lat;
0056 <span class="keyword">end</span>
0057
0058 figure
0059 patch(<span class="string">'Vertices'</span>,[x,y],<span class="string">'Faces'</span>,Mobj.tri,<span class="keyword">...</span>
0060 <span class="string">'Cdata'</span>,Mobj.h,<span class="string">'edgecolor'</span>,<span class="string">'k'</span>,<span class="string">'facecolor'</span>,<span class="string">'interp'</span>);
0061 hold on;
0062 plot(x(SpongeList),y(SpongeList),<span class="string">'wx'</span>)
0063 axis(<span class="string">'equal'</span>,<span class="string">'tight'</span>)
0064 <span class="keyword">end</span>
0065
0066 npts = size(SpongeList,2);
0067
0068 <span class="keyword">if</span>(npts == 0)
0069 fprintf(<span class="string">'No points in given list'</span>)
0070 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0071 <span class="keyword">return</span>
0072 <span class="keyword">end</span>
0073 <span class="keyword">if</span>(ftbverbose)
0074 fprintf(<span class="string">'%d points provided\n'</span>,npts)
0049 <span class="comment">% Plot the mesh</span>
0050 <span class="comment">%------------------------------------------------------------------------------</span>
0051
0052 <span class="keyword">if</span> plotFig == 1
0053 <span class="keyword">if</span>(lower(Mobj.nativeCoords(1:3)) == <span class="string">'car'</span>)
0054 x = Mobj.x;
0055 y = Mobj.y;
0056 <span class="keyword">else</span>
0057 x = Mobj.lon;
0058 y = Mobj.lat;
0059 <span class="keyword">end</span>
0060
0061 figure
0062 patch(<span class="string">'Vertices'</span>,[x,y],<span class="string">'Faces'</span>,Mobj.tri,<span class="keyword">...</span>
0063 <span class="string">'Cdata'</span>,Mobj.h,<span class="string">'edgecolor'</span>,<span class="string">'k'</span>,<span class="string">'facecolor'</span>,<span class="string">'interp'</span>);
0064 hold on;
0065 plot(x(SpongeList),y(SpongeList),<span class="string">'wx'</span>)
0066 axis(<span class="string">'equal'</span>,<span class="string">'tight'</span>)
0067 <span class="keyword">end</span>
0068
0069 npts = length(SpongeList);
0070
0071 <span class="keyword">if</span>(npts == 0)
0072 fprintf(<span class="string">'No points in given list'</span>)
0073 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0074 <span class="keyword">return</span>
0075 <span class="keyword">end</span>
0076
0077 <span class="comment">% add to mesh object</span>
0078 Mobj.nSponge = Mobj.nSponge + 1;
0079 Mobj.nSpongeNodes(Mobj.nSponge) = npts;
0080 Mobj.sponge_nodes(Mobj.nSponge,1:npts) = SpongeList;
0081 Mobj.sponge_name{Mobj.nSponge} = SpongeName;
0082 Mobj.sponge_rad(Mobj.nSponge) = SpongeRadius;
0083 Mobj.sponge_fac(Mobj.nSponge) = SpongeCoeff;
0084
0085 <span class="keyword">if</span>(ftbverbose)
0086 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0087 <span class="keyword">end</span>
0088
0089</pre></div>
<hr><address>Generated on Tue 18-Dec-2012 12:37:31 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
0076 <span class="keyword">if</span>(ftbverbose)
0077 fprintf(<span class="string">'%d points provided\n'</span>,npts)
0078 <span class="keyword">end</span>
0079
0080 <span class="comment">% add to mesh object</span>
0081 Mobj.nSponge = Mobj.nSponge + 1;
0082 Mobj.nSpongeNodes(Mobj.nSponge) = npts;
0083 Mobj.sponge_nodes(Mobj.nSponge,1:npts) = SpongeList;
0084 Mobj.sponge_name{Mobj.nSponge} = SpongeName;
0085 Mobj.sponge_fac(Mobj.nSponge) = SpongeCoeff;
0086
0087 <span class="keyword">if</span> max(size(SpongeRadius))==1 <span class="comment">% if you have a constant sponge radius</span>
0088 Mobj.sponge_rad(Mobj.nSponge) = SpongeRadius;
0089 <span class="keyword">else</span> <span class="comment">% if you have a variable sponge radius</span>
0090 Mobj.sponge_rad(Mobj.nSponge,1:npts) = SpongeRadius;
0091 <span class="keyword">end</span>
0092
0093 <span class="keyword">if</span>(ftbverbose)
0094 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0095 <span class="keyword">end</span>
0096</pre></div>
<hr><address>Generated on Mon 04-Feb-2013 14:22:28 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of calc_sponge_radius</title>
<meta name="keywords" content="calc_sponge_radius">
<meta name="description" content="Calculate a variable sponge radius based on distance to the boundary">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt; <a href="index.html">fvcom_prepro</a> &gt; calc_sponge_radius.m</div>
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
<h1>calc_sponge_radius
</h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Calculate a variable sponge radius based on distance to the boundary</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [spongeRadius] = calc_sponge_radius(Mobj,Nlist) </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Calculate a variable sponge radius based on distance to the boundary
node's furthest neighbour.
(Adapted from Phil Hall's 'produce_netcdf_input_data.py')
spongeRadius = calc_sponge_radius(Mobj,Nlist)
DESCRIPTION
Calculates the sponge radius for each node on the open boundary, based
on the minimum of either the distance to the node's furthest
neighbour, or 100 km.
INPUT
Mobj = Matlab mesh object
Nlist = List of nodes
OUTPUT
spongeRadius = List of variable sponge radii
EXAMPLE USAGE
spongeRadius = calc_sponge_radius(Mobj,Nlist)
Author(s)
Karen Thurston (National Oceanography Centre, Liverpool)
==========================================================================</pre></div>
<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [spongeRadius] = calc_sponge_radius(Mobj,Nlist) </a>
0002
0003 <span class="comment">% Calculate a variable sponge radius based on distance to the boundary</span>
0004 <span class="comment">% node's furthest neighbour.</span>
0005 <span class="comment">% (Adapted from Phil Hall's 'produce_netcdf_input_data.py')</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% spongeRadius = calc_sponge_radius(Mobj,Nlist)</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% DESCRIPTION</span>
0010 <span class="comment">% Calculates the sponge radius for each node on the open boundary, based</span>
0011 <span class="comment">% on the minimum of either the distance to the node's furthest</span>
0012 <span class="comment">% neighbour, or 100 km.</span>
0013 <span class="comment">%</span>
0014 <span class="comment">% INPUT</span>
0015 <span class="comment">% Mobj = Matlab mesh object</span>
0016 <span class="comment">% Nlist = List of nodes</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% OUTPUT</span>
0019 <span class="comment">% spongeRadius = List of variable sponge radii</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% EXAMPLE USAGE</span>
0022 <span class="comment">% spongeRadius = calc_sponge_radius(Mobj,Nlist)</span>
0023 <span class="comment">%</span>
0024 <span class="comment">% Author(s)</span>
0025 <span class="comment">% Karen Thurston (National Oceanography Centre, Liverpool)</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%==========================================================================</span>
0028 subname = <span class="string">'calc_sponge_radius'</span>;
0029 <span class="keyword">global</span> ftbverbose
0030 <span class="keyword">if</span>(ftbverbose)
0031 fprintf(<span class="string">'\n'</span>)
0032 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0033 <span class="keyword">end</span>
0034
0035 <span class="comment">%--------------------------------------------------------------------------</span>
0036 <span class="comment">% Get a unique list and make sure they are in the range of node numbers</span>
0037 <span class="comment">%--------------------------------------------------------------------------</span>
0038 Nlist = unique(Nlist);
0039
0040 spongeRadius = 100000+zeros(size(Nlist));
0041
0042 <span class="comment">% For each node on the open boundary</span>
0043 <span class="keyword">for</span> i =1:length(Nlist)
0044 <span class="comment">% Find the neighbouring nodes</span>
0045 [r,c]=find(Mobj.tri==Nlist(i));
0046 neighbours = unique(Mobj.tri(r,:));
0047
0048 <span class="comment">% Remove the node of interest from the neighbours list</span>
0049 n = find(neighbours~=Nlist(i));
0050 neighbours = neighbours(n);
0051
0052 <span class="comment">% Calculate the arc length (in degrees) between the node and its</span>
0053 <span class="comment">% neighbours</span>
0054 arclen = distance(Mobj.lat(Nlist(i)),Mobj.lon(Nlist(i)),<span class="keyword">...</span>
0055 Mobj.lat(neighbours),Mobj.lon(neighbours));
0056
0057 <span class="comment">% Convert from degrees to whole metres</span>
0058 arclen = ceil(1000*deg2km(arclen));
0059
0060 <span class="comment">% If the smallest distance is less than 100km, keep it</span>
0061 <span class="keyword">if</span> min(arclen)&lt;spongeRadius(i)
0062 spongeRadius(i)=min(arclen);
0063 <span class="keyword">end</span>
0064 <span class="keyword">end</span>
0065
0066 <span class="keyword">if</span>(ftbverbose)
0067 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0068 <span class="keyword">end</span>
0069</pre></div>
<hr><address>Generated on Mon 04-Feb-2013 14:22:28 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of get_AMM</title>
<meta name="keywords" content="get_AMM">
<meta name="description" content="Extract boundary forcing information from NOC Operational Tide Surge">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt; <a href="index.html">fvcom_prepro</a> &gt; get_AMM.m</div>
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
<h1>get_AMM
</h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Extract boundary forcing information from NOC Operational Tide Surge</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [Mobj] = get_AMM(Mobj,StartDate,EndDate,ModelFolder) </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Extract boundary forcing information from NOC Operational Tide Surge
Model output output
function get_AMM(Mobj,StartDate,EndDate,ModelFolder)
DESCRIPTION:
Extract boundary forcing information from NOC Operational Tide Surge
Model output and interpolate to FVCOM open boundary nodes.
INPUT
Mobj = Matlab mesh object
StartDate = Start date and time for FVCOM run
EndDate = End date and time for FVCOM run
ModelFolder = Location of AMM/S12 hourly outputs
OUTPUT:
Mobj.surfaceElevation = Addition to Matlab mesh object
EXAMPLE USAGE
function get_AMM(Mobj,StartDate,EndDate,ModelFolder)
Author(s):
Karen Thurston (National Oceanography Centre Liverpool)
Revision history
2012-12-04 First version.
==============================================================================</pre></div>
<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [Mobj] = get_AMM(Mobj,StartDate,EndDate,ModelFolder)</a>
0002
0003 <span class="comment">% Extract boundary forcing information from NOC Operational Tide Surge</span>
0004 <span class="comment">% Model output output</span>
0005 <span class="comment">%</span>
0006 <span class="comment">% function get_AMM(Mobj,StartDate,EndDate,ModelFolder)</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% DESCRIPTION:</span>
0009 <span class="comment">% Extract boundary forcing information from NOC Operational Tide Surge</span>
0010 <span class="comment">% Model output and interpolate to FVCOM open boundary nodes.</span>
0011 <span class="comment">%</span>
0012 <span class="comment">% INPUT</span>
0013 <span class="comment">% Mobj = Matlab mesh object</span>
0014 <span class="comment">% StartDate = Start date and time for FVCOM run</span>
0015 <span class="comment">% EndDate = End date and time for FVCOM run</span>
0016 <span class="comment">% ModelFolder = Location of AMM/S12 hourly outputs</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% OUTPUT:</span>
0019 <span class="comment">% Mobj.surfaceElevation = Addition to Matlab mesh object</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% EXAMPLE USAGE</span>
0022 <span class="comment">% function get_AMM(Mobj,StartDate,EndDate,ModelFolder)</span>
0023 <span class="comment">%</span>
0024 <span class="comment">% Author(s):</span>
0025 <span class="comment">% Karen Thurston (National Oceanography Centre Liverpool)</span>
0026 <span class="comment">%</span>
0027 <span class="comment">% Revision history</span>
0028 <span class="comment">% 2012-12-04 First version.</span>
0029 <span class="comment">%</span>
0030 <span class="comment">%==============================================================================</span>
0031 subname = <span class="string">'get_AMM'</span>;
0032 <span class="keyword">global</span> ftbverbose;
0033 <span class="keyword">if</span>(ftbverbose);
0034 fprintf(<span class="string">'\n'</span>)
0035 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0036 <span class="keyword">end</span>;
0037
0038 <span class="comment">%% Put the open boundary nodes into a single array for convenience</span>
0039 count = 0;
0040 ObcNodes = nan(1,sum(Mobj.nObcNodes));
0041 <span class="keyword">for</span> ob=1:Mobj.nObs
0042 nObcs = Mobj.nObcNodes(ob);
0043 <span class="keyword">for</span> j=1:nObcs
0044 count = count + 1;
0045 ObcNodes(count) = Mobj.obc_nodes(ob,j); <span class="comment">% set the open boundary nodes</span>
0046 <span class="keyword">end</span>
0047 <span class="keyword">end</span>
0048
0049 <span class="comment">% Create an array of hourly timesteps</span>
0050 timesteps = datevec(datenum(StartDate):1/24:datenum(EndDate));
0051
0052 <span class="comment">% Initialise an array for the sea surface elevation</span>
0053 SurfaceElevation = nan(count,size(timesteps,1));
0054
0055 <span class="comment">% For each timestep, find the appropriate AMM/S12 file and extract the</span>
0056 <span class="comment">% surface elevation</span>
0057 <span class="keyword">for</span> i=1:size(timesteps,1)
0058 <span class="comment">% Create AMM/S12 output filename from date</span>
0059 <span class="comment">% First, accommodate Operational Model idiosyncracy about output times</span>
0060 <span class="keyword">if</span> timesteps(i,3)==1 &amp;&amp; sum(timesteps(i,4:6)) == 0
0061 tempdate = datevec(addtodate(datenum(timesteps(i,:)),-1,<span class="string">'month'</span>));
0062 AMMfile=[ModelFolder,num2str(tempdate(1)),<span class="string">'-'</span>,num2str(tempdate(2),<span class="string">'%02i'</span>),<span class="string">'.nc'</span>];
0063 <span class="keyword">else</span>
0064 AMMfile=[ModelFolder,num2str(timesteps(i,1)),<span class="string">'-'</span>,num2str(timesteps(i,2),<span class="string">'%02i'</span>),<span class="string">'.nc'</span>];
0065 <span class="keyword">end</span>
0066
0067 <span class="comment">% Convert FVCOM timestep into AMM/S12 output (seconds since</span>
0068 <span class="comment">% 20071101:000000)</span>
0069 AMM_time = etime(timesteps(i,:),[2007,11,01,0,0,0]);
0070
0071 <span class="comment">% Load the timeseries from the AMM/S12 output file</span>
0072 AMM_timeseries = ncread(AMMfile,<span class="string">'time'</span>);
0073
0074 <span class="comment">% Locate the appropriate timestep number</span>
0075 AMM_timestep = find(AMM_timeseries==AMM_time);
0076
0077 <span class="comment">% Load the sea surface elevation ouptut, lat and lon</span>
0078 AMM_elev = ncread(AMMfile,<span class="string">'zet'</span>,[1 1 AMM_timestep],[Inf Inf 1])';
0079 AMM_lat = ncread(AMMfile,<span class="string">'lat'</span>);
0080 AMM_lon = ncread(AMMfile,<span class="string">'lon'</span>);
0081
0082 <span class="comment">% Interpolate the sea surface elevation output to the open boundary</span>
0083 <span class="comment">% nodes</span>
0084 [X,Y]=meshgrid(AMM_lon,AMM_lat);
0085 SurfaceElevation(:,i) = interp2(X,Y,AMM_elev,Mobj.lon(ObcNodes),<span class="keyword">...</span>
0086 Mobj.lat(ObcNodes));
0087 <span class="keyword">end</span>
0088
0089 Mobj.surfaceElevation = SurfaceElevation;
0090
0091 <span class="keyword">if</span>(ftbverbose);
0092 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>]);
0093 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 04-Feb-2013 14:22:28 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -151,7 +151,7 @@ This function is called by:
0079 <span class="keyword">for</span> i=1:length(Mobj.Components)
0080 pPos = pInd(strcmp(Mobj.Components{i}, header.Harmonics));
0081 <span class="keyword">if</span> isempty(pPos)
0082 warning(<span class="string">'Supplied constituent (%s) is not present in the POLPRED data'</span>) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0082 warning(<span class="string">'Supplied constituent (%s) is not present in the POLPRED data'</span>, Mobj.Components{i}) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0083 <span class="keyword">else</span>
0084 <span class="comment">% Make index start at zero so the multiplication works, but</span>
0085 <span class="comment">% compensate for that once the offset has been applied. Also add</span>
......@@ -227,34 +227,37 @@ This function is called by:
0155 <span class="comment">% Mobj).</span>
0156 distance = nan(size(obc_lon));
0157 point = nan(size(distance));
0158 amp = nan(length(obc_lon), length(pIndUse));
0159 phase = nan(size(amp));
0160 <span class="keyword">for</span> i=1:length(obc_lon)
0161 radvec = sqrt((obc_lon(i)-data(:,2)).^2 + (obc_lat(i)-data(:,1)).^2);
0162 [distance(i), point(i)] = min(radvec);
0163 <span class="comment">% Get the amplitude and phase for each constituent (in order of</span>
0164 <span class="comment">% Mobj.Components).</span>
0165 amp(i, :) = data(point(i), pIndUse(:, 1));
0166 phase(i, :) = data(point(i), pIndUse(:, 2));
0167 <span class="keyword">end</span>
0168
0169 <span class="comment">% Check for and warn about NaNs (-999.9 in POLPRED data).</span>
0170 <span class="keyword">if</span> sum(amp(:)==-999.9) &gt; 0
0171 warning(<span class="string">'NaN values (-999.9 in POLPRED terms) in the amplitude data. Are your boundaries on land?'</span>) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0172 <span class="keyword">end</span>
0173 <span class="keyword">if</span> sum(phase(:)==-999.9) &gt; 0
0174 warning(<span class="string">'NaN values (-999.9 in POLPRED terms) in the phase data. Are your boundaries on land?'</span>) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0158 <span class="comment">% Omit the NaNs in the indices from POLPRED when calculating the output</span>
0159 <span class="comment">% array size.</span>
0160 amp = nan(length(obc_lon), length(pIndUse(~isnan(pIndUse(:, 1)), 1)));
0161 phase = nan(size(amp));
0162 <span class="keyword">for</span> i=1:length(obc_lon)
0163 radvec = sqrt((obc_lon(i)-data(:,2)).^2 + (obc_lat(i)-data(:,1)).^2);
0164 [distance(i), point(i)] = min(radvec);
0165 <span class="comment">% Get the amplitude and phase for each constituent (in order of</span>
0166 <span class="comment">% Mobj.Components). Check for and omit NaNs here (for missing tidal</span>
0167 <span class="comment">% constituents in the supplied list and what's given in POLPRED).</span>
0168 amp(i, :) = data(point(i), pIndUse(~isnan(pIndUse(:, 1)), 1));
0169 phase(i, :) = data(point(i), pIndUse(~isnan(pIndUse(:, 1)), 2));
0170 <span class="keyword">end</span>
0171
0172 <span class="comment">% Check for and warn about NaNs (-999.9 in POLPRED data).</span>
0173 <span class="keyword">if</span> sum(amp(:)==-999.9) &gt; 0
0174 warning(<span class="string">'NaN values (-999.9 in POLPRED terms) in the amplitude data. Are your boundaries on land?'</span>) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0175 <span class="keyword">end</span>
0176
0177 Mobj.amp = amp;
0178 Mobj.phase = phase;
0176 <span class="keyword">if</span> sum(phase(:)==-999.9) &gt; 0
0177 warning(<span class="string">'NaN values (-999.9 in POLPRED terms) in the phase data. Are your boundaries on land?'</span>) <span class="comment">%#ok&lt;WNTAG&gt;</span>
0178 <span class="keyword">end</span>
0179
0180 <span class="comment">% Plot the open boundary positions and the closest POLPRED point.</span>
0181 <span class="comment">% figure(1000)</span>
0182 <span class="comment">% plot(obc_lon, obc_lat, 'o')</span>
0183 <span class="comment">% hold on</span>
0184 <span class="comment">% plot(data(point,2), data(point,1), 'rx')</span>
0185</pre></div>
<hr><address>Generated on Tue 18-Dec-2012 12:37:31 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
0180 Mobj.amp = amp;
0181 Mobj.phase = phase;
0182
0183 <span class="comment">% Plot the open boundary positions and the closest POLPRED point.</span>
0184 <span class="comment">% figure(1000)</span>
0185 <span class="comment">% plot(obc_lon, obc_lat, 'o')</span>
0186 <span class="comment">% hold on</span>
0187 <span class="comment">% plot(data(point,2), data(point,1), 'rx')</span>
0188</pre></div>
<hr><address>Generated on Mon 04-Feb-2013 14:22:28 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -183,7 +183,11 @@ This function is called by:
0112 <span class="keyword">end</span>
0113 <span class="keyword">end</span>
0114
0115 netcdf.close(ncERA)</pre></div>
<hr><address>Generated on Tue 18-Dec-2012 12:37:31 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
0115 netcdf.close(ncERA)
0116
0117 <span class="keyword">if</span> ftbverbose;
0118 fprintf([<span class="string">'end : '</span> subname <span class="string">'\n'</span>])
0119 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 04-Feb-2013 14:22:28 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -46,8 +46,10 @@
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Karen Thurston (National Oceanography Centre, Liverpool)
Revision history
2013-01-18 Added support for variable sponge radius
==============================================================================</pre></div>
......@@ -85,46 +87,54 @@ This function is called by:
0019 <span class="comment">%</span>
0020 <span class="comment">% Author(s):</span>
0021 <span class="comment">% Geoff Cowles (University of Massachusetts Dartmouth)</span>
0022 <span class="comment">%</span>
0023 <span class="comment">% Revision history</span>
0024 <span class="comment">%</span>
0025 <span class="comment">%==============================================================================</span>
0026 subname = <span class="string">'write_FVCOM_sponge'</span>;
0027 <span class="keyword">global</span> ftbverbose
0028 <span class="keyword">if</span>(ftbverbose)
0029 fprintf(<span class="string">'\n'</span>); fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>]);
0030 <span class="keyword">end</span>;
0031
0032 <span class="comment">%------------------------------------------------------------------------------</span>
0033 <span class="comment">% Parse input arguments</span>
0022 <span class="comment">% Karen Thurston (National Oceanography Centre, Liverpool)</span>
0023 <span class="comment">%</span>
0024 <span class="comment">% Revision history</span>
0025 <span class="comment">% 2013-01-18 Added support for variable sponge radius</span>
0026 <span class="comment">%</span>
0027 <span class="comment">%==============================================================================</span>
0028 subname = <span class="string">'write_FVCOM_sponge'</span>;
0029 <span class="keyword">global</span> ftbverbose
0030 <span class="keyword">if</span>(ftbverbose)
0031 fprintf(<span class="string">'\n'</span>); fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>]);
0032 <span class="keyword">end</span>;
0033
0034 <span class="comment">%------------------------------------------------------------------------------</span>
0035 <span class="keyword">if</span>(exist(<span class="string">'Mobj'</span>)*exist(<span class="string">'filename'</span>)==0)
0036 error(<span class="string">'arguments to write_FVCOM_sponge are incorrect'</span>)
0037 <span class="keyword">end</span>;
0038
0039 <span class="comment">%------------------------------------------------------------------------------</span>
0040 <span class="comment">% Dump the file</span>
0035 <span class="comment">% Parse input arguments</span>
0036 <span class="comment">%------------------------------------------------------------------------------</span>
0037 <span class="keyword">if</span>(exist(<span class="string">'Mobj'</span>)*exist(<span class="string">'filename'</span>)==0)
0038 error(<span class="string">'arguments to write_FVCOM_sponge are incorrect'</span>)
0039 <span class="keyword">end</span>;
0040
0041 <span class="comment">%------------------------------------------------------------------------------</span>
0042 <span class="keyword">if</span>(ftbverbose); fprintf(<span class="string">'writing FVCOM spongefile %s\n'</span>,filename); <span class="keyword">end</span>;
0043 fid = fopen(filename,<span class="string">'w'</span>);
0044
0045 <span class="keyword">if</span>(Mobj.nSponge==0)