Message Boards Message Boards

0
|
4135 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Setting and changing MetaInformation for arbitrary objects

Posted 10 years ago

I work with a lot of dynamic data in {{date, datum}. . .} format,

datedatalist={{{2001, 1, 1}, 45.2}, {{2002, 1, 1}, 132.}, {{2003, 1, 2}, 121.1}};

and I have historically attached a header to each object in a format like

datedataObject={{header version, data series name, type (value, % change, etc.)}, datedatalist};

I can see advantages to using Mathematica's TemporalData[] type, and to using MetaInformation[] for recording the header. I would set this up with something like

newObject = TemporalData[datedatalist, MetaInformation -> {"name" ->"whatever", "type" -> "value"}];

and extract header items with, for example

newObject["name"]

But this leaves me with two puzzles,

  1. How do I add MetaInformation after the object has been created? and
  2. How do I change existing MetaInformation?
POSTED BY: Michael Stern
2 Replies

It appears that the Options to TemporalData objects are not recoverable or resettable by using Options or SetOptions as one might wish. So an alternative approach may be to use pattern matching and replacement rules as in the following example (using your original code as the example).

newObject = newObject /. {("name" -> _) :> ("name" -> "Happy feet")}

changes the "name" part of the MetaInformation in newObject. And

newObject = 
 newObject /. {(MetaInformation -> x_) :> (MetaInformation -> Flatten[{x, "another" -> "Something"}])} 

Will add the "another" -> "Something" rule to the MetaInformation of newObject.

One could certainly use this sort of approach to write functions that take care of these sorts of changes.

POSTED BY: David Reiss

Setting and changing MetaInformation for TemporalData objects appears to be inconsistent with the usual way options are handled in Mathematica. And, in fact, in the documentation for MetaInformation it gives the example of the MetaInformation for an Image and points out that that option can be accessed using Options and changed using SetOptions.

Actually I just checked and, though Options does work on an Image (but it does not work on TemporalData), SetOptions does not work for an Image in spite of what the documentation (under Details) for MetaInformation says.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract