MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Implementing own data functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84185] Re: Implementing own data functions
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 12 Dec 2007 20:03:16 -0500 (EST)
  • References: <fjkqi6$kh3$1@smc.vnet.net>


Hi Mac,

what you call Data Functions is nothing else than ordinary functions 

that you may define yourselve.

E.g. assume we have objects: obj1 and obj2. They have attributes color: 

col1,col2 and size: siz1,siz2 and "name" (only to have show that it also 

works with a string): "nam1", "nam2". We may nor define:

Attrib[obj1,color]=col1;

Attrib[obj2,color]=col2;

Attrib[obj1,size]=siz1;

Attrib[obj2,size]=siz2;

Attrib[obj1,"name"]="nam1";

Attrib[obj2,"name"]="nam2";

if you now say Attrib[obj2,color] you get col2 or Attrib[obj2,"name"] 

you get "name2".

hope this helps, Daniel



Mac wrote:

> Mathematica 6 comes with useful data functions covering topics ranging

> from financial data to chemical isotope decay chains. Having

> established the syntax and functionality through these functions, it

> would make sense to me if there was a mechanism for users to build up

> their own data functions. It would be a useful way of sharing data

> with other users.

> 

> Unfortunately I haven't come across any tutorial or description of how

> data functions are implemented. As far as I can make out some of the

> features of data functions are similar to associative arrays (or

> hashes) as found in other languages such as Perl. Indeed, I've

> starting putting together some very simple data on radar satellite

> missions and launch rockets but using a simple 1 level hash-like

> syntax. An example is provided below.

> 

> Does anybody have a better insight or examples of how WRI data

> functions are implemented and could be made to work for individual

> efforts ?

> 

> Many thanks

> 

> Mac

> 

> Here an example for the Japanese JERS-1 satellite

> 

> Clear[jers1, keys]

> keys[hash_] := Map[#[[1, 1, 1]] &, DownValues[hash]];

> jers1["Platform"] = {

>    {"Dates",

>     "monthdayyear", {"February 11, 1992", "October 11, 1992"}},

>    {"Repeatcycle", "days", 44},

>    {"Altitude", "km", 568},

>    {"OrbitInclination", "deg", 97.67},

>    {"Rollerr", "deg", 0.12},

>    {"Rollerr", "deg", 0.16},

>    {"Yawerr", "deg", 0.13}

>    };

> jers1["SARPayload"] = {

>    {"Frequency", "Ghz", 1.275},

>    {"AntennaLength", "m", 11.9 },

>    {"AntennaWidth", "m", 2.4},

>    {"Bandwidth", "MHz", 15},

>    {"PRF", "Hz", {1505, 1602}},

>    {"Look direction", " ", "right"},

>    {"NumberModes", " ", 1}};

> 

> 




  • Prev by Date: Silly question about Contexts
  • Next by Date: Re: NIntegrate bug in Mathematica 6?
  • Previous by thread: Implementing own data functions
  • Next by thread: how to speed up lenghty formulas??