User Contrib:Mathematica - MdsWiki
Navigation
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:

Needs["JLink`"];
InstallJava[];
AddToClassPath["/usr/local/mdsplus/java/classes/MdsPlus.jar"];

(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 "saturn.mdsplus.org".

MDSplus = JavaNew["MdsPlus.MdsPlus", "saturn.mdsplus.org", 8000];

Then you can do the interesting things...

MDSplus = JavaNew["MdsPlus.MdsPlus", "saturn.mdsplus.org", 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]

Image:ldx_ece_data_mathematica.png


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.

Constructors["MdsPlus.MdsPlus"]
MdsPlus(String, int) throws java.net.UnknownHostException, java.io.IOException, MdsPlus.MdsPlusException
MdsPlus(String, int, Object) throws java.net.UnknownHostException, java.io.IOException, MdsPlus.MdsPlusException


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


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


Fields["MdsPlus.MdsPlusDescriptor"]
[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)