changeset 10481:cd1d7491a4f4 octave-forge

(none)
author abarth93
date Fri, 22 Jun 2012 15:09:28 +0000
parents 00c615476b92
children c81dbbe85a49
files extra/ncArray/inst/@ncBaseArray@/display.m extra/ncArray/inst/@ncBaseArray@/ncArray.m extra/ncArray/inst/@ncBaseArray@/ncsub.m extra/ncArray/inst/@ncBaseArray@/subsasgn.m extra/ncArray/inst/@ncBaseArray@/subsref.m
diffstat 5 files changed, 0 insertions(+), 201 deletions(-) [+]
line wrap: on
line diff
--- a/extra/ncArray/inst/@ncBaseArray@/display.m	Fri Jun 22 15:08:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-function display(self)
-disp([self.varname ' from ' self.filename]);
-%self.vinfo
-%self.dims
--- a/extra/ncArray/inst/@ncBaseArray@/ncArray.m	Fri Jun 22 15:08:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-% 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
--- a/extra/ncArray/inst/@ncBaseArray@/ncsub.m	Fri Jun 22 15:08:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-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
--- a/extra/ncArray/inst/@ncBaseArray@/subsasgn.m	Fri Jun 22 15:08:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-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
--- a/extra/ncArray/inst/@ncBaseArray@/subsref.m	Fri Jun 22 15:08:33 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-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