User Contrib:Mathematica - MdsWiki
Personal tools

From MdsWiki

Jump to: navigation, search

MDSplus Data in Mathematica

So, you probably thought, I'd love to analyse this data in Mathematica, and done something in IDL to get the data out of MDSplus and then read it back into Mathematica and then... well you get the idea. I've done it.

Well, I thought there must be a better way, but I didn't really want to right my own MDSplus - Mathematica link code. So, I didn't. I used a trick... its slower than it could be, but it works for me... maybe it works for you.

Presenting Darren's Mathematica -> J/Link -> MDSplus.jar link. There is a PURE Java MDSplus client. One may load it into a Mathematica session quite easily:


(This is the standard location when install MDSplus, but it can be found elsewhere in your system... in fact, if you don't have it MDSplus installed, you don't even need to.. just get this one file. (I would include it here, but I think the wiki won't let me upload a Java file... understandable.)

After that, you need to connect to an MDSplus server... this is a constructor for the MDSplus object you'll create. In this example, I'll connect to a fictional server at "".

MDSplus = JavaNew["MdsPlus.MdsPlus", "", 8000];

Then you can do the interesting things...

MDSplus = JavaNew["MdsPlus.MdsPlus", "", 8000];

MDSplus@OpenTree["ldx", 81217004];
data = MDSplus@Value["\ece_137"]@Double[];
time = MDSplus@Value["dim_of(\ece_137)"]@Double[];
range = MDSplus@Value["_t=dim_of(\ece_137),[minval(_t),maxval(_t)]"]@Double[]

{-0.98304, 40.9599}

And of course, the proof... (BTW, I'm not a Mathematica guru, there is surely a better way to get a smart plot without having to decimate and force the range)

ListPlot[-data[[;; ;; 100]], DataRange -> range]


Lots more can be done.... here is some results of querying the underlying Java object. One uses the @ sign to reference the method calls in Mathematica.

MdsPlus(String, int) throws,, MdsPlus.MdsPlusException
MdsPlus(String, int, Object) throws,, MdsPlus.MdsPlusException

static void Cancel(MdsPlus.MdsPlusEvent)
void close()
void CloseTree(String, int) throws, MdsPlus.MdsPlusException
static MdsPlus.MdsPlus connect(String, int, Object) throws,, MdsPlus.MdsPlusException
void connect(String, int) throws,, MdsPlus.MdsPlusException
void disconnect(Object)
boolean equals(Object)
static byte EventAst(MdsPlus.MdsPlusEvent, throws,, MdsPlus.MdsPlusException
static byte EventAst(MdsPlus.MdsPlusEvent, String, int) throws,, MdsPlus.MdsPlusException
Class getClass()
int hashCode()
void notify()
void notifyAll()
void OpenTree(String, int) throws, MdsPlus.MdsPlusException
void Put(String, String, MdsPlus.MdsPlusDescriptor[]) throws, MdsPlus.MdsPlusException
void run()
void SetDefault(String) throws, MdsPlus.MdsPlusException
void SetEvent(String) throws, MdsPlus.MdsPlusException
String toString()
MdsPlus.MdsPlusDescriptor Value(String, MdsPlus.MdsPlusDescriptor[]) throws, MdsPlus.MdsPlusException
MdsPlus.MdsPlusDescriptor Value(String) throws, MdsPlus.MdsPlusException
void wait(long, int) throws InterruptedException
void wait(long) throws InterruptedException
void wait() throws InterruptedException

byte[] Byte() throws, MdsPlus.MdsPlusException
double[] Double() throws, MdsPlus.MdsPlusException
boolean equals(Object)
float[] Float() throws, MdsPlus.MdsPlusException
Class getClass()
String GetErrorString()
int hashCode()
int[] Int() throws, MdsPlus.MdsPlusException
void notify()
void notifyAll()
short[] Short() throws, MdsPlus.MdsPlusException
String String()
String toString()
void wait(long, int) throws InterruptedException
void wait(long) throws InterruptedException
void wait() throws InterruptedException

[B data
[I dims
byte dtype
static final byte DTYPE_CHAR
static final byte DTYPE_COMPLEX
static final byte DTYPE_CSTRING
static final byte DTYPE_DOUBLE
static final byte DTYPE_FLOAT
static final byte DTYPE_INT
static final byte DTYPE_SHORT
static final byte DTYPE_UCHAR
static final byte DTYPE_UINT
static final byte DTYPE_USHORT
int status

Good luck. --DTG 20:39, 27 January 2009 (EST)