Getting Started with

MDSplus

Section 7 - MDSplus Data Types and Structures


Under Construction




MDSplus can understand a wide variety of data types including simple ones that you are probably familiar with from languages such as fortran, c, and IDL as well as some complex data types. Details of the data types supported are listed in a table.

All of the simple data types can exist as scalars or arrays. Arrays can have up to a maximum of eight dimensions. Many of the MDSplus datatypes are used in storing expressions, actions, timebase representations and devices and are handled transparently by the system. In this introduction we will try to discuss only the more important types that you will need to understand when reading and writing MDSplus data.

When interactiing with MDSplus data using the MdsValue and MdsPut functions (available in languages such as Fortran, C, IDL, Matlab, and Labview) the data is passed to and from these functions in simple data types appropriate to the application and platform being used. The MDSplus datatypes are generally collections of simple datatypes or expression which when evaluated result in either simple data types or other MDSplus datatypes. When returning the value for a MDSplus datatype using one of these programming languages, the system attempts to return a simple datatype using default rules to determine which piece of the collection you are likely to want. Before the previous statement makes much sense it would be a good idea to describe some of the more common MDSplus datatypes that you will likely be accessing.

One  MDSplus datatypes that you will be undoubtedly be accessing is the SIGNAL datatype. This datatype consists of at least three parts, the value part, the raw data part, and one or more dimension descriptions. A common occurence of this datatype is the data stored in a digitizer channel. In this instance, the value part usually represents the voltage of the input to that channel of the digitizer and is often an arithmetic expression referencing the raw data portion of the same signal. The raw data part would contain the integer digitized count values as read out of the digitizer memory. The third part would be some representation of the timestamps at which the digitizer took the samples. This representation normally would contain references to a clock signal and a trigger time. Some signals may be stored by analysis programs and may have the raw data part missing. Signals generally have the same number of dimension parts as the array dimensions of the value part. When accessing the data associated with a SIGNAL data item, if no particular part is requested the value part is evaluated and returned. There are built-in functions in MDSplus to specify the part you are interested in obtaining. These functions look like xxx_OF() where xxx is the name of the part desired. In the case of the SIGNAL you can use functions such as RAW_OF(signal) or DIM_OF(signal[,dim-num]) to get the raw data part or the dimensions. Any part of any MDSplus datatype can be any other MDSplus datatype. The value part of a SIGNAL might actually contain a WITH_UNITS datatype which has a value part and a units part. If you want the units of the signal then you would use the UNITS_OF() function like UNITS_OF(signal). The dimension part may also have units. To get these units you would have to use UNITS_OF(DIM_OF(signal)) where the DIM_OF() function grabs the dimension part and the UNITS_OF() grabs the units part of the dimension.

The SIGNAL datatype in MDSplus is one of the most important and powerful data type in MDSplus. Utilities such as dwscope and jScope will automatically plot the value against the dimension or a signal. SIGNAL's can also be subscripted where the subscript is in the terms of the dimensions. The expression signal[1.5] will use the subscript value, 1.5, to compute an index into the value array according to the first dimension of the signal. If the first dimension evaluated to timestamps of [1.1,1.2,1.3,1.4,1.5,1.6...], then the expression signal[1.5] would return the VALUE_OF(signal)[4] or the fifth element of the value part (array subscripts start at 0). This subscripting feature of SIGNAL's can sometimes lead to confusion. You will undoubtedly forget about this powerful feature on occasion and try to subcript a signal by the array index instead of the using the dimension range such as specifying signal[4] when you wanted the fifth element of the array. If you want to use the index into the array for subscripting, you can use the DATA() function before subscripting. The DATA() function converts its argument into a simple data type and the DIM_OF() an array is simply its array indices.

When you write an analysis program and want to store data back into an MDSplus tree, you probably will want to store some SIGNAL's. Although it is possible to construct a SIGNAL structure in a C program and call some low level MDSplus library routines to store it, you will more likely be storing the signal using a higher level interface using the MdsPut routine. Since you must pass only simple data types from your application when using the MdsPut routine, you must use the BUILD_xxx or MAKE_xxx built-in functions to construct the complex MDSplus data types. To store a SIGNAL, you would use the BUILD_SIGNAL() routine. The BUILD_SIGNAL routine takes 3 or more argument representing the value, raw data and dimensions. If you were using IDL and had calculated the value of the signal in the variable y with the independent values in variable x and wanted to store this as a signal all you would need to do is:

IDL> MdsPut,'mynode','BUILD_SIGNAL($,*,$)',y,x

The y values would be stored in the value part of the signal; there would be no raw data part; and the x values would become the dimension part. We will be discussing more about getting and putting MDSplus data in other parts of this manual.

Now that you've seen what a SIGNAL is like and how it is constructed, it will be easy to understand some of the other MDSplus datatypes. We alread discussed briefly the WITH_UNITS datatype. This simply contains two parts, the value and the units. You would use the VALUE_OF() and UNITS_OF() built-in functions to extract the part you are interested in. You would use the BUILD_WITH_UNITS() to construct this type.

Another simple data type is the WITH_ERROR data type. This also has two parts, the value and the error. You would use the VALUE_OF() and ERROR_OF() functions to extract these parts and use the BUILD_WITH_ERROR() function to construct one.

The NODE (path) datatype is similar to the text data type in that it is simply a sequence of characters. The only difference is how the expression evaluator in MDSplus treats this data type. If you passed an expression such as DATA("MYNODE") to MDSplus, the system would interpret "MYNODE" as simply text and the DATA() routine would just return the string, "MYNODE". On the other hand, if you passed the expression, DATA(MYNODE), the compiler would intepret MYNODE as a node reference and construct a NODE (path) data type and the DATA() routine would return the data from the contents of the node, MYNODE.