# HG changeset patch # User abarth93 # Date 1431457885 0 # Node ID a6a3ef83435398d527ec3a8ae90e4a0eb0967035 # Parent 9cb56e0cd09ba796c96f6c8eb58a4dc32c41ac58 make concatenation more robust diff -r 9cb56e0cd09b -r a6a3ef834353 extra/ncArray/inst/@ncArray/display.m --- 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 = ''; + end + + fprintf(' Name: %15s; standard name: %25s; size %10s\n',... + c(i).name,stdname,tmp(1:end-1)); end diff -r 9cb56e0cd09b -r a6a3ef834353 extra/ncArray/inst/ncCatArray.m --- 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 diff -r 9cb56e0cd09b -r a6a3ef834353 extra/ncArray/inst/nccoord.m --- 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)