Skip to content

Commit

Permalink
Adjusted try catch blocks in coordinates to allow spatial means
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKing93 committed Apr 10, 2020
1 parent 623493d commit f0b10be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion 2. State Vectors and Ensembles/@ensemble/load.m
Expand Up @@ -24,7 +24,7 @@
if isempty(loadH)
loadH = 1:obj.ensSize(1);
end
[scsRow, keepRows] = loadKeep( loadH );
[scsRow, keepRows] = loadKeep( find(loadH) );
rows = scsIndices( scsRow );

% Attempt to load the entire panel
Expand Down
34 changes: 19 additions & 15 deletions 2. State Vectors and Ensembles/@ensembleMetadata/coordinates.m
Expand Up @@ -18,25 +18,29 @@
for v = 1:numel(obj.varName)
try
latlon = obj.getLatLonSequence( obj.varName(v) );

% Replicate over a complete grid
nIndex = prod(obj.varSize(v,:));
nRep = nIndex ./ size(latlon,1);
latlon = repmat( latlon, [nRep,1] );

% Reduce if a partial grid
if obj.partialGrid(v)
latlon = latlon(obj.partialH{v}, :);
end
trycat = true;
catch
warning('Unable to determine coordinates for variable %s.', obj.varName(v));
end

% Replicate over a complete grid
nIndex = prod(obj.varSize(v,:));
nRep = nIndex ./ size(latlon,1);
latlon = repmat( latlon, [nRep,1] );

% Reduce if a partial grid
if obj.partialGrid(v)
latlon = latlon(obj.partialH{v}, :);
fprintf('Warning: Unable to determine coordinates for variable %s.\n', obj.varName(v));
trycat = false;
end

% Try concatenating the data
try
coord( obj.varIndices(obj.varName(v)), : ) = latlon;
catch
warning('Cannot concatenate coordinates for variable %s.', obj.varName(v) );
if trycat
try
coord( obj.varIndices(obj.varName(v)), : ) = latlon;
catch
fprintf('Warning: Cannot concatenate coordinates for variable %s.\n', obj.varName(v) );
end
end
end

Expand Down

0 comments on commit f0b10be

Please sign in to comment.