changeset 12614:a6a3ef834353 octave-forge

make concatenation more robust
author abarth93
date Tue, 12 May 2015 19:11:25 +0000
parents 9cb56e0cd09b
children 0039c65e5e44
files extra/ncArray/inst/@ncArray/display.m extra/ncArray/inst/ncCatArray.m extra/ncArray/inst/nccoord.m
diffstat 3 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extra/ncArray/inst/@ncArray/display.m	Fri May 08 20:08:28 2015 +0000
+++ b/extra/ncArray/inst/@ncArray/display.m	Tue May 12 19:11:25 2015 +0000
@@ -10,8 +10,13 @@
 
 for i = 1:length(c)
   tmp = sprintf('%dx',size(c(i).val));
-  fprintf('  Name: "%s" standard name: "%s" size %s\n',...
-          c(i).name,c(i).standard_name,tmp(1:end-1));
+  stdname = c(i).standard_name;
+  if isempty(stdname)
+     stdname = '<unset>';
+  end
+
+  fprintf('  Name: %15s; standard name: %25s; size %10s\n',...
+          c(i).name,stdname,tmp(1:end-1));
 end
 
 
--- a/extra/ncArray/inst/ncCatArray.m	Fri May 08 20:08:28 2015 +0000
+++ b/extra/ncArray/inst/ncCatArray.m	Tue May 12 19:11:25 2015 +0000
@@ -120,12 +120,22 @@
     dims{dim} = catdimname;
     coord(dim).dims = {catdimname};
     coord(dim).val = range;
+    coord(dim).name = catdimname;
 end
 
 
 for i=1:length(coord)
+
+    %test if value is already defined, if yes do nothing
+    if ~isempty(coord(i).val) 
+       continue
+    end
+
     % the number of the dimension might be different
     % find in coord(i).dims the index of the dimension called  dims{dim}
+    % for example we concatenate over time, then two situations can arrise
+    % the coordinate variable lon can dependent on time (dimc is not empty)
+    % or it does not depdent on time (dimc is empty)
     dimc = find(strcmp(coord(i).dims,dims{dim}));
     
     if isempty(dimc)      
@@ -133,6 +143,7 @@
       coord(i).val = ncBaseArray(filenames{1},coord(i).name,'vinfo',vinfo);
     else    
       % coordinates do also depend on the dimension over which we concatenate
+      i,coord(i).name,dimc,dims{dim}
       coord(i).val = arr(dimc,filenames,coord(i).name,finfos);
     end
     
--- a/extra/ncArray/inst/nccoord.m	Fri May 08 20:08:28 2015 +0000
+++ b/extra/ncArray/inst/nccoord.m	Tue May 12 19:11:25 2015 +0000
@@ -12,6 +12,9 @@
 % coord is an empty structure if no coordinate information have been
 % found.
 
+% TODO: use a predictable order for coord:
+% lon, lat, depth, time, ensemble,...
+
 % Author: Alexander Barth (barth.alexander@gmail.com)
 
 function [dims,coord] = nccoord(filename,varname)