Mercurial > forge
changeset 12663:7c7960da6a76 octave-forge
convert time to datenum
author | abarth93 |
---|---|
date | Wed, 08 Jul 2015 08:06:05 +0000 |
parents | 2a027badd794 |
children | f4b39e33e0d0 |
files | extra/ncArray/inst/@ncArray/load.m |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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};