Skip to content

Commit

Permalink
Updated tutorials and debugged for run
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKing93 committed Nov 11, 2019
1 parent 865785c commit b3a0dfe
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions 1. Grid files/@gridFile/gridFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@

% Create a metadata structure for a grid or gridded data
[meta] = defineMetadata( varargin )

% Exract metadata from existing .grid file
[meta, dimID, gridSize] = meta( file );

% Create new grid file
new( filename, type, source, varName, dimOrder, atts, varargin );
grid = new( filename, type, source, varName, dimOrder, atts, varargin );

end

Expand All @@ -48,9 +51,6 @@
% Adds data to a .grid file
addData( obj, type, source, varName, dimOrder, meta );

% Exract metadata from existing .grid file
[meta, dimID, gridSize] = meta( obj );

% Increase the size of a dimension in a .grid file.
expand( obj, dim, newMeta );

Expand Down
12 changes: 6 additions & 6 deletions 1. Grid files/@gridFile/meta.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function[meta, dimID, gridSize] = meta( obj )
function[meta, dimID, gridSize] = meta( file )
%% Returns a structure with metadata for a gridded .mat file.
%
% [meta, dimID, gridSize] = gridFile.meta( file )
Expand All @@ -19,12 +19,12 @@
% ----- Written By -----
% Jonathan King, University of Arizona, 2019

% Update in case changes occured
obj.update;
% Check the file is real
grid = gridFile(file);

% Extract the output fields
meta = obj.metadata;
dimID = obj.dimOrder;
gridSize = obj.gridSize;
meta = grid.metadata;
dimID = grid.dimOrder;
gridSize = grid.gridSize;

end
5 changes: 4 additions & 1 deletion 1. Grid files/@gridFile/new.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function[] = new( filename, meta, attributes )
function[grid] = new( filename, meta, attributes )
%% Initializes a new gridded data (.grid) file. This is a container object that
% contains instructions on reading data from different sources, including:
% NetCDF files, .mat Files, and Matlab numeric arrays.
Expand Down Expand Up @@ -67,4 +67,7 @@
m.dimLimit = [];
m.valid = true;

% Return the object as output
grid = gridFile( filename );

end
2 changes: 1 addition & 1 deletion 1. Grid files/@gridFile/rewriteMetadata.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
% dimension.

% Update in case the matfile changed
obj.udpate;
obj.update;

% Check the dim is an ID
if ~isstrflag( dim )
Expand Down
2 changes: 1 addition & 1 deletion 2. State Vectors and Ensembles/@varDesign/varDesign.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
obj.file = string(file);

% Get the grid file metadata
[meta, dimID, dimSize] = gridFile.meta( file );
[meta, dimID, dimSize] = gridFile.meta( obj.file );

% Ensure that the gridfile contains all known IDs
allID = getDimIDs;
Expand Down
14 changes: 8 additions & 6 deletions 4. DA Analyses/@kalmanFilter/settings.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,20 @@
error('Cannot compute only the ensemble mean when returning full ensemble deviations.');
end

nState = size(obj.M,1);
nObs = size(obj.D,1);
if ~isempty(weights)
if strcmpi(type,'joint')
if ( ~iscell(weights) || numel(weights)~=2 )
error(['Localization weights for joint updates must be provided as the 2-element cell: {w, yloc}\n',...
'Please see dash.localizationWeights for details.'] );
elseif ~isnumeric(weights{2}) || ~isreal(weights{2}) || ~ismatrix(weights{2}) || ~isequal(size(weights{2}), [obj.nObs, obj.nObs])
error('The second element of joint localization weights must be a %.f x %.f numeric matrix', obj.nObs, obj.nObs );
elseif ~isnumeric(weights{1}) || ~isreal(weights{1}) || ~ismatrix(weights{1}) || ~isequal(size(weights{1}), [obj.nState, obj.nObs])
error('The first element of joint localization weights must be a %.f x %.f numeric matrix.', obj.nState, obj.nObs );
elseif ~isnumeric(weights{2}) || ~isreal(weights{2}) || ~ismatrix(weights{2}) || ~isequal(size(weights{2}), [nObs, nObs])
error('The second element of joint localization weights must be a %.f x %.f numeric matrix', nObs, nObs );
elseif ~isnumeric(weights{1}) || ~isreal(weights{1}) || ~ismatrix(weights{1}) || ~isequal(size(weights{1}), [nState, nObs])
error('The first element of joint localization weights must be a %.f x %.f numeric matrix.', nState, nObs );
end
elseif strcmpi(type, 'serial') && ( ~isnumeric(weights) || ~isreal(weights) || ~ismatrix(weights) || ~isequal(size(weights), [obj.nState, obj.nObs]) )
error('serial localization weights must be a %.f x %.f numeric matrix.', obj.nState, obj.nObs );
elseif strcmpi(type, 'serial') && ( ~isnumeric(weights) || ~isreal(weights) || ~ismatrix(weights) || ~isequal(size(weights), [nState, nObs]) )
error('serial localization weights must be a %.f x %.f numeric matrix.', nState, nObs );
end
end

Expand Down

0 comments on commit b3a0dfe

Please sign in to comment.