10
$\begingroup$

When I create two TimeSeries with some MetaInformation I can combine them into one TemporalData object. But I lose the MetaInformation for the TimeSeries objects.

ts1 = TimeSeries[{{1, 2}, {2, 5}, {3, 7}, {4, 3}}, MetaInformation -> {"signaalnaam" -> "CR1HAH90", "Eenheid" -> "m^3"}]
ts2 = TimeSeries[{{1, 4}, {2.5, 2}, {4, 4}}, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 0}, MetaInformation -> {"signaalnaam" -> "CR1HAH98", "Eenheid" -> "m^2"}]

td = TemporalData[{ts1, ts2}]

In td the MetaInformation of ts2 is gone. Is this by design?

$\endgroup$
10
$\begingroup$

This is as designed but an argument could be made for making some tweaks to it. The driving concern was to preserve options (e.g. ResamplingMethod) where it makes sense. If options are contained in one and only one object that option is kept as is. If an option is shared among objects the combined object inherits the first occurrence (MetaInformation for ts1 in your case).

It has been a while since I worked on this (I left WRI about a year ago) and I don't have M10 in front of me at the moment but I believe a similar set of rules applies within shared MetaInformation.

An alternative design for MetaInformation might be to create lists for each series in cases like this but then what to do if there are say 3 such objects and only two of them have repeated information? The deeper you get into this sort of thing the more difficult the design decisions become.

The only immediate work around that comes to mind would be to give unique meta property names.

EDIT

I've been wanting to find an example to expose this functionality with for a while. It's a bit ugly for this example but I hope some might find interesting applications for it. There is an undocumented (use at your own risk) object in TemporalData context called Self that allows you to refer to properties of the object to compute other properties.

Let me show a toy example.

img[x_] := Graphics[{Hue[x], Disk[]}]

ts = TimeSeries[Sort@RandomReal[{0, 1}, 1000], 
  MetaInformation -> {"animation" :> 
     ListAnimate[TimeSeriesMap[img, TemporalData`Self]]}]

If you were to check the input form of the object you would find that the meta information does not evaluate the right-hand side and hence does not consume much additional memory until the property is extracted. I'll leave it to curious individuals to run the animation.

ts["animation"]

Now with the problem at hand we could store the individual names as lists and create a function property that returns the names via index...

ts1 = TimeSeries[{{1, 2}, {2, 5}, {3, 7}, {4, 3}}];
ts2 = TimeSeries[{{1, 4}, {2.5, 2}, {4, 4}}];

td = 
  TemporalData[{ts1, ts2}, 
   MetaInformation -> {"sn" -> {"CR1HAH90", "CR1HAH98"}, 
     "en" -> {"m^3", "m^2"}, 
     "signaalnaam" :> (TemporalData`Self["sn"][[#]] &), 
     "Eenheid" :> (TemporalData`Self["en"][[#]] &)}];

td["signaalnaam"][2]

(* "CR1HAH98" *)

td["Eenheid"][1]

(* "m^3" *)
$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.