Commit 151330ef authored by Ricardo Torres's avatar Ricardo Torres 💬
Browse files

Remove split in concentrations when dividing rivers. Other more general tidy ups

parent 78013e86
......@@ -176,10 +176,10 @@ for obc_idx = 1:Mobj.nObs
Nested.nObs = Nested.nObs + 1;
Nested.obc_type(cumulative_node_idx) = conf.Nested_type(obc_idx);
if ftbverbose
% figure(1)
% scatter(Nested.x(Nested.read_obc_nodes{cumulative_node_idx}), Nested.y(Nested.read_obc_nodes{cumulative_node_idx}), 20, Nested.weight_node{cumulative_node_idx}, 'filled')
% scatter(Nested.xc(Nested.read_obc_elems{cumulative_elem_idx}), Nested.yc(Nested.read_obc_elems{cumulative_elem_idx}), 20, Nested.weight_cell{cumulative_elem_idx}, 'filled')
if ftbverbose && conf.Nested_type(obc_idx) ~= 1
% figure(1)
% scatter(Nested.x(Nested.read_obc_nodes{cumulative_node_idx}), Nested.y(Nested.read_obc_nodes{cumulative_node_idx}), 20, Nested.weight_node{cumulative_node_idx}, 'filled')
% scatter(Nested.xc(Nested.read_obc_elems{cumulative_elem_idx}), Nested.yc(Nested.read_obc_elems{cumulative_elem_idx}), 20, Nested.weight_cell{cumulative_elem_idx}, 'filled')
fprintf('Original open boundary %d\n', obc_idx)
end
......@@ -210,12 +210,12 @@ for obc_idx = 1:Mobj.nObs
end
end
if ftbverbose
% figure(1)
% scatter(Nested.x(Nested.read_obc_nodes{cumulative_node_idx}), Nested.y(Nested.read_obc_nodes{cumulative_node_idx}), 20, Nested.weight_node{cumulative_node_idx}, 'filled')
% if lev ~= conf.levels(obc_idx)
% scatter(Nested.xc(Nested.read_obc_elems{cumulative_elem_idx}), Nested.yc(Nested.read_obc_elems{cumulative_elem_idx}), 20, Nested.weight_cell{cumulative_elem_idx}, 'filled')
% end
if ftbverbose && conf.Nested_type(obc_idx) ~= 1
% figure(1)
% scatter(Nested.x(Nested.read_obc_nodes{cumulative_node_idx}), Nested.y(Nested.read_obc_nodes{cumulative_node_idx}), 20, Nested.weight_node{cumulative_node_idx}, 'filled')
% if lev ~= conf.levels(obc_idx)
% scatter(Nested.xc(Nested.read_obc_elems{cumulative_elem_idx}), Nested.yc(Nested.read_obc_elems{cumulative_elem_idx}), 20, Nested.weight_cell{cumulative_elem_idx}, 'filled')
% end
fprintf('Nested level %d\n', lev)
end
......
......@@ -283,13 +283,13 @@ for r = riv_idx
% m^{3}s^{-1} and max_discharge is 2000 m^{3}s^{-1}, then you split
% over 5 nodes.
nsplit = ceil(max(tmp_struct.river_flux) / max_discharge);
tmp_struct.river_flux = tmp_struct.river_flux / nsplit;
% Scale the data by nsplit.
for e = 1:length(enames)
if isfield(Mobj, enames{e})
tmp_struct.(enames{e}) = tmp_struct.(enames{e}) / nsplit;
end
end
% for e = 1:length(enames)
% if isfield(Mobj, enames{e})
% tmp_struct.(enames{e}) = tmp_struct.(enames{e}) / nsplit;
% end
% end
% We can keep the original node, but we need to find the
% remaining nsplit-1 nodes.
......
......@@ -65,6 +65,10 @@ if ftbverbose
fprintf('\nbegin : %s\n', subname)
end
if nargin == 0
error('Not enough input arguments. See HELP %s', subname)
end
% Run jobs on multiple workers if we have that functionality. Not sure if
% it's necessary, but check we have the Parallel Toolbox first.
wasOpened = false;
......@@ -159,13 +163,19 @@ for vv = 1:length(varlist);
tic
parfor zi = 1:fz
% Get the current depth layer's data and mask out the NaN
% values.
hytempzcurrent = hytempz(:, :, zi);
% Strip out NaNs so we can extrapolate with TriScatteredInterp.
nanmask = ~isnan(hytempzcurrent);
plonclean = plon(nanmask);
platclean = plat(nanmask);
hytempzclean = hytempzcurrent(nanmask);
% Set up the interpolation object and interpolate the
% current variable to the FVCOM unstructured grid.
% changed to do linear extrapolations
% this should work ok for biology but probably not so well
% for physical variables. Before it was 'natural' and no
% extrapolation
ft = scatteredInterpolant(plon, plat, reshape(hytempz(:, :, zi), [], 1), 'nearest','linear');
ft = scatteredInterpolant(plonclean, platclean, ...
hytempzclean, 'natural', 'nearest');
fvtemp(:, zi) = ft(flon, flat);
end
else
......
......@@ -157,14 +157,14 @@ if isfield(conf.nest,'levels')
Nweight_node = unique(nest.weight_node); % these are sorted increasing
Nweight_cell = unique(nest.weight_cell); % these are sorted increasing
nlevs = unique(conf.nest.levels);
if nlevs==conf.nest.levels
if length(Nweight_node)==conf.nest.levels
warning(['conf.nest.levels have been provided but it has the same number of levels',...
'as the original file. Nothing has changed unless you have provided new weights'])
else
% Decide how many levels to keep
warning(['Chopping levels from nesting file. Assuming unique weight values for',...
'each nesting level. If there are repeated values, this function will not work'])
levels2keepN = Nweight_node(end:-1:end-nlevs+1); % these are now decreasing in order
levels2keepN = Nweight_node(end:-1:end-nlevs); % these are now decreasing in order
levels2keepC = Nweight_cell(end:-1:end-nlevs+1); % these are now decreasing in order
% remove nodes and cells from each variable
nodeid = netcdf.inqDimID(nc2read,'node');
......
......@@ -54,12 +54,12 @@ figure(plotOPTS.figure);clf
if isfield(plotOPTS,'Lontick')
MerTick = plotOPTS.Lontick;
else
MerTick = 0.5;
MerTick = floor(10*(diff(plotOPTS.range_lon)/5))/10;
end
if isfield(plotOPTS,'Lattick')
ParTick = plotOPTS.Lattick;
else
ParTick = 0.5;
ParTick = floor(10*(diff(plotOPTS.range_lat)/5))/10;
end
axesm('mercator','MapLatLimit',plotOPTS.range_lat,'MapLonLimit',[plotOPTS.range_lon],'MeridianLabel','on',...
......
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