


Extract boundary forcing information from NOC Operational Tide Model
output.
function get_AMM(Mobj,StartDate,EndDate,ModelFolder)
DESCRIPTION:
Extract boundary forcing information from NOC Operational Tide
Model (no surge) 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.
==============================================================================

0001 function [Mobj] = get_AMM(Mobj,StartDate,EndDate,ModelFolder) 0002 0003 % Extract boundary forcing information from NOC Operational Tide Model 0004 % output. 0005 % 0006 % function get_AMM(Mobj,StartDate,EndDate,ModelFolder) 0007 % 0008 % DESCRIPTION: 0009 % Extract boundary forcing information from NOC Operational Tide 0010 % Model (no surge) output and interpolate to FVCOM open boundary nodes. 0011 % 0012 % INPUT 0013 % Mobj = Matlab mesh object 0014 % StartDate = Start date and time for FVCOM run 0015 % EndDate = End date and time for FVCOM run 0016 % ModelFolder = Location of AMM/S12 hourly outputs 0017 % 0018 % OUTPUT: 0019 % Mobj.surfaceElevation = Addition to Matlab mesh object 0020 % 0021 % EXAMPLE USAGE 0022 % function get_AMM(Mobj,StartDate,EndDate,ModelFolder) 0023 % 0024 % Author(s): 0025 % Karen Thurston (National Oceanography Centre Liverpool) 0026 % 0027 % Revision history 0028 % 2012-12-04 First version. 0029 % 0030 %============================================================================== 0031 subname = 'get_AMM'; 0032 global ftbverbose; 0033 if(ftbverbose); 0034 fprintf('\n') 0035 fprintf(['begin : ' subname '\n']) 0036 end; 0037 0038 %% Put the open boundary nodes into a single array for convenience 0039 count = 0; 0040 ObcNodes = nan(1,sum(Mobj.nObcNodes)); 0041 for ob=1:Mobj.nObs 0042 nObcs = Mobj.nObcNodes(ob); 0043 for j=1:nObcs 0044 count = count + 1; 0045 ObcNodes(count) = Mobj.obc_nodes(ob,j); % set the open boundary nodes 0046 end 0047 end 0048 0049 % Create an array of hourly timesteps 0050 timesteps = datevec(datenum(StartDate):1/24:datenum(EndDate)); 0051 0052 % Initialise an array for the sea surface elevation 0053 SurfaceElevation = nan(count,size(timesteps,1)); 0054 0055 % For each timestep, find the appropriate AMM/S12 file and extract the 0056 % surface elevation 0057 for i=1:size(timesteps,1) 0058 % Create AMM/S12 output filename from date 0059 % First, accommodate Operational Model idiosyncracy about output times 0060 if timesteps(i,3)==1 && sum(timesteps(i,4:6)) == 0 0061 tempdate = datevec(addtodate(datenum(timesteps(i,:)),-1,'month')); 0062 AMMfile=[ModelFolder,num2str(tempdate(1)),'-',num2str(tempdate(2),'%02i'),'.nc']; 0063 else 0064 AMMfile=[ModelFolder,num2str(timesteps(i,1)),'-',num2str(timesteps(i,2),'%02i'),'.nc']; 0065 end 0066 0067 % Convert FVCOM timestep into AMM/S12 output (seconds since 0068 % 20071101:000000) 0069 AMM_time = etime(timesteps(i,:),[2007,11,01,0,0,0]); 0070 0071 % Load the timeseries from the AMM/S12 output file 0072 AMM_timeseries = ncread(AMMfile,'time'); 0073 0074 % Locate the appropriate timestep number 0075 AMM_timestep = find(AMM_timeseries==AMM_time); 0076 0077 % Load the sea surface elevation ouptut, lat and lon 0078 AMM_elev = ncread(AMMfile,'zet',[1 1 AMM_timestep],[Inf Inf 1])'; 0079 AMM_lat = ncread(AMMfile,'lat'); 0080 AMM_lon = ncread(AMMfile,'lon'); 0081 0082 % Interpolate the sea surface elevation output to the open boundary 0083 % nodes 0084 [X,Y]=meshgrid(AMM_lon,AMM_lat); 0085 SurfaceElevation(:,i) = interp2(X,Y,AMM_elev,Mobj.lon(ObcNodes),... 0086 Mobj.lat(ObcNodes)); 0087 end 0088 0089 Mobj.surfaceElevation = SurfaceElevation; 0090 0091 if(ftbverbose); 0092 fprintf(['end : ' subname '\n']); 0093 end