comparison extra/ncArray/inst/ncCatArray.m @ 12614:a6a3ef834353 octave-forge

make concatenation more robust
author abarth93
date Tue, 12 May 2015 19:11:25 +0000
parents 25f9c66d40bf
children 0039c65e5e44
comparison
equal deleted inserted replaced
12613:9cb56e0cd09b 12614:a6a3ef834353
118 if (dim > length(dims)) && ~isempty(coord) 118 if (dim > length(dims)) && ~isempty(coord)
119 % concatenate is new dimension 119 % concatenate is new dimension
120 dims{dim} = catdimname; 120 dims{dim} = catdimname;
121 coord(dim).dims = {catdimname}; 121 coord(dim).dims = {catdimname};
122 coord(dim).val = range; 122 coord(dim).val = range;
123 coord(dim).name = catdimname;
123 end 124 end
124 125
125 126
126 for i=1:length(coord) 127 for i=1:length(coord)
128
129 %test if value is already defined, if yes do nothing
130 if ~isempty(coord(i).val)
131 continue
132 end
133
127 % the number of the dimension might be different 134 % the number of the dimension might be different
128 % find in coord(i).dims the index of the dimension called dims{dim} 135 % find in coord(i).dims the index of the dimension called dims{dim}
136 % for example we concatenate over time, then two situations can arrise
137 % the coordinate variable lon can dependent on time (dimc is not empty)
138 % or it does not depdent on time (dimc is empty)
129 dimc = find(strcmp(coord(i).dims,dims{dim})); 139 dimc = find(strcmp(coord(i).dims,dims{dim}));
130 140
131 if isempty(dimc) 141 if isempty(dimc)
132 vinfo = varinfo(finfos{1},coord(i).name); 142 vinfo = varinfo(finfos{1},coord(i).name);
133 coord(i).val = ncBaseArray(filenames{1},coord(i).name,'vinfo',vinfo); 143 coord(i).val = ncBaseArray(filenames{1},coord(i).name,'vinfo',vinfo);
134 else 144 else
135 % coordinates do also depend on the dimension over which we concatenate 145 % coordinates do also depend on the dimension over which we concatenate
146 i,coord(i).name,dimc,dims{dim}
136 coord(i).val = arr(dimc,filenames,coord(i).name,finfos); 147 coord(i).val = arr(dimc,filenames,coord(i).name,finfos);
137 end 148 end
138 149
139 if dim > length(coord(i).dims) 150 if dim > length(coord(i).dims)
140 coord(i).dims{dim} = catdimname; 151 coord(i).dims{dim} = catdimname;