timeseries from existing variable Time and synchronize
Bug Description
- not explicit message issued by
timeseries
ortable2timeseries
when passing existing list of variable names that include "Time". - default call to
synchronize
with two existing timeseries to merge is failing to produce expected resulting timeserie, as union of the two timestep : the result is mix of 0 and nan, original information at original times is lost in the merge timeserie.
Steps to reproduce
execute following code, use the starting raw data from sod file attached .
function hsimd= dtmtohsim(dtmsim0, hsim0, dtmd)
//function calculate an absolute decimal time from datatimes for plotting later on while keeping zooming capabilities and autoticks of the x-axis (not (yet) possible with stackedplot of datetime timeseries)
hsimd= (dtmd-dtmsim0).duration /1000/3600 + hsim0
endfunction
//TS1= readtimeseries(f1); //data from first file dataset
//T2= readtable(f2); //data from second file dataset
load("dataTS1T2.sod", "TS1", "T2"); //the 2 previous varaibles were saved
t2=datetime("2024-02-19 10:24:00")+duration(T2.Time); //create datetime vector from table T2 "time" information , knowing the actual absolute time of the first data in the file
TS2 = table2timeseries(T2, 'RowTimes', t2); //fail
T2(:,find(T2.Properties.VariableNames=="Time"))=[]; // supprimer la variable nommée "Time" sinon conflit dans appel ci-dessous à timeseries ou table2timeseries, où nom Time utilisé par défaut
TS2 = table2timeseries(T2, 'RowTimes', t2); //ok
hsim1= dtmtohsim(TS1("Date and time")(1), 0, TS1("Date and time")); // conversion to arbitrary absolute decimal time expressed in hour
hsim2= dtmtohsim(TS2("Time")(1), 1/60+4/3600, TS2("Time")); //idem for second dataset, origin is supposed these from hsim1
TS12= synchronize(TS1,TS2); // no error message, looks like eveerything is fine, the number of times looks coherent with the union of both
hsim12= dtmtohsim(TS12("Date and time")(1), 0, TS12("Date and time")); // first element is supposed these of the first dataset hence absolute time origin is 0 also for the union
scf()
plot2d(hsim1, TS1.Var17 *1000)
plot2d(hsim2, msscanf(-1,TS2.Var6,"%dW"), 2)
//at this stage, both plots are coherent with both datasets
plot2d(hsim12, TS12.Var17 *1000,3) // 0 and Nan everywhere in the merge timeseries, especially in vector of decimal values "Var17" from TS1
legends(["TS1.Var17";"TS2.Var6";"TS12.Var17"],[1 2 3],opt="ll",with_box=%f)
xlabel("h")
What is the expected correct behavior?
- timeseries or table2timeseries on existing variables with already "Time" variable name issue: should point out that it fails because of : first explicit Name, and default naming of time variable with "Time" name should be mentionned in help pages of thes functions
- synchronize issue : original values at original timeserie datatimes are expected in the merge timeserie and proper extrapolated values at non original extrapolated datetimes according to default option.
Edited by David Chèze