Skip to content
Snippets Groups Projects
Commit c6def35e authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Changed behaviour when two dseries have common variables.

If a variable, say x, is defined both in dseries objects o and p, then
merge(o, p) will select the variable x as defined in the second input, p,
except for NaNs elements in p if corresponding elements in the first
input, o, are numbers.
parent 82343061
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,8 @@ q = dseries();
[q.name, IBC, ~] = unique([o.name; p.name], 'last');
[list_of_common_variables, iO, iP] = intersect(o.name, p.name);
tex = [o.tex; p.tex];
q.tex = tex(IBC);
......@@ -89,6 +91,15 @@ elseif firstdate(o) >= firstdate(p)
end
Z = [Z1 Z2];
q.data = Z(:,IBC);
if ~isempty(list_of_common_variables)
for i=1:length(iP)
jO = iO(i);
jP = iP(i);
jQ = find(strcmp(o.name{jO}, q.name));
id = isnan(q.data(:,jQ)) & ~isnan(Z1(:,jO)) & isnan(Z2(:,jP));
q.data(id, jQ) = Z1(id,jO);
end
end
q_init = firstdate(p);
else
diff = firstdate(p) - firstdate(o);
......@@ -104,6 +115,15 @@ else
end
Z = [Z2 Z1];
q.data = Z(:,IBC);
if ~isempty(list_of_common_variables)
for i=1:length(iP)
jO = iO(i);
jP = iP(i);
jQ = find(strcmp(o.name{jO}, q.name));
id = isnan(q.data(:,jQ)) & isnan(Z1(:,jP)) & ~isnan(Z2(:,jO));
q.data(id, jQ) = Z2(id,jO);
end
end
q_init = firstdate(o);
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment