# HG changeset patch # User abarth93 # Date 1436342765 0 # Node ID 7c7960da6a7646a02ccba06634fdc8b8b8b2a67d # Parent 2a027badd79491eaf4c96cb204585556f981bc09 convert time to datenum diff -r 2a027badd794 -r 7c7960da6a76 extra/ncArray/inst/@ncArray/load.m --- a/extra/ncArray/inst/@ncArray/load.m Tue Jul 07 13:52:48 2015 +0000 +++ b/extra/ncArray/inst/@ncArray/load.m Wed Jul 08 08:06:05 2015 +0000 @@ -2,6 +2,7 @@ % Load a subset of a variable based on range of coordiante variables. % The names of the coordinates (coord_name1, coord_name2,...) coorespond to the standard_name attribute. % Only 1-dimensional coordinates are currently supported. +% Time units are converted to "datenum". % % % Example @@ -16,6 +17,13 @@ % per default take all data along a dimension c(i).index = ':'; c(i).sub = c(i).v; + + % convert time units + if ~isempty(strfind(c(i).units,'since')) + [t0,f] = nctimeunits(c(i).units); + c(i).v = f*double(c(i).v) + t0; + end + end % loop over all constraints @@ -38,7 +46,11 @@ if numel(range) == 1 dist = abs(c(j).v - range); [mindist,i] = min(dist); + + %i %mindist + %c(j).v(i) + %datevec(c(j).v(i)) else i = find(range(1) < c(j).v & c(j).v < range(end)); i = min(i):max(i); @@ -49,6 +61,7 @@ end idx = substruct('()',{c.index}); +%idx data = subsref (self,idx); varargout = {data,c.sub};