


Read temperature, salinity, u and v data from the HYCOM model output
structure and interpolate onto the open boundaries in Mobj.
function Mobj = get_HYCOM_tsobc(Mobj, hycom, varlist)
DESCRIPTION:
Interpolate temperature and salinity values onto the FVCOM open
boundaries at all sigma levels.
INPUT:
Mobj = MATLAB mesh structure which must contain:
- Mobj.siglayz - sigma layer depths for all model nodes.
- Mobj.siglayzc - sigma layer depths for all model elements.
- Mobj.lon, Mobj.lat - node coordinates (lat/long).
- Mobj.lonc, Mobj.latc - element coordinates (lat/long).
- Mobj.read_obc_nodes - cell array of open boundary nodes.
- Mobj.read_obc_elems - cell array of open boundary
elements (only if using velocities - use find_nested_region
to get these indices).
- Mobj.h - water depths at nodes.
- Mobj.tri - triangulation table for the grid (nv in FVCOM
terms).
- Mobj.nObcNodes - number of nodes in each open boundary.
hycom = Struct with HYCOM data covering the model domain. Unless
varlist is specified (see below), all 4D fields will be
interpolated onto the open boundaries (1-3D data will be
ignored).
varlist = [optional] cell array of variable (field) names to use from
hycom.
OUTPUT:
Mobj = MATLAB structure with new fields whose names match those given
in hycom. The fields have sizes (sum(Mobj.nObcNodes), sigma, time).
The time dimension is determined based on the number of time steps in
hycom. The ts_time variable is just the input file times in Modified
Julian Day.
EXAMPLE USAGE
hycom = get_HYCOM_forcing(Mobj, [51500, 51531]);
Mobj = get_HYCOM_tsobc(Mobj, hycom, {'u', 'v', 'temperature', 'salinity'})
Author(s):
Pierre Cazenave (Plymouth Marine Laboratory)
Revision history
2013-09-03 First version based on get_POLCOMS_tsobc.m.
2014-04-28 Update interp1 function to use pchip instead of csap as the
latter will be removed in a future version of MATLAB and the
innumerable warnings were doing my nut in. I checked the output using
the new interp1 call and it's identical to the old version. Also
update the parallel toolbox stuff for the same reason (future
removal).
2015-05-21 Remove the old parallel processing bits and replace with
the current versions.
2016-03-15 Add fallback interpolation to inverse distance weighted if
the triangular interpolation fails (which can happen if the points
supplied are all in a line, for example).
2017-01-27 Subset the coarse data (HYCOM, CMEMS etc.). This yields a
significant performance improvement (both in memory usage and time).
2017-02-16 Further performance improvement by only using the coarse
data in the vicinity of the open boundary nodes.
2017-10-12 Fix bug in indexing the open boundary positions which may
have caused the interpolation to fail as the identified positions
would be too far from the open boundary nodes.
==========================================================================

0001 function Mobj = get_HYCOM_tsobc(Mobj, hycom, varlist) 0002 % Read temperature, salinity, u and v data from the HYCOM model output 0003 % structure and interpolate onto the open boundaries in Mobj. 0004 % 0005 % function Mobj = get_HYCOM_tsobc(Mobj, hycom, varlist) 0006 % 0007 % DESCRIPTION: 0008 % Interpolate temperature and salinity values onto the FVCOM open 0009 % boundaries at all sigma levels. 0010 % 0011 % INPUT: 0012 % Mobj = MATLAB mesh structure which must contain: 0013 % - Mobj.siglayz - sigma layer depths for all model nodes. 0014 % - Mobj.siglayzc - sigma layer depths for all model elements. 0015 % - Mobj.lon, Mobj.lat - node coordinates (lat/long). 0016 % - Mobj.lonc, Mobj.latc - element coordinates (lat/long). 0017 % - Mobj.read_obc_nodes - cell array of open boundary nodes. 0018 % - Mobj.read_obc_elems - cell array of open boundary 0019 % elements (only if using velocities - use find_nested_region 0020 % to get these indices). 0021 % - Mobj.h - water depths at nodes. 0022 % - Mobj.tri - triangulation table for the grid (nv in FVCOM 0023 % terms). 0024 % - Mobj.nObcNodes - number of nodes in each open boundary. 0025 % hycom = Struct with HYCOM data covering the model domain. Unless 0026 % varlist is specified (see below), all 4D fields will be 0027 % interpolated onto the open boundaries (1-3D data will be 0028 % ignored). 0029 % varlist = [optional] cell array of variable (field) names to use from 0030 % hycom. 0031 % 0032 % OUTPUT: 0033 % Mobj = MATLAB structure with new fields whose names match those given 0034 % in hycom. The fields have sizes (sum(Mobj.nObcNodes), sigma, time). 0035 % The time dimension is determined based on the number of time steps in 0036 % hycom. The ts_time variable is just the input file times in Modified 0037 % Julian Day. 0038 % 0039 % EXAMPLE USAGE 0040 % hycom = get_HYCOM_forcing(Mobj, [51500, 51531]); 0041 % Mobj = get_HYCOM_tsobc(Mobj, hycom, {'u', 'v', 'temperature', 'salinity'}) 0042 % 0043 % Author(s): 0044 % Pierre Cazenave (Plymouth Marine Laboratory) 0045 % 0046 % Revision history 0047 % 2013-09-03 First version based on get_POLCOMS_tsobc.m. 0048 % 2014-04-28 Update interp1 function to use pchip instead of csap as the 0049 % latter will be removed in a future version of MATLAB and the 0050 % innumerable warnings were doing my nut in. I checked the output using 0051 % the new interp1 call and it's identical to the old version. Also 0052 % update the parallel toolbox stuff for the same reason (future 0053 % removal). 0054 % 2015-05-21 Remove the old parallel processing bits and replace with 0055 % the current versions. 0056 % 2016-03-15 Add fallback interpolation to inverse distance weighted if 0057 % the triangular interpolation fails (which can happen if the points 0058 % supplied are all in a line, for example). 0059 % 2017-01-27 Subset the coarse data (HYCOM, CMEMS etc.). This yields a 0060 % significant performance improvement (both in memory usage and time). 0061 % 2017-02-16 Further performance improvement by only using the coarse 0062 % data in the vicinity of the open boundary nodes. 0063 % 2017-10-12 Fix bug in indexing the open boundary positions which may 0064 % have caused the interpolation to fail as the identified positions 0065 % would be too far from the open boundary nodes. 0066 % 0067 %========================================================================== 0068 0069 % This is just a wrapper around the more generic interp_coarse_to_obc 0070 % function. This is to maintain backwards compatibility. 0071 Mobj = interp_coarse_to_obc(Mobj, hycom, varlist);