From: <aba...@us...> - 2012-06-22 15:04:49
|
Revision: 10664 http://octave.svn.sourceforge.net/octave/?rev=10664&view=rev Author: abarth93 Date: 2012-06-22 15:04:40 +0000 (Fri, 22 Jun 2012) Log Message: ----------- initial import of ncArray Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/private/ trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m Added: trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m 2012-06-22 15:04:40 UTC (rev 10664) @@ -0,0 +1,35 @@ +function ncarray_example_file(filename,data) + +nc = netcdf(filename,'c'); + +% dimensions + +nc('x') = size(data,1); +nc('y') = size(data,2); +nc('time') = size(data,3); + +% variables + +nc{'lon'} = ncfloat('y','x'); % 31680 elements +nc{'lon'}.long_name = ncchar('Longitude'); +nc{'lon'}.units = ncchar('degrees_east'); + +nc{'lat'} = ncfloat('y','x'); % 31680 elements +nc{'lat'}.long_name = ncchar('Latitude'); +nc{'lat'}.units = ncchar('degrees_north'); + +nc{'time'} = ncfloat('time'); % 1 elements +nc{'time'}.long_name = ncchar('Time'); +nc{'time'}.units = ncchar('days since 1858-11-17 00:00:00 GMT'); + +nc{'SST'} = ncfloat('time','y','x'); % 31680 elements +nc{'SST'}.missing_value = ncfloat(9999); +nc{'SST'}.FillValue_ = ncfloat(9999); +nc{'SST'}.units = ncchar('degC'); +nc{'SST'}.long_name = ncchar('Sea Surface Temperature'); +nc{'SST'}.coordinates = ncchar('lat lon'); + +% global attributes + +nc{'SST'}(:) = permute(data,[3 2 1]); +close(nc) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:06:04
|
Revision: 10665 http://octave.svn.sourceforge.net/octave/?rev=10665&view=rev Author: abarth93 Date: 2012-06-22 15:05:53 +0000 (Fri, 22 Jun 2012) Log Message: ----------- initial import of ncArray Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/ trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m trunk/octave-forge/extra/ncArray/inst/@CatArray/ trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m trunk/octave-forge/extra/ncArray/inst/@ncArray/ trunk/octave-forge/extra/ncArray/inst/@ncArray/display.m trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m trunk/octave-forge/extra/ncArray/inst/@ncArray/ncsub.m trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m trunk/octave-forge/extra/ncArray/inst/@ncData/ trunk/octave-forge/extra/ncArray/inst/@ncData/coord.m trunk/octave-forge/extra/ncArray/inst/@ncData/ncData.m trunk/octave-forge/extra/ncArray/inst/@ncData/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@ncData/subsref.m Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,7 @@ +% sz size of the array (with at least two elements) + +function retval = BaseArray(sz) + +self.sz = sz; + +retval = class(self,'BaseArray'); \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,3 @@ +function e = end(self,k,n) + +e = size(self,k); Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,10 @@ +function F = full(self); + +n = length(self.sz); +idx.type = '()'; + +for i=1:n + idx.subs{i} = ':'; +end + +F = subsref(self,idx); \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,8 @@ +function sz = size(self,dim) + +sz = self.sz; + +if nargin == 2 + sz = sz(dim); +end + Added: trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,70 @@ +% C = CatArray(dim,{array1,array2,...}) +% +% Create a concatenated array from a cell-list of arrays. Individual +% elements can be accessed by subscribs, e.g.: +% C(2,3) + + +function retval = CatArray(dim,arrays) + +self.dim = dim; +self.arrays = arrays; +self.na = length(arrays); + +% number of dimensions +self.nd = length(size(arrays{1})); +if dim > self.nd + self.nd = dim; +end + +self.size = ones(self.na,self.nd); +self.start = ones(self.na,self.nd); + +% get size of all arrays +for i=1:self.na + tmp = size(arrays{i}); + self.size(i,1:length(tmp)) = tmp; +end + +% check if dimensions are consistent +ncd = 1:self.nd ~= dim; +for i=2:self.na + if ~all(self.size(i,ncd) == self.size(1,ncd)) + error('Array number %d has inconsistent dimension',i); + end +end + +% start index of each sub-array + +for i=2:self.na + self.start(i,:) = self.start(i-1,:); + self.start(i,dim) = self.start(i,dim) + self.size(i-1,dim); +end + +self.end = self.start + self.size - 1; + +self.sz = self.size(1,:); +self.sz(dim) = sum(self.size(:,dim)); +self.overlap = false; +self.bounds = [0; cumsum(prod(self.size,2))]; + +retval = class(self,'CatArray',BaseArray(self.sz)); + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + + + Added: trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,6 @@ +function display(self) + +for i=1:self.na + display(self.arrays{i}) +end + \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,58 @@ +% private method + +function [idx_global,idx_local,sz] = idx_global_local_(self,idx) + +assert(strcmp(idx.type,'()')) + +n = length(size(self)); + +% number of indices must be equal to dimension +assert(length(idx.subs) == n) + +lb = ones(1,n); % lower bound +ub = ones(1,n); % upper bound +sz = ones(1,n); % size + +% transform all colons to index range +for i=1:n + if strcmp(idx.subs{i},':') + idx.subs{i} = 1:self.sz(i); + end + + lb(i) = min(idx.subs{i}); + ub(i) = max(idx.subs{i}); + sz(i) = length(idx.subs{i}); +end + +%sz = ub-lb+1; + +idx_local = cell(1,self.na); +idx_global = cell(1,self.na); + +% loop over all arrays +for j=1:self.na + idx_local{j} = idx; + idx_global{j} = idx; + + % loop over all dimensions + for i=1:n + % rebase subscribt at self.start(j,i) + tmp = idx.subs{i} - self.start(j,i) + 1; + + % only indeces within bounds of the j-th array + sel = 1 <= tmp & tmp <= self.size(j,i); + + % index for getting the data from the local j-th array + idx_local{j}.subs{i} = tmp(sel); + + % index for setting the data in the global B array + %idx_global{j}.subs{i} = idx.subs{i}(sel) - lb(i)+1; + + if sum(sel) == 0 + idx_global{j}.subs{i} = []; + else + idx_global{j}.subs{i} = (1:sum(sel)) + find(sel,1,'first') - 1; + end + end + +end Added: trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,14 @@ +function self = subsasgn(self,idx,x) + +[idx_global,idx_local,sz] = idx_global_local_(self,idx); + + + + +for j=1:self.na + % get subset from global array x + subset = subsref(x,idx_global{j}); + + % set subset in j-th array + subsasgn(self.arrays{j},idx_local{j},subset); +end \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,79 @@ +function B = subsref(self,idx) + +% handle case with a single subscript +% for example CA(234) + +if strcmp(idx.type,'()') && length(idx.subs) == 1 + % indices of elements in B + ind = idx.subs{1}; + + % output array + B = zeros(size(ind)); + B(:) = NaN; + + if self.overlap + % transform index to subscript + subs = cell(1,self.nd); + [subs{:}] = ind2sub(size(self),ind); + + % make a nice array length(ind) by self.nd + subs = cell2mat(subs); + + + % get every element + idxe.type = '()'; + idxe.subs = cell(1,self.nd); + + for i=1:length(ind) + idxe.subs = mat2cell(subs(i,:),1,ones(1,self.nd)); + %B(i) = subsref_canonical(self,idxe); + + [idx_global,idx_local,sz] = idx_global_local_(self,idxe); + tmp = zeros(sz); + tmp(:) = NaN; + + + for j=1:self.na + % get subset from j-th array + subset = subsref(self.arrays{j},idx_local{j}); + + % set subset in global array B + tmp = subsasgn(tmp,idx_global{j},subset); + end + B(i) = tmp; + + end + else + % assume all arrays does not overlap + + for j=1:self.na + sel = self.bounds(j) < ind & ind <= self.bounds(j+1); + B(sel) = self.arrays{j}(ind(sel) - self.bounds(j)); + end + + end + +else + B = subsref_canonical(self,idx); +end + +end + +% for this function we assume that idx.subs has the same dimension than +% the array + +function B = subsref_canonical(self,idx) +[idx_global,idx_local,sz] = idx_global_local_(self,idx); + +B = zeros(sz); +B(:) = NaN; + +for j=1:self.na + % get subset from j-th array + subset = subsref(self.arrays{j},idx_local{j}); + + % set subset in global array B + B = subsasgn(B,idx_global{j},subset); +end + +end \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@ncArray/display.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/display.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/display.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,4 @@ +function display(self) +disp([self.varname ' from ' self.filename]); +%self.vinfo +%self.dims Added: trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,61 @@ +% V = ncArray(filename,varname) +% V = ncArray(filename,varname,'property',value,...) +% create a ncArray that can be accessed as a normal matlab array. +% +% For read access filename can be compressed if it has the extensions +% ".gz" or ".bz2". It use the function cache_decompress to cache to +% decompressed files. +% +% Data is loaded by ncread and saved by ncwrite. Values equal to _FillValue +% are thus replaced by NaN and the scaling (add_offset and +% scale_factor) is applied during loading and saving. +% +% Properties: +% 'tooBigToLoad': if tooBigToLoad is set to true, then only the minimum +% data will be loaded. However this can be quite slow. +% +% Example: +% +% Loading the variable (assuming V is 3 dimensional): +% +% x = V(1,1,1); % load element 1,1,1 +% x = V(:,:,:); % load the complete array +% x = V(); x = full(V) % loads also the complete array +% +% Saving data in the netcdf file: +% V(1,1,1) = x; % save x in element 1,1,1 +% V(:,:,:) = x; +% +% Attributes +% units = V.units; % get attribute called "units" +% V.units = 'degree C'; % set attributes; +% +% Note: use the '.()' notation if the attribute has a leading underscore +% (due to a limitation in the matlab parser): +% +% V.('_someStrangeAttribute') = 123; +% +% see also cache_decompress + +function retval = ncArray(filename,varname,varargin) + +self.tooBigToLoad = false; +prop = varargin; + +for i=1:2:length(prop) + if strcmp(prop{i},'tooBigToLoad ') + self.tooBigToLoad = prop{i+1}; + end +end + +self.filename = filename; +self.varname = varname; + +self.vinfo = ncinfo(cached_decompress(filename),varname); +self.sz = self.vinfo.Size; + +self.dims = self.vinfo.Dimensions; +self.nd = length(self.dims); + +retval = class(self,'ncArray',BaseArray(self.sz)); +end Added: trunk/octave-forge/extra/ncArray/inst/@ncArray/ncsub.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/ncsub.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncsub.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,61 @@ +function [start, count, stride] = ncsub(self,idx) + +assert(strcmp(idx.type,'()')) + +% number of dimension (including singleton dimensions) +%n = length(size(self)); +n = self.nd; + +% number of subscripts +ns = length(idx.subs); + +if ns == 0 + % load all + start = ones(1,n); + count = self.sz; + stride = ones(1,n); +else + + start = ones(1,ns); + count = ones(1,ns); + stride = ones(1,ns); + + % sz is the size padded by 1 if more indices are given than n + sz = ones(1,ns); + sz(1:length(self.sz)) = self.sz; + + for i=1:ns + if isempty(idx.subs{i}) + count(i) = 0; + + elseif strcmp(idx.subs{i},':') + count(i) = sz(i); + + else + tmp = idx.subs{i}; + + if length(tmp) == 1 + start(i) = tmp; + else + test = tmp(1):tmp(2)-tmp(1):tmp(end); + + if all(tmp == test) + start(i) = tmp(1); + stride(i) = tmp(2)-tmp(1); + count(i) = (tmp(end)-tmp(1))/stride(i) +1; + else + error('indeces'); + end + end + end + end + + assert(all(count(n+1:end) == 1 | count(n+1:end) == 0)) + assert(all(start(n+1:end) == 1)) + + if ~any(count == 0) + count = count(1:n); + start = start(1:n); + stride = stride(1:n); + end +end \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,10 @@ +function self = subsasgn(self,idxs,x) +%idx + +idx = idxs(1); +assert(strcmp(idx.type,'()')) +[start, count, stride] = ncsub(self,idx); + +if all(count ~= 0) + ncwrite(self.filename,self.varname,x,start,stride); +end Added: trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,65 @@ +function x = subsref(self,idx) + +assert(length(idx) == 1) + +if strcmp(idx.type,'()') + % load data + + if strcmp(idx.type,'()') && length(idx.subs) == 1 ... + && length(idx.subs) < self.nd + % reference like A([2 3 1 5]) + + if self.tooBigToLoad + % number of elements in x + ind = idx.subs{1}; + + % transform index to subscript + subs = cell(1,self.nd); + [subs{:}] = ind2sub(size(self),ind); + + % make a nice array length(ind) by self.nd + subs = cell2mat(subs); + + % output array + x = zeros(size(ind)); + x(:) = NaN; + + + % get every element + % can be quite slow + idxe.type = '()'; + idxe.subs = cell(1,self.nd); + + for i=1:length(ind) + idxe.subs = mat2cell(subs(i,:),1,ones(1,self.nd)); + x(i) = subsref(self,idxe); + end + else + % load full array + tmp = full(self); + x = subsref(tmp,idx); + end + else + [start, count, stride] = ncsub(self,idx); + + if any(count == 0) + x = zeros(count); + else + x = ncread(cached_decompress(self.filename),self.varname,... + start,count,stride); + end + end +elseif strcmp(idx.type,'.') + % load attribute + name = idx.subs; + index = strmatch(name,{self.vinfo.Attributes(:).Name}); + + if isempty(index) + error('variable %s has no attribute called %s',self.varname,name); + else + x = self.vinfo.Attributes(index).Value; + end +else + error('not supported'); + +end \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@ncData/coord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/coord.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncData/coord.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,3 @@ +function c = coord(self) +c = self.coord; +%'her' \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@ncData/ncData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/ncData.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncData/ncData.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,30 @@ +% data = ncData(filename,varname) +% data = ncData(var,dims,coord) +% data with coordinate values + +function retval = ncData(varargin) + +if ischar(varargin{1}) + filename = varargin{1}; + varname = varargin{2}; + var = ncArray(filename,varname); + [dims,coord] = nccoord(cached_decompress(filename),varname); + + for i=1:length(coord) + coord(i).val = ncArray(filename,coord(i).name); + end +else + var = varargin{1}; + dims = varargin{2}; + coord = varargin{3}; +end + +self.var = var; +self.dims = dims; +self.nd = length(self.dims); +self.coord = coord; + +retval = class(self,'ncData',BaseArray(size(self.var))); + + + Added: trunk/octave-forge/extra/ncArray/inst/@ncData/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/subsasgn.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncData/subsasgn.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,3 @@ +function self = subsasgn(self,idx,x) + +self = subsasgn(self.var,idx,x); Added: trunk/octave-forge/extra/ncArray/inst/@ncData/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/subsref.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncData/subsref.m 2012-06-22 15:05:53 UTC (rev 10665) @@ -0,0 +1,32 @@ +function varargout = subsref(self,idx) + +if strcmp(idx(1).type,'()') + + % no subscripts mean that we load all () -> (:,:,...) + if isempty(idx(1).subs) + for i=1:self.nd + idx(1).subs{i} = ':'; + end + end +end + +% catch expressions like: +% data(:,:,:).coord + +if length(idx) == 2 && strcmp(idx(2).type,'.') && strcmp(idx(2).subs,'coord') + for i=1:length(self.coord) + % get indeces of the dimensions of the i-th coordinate which are also + % coordinate of the variable + + % replace dummy by ~ once older version have died + [dummy,j] = intersect(self.dims,self.coord(i).dims); + j = sort(j); + idx_c.type = '()'; + idx_c.subs = idx(1).subs(j); + + varargout{i} = subsref(self.coord(i).val,idx_c); + end +else + % pass subsref to underlying ncArray + varargout{1} = subsref(self.var,idx); +end \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:08:43
|
Revision: 10666 http://octave.svn.sourceforge.net/octave/?rev=10666&view=rev Author: abarth93 Date: 2012-06-22 15:08:33 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray@/ Removed Paths: ------------- trunk/octave-forge/extra/ncArray/inst/@ncArray/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:13:51
|
Revision: 10668 http://octave.svn.sourceforge.net/octave/?rev=10668&view=rev Author: abarth93 Date: 2012-06-22 15:13:45 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m trunk/octave-forge/extra/ncArray/inst/ncCatData.m trunk/octave-forge/extra/ncArray/inst/ncData/ncData.m trunk/octave-forge/extra/ncArray/inst/ncData/subsref.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/ncData/ Removed Paths: ------------- trunk/octave-forge/extra/ncArray/inst/@ncData/ Modified: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-06-22 15:09:28 UTC (rev 10667) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-06-22 15:13:45 UTC (rev 10668) @@ -56,7 +56,7 @@ arrays = cell(1,length(filenames)); for i=1:length(filenames) - arrays{i} = ncArray(filenames{i},varname); + arrays{i} = ncBaseArray(filenames{i},varname); end Modified: trunk/octave-forge/extra/ncArray/inst/ncCatData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:09:28 UTC (rev 10667) +++ trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:13:45 UTC (rev 10668) @@ -87,7 +87,7 @@ function CA = arr(dim,filenames,varname) arrays = cell(1,length(filenames)); for i=1:length(filenames) - arrays{i} = ncArray(filenames{i},varname); + arrays{i} = ncBaseArray(filenames{i},varname); end CA = CatArray(dim,arrays); Modified: trunk/octave-forge/extra/ncArray/inst/ncData/ncData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/ncData.m 2012-06-22 15:05:53 UTC (rev 10665) +++ trunk/octave-forge/extra/ncArray/inst/ncData/ncData.m 2012-06-22 15:13:45 UTC (rev 10668) @@ -7,11 +7,11 @@ if ischar(varargin{1}) filename = varargin{1}; varname = varargin{2}; - var = ncArray(filename,varname); + var = ncBaseArray(filename,varname); [dims,coord] = nccoord(cached_decompress(filename),varname); for i=1:length(coord) - coord(i).val = ncArray(filename,coord(i).name); + coord(i).val = ncBaseArray(filename,coord(i).name); end else var = varargin{1}; Modified: trunk/octave-forge/extra/ncArray/inst/ncData/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncData/subsref.m 2012-06-22 15:05:53 UTC (rev 10665) +++ trunk/octave-forge/extra/ncArray/inst/ncData/subsref.m 2012-06-22 15:13:45 UTC (rev 10668) @@ -27,6 +27,6 @@ varargout{i} = subsref(self.coord(i).val,idx_c); end else - % pass subsref to underlying ncArray + % pass subsref to underlying ncBaseArray varargout{1} = subsref(self.var,idx); end \ No newline at end of file Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:09:28 UTC (rev 10667) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:13:45 UTC (rev 10668) @@ -1,5 +1,5 @@ function test_ncarray() -% test ncArray, ncCatArray, ncData and ncCatData +% test ncBaseArray, ncCatArray, ncData and ncCatData varname = 'SST'; @@ -30,12 +30,12 @@ assert(isequalwithequalnans(test,SST_ref)) -%%% test ncArray +%%% test ncBaseArray % reading copyfile(files{2},tmpfname); -SST = ncArray(tmpfname,varname); +SST = ncBaseArray(tmpfname,varname); test = SST(:,:,:); SST_ref = ncread(tmpfname,varname); @@ -63,9 +63,9 @@ % reading CA = CatArray(3,{... - ncArray(filename,varname),... - ncArray(files{2},varname),... - ncArray(files{3},varname)... + ncBaseArray(filename,varname),... + ncBaseArray(files{2},varname),... + ncBaseArray(files{3},varname)... }); assert(isequalwithequalnans(size(CA),[220 144 3])) @@ -84,9 +84,9 @@ assert(isequalwithequalnans(SST_test,SST_ref)) CA2 = CatArray(4,{... - ncArray(files{1},varname),... - ncArray(files{2},varname),... - ncArray(files{3},varname)... + ncBaseArray(files{1},varname),... + ncBaseArray(files{2},varname),... + ncBaseArray(files{3},varname)... }); SST_test = CA2(:,:,:,2); @@ -164,17 +164,17 @@ if 1 % test ncData (constructor: ncData(var,dims,coord) - SST = ncArray(filename,varname); + SST = ncBaseArray(filename,varname); SST_ref = ncread(filename,varname); lon_ref = ncread(filename,'lon'); - coord(1).val = ncArray(filename,'lon'); + coord(1).val = ncBaseArray(filename,'lon'); coord(1).dims = {'x','y'}; - coord(2).val = ncArray(filename,'lat'); + coord(2).val = ncBaseArray(filename,'lat'); coord(2).dims = {'x','y'}; - coord(3).val = ncArray(filename,'time'); + coord(3).val = ncBaseArray(filename,'time'); coord(3).dims = {'time'}; data = ncData(SST,{'x','y','time'},coord); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:15:27
|
Revision: 10669 http://octave.svn.sourceforge.net/octave/?rev=10669&view=rev Author: abarth93 Date: 2012-06-22 15:15:16 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/ncCatData.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@ncArray/ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m Removed Paths: ------------- trunk/octave-forge/extra/ncArray/inst/@ncArray/ncData.m trunk/octave-forge/extra/ncArray/inst/ncData/ Copied: trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m (from rev 10668, trunk/octave-forge/extra/ncArray/inst/ncData/ncData.m) =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m 2012-06-22 15:15:16 UTC (rev 10669) @@ -0,0 +1,30 @@ +% data = ncArray(filename,varname) +% data = ncArray(var,dims,coord) +% data with coordinate values + +function retval = ncArray(varargin) + +if ischar(varargin{1}) + filename = varargin{1}; + varname = varargin{2}; + var = ncBaseArray(filename,varname); + [dims,coord] = nccoord(cached_decompress(filename),varname); + + for i=1:length(coord) + coord(i).val = ncBaseArray(filename,coord(i).name); + end +else + var = varargin{1}; + dims = varargin{2}; + coord = varargin{3}; +end + +self.var = var; +self.dims = dims; +self.nd = length(self.dims); +self.coord = coord; + +retval = class(self,'ncArray',BaseArray(size(self.var))); + + + Deleted: trunk/octave-forge/extra/ncArray/inst/@ncArray/ncData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncData/ncData.m 2012-06-22 15:13:45 UTC (rev 10668) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncData.m 2012-06-22 15:15:16 UTC (rev 10669) @@ -1,30 +0,0 @@ -% data = ncData(filename,varname) -% data = ncData(var,dims,coord) -% data with coordinate values - -function retval = ncData(varargin) - -if ischar(varargin{1}) - filename = varargin{1}; - varname = varargin{2}; - var = ncBaseArray(filename,varname); - [dims,coord] = nccoord(cached_decompress(filename),varname); - - for i=1:length(coord) - coord(i).val = ncBaseArray(filename,coord(i).name); - end -else - var = varargin{1}; - dims = varargin{2}; - coord = varargin{3}; -end - -self.var = var; -self.dims = dims; -self.nd = length(self.dims); -self.coord = coord; - -retval = class(self,'ncData',BaseArray(size(self.var))); - - - Modified: trunk/octave-forge/extra/ncArray/inst/ncCatData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:13:45 UTC (rev 10668) +++ trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:15:16 UTC (rev 10669) @@ -79,7 +79,7 @@ end end -data = ncData(var,dims,coord); +data = ncArray(var,dims,coord); end Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:13:45 UTC (rev 10668) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:15:16 UTC (rev 10669) @@ -1,5 +1,5 @@ function test_ncarray() -% test ncBaseArray, ncCatArray, ncData and ncCatData +% test ncBaseArray, ncCatArray, ncArray and ncCatData varname = 'SST'; @@ -162,7 +162,7 @@ if 1 - % test ncData (constructor: ncData(var,dims,coord) + % test ncArray (constructor: ncData(var,dims,coord) SST = ncBaseArray(filename,varname); SST_ref = ncread(filename,varname); @@ -177,7 +177,7 @@ coord(3).val = ncBaseArray(filename,'time'); coord(3).dims = {'time'}; - data = ncData(SST,{'x','y','time'},coord); + data = ncArray(SST,{'x','y','time'},coord); [x,y,t] = data(:,:,:).coord; @@ -192,8 +192,8 @@ [x,y,t] = data(1:3:end,:,:).coord; assert(isequalwithequalnans(x,lon_ref(1:3:end,:))) - % test ncData (constructor: ncData(filename,varname) - SST = ncData(filename,varname); + % test ncArray (constructor: ncData(filename,varname) + SST = ncArray(filename,varname); [x,y,t] = data(:,:,:).coord; assert(isequalwithequalnans(data(:,:,:),SST_ref)) @@ -218,7 +218,7 @@ zname = [tmpfname '.gz']; system(['gzip --stdout ' tmpfname ' > ' zname]); -SST = ncData(zname,'SST'); +SST = ncArray(zname,'SST'); SST_ref = ncread(tmpfname,'SST'); assert(isequalwithequalnans(SST(),SST_ref)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:20:44
|
Revision: 10671 http://octave.svn.sourceforge.net/octave/?rev=10671&view=rev Author: abarth93 Date: 2012-06-22 15:20:33 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m Removed Paths: ------------- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m trunk/octave-forge/extra/ncArray/inst/ncCatData.m Deleted: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-06-22 15:16:45 UTC (rev 10670) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-06-22 15:20:33 UTC (rev 10671) @@ -1,81 +0,0 @@ -% C = ncCatArray(dim,filenames,varname) -% C = ncCatArray(dim,pattern,varname) -% C = ncCatArray(dim,filenamefun,varname,range) -% -% create a concatenated array from variables (varname) in a list of -% netcdf files along dimension dim.Individual elements can be accessed by -% subscribs, e.g. C(2,3) and the corrsponding subset of the appropriate file is loaded -% -% This list of netcdf files can be specified as a cell array (filenames), -% shell wildcard pattern (e.g. file_*.nc) or a function handle -% filenamefun. In this later case, this i-th filename is -% filenamefun(range(i)). -% -% Example: -% -% data = ncCatArray(3,{'file-20120708.nc','file-20120709.nc'},'SST') -% -% data = ncCatArray(3,'file-*.nc','SST') -% -% data = ncCatArray(3,@(t) ['file-' datestr(t,'yyyymmdd') '.nc'],... -% datenum(2012,07,08):datenum(2012,07,09)); -% -% Note: in Octave the glob function is used to determine files matching the -% shell wildcard pattern, while in Matlab rdir is used. The function rdir -% is available from Matlab exchange under BSD license -% (http://www.mathworks.com/matlabcentral/fileexchange/19550). - -% Author: Alexander Barth (bar...@gm...) -% -function ncCA = ncCatArray(dim,pattern,varname,range) - -if iscell(pattern) - filenames = pattern; - -elseif ischar(pattern) - try - filenames = glob(pattern); - catch - try - d = rdir(pattern); - filenames = {d(:).name}; - catch - error(['The function rdir or glob (octave) is not available. '... - 'rdir can be installed from '... - 'http://www.mathworks.com/matlabcentral/fileexchange/19550']); - end - end -elseif isa(pattern, 'function_handle') - filenames = cell(1,length(range)); - - for i=1:length(range) - filenames{i} = pattern(range(i)); - end -end - -arrays = cell(1,length(filenames)); - -for i=1:length(filenames) - arrays{i} = ncBaseArray(filenames{i},varname); -end - - -ncCA = CatArray(dim,arrays); - -% Copyright (C) 2012 Alexander Barth <bar...@gm...> -% -% This program is free software; you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 2 of the License, or -% (at your option) any later version. -% -% This program is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this program; If not, see <http://www.gnu.org/licenses/>. - - - Copied: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m (from rev 10669, trunk/octave-forge/extra/ncArray/inst/ncCatData.m) =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-06-22 15:20:33 UTC (rev 10671) @@ -0,0 +1,111 @@ +% C = ncCatArray(dim,filenames,varname) +% C = ncCatArray(dim,pattern,varname) +% C = ncCatArray(dim,filenamefun,varname,range) +% +% create a concatenated array from variables (varname) in a list of +% netcdf files along dimension dim.Individual elements can be accessed by +% subscribs, e.g. C(2,3) and the corrsponding subset of the appropriate file is loaded + +% This list of netcdf files can be specified as a cell array (filenames), +% shell wildcard pattern (e.g. file_*.nc) or a function handle +% filenamefun. In this later case, this i-th filename is +% filenamefun(range(i)). +% +% Example: +% +% data = ncCatArray(3,{'file-20120708.nc','file-20120709.nc'},'SST') +% +% data = ncCatArray(3,'file-*.nc','SST') +% +% data = ncCatArray(3,@(t) ['file-' datestr(t,'yyyymmdd') '.nc'],... +% datenum(2012,07,08):datenum(2012,07,09)); +% +% Note: in Octave the glob function is used to determine files matching the +% shell wildcard pattern, while in Matlab rdir is used. The function rdir +% is available from Matlab exchange under BSD license +% (http://www.mathworks.com/matlabcentral/fileexchange/19550). + +% Author: Alexander Barth (bar...@gm...) +% +function data = ncCatArray(dim,pattern,varname,range) + +catdimname = '_cat_dim'; + +if iscell(pattern) + filenames = pattern; + +elseif ischar(pattern) + try + filenames = glob(pattern); + catch + try + d = rdir(pattern); + filenames = {d(:).name}; + catch + error(['The function rdir or glob (octave) is not available. '... + 'rdir can be installed from '... + 'http://www.mathworks.com/matlabcentral/fileexchange/19550']); + end + end +elseif isa(pattern, 'function_handle') + filenames = cell(1,length(range)); + + for i=1:length(range) + filenames{i} = pattern(range(i)); + end +end + +if nargin == 3 + range = 1:length(filenames); +end + +var = arr(dim,filenames,varname); + +[dims,coord] = nccoord(cached_decompress(filenames{1}),varname); + +if dim > length(dims) + % concatenate is new dimension + dims{dim} = catdimname; + coord(dim).dims = {catdimname}; + coord(dim).val = range; +end + + +for i=1:length(coord) + % coordinates do also depend on the dimension only which we concatenate + coord(i).val = arr(dim,filenames,coord(i).name); + if dim > length(coord(i).dims) + coord(i).dims{dim} = catdimname; + end +end + +data = ncArray(var,dims,coord); + +end + + +function CA = arr(dim,filenames,varname) +arrays = cell(1,length(filenames)); +for i=1:length(filenames) + arrays{i} = ncBaseArray(filenames{i},varname); +end + +CA = CatArray(dim,arrays); +end +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + + + Deleted: trunk/octave-forge/extra/ncArray/inst/ncCatData.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:16:45 UTC (rev 10670) +++ trunk/octave-forge/extra/ncArray/inst/ncCatData.m 2012-06-22 15:20:33 UTC (rev 10671) @@ -1,111 +0,0 @@ -% C = ncCatArray(dim,filenames,varname) -% C = ncCatArray(dim,pattern,varname) -% C = ncCatArray(dim,filenamefun,varname,range) -% -% create a concatenated array from variables (varname) in a list of -% netcdf files along dimension dim.Individual elements can be accessed by -% subscribs, e.g. C(2,3) and the corrsponding subset of the appropriate file is loaded - -% This list of netcdf files can be specified as a cell array (filenames), -% shell wildcard pattern (e.g. file_*.nc) or a function handle -% filenamefun. In this later case, this i-th filename is -% filenamefun(range(i)). -% -% Example: -% -% data = ncCatArray(3,{'file-20120708.nc','file-20120709.nc'},'SST') -% -% data = ncCatArray(3,'file-*.nc','SST') -% -% data = ncCatArray(3,@(t) ['file-' datestr(t,'yyyymmdd') '.nc'],... -% datenum(2012,07,08):datenum(2012,07,09)); -% -% Note: in Octave the glob function is used to determine files matching the -% shell wildcard pattern, while in Matlab rdir is used. The function rdir -% is available from Matlab exchange under BSD license -% (http://www.mathworks.com/matlabcentral/fileexchange/19550). - -% Author: Alexander Barth (bar...@gm...) -% -function data = ncCatData(dim,pattern,varname,range) - -catdimname = '_cat_dim'; - -if iscell(pattern) - filenames = pattern; - -elseif ischar(pattern) - try - filenames = glob(pattern); - catch - try - d = rdir(pattern); - filenames = {d(:).name}; - catch - error(['The function rdir or glob (octave) is not available. '... - 'rdir can be installed from '... - 'http://www.mathworks.com/matlabcentral/fileexchange/19550']); - end - end -elseif isa(pattern, 'function_handle') - filenames = cell(1,length(range)); - - for i=1:length(range) - filenames{i} = pattern(range(i)); - end -end - -if nargin == 3 - range = 1:length(filenames); -end - -var = arr(dim,filenames,varname); - -[dims,coord] = nccoord(cached_decompress(filenames{1}),varname); - -if dim > length(dims) - % concatenate is new dimension - dims{dim} = catdimname; - coord(dim).dims = {catdimname}; - coord(dim).val = range; -end - - -for i=1:length(coord) - % coordinates do also depend on the dimension only which we concatenate - coord(i).val = arr(dim,filenames,coord(i).name); - if dim > length(coord(i).dims) - coord(i).dims{dim} = catdimname; - end -end - -data = ncArray(var,dims,coord); - -end - - -function CA = arr(dim,filenames,varname) -arrays = cell(1,length(filenames)); -for i=1:length(filenames) - arrays{i} = ncBaseArray(filenames{i},varname); -end - -CA = CatArray(dim,arrays); -end -% Copyright (C) 2012 Alexander Barth <bar...@gm...> -% -% This program is free software; you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 2 of the License, or -% (at your option) any later version. -% -% This program is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this program; If not, see <http://www.gnu.org/licenses/>. - - - Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:16:45 UTC (rev 10670) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-22 15:20:33 UTC (rev 10671) @@ -1,5 +1,5 @@ function test_ncarray() -% test ncBaseArray, ncCatArray, ncArray and ncCatData +% test ncBaseArray, ncCatArray, ncArray and ncCatArray varname = 'SST'; @@ -224,7 +224,7 @@ -CA2 = ncCatData(3,fullfile(tmpdir,'file*nc'),varname); +CA2 = ncCatArray(3,fullfile(tmpdir,'file*nc'),varname); SST_test = CA2(:,:,2); SST_ref = ncread(files{2},'SST'); assert(isequalwithequalnans(SST_test,SST_ref)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-22 15:52:42
|
Revision: 10673 http://octave.svn.sourceforge.net/octave/?rev=10673&view=rev Author: abarth93 Date: 2012-06-22 15:52:36 +0000 (Fri, 22 Jun 2012) Log Message: ----------- Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m Added: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m 2012-06-22 15:52:36 UTC (rev 10673) @@ -0,0 +1,4 @@ +function display(self) +disp([self.varname ' from ' self.filename]); +%self.vinfo +%self.dims Added: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-06-22 15:52:36 UTC (rev 10673) @@ -0,0 +1,62 @@ +% V = ncBaseArray(filename,varname) +% V = ncBaseArray(filename,varname,'property',value,...) +% create a ncBaseArray that can be accessed as a normal matlab array. +% Ths object is a helper object. Users should normally call ncArray. +% +% For read access filename can be compressed if it has the extensions +% ".gz" or ".bz2". It use the function cache_decompress to cache to +% decompressed files. +% +% Data is loaded by ncread and saved by ncwrite. Values equal to _FillValue +% are thus replaced by NaN and the scaling (add_offset and +% scale_factor) is applied during loading and saving. +% +% Properties: +% 'tooBigToLoad': if tooBigToLoad is set to true, then only the minimum +% data will be loaded. However this can be quite slow. +% +% Example: +% +% Loading the variable (assuming V is 3 dimensional): +% +% x = V(1,1,1); % load element 1,1,1 +% x = V(:,:,:); % load the complete array +% x = V(); x = full(V) % loads also the complete array +% +% Saving data in the netcdf file: +% V(1,1,1) = x; % save x in element 1,1,1 +% V(:,:,:) = x; +% +% Attributes +% units = V.units; % get attribute called "units" +% V.units = 'degree C'; % set attributes; +% +% Note: use the '.()' notation if the attribute has a leading underscore +% (due to a limitation in the matlab parser): +% +% V.('_someStrangeAttribute') = 123; +% +% see also cache_decompress + +function retval = ncBaseArray(filename,varname,varargin) + +self.tooBigToLoad = false; +prop = varargin; + +for i=1:2:length(prop) + if strcmp(prop{i},'tooBigToLoad ') + self.tooBigToLoad = prop{i+1}; + end +end + +self.filename = filename; +self.varname = varname; + +self.vinfo = ncinfo(cached_decompress(filename),varname); +self.sz = self.vinfo.Size; + +self.dims = self.vinfo.Dimensions; +self.nd = length(self.dims); + +retval = class(self,'ncBaseArray',BaseArray(self.sz)); +end Added: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m 2012-06-22 15:52:36 UTC (rev 10673) @@ -0,0 +1,61 @@ +function [start, count, stride] = ncsub(self,idx) + +assert(strcmp(idx.type,'()')) + +% number of dimension (including singleton dimensions) +%n = length(size(self)); +n = self.nd; + +% number of subscripts +ns = length(idx.subs); + +if ns == 0 + % load all + start = ones(1,n); + count = self.sz; + stride = ones(1,n); +else + + start = ones(1,ns); + count = ones(1,ns); + stride = ones(1,ns); + + % sz is the size padded by 1 if more indices are given than n + sz = ones(1,ns); + sz(1:length(self.sz)) = self.sz; + + for i=1:ns + if isempty(idx.subs{i}) + count(i) = 0; + + elseif strcmp(idx.subs{i},':') + count(i) = sz(i); + + else + tmp = idx.subs{i}; + + if length(tmp) == 1 + start(i) = tmp; + else + test = tmp(1):tmp(2)-tmp(1):tmp(end); + + if all(tmp == test) + start(i) = tmp(1); + stride(i) = tmp(2)-tmp(1); + count(i) = (tmp(end)-tmp(1))/stride(i) +1; + else + error('indeces'); + end + end + end + end + + assert(all(count(n+1:end) == 1 | count(n+1:end) == 0)) + assert(all(start(n+1:end) == 1)) + + if ~any(count == 0) + count = count(1:n); + start = start(1:n); + stride = stride(1:n); + end +end \ No newline at end of file Added: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m 2012-06-22 15:52:36 UTC (rev 10673) @@ -0,0 +1,10 @@ +function self = subsasgn(self,idxs,x) +%idx + +idx = idxs(1); +assert(strcmp(idx.type,'()')) +[start, count, stride] = ncsub(self,idx); + +if all(count ~= 0) + ncwrite(self.filename,self.varname,x,start,stride); +end Added: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-06-22 15:52:36 UTC (rev 10673) @@ -0,0 +1,65 @@ +function x = subsref(self,idx) + +assert(length(idx) == 1) + +if strcmp(idx.type,'()') + % load data + + if strcmp(idx.type,'()') && length(idx.subs) == 1 ... + && length(idx.subs) < self.nd + % reference like A([2 3 1 5]) + + if self.tooBigToLoad + % number of elements in x + ind = idx.subs{1}; + + % transform index to subscript + subs = cell(1,self.nd); + [subs{:}] = ind2sub(size(self),ind); + + % make a nice array length(ind) by self.nd + subs = cell2mat(subs); + + % output array + x = zeros(size(ind)); + x(:) = NaN; + + + % get every element + % can be quite slow + idxe.type = '()'; + idxe.subs = cell(1,self.nd); + + for i=1:length(ind) + idxe.subs = mat2cell(subs(i,:),1,ones(1,self.nd)); + x(i) = subsref(self,idxe); + end + else + % load full array + tmp = full(self); + x = subsref(tmp,idx); + end + else + [start, count, stride] = ncsub(self,idx); + + if any(count == 0) + x = zeros(count); + else + x = ncread(cached_decompress(self.filename),self.varname,... + start,count,stride); + end + end +elseif strcmp(idx.type,'.') + % load attribute + name = idx.subs; + index = strmatch(name,{self.vinfo.Attributes(:).Name}); + + if isempty(index) + error('variable %s has no attribute called %s',self.varname,name); + else + x = self.vinfo.Attributes(index).Value; + end +else + error('not supported'); + +end \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-24 09:56:19
|
Revision: 10679 http://octave.svn.sourceforge.net/octave/?rev=10679&view=rev Author: abarth93 Date: 2012-06-24 09:56:12 +0000 (Sun, 24 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-06-24 09:56:12 UTC (rev 10679) @@ -0,0 +1,28 @@ +function s = reduce(self,funred,funelem,dim) + +sz = size(self); +if nargin == 3 + dim = find(sz ~= 1,1); + if isempty(dim) + dim = 1; + end +end + +idx.type = '()'; +nd = length(sz); +idx.subs = cell(1,nd); +for i=1:nd + idx.subs{i} = ':'; +end + +if size(self,dim) == 0 + s = []; +else + idx.subs{dim} = 1; + s = funelem(subsref(self,idx)); + + for i=2:size(self,dim) + idx.subs{dim} = i; + s = funred(s,funelem(subsref(self,idx))); + end +end Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-06-24 05:35:16 UTC (rev 10678) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-06-24 09:56:12 UTC (rev 10679) @@ -3,6 +3,10 @@ sz = self.sz; if nargin == 2 - sz = sz(dim); + if dim > length(sz) + sz = 1; + else + sz = sz(dim); + end end Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-06-24 09:56:12 UTC (rev 10679) @@ -0,0 +1,10 @@ +function s = sum(self,varargin) + +funred = @plus; +funelem = @(x) x; + +s = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = 0; +end Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-06-24 05:35:16 UTC (rev 10678) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-06-24 09:56:12 UTC (rev 10679) @@ -56,7 +56,7 @@ self.sz = self.vinfo.Size; self.dims = self.vinfo.Dimensions; -self.nd = length(self.dims); +self.nd = length(self.dims); % number of netcdf dimensions retval = class(self,'ncBaseArray',BaseArray(self.sz)); end Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 05:35:16 UTC (rev 10678) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 09:56:12 UTC (rev 10679) @@ -1,4 +1,4 @@ -function test_ncarray() +%function test_ncarray() % test ncBaseArray, ncCatArray and ncArray varname = 'SST'; @@ -75,6 +75,27 @@ ind = floor(numel(SST_ref) * rand(100,1))+1; assert(isequalwithequalnans(SST(ind),SST_ref(ind))) +assert(isequalwithequalnans(SST_ref(1,:,:), SST(1,:,:))) + +% sum + +sumSST = sum(SST,1); +sumSSTref = sum(SST_ref,1); +assert(isequalwithequalnans(sumSST, sumSSTref)) + +sumSST = sum(SST,2); +sumSSTref = sum(SST_ref,2); +assert(isequalwithequalnans(sumSST, sumSSTref)) + +sumSST = sum(SST,3); +sumSSTref = sum(SST_ref,3); +assert(isequalwithequalnans(sumSST, sumSSTref)) + +sumSST = sum(SST); +sumSSTref = sum(SST_ref); +assert(isequalwithequalnans(sumSST, sumSSTref)) + + % writing r = round(randn(size(SST))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-24 10:26:30
|
Revision: 10680 http://octave.svn.sourceforge.net/octave/?rev=10680&view=rev Author: abarth93 Date: 2012-06-24 10:26:23 +0000 (Sun, 24 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -0,0 +1,16 @@ +% s = mean (X, DIM) +% compute the mean along dimension dim +% See also +% mean +function s = mean(self,varargin) + +funred = @plus; +funelem = @(x) x; + +[s,n] = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = 0; +else + s = s/n; +end Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -0,0 +1,10 @@ +function s = prod(self,varargin) + +funred = @times; +funelem = @(x) x; + +s = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = 1; +end Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-06-24 09:56:12 UTC (rev 10679) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -1,5 +1,9 @@ -function s = reduce(self,funred,funelem,dim) +% [s,n] = reduce(self,funred,funelem,dim) +% reduce array using the function funred applied to all elements +% after the function funelem was applied along dimension dim +function [s,n] = reduce(self,funred,funelem,dim) + sz = size(self); if nargin == 3 dim = find(sz ~= 1,1); @@ -15,13 +19,15 @@ idx.subs{i} = ':'; end -if size(self,dim) == 0 +n = size(self,dim); + +if n == 0 s = []; else idx.subs{dim} = 1; s = funelem(subsref(self,idx)); - for i=2:size(self,dim) + for i=2:n idx.subs{dim} = i; s = funred(s,funelem(subsref(self,idx))); end Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -0,0 +1,7 @@ +% s = std (X, OPT, DIM) +% compute the standard deviation +% See also +% std +function s = std(self,varargin) + +s = sqrt(var(self,varargin{:})); Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-06-24 09:56:12 UTC (rev 10679) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -1,3 +1,8 @@ +% s = sum (X, DIM) +% compute the sum along dimension dim +% See also +% sum + function s = sum(self,varargin) funred = @plus; Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -0,0 +1,15 @@ +% s = sumsq (x, dim) +% compute the sum squared along dimension dim +% See also +% sum + +function s = sumsq(self,varargin) + +funred = @plus; +funelem = @(x) x.^2; + +s = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = 1; +end Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -0,0 +1,29 @@ +% s = var (x, opt, dim) +% compute the variance along dimension dim +% See also +% var + +function s = var(self,opt,varargin) + +if nargin == 1 + opt = 0; +elseif isempty(opt) + opt = 0; +end + +m = mean(self,varargin{:}); + +funred = @plus; +funelem = @(x) (x-m).^2; + +[s,n] = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = 0; +else + if opt == 0 + s = s/(n-1); + else + s = s/n; + end +end Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 09:56:12 UTC (rev 10679) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 10:26:23 UTC (rev 10680) @@ -95,7 +95,44 @@ sumSSTref = sum(SST_ref); assert(isequalwithequalnans(sumSST, sumSSTref)) +prodSST = prod(SST); +prodSSTref = prod(SST_ref); +assert(isequalwithequalnans(prodSST, prodSSTref)) + +sumsqSST = sumsq(SST); +sumsqSSTref = sumsq(SST_ref); +assert(isequalwithequalnans(sumsqSST, sumsqSSTref)) + +meanSST = mean(SST); +meanSSTref = mean(SST_ref); +assert(isequalwithequalnans(meanSST, meanSSTref)) + +varSST = var(SST); +varSSTref = var(SST_ref); +assert(isequalwithequalnans(varSST, varSSTref)) + +varSST = var(SST,1); +varSSTref = var(SST_ref,1); +assert(isequalwithequalnans(varSST, varSSTref)) + +varSST = var(SST,[],2); +varSSTref = var(SST_ref,[],2); +assert(isequalwithequalnans(varSST, varSSTref)) + +stdSST = std(SST); +stdSSTref = std(SST_ref); +assert(isequalwithequalnans(stdSST, stdSSTref)) + +stdSST = std(SST,1); +stdSSTref = std(SST_ref,1); +assert(isequalwithequalnans(stdSST, stdSSTref)) + +stdSST = std(SST,[],2); +stdSSTref = std(SST_ref,[],2); +assert(isequalwithequalnans(stdSST, stdSSTref)) + + % writing r = round(randn(size(SST))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-06-24 10:35:03
|
Revision: 10681 http://octave.svn.sourceforge.net/octave/?rev=10681&view=rev Author: abarth93 Date: 2012-06-24 10:34:56 +0000 (Sun, 24 Jun 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m 2012-06-24 10:34:56 UTC (rev 10681) @@ -0,0 +1,13 @@ +% s = max (x, [], dim) +% compute the maximum along dimension dim +% See also +% max + +function s = max(self,B,varargin) + +assert(isempty(B)) + +funred = @max; +funelem = @(x) x; + +s = reduce(self,funred,funelem,varargin{:}); Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m 2012-06-24 10:34:56 UTC (rev 10681) @@ -0,0 +1,13 @@ +% s = min (x, [], dim) +% compute the minimum along dimension dim +% See also +% min + +function s = min(self,B,varargin) + +assert(isempty(B)) + +funred = @min; +funelem = @(x) x; + +s = reduce(self,funred,funelem,varargin{:}); Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-06-24 10:26:23 UTC (rev 10680) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-06-24 10:34:56 UTC (rev 10681) @@ -1,4 +1,4 @@ -% s = sum (X, DIM) +% s = sum (x, dim) % compute the sum along dimension dim % See also % sum Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 10:26:23 UTC (rev 10680) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-06-24 10:34:56 UTC (rev 10681) @@ -132,7 +132,15 @@ stdSSTref = std(SST_ref,[],2); assert(isequalwithequalnans(stdSST, stdSSTref)) +maxSST = max(SST,[],2); +maxSSTref = max(SST_ref,[],2); +assert(isequalwithequalnans(maxSST, maxSSTref)) +minSST = min(SST,[],2); +minSSTref = min(SST_ref,[],2); +assert(isequalwithequalnans(minSST, minSSTref)) + + % writing r = round(randn(size(SST))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-07-03 13:28:55
|
Revision: 10720 http://octave.svn.sourceforge.net/octave/?rev=10720&view=rev Author: abarth93 Date: 2012-07-03 13:28:45 +0000 (Tue, 03 Jul 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/cached_decompress.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Modified: trunk/octave-forge/extra/ncArray/inst/cached_decompress.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/cached_decompress.m 2012-07-03 13:21:20 UTC (rev 10719) +++ trunk/octave-forge/extra/ncArray/inst/cached_decompress.m 2012-07-03 13:28:45 UTC (rev 10720) @@ -8,9 +8,7 @@ % Output: % fname: the filename of the uncompressed file % -% Example: -% -% + % Alexander Barth, 2012-06-13 % Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-07-03 13:21:20 UTC (rev 10719) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-07-03 13:28:45 UTC (rev 10720) @@ -79,6 +79,12 @@ % sum + +momentSST = moment(SST,2,1); +momentSSTref = moment(SST_ref,2,1); +assert(isequalwithequalnans(momentSST, momentSSTref)) + + sumSST = sum(SST,1); sumSSTref = sum(SST_ref,1); assert(isequalwithequalnans(sumSST, sumSSTref)) @@ -99,11 +105,11 @@ prodSSTref = prod(SST_ref); assert(isequalwithequalnans(prodSST, prodSSTref)) +% only for octave +%sumsqSST = sumsq(SST); +%sumsqSSTref = sumsq(SST_ref); % does not work in matlab +%assert(isequalwithequalnans(sumsqSST, sumsqSSTref)) -sumsqSST = sumsq(SST); -sumsqSSTref = sumsq(SST_ref); -assert(isequalwithequalnans(sumsqSST, sumsqSSTref)) - meanSST = mean(SST); meanSSTref = mean(SST_ref); assert(isequalwithequalnans(meanSST, meanSSTref)) @@ -231,6 +237,10 @@ ind = floor(numel(SST_ref) * rand(100,1))+1; assert(isequalwithequalnans(CA2(ind),SST_ref(ind))) +meanSST = mean(CA2,3); +meanSSTref = mean(SST_ref,3); +assert(isequalwithequalnans(meanSST, meanSSTref)) + % writing for i=1:3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-07-03 13:38:51
|
Revision: 10721 http://octave.svn.sourceforge.net/octave/?rev=10721&view=rev Author: abarth93 Date: 2012-07-03 13:38:39 +0000 (Tue, 03 Jul 2012) Log Message: ----------- add license Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m trunk/octave-forge/extra/ncArray/inst/@ncArray/coord.m trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m trunk/octave-forge/extra/ncArray/inst/cached_decompress.m trunk/octave-forge/extra/ncArray/inst/ncCatArray.m trunk/octave-forge/extra/ncArray/inst/nccoord.m trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m trunk/octave-forge/extra/ncArray/inst/test_ncarray.m Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -4,4 +4,21 @@ self.sz = sz; -retval = class(self,'BaseArray'); \ No newline at end of file +retval = class(self,'BaseArray'); + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -1,3 +1,21 @@ function e = end(self,k,n) e = size(self,k); + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/full.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -7,4 +7,21 @@ idx.subs{i} = ':'; end -F = subsref(self,idx); \ No newline at end of file +F = subsref(self,idx); + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -11,3 +11,21 @@ funelem = @(x) x; s = reduce(self,funred,funelem,varargin{:}); + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -14,3 +14,21 @@ else s = s/n; end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -11,3 +11,21 @@ funelem = @(x) x; s = reduce(self,funred,funelem,varargin{:}); + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -8,3 +8,21 @@ if isempty(s) s = 1; end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -32,3 +32,21 @@ s = funred(s,funelem(subsref(self,idx))); end end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -10,3 +10,21 @@ end end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -5,3 +5,21 @@ function s = std(self,varargin) s = sqrt(var(self,varargin{:})); + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -13,3 +13,21 @@ if isempty(s) s = 0; end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -13,3 +13,21 @@ if isempty(s) s = 1; end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -27,3 +27,21 @@ s = s/n; end end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/CatArray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -68,3 +68,21 @@ + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/display.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -3,4 +3,21 @@ for i=1:self.na display(self.arrays{i}) end - \ No newline at end of file + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/idx_global_local_.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -56,3 +56,21 @@ end end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/subsasgn.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -11,4 +11,21 @@ % set subset in j-th array subsasgn(self.arrays{j},idx_local{j},subset); -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@CatArray/subsref.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -78,4 +78,21 @@ B = subsasgn(B,idx_global{j},subset); end -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncArray/coord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/coord.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/coord.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -1,3 +1,20 @@ function c = coord(self) c = self.coord; -%'her' \ No newline at end of file +%'her' + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/ncArray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -64,3 +64,21 @@ + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/subsasgn.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -1,3 +1,21 @@ function self = subsasgn(self,idx,x) self = subsasgn(self.var,idx,x); + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncArray/subsref.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -29,4 +29,21 @@ else % pass subsref to underlying ncBaseArray varargout{1} = subsref(self.var,idx); -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/display.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -2,3 +2,21 @@ disp([self.varname ' from ' self.filename]); %self.vinfo %self.dims + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -60,3 +60,21 @@ retval = class(self,'ncBaseArray',BaseArray(self.sz)); end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncsub.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -58,4 +58,21 @@ start = start(1:n); stride = stride(1:n); end -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsasgn.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -8,3 +8,21 @@ if all(count ~= 0) ncwrite(self.filename,self.varname,x,start,stride); end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -62,4 +62,21 @@ else error('not supported'); -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/cached_decompress.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/cached_decompress.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/cached_decompress.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -113,4 +113,21 @@ if status ~= 0 error(['command "' cmd '" failed: ' output]); end -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -92,6 +92,10 @@ CA = CatArray(dim,arrays); end + + + + % Copyright (C) 2012 Alexander Barth <bar...@gm...> % % This program is free software; you can redistribute it and/or modify @@ -107,5 +111,3 @@ % You should have received a copy of the GNU General Public License % along with this program; If not, see <http://www.gnu.org/licenses/>. - - Modified: trunk/octave-forge/extra/ncArray/inst/nccoord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -51,4 +51,21 @@ end end -end \ No newline at end of file +end + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/private/ncarray_example_file.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -32,4 +32,21 @@ % global attributes nc{'SST'}(:) = permute(data,[3 2 1]); -close(nc) \ No newline at end of file +close(nc) + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/test_ncarray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-07-03 13:28:45 UTC (rev 10720) +++ trunk/octave-forge/extra/ncArray/inst/test_ncarray.m 2012-07-03 13:38:39 UTC (rev 10721) @@ -80,9 +80,9 @@ % sum -momentSST = moment(SST,2,1); -momentSSTref = moment(SST_ref,2,1); -assert(isequalwithequalnans(momentSST, momentSSTref)) +%momentSST = moment(SST,2,1); +%momentSSTref = moment(SST_ref,2,1); +%assert(isequalwithequalnans(momentSST, momentSSTref)) sumSST = sum(SST,1); @@ -338,3 +338,21 @@ assert(strcmp(CA2.units,'degC')); disp('All tests passed.') + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-07-03 15:39:32
|
Revision: 10725 http://octave.svn.sourceforge.net/octave/?rev=10725&view=rev Author: abarth93 Date: 2012-07-03 15:39:22 +0000 (Tue, 03 Jul 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m 2012-07-03 15:39:22 UTC (rev 10725) @@ -0,0 +1,3 @@ +function n = numel(self) + +n = prod(self.sz); Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-07-03 15:23:26 UTC (rev 10724) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/ncBaseArray.m 2012-07-03 15:39:22 UTC (rev 10725) @@ -44,7 +44,7 @@ prop = varargin; for i=1:2:length(prop) - if strcmp(prop{i},'tooBigToLoad ') + if strcmp(prop{i},'tooBigToLoad') self.tooBigToLoad = prop{i+1}; end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-07-05 13:39:34
|
Revision: 10730 http://octave.svn.sourceforge.net/octave/?rev=10730&view=rev Author: abarth93 Date: 2012-07-05 13:39:24 +0000 (Thu, 05 Jul 2012) Log Message: ----------- Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m trunk/octave-forge/extra/ncArray/inst/nccoord.m Added Paths: ----------- trunk/octave-forge/extra/ncArray/inst/@BaseArray/isnumeric.m trunk/octave-forge/extra/ncArray/inst/@BaseArray/moment.m Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/BaseArray.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,4 +1,4 @@ -% create a BaseArray of size size sz +% Create a BaseArray of size sz. % sz has at least two elements. function retval = BaseArray(sz) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/end.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,3 +1,5 @@ +% Return last index along a dimension. + function e = end(self,k,n) e = size(self,k); Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/isnumeric.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/isnumeric.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/isnumeric.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -0,0 +1,22 @@ +% Test if array is numeric. +% isn = isnumeric(self) + +function isn = isnumeric(self) +isn = true; + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/max.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,6 @@ -% s = max (x, [], dim) -% compute the maximum along dimension dim -% See also -% max +% Compute the maximum. +% S = max (X, [], DIM) +% Compute the maximum along dimension DIM. function s = max(self,B,varargin) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/mean.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,7 @@ +% Compute the mean. % s = mean (X, DIM) -% compute the mean along dimension dim -% See also -% mean +% Compute the mean along dimension DIM. + function s = mean(self,varargin) funred = @plus; Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/min.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,6 @@ -% s = min (x, [], dim) -% compute the minimum along dimension dim -% See also -% min +% Compute the minimum. +% S = min (X, [], DIM) +% Compute the minimum along dimension DIM. function s = min(self,B,varargin) Added: trunk/octave-forge/extra/ncArray/inst/@BaseArray/moment.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/moment.m (rev 0) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/moment.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -0,0 +1,36 @@ +% Compute the central moment. +% M = moment (X, ORDER, DIM) +% compute the central moment of the given order along dimension DIM. + +function s = moment(self,order,varargin) + +m = mean(self,varargin{:}); + +funred = @plus; +funelem = @(x) (x-m).^order; + +[s,n] = reduce(self,funred,funelem,varargin{:}); + +if isempty(s) + s = NaN; +else + s = s/n; +end + + + +% Copyright (C) 2012 Alexander Barth <bar...@gm...> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; If not, see <http://www.gnu.org/licenses/>. + Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/numel.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,3 +1,6 @@ +% Number of elements. +% n = numel(A) + function n = numel(self) n = prod(self.sz); Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/prod.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,3 +1,6 @@ +% Compute the product. +% P = prod (X, DIM) +% Compute the product of all elements along dimension DIM. function s = prod(self,varargin) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/reduce.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,6 +1,7 @@ -% [s,n] = reduce(self,funred,funelem,dim) -% reduce array using the function funred applied to all elements -% after the function funelem was applied along dimension dim +% Reduce array using callback fundtions. +% [S,N] = reduce(SELF,FUNRED,FUNELEM,DIM) +% reduce array using the function FUNRED applied to all elements +% after the function FUNELEM was applied along dimension DIM. function [s,n] = reduce(self,funred,funelem,dim) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/size.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,3 +1,6 @@ +% Size of array. +% sz = size(self,dim) + function sz = size(self,dim) sz = self.sz; Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/std.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,6 @@ -% s = std (X, OPT, DIM) -% compute the standard deviation -% See also -% std +% Compute the standard deviation. +% S = std (X, OPT, DIM) + function s = std(self,varargin) s = sqrt(var(self,varargin{:})); Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sum.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,6 @@ -% s = sum (x, dim) -% compute the sum along dimension dim -% See also -% sum +% Compute the sum. +% S = sum (X, DIM) +% Compute the sum along dimension DIM. function s = sum(self,varargin) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/sumsq.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,6 @@ -% s = sumsq (x, dim) -% compute the sum squared along dimension dim -% See also -% sum +% Compute the sum squared. +% S = sumsq (X, DIM) +% Compute the sum squared along dimension DIM. function s = sumsq(self,varargin) Modified: trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/@BaseArray/var.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,7 +1,7 @@ -% s = var (x, opt, dim) -% compute the variance along dimension dim -% See also -% var +% Compute the variance. +% V = var (X, OPT, DIM) +% Compute the variance along dimension DIM. +% If OPT is equal to 1, then the variance is bias-corrected. function s = var(self,opt,varargin) Modified: trunk/octave-forge/extra/ncArray/inst/nccoord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-05 13:13:20 UTC (rev 10729) +++ trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-05 13:39:24 UTC (rev 10730) @@ -1,4 +1,4 @@ -% Coordinate of a NetCDF variable. +% Coordinates of a NetCDF variable. % % coord = nccoord(filename,varname) % get coordinates of the variable varname in the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aba...@us...> - 2012-07-31 11:34:34
|
Revision: 10789 http://octave.svn.sourceforge.net/octave/?rev=10789&view=rev Author: abarth93 Date: 2012-07-31 11:34:27 +0000 (Tue, 31 Jul 2012) Log Message: ----------- bug fix: elements of struct arrays are found by strcmp instead of strmatch Modified Paths: -------------- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m trunk/octave-forge/extra/ncArray/inst/ncCatArray.m trunk/octave-forge/extra/ncArray/inst/nccoord.m Modified: trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/@ncBaseArray/subsref.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -52,7 +52,7 @@ elseif strcmp(idx.type,'.') % load attribute name = idx.subs; - index = strmatch(name,{self.vinfo.Attributes(:).Name}); + index = find(strcmp(name,{self.vinfo.Attributes(:).Name})); if isempty(index) error('variable %s has no attribute called %s',self.varname,name); Modified: trunk/octave-forge/extra/ncArray/inst/ncCatArray.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/ncCatArray.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -77,7 +77,7 @@ for i=1:length(coord) - % coordinates do also depend on the dimension only which we concatenate + % coordinates do also depend on the dimension on which we concatenate coord(i).val = arr(dim,filenames,coord(i).name); if dim > length(coord(i).dims) coord(i).dims{dim} = catdimname; Modified: trunk/octave-forge/extra/ncArray/inst/nccoord.m =================================================================== --- trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-31 08:46:57 UTC (rev 10788) +++ trunk/octave-forge/extra/ncArray/inst/nccoord.m 2012-07-31 11:34:27 UTC (rev 10789) @@ -24,19 +24,21 @@ coord = struct('name',{},'dims',{}); % check the coordinate attribute -index = strmatch('coordinates',{vinfo.Attributes(:).Name}); -if ~isempty(index) +if ~isempty(vinfo.Attributes) + index = find(strcmp('coordinates',{vinfo.Attributes(:).Name})); + if ~isempty(index) tmp = strsplit(vinfo.Attributes(index).Value,' '); for i=1:length(tmp) coord = addcoord(coord,tmp{i},finfo); end + end end % check for coordinate dimensions for i=1:length(dims) % check if variable with the same name than the dimension exist - index = strmatch(dims{i},{finfo.Variables(:).Name}); + index = find(strcmp(dims{i},{finfo.Variables(:).Name})); if ~isempty(index) coord = addcoord(coord,dims{i},finfo); end @@ -48,14 +50,17 @@ function coord = addcoord(coord,name,finfo) % check if coordinate is aleady in the list -if isempty(strmatch(name,{coord(:).name})) +if isempty(find(strcmp(name,{coord(:).name}))) % check if name is variable - index = strmatch(name,{finfo.Variables(:).Name}); + index = find(strcmp(name,{finfo.Variables(:).Name})); if ~isempty(index) c.name = name; - c.dims = {finfo.Variables(index).Dimensions(:).Name}; - + d = finfo.Variables(index).Dimensions; + c.dims = {d(:).Name}; + % does not work in octave + %c.dims = {finfo.Variables(index).Dimensions(:).Name}; + %keyboard coord(end+1) = c; end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |