Commit 7b3cfce0 authored by Pierre Cazenave's avatar Pierre Cazenave

Two things:

1. Remove the totally unnecessary loop iterating through the vertical levels on the vertical interpolation secion. No idea what that was doing there.

2. Change the interpolation of the vertical profiles to scale the POLCOMS depths to the current FVCOM node's depth range. This means the full profile structure is maintained in the interpolated profiles but that it is squashed or stretched to fit the scaled depths. This also means the surface and seabed value are fully captured.
parent e35c6705
......@@ -46,6 +46,12 @@ function Mobj = get_POLCOMS_tsobc(Mobj, ts)
%
% Revision history
% 2013-02-07 First version.
% 2013-02-27 Change the vertical interpolation to be scaled within the
% POLCOMS-ERSEM depth range for the current node. The net result is that
% the vertical profiles are squashed or stretched to fit within the
% FVCOM depths. This means the full profile structure is maintained in
% the resulting FVCOM boundary input despite the differing depths at the
% FVCOM boundary node.
%
%==========================================================================
......@@ -178,35 +184,47 @@ for t = 1:nt
% Now we've interpolated in space, we can interpolate the z-values
% to the sigma depths.
oNodes = Mobj.obc_nodes(Mobj.obc_nodes ~= 0);
for zi = 1:fz
% Preallocate the output arrays
fvtempz = nan(nf, fz);
fvsalz = nan(nf, fz);
for pp = 1:nf
% Get the FVCOM depths at this node
tfz = Mobj.siglayz(oNodes(pp), :);
% Now get the interpolated PML POLCOMS-ERSEM depth at this node
tpz = idepthz(pp, :);
% Get the temperature and salinity values for this node and
% interpolate down the water column (from PML POLCOMS-ERSEM to
% FVCOM). I had originally planned to use csaps for the
% vertical interplation/subsampling at each location. However,
% the demo of csaps in the MATLAB documentation makes the
% interpolation look horrible (shaving off extremes). interp1
% provides a range of interpolation schemes, of which pchip
% seems to do a decent job of the interpolation (at least
% qualitatively).
if ~isnan(tpz)
fvtempz(pp, :) = interp1(tpz, itempz(pp, :), tfz, 'linear', 'extrap');
fvsalz(pp, :) = interp1(tpz, isalz(pp, :), tfz, 'linear', 'extrap');
else
warning('Should never see this... ') % because we test for NaNs when fetching the values.
warning('FVCOM boundary node at %f, %f is outside the PML POLCOMS-ERSEM domain. Skipping.', fvlon(pp), fvlat(pp))
continue
end
% Preallocate the output arrays
fvtempz = nan(nf, fz);
fvsalz = nan(nf, fz);
for pp = 1:nf
% Get the FVCOM depths at this node
tfz = Mobj.siglayz(oNodes(pp), :);
% Now get the interpolated PML POLCOMS-ERSEM depth at this node
tpz = idepthz(pp, :);
% To ensure we get the full vertical expression of the vertical
% profiles, we need to normalise the POLCOMS-ERSEM and FVCOM
% depths to the same range. This is because in instances where
% FVCOM depths are shallower (e.g. in coastal regions), if we
% don't normalise the depths, we end up truncating the vertical
% profile. This approach ensures we always use the full
% vertical profile, but we're potentially squeezing it into a
% smaller depth.
A = max(tpz);
B = min(tpz);
C = max(tfz);
D = min(tfz);
norm_tpz = (((D - C) * (tpz - A)) / (B - A)) + C;
% Get the temperature and salinity values for this node and
% interpolate down the water column (from PML POLCOMS-ERSEM to
% FVCOM). I had originally planned to use csaps for the
% vertical interplation/subsampling at each location. However,
% the demo of csaps in the MATLAB documentation makes the
% interpolation look horrible (shaving off extremes). interp1
% provides a range of interpolation schemes, of which pchip
% seems to do a decent job of the interpolation (at least
% qualitatively).
if ~isnan(tpz)
fvtempz(pp, :) = interp1(norm_tpz, itempz(pp, :), tfz, 'linear', 'extrap');
fvsalz(pp, :) = interp1(norm_tpz, isalz(pp, :), tfz, 'linear', 'extrap');
else
warning('Should never see this... ') % because we test for NaNs when fetching the values.
warning('FVCOM boundary node at %f, %f is outside the PML POLCOMS-ERSEM domain. Skipping.', fvlon(pp), fvlat(pp))
continue
end
end
......
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