Skip to content

Commit

Permalink
Merge branch 'validPSM'
Browse files Browse the repository at this point in the history
  • Loading branch information
JonKing93 committed Mar 12, 2020
2 parents b7b58e3 + b5b31c1 commit cef8c62
Show file tree
Hide file tree
Showing 194 changed files with 13,385 additions and 12,981 deletions.
32 changes: 16 additions & 16 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
*.mlx -crlf -diff -merge
*.mat -crlf -diff -merge
*.fig -crlf -diff -merge
*.p -crlf -diff -merge
*.slx -crlf -diff -merge
*.mdl -crlf -diff -merge
*.mdlp -crlf -diff -merge
*.slxp -crlf -diff -merge
*.sldd -crlf -diff -merge
*.mexa64 -crlf -diff -merge
*.mexw64 -crlf -diff -merge
*.mexmaci64 -crlf -diff -merge
*.xlsx -crlf -diff -merge
*.docx -crlf -diff -merge
*.pdf -crlf -diff -merge
*.jpg -crlf -diff -merge
*.mlx -crlf -diff -merge
*.mat -crlf -diff -merge
*.fig -crlf -diff -merge
*.p -crlf -diff -merge
*.slx -crlf -diff -merge
*.mdl -crlf -diff -merge
*.mdlp -crlf -diff -merge
*.slxp -crlf -diff -merge
*.sldd -crlf -diff -merge
*.mexa64 -crlf -diff -merge
*.mexw64 -crlf -diff -merge
*.mexmaci64 -crlf -diff -merge
*.xlsx -crlf -diff -merge
*.docx -crlf -diff -merge
*.pdf -crlf -diff -merge
*.jpg -crlf -diff -merge
*.png -crlf -diff -merge
36 changes: 18 additions & 18 deletions 1. Grid files/@gridData/char2dims.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function[dims] = char2dims( dimChar )
% Converts a comma delimited character array of dimension names to string
dims = "";
if ~isempty(dimChar)
comma = strfind(dimChar, ',');
nDims = numel(comma) + 1;
dims = cell(1, nDims);

start = [1, comma+1];
stop = [comma-1, numel(dimChar)];

for d = 1:nDims
dims{d} = dimChar( start(d):stop(d) );
end

dims = string( dims );
end

function[dims] = char2dims( dimChar )
% Converts a comma delimited character array of dimension names to string
dims = "";
if ~isempty(dimChar)
comma = strfind(dimChar, ',');
nDims = numel(comma) + 1;
dims = cell(1, nDims);

start = [1, comma+1];
stop = [comma-1, numel(dimChar)];

for d = 1:nDims
dims{d} = dimChar( start(d):stop(d) );
end

dims = string( dims );
end

end
18 changes: 9 additions & 9 deletions 1. Grid files/@gridData/dims2char.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function[dimChar] = dims2char( dims )
% Converts a string array of dimension names to a comma delimited char
dimChar = '';
if ~isempty(dims)
dimChar = char(dims(1));
for k = 2:numel(dims)
dimChar = [dimChar,',',char(dims(k))]; %#ok<AGROW>
end
end
function[dimChar] = dims2char( dims )
% Converts a string array of dimension names to a comma delimited char
dimChar = '';
if ~isempty(dims)
dimChar = char(dims(1));
for k = 2:numel(dims)
dimChar = [dimChar,',',char(dims(k))]; %#ok<AGROW>
end
end
end
46 changes: 23 additions & 23 deletions 1. Grid files/@gridData/fullSize.m
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
function[siz] = fullSize( siz, d )
%% This gets the size of an array through a minumum number of dimensions.
%
% siz = fullSize( siz, d )
% Pads a size vector with trailing singletons through a minimum of d dimensions.
%
% ----- Inputs -----
%
% siz: A size vector
%
% d: The minimum number of dimensions.
%
% ----- Outputs -----
%
% siz: The size of the array.

% ----- Written By -----
% Jonathan King, University of Arizona, 2019

% Get the size
nDim = numel(siz);
siz(nDim+1:d) = 1;

function[siz] = fullSize( siz, d )
%% This gets the size of an array through a minumum number of dimensions.
%
% siz = fullSize( siz, d )
% Pads a size vector with trailing singletons through a minimum of d dimensions.
%
% ----- Inputs -----
%
% siz: A size vector
%
% d: The minimum number of dimensions.
%
% ----- Outputs -----
%
% siz: The size of the array.

% ----- Written By -----
% Jonathan King, University of Arizona, 2019

% Get the size
nDim = numel(siz);
siz(nDim+1:d) = 1;

end
96 changes: 48 additions & 48 deletions 1. Grid files/@gridData/gridData.m
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
classdef (Abstract) gridData
% Defines an interface for data structures that are placed in a
% gridFile container object.

properties
dimOrder; % The order of dimensions in the gridded dataset
size; % The size of the gridded dataset
mergeSet; % Maps the merged dimensions back onto unmerged dimensions
unmergedSize; % Size without any squashed dimensions
merge; % Indicates which dimensions should be merged
end

% Interface methods
methods (Abstract = true)
% Reads data from the data structure
[X] = read( obj, scs );
end

% Static Utilities
methods (Static)
% Removes trailing singletons from a size vector
siz = squeezeSize( siz );

% Returns a list of numeric types
[types] = numericTypes

% Get the size up to n dimensions
[siz] = fullSize( siz, d )

% Initial processing of merged dimensions
[umSize, mSize, uniqDim, merge, mergeSet] = processSourceDims( dimOrder, iSize )

% Actually merge data dimension
[X] = mergeDims( X, merge )

% Convert string array of dimensions to comma delimited char
dimChar = dims2char( dims );

% Convert comma delimietd char to string array of dimensions
dims = char2dims( dimChar );
end

methods
% Adjust SCS and keep for merged
[fullSCS, keep] = unmergeSCS( obj, scs )
end

end
classdef (Abstract) gridData
% Defines an interface for data structures that are placed in a
% gridFile container object.

properties
dimOrder; % The order of dimensions in the gridded dataset
size; % The size of the gridded dataset
mergeSet; % Maps the merged dimensions back onto unmerged dimensions
unmergedSize; % Size without any squashed dimensions
merge; % Indicates which dimensions should be merged
end

% Interface methods
methods (Abstract = true)
% Reads data from the data structure
[X] = read( obj, scs );
end

% Static Utilities
methods (Static)
% Removes trailing singletons from a size vector
siz = squeezeSize( siz );

% Returns a list of numeric types
[types] = numericTypes

% Get the size up to n dimensions
[siz] = fullSize( siz, d )

% Initial processing of merged dimensions
[umSize, mSize, uniqDim, merge, mergeSet] = processSourceDims( dimOrder, iSize )

% Actually merge data dimension
[X] = mergeDims( X, merge )

% Convert string array of dimensions to comma delimited char
dimChar = dims2char( dims );

% Convert comma delimietd char to string array of dimensions
dims = char2dims( dimChar );
end

methods
% Adjust SCS and keep for merged
[fullSCS, keep] = unmergeSCS( obj, scs )
end

end

56 changes: 28 additions & 28 deletions 1. Grid files/@gridData/mergeDims.m
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
function[X] = mergeDims( X, merge )

% For each set of merged dimension
mergeSet = unique( merge(~isnan(merge)) );
dimIndex = 1:numel(merge);
for m = 1:numel(mergeSet)

% Get the dimensions being merged and permute to front
dims = ( mergeSet(m) == merge );
permOrder = [dimIndex(dims), dimIndex(~dims)];
X = permute( X, permOrder );

% Reshape the merged dims. Replace secondary dimensions with singletons
% to preserve dimension order
siz = size(X);
nMerge = sum(dims);
X = reshape( X, [prod(siz(1:nMerge)), ones(1,nMerge-1), siz(nMerge+1:end)] );

% Unpermute
[~, unorder] = sort( permOrder );
X = permute( X, unorder );
end

% Remove the merged singletons
X = squeeze(X);

end

function[X] = mergeDims( X, merge )

% For each set of merged dimension
mergeSet = unique( merge(~isnan(merge)) );
dimIndex = 1:numel(merge);
for m = 1:numel(mergeSet)

% Get the dimensions being merged and permute to front
dims = ( mergeSet(m) == merge );
permOrder = [dimIndex(dims), dimIndex(~dims)];
X = permute( X, permOrder );

% Reshape the merged dims. Replace secondary dimensions with singletons
% to preserve dimension order
siz = size(X);
nMerge = sum(dims);
X = reshape( X, [prod(siz(1:nMerge)), ones(1,nMerge-1), siz(nMerge+1:end)] );

% Unpermute
[~, unorder] = sort( permOrder );
X = permute( X, unorder );
end

% Remove the merged singletons
X = squeeze(X);

end


12 changes: 6 additions & 6 deletions 1. Grid files/@gridData/numericTypes.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function[types] = numericTypes
% Returns a list of matlab numeric types.

types = ["single";"double";"int8";"uint8";"int16";"uint16";"int32";"uint32";...
"int64";"uint64"];

function[types] = numericTypes
% Returns a list of matlab numeric types.

types = ["single";"double";"int8";"uint8";"int16";"uint16";"int32";"uint32";...
"int64";"uint64"];

end
Loading

0 comments on commit cef8c62

Please sign in to comment.