From MdsWiki
Contents |
Python interface to MDSplus - wip
There are two APIs provided in python for MDSplus, and several ways to access each of them. This page is a work in progress. Further information on the MDSplus object interface can be found in the tutorial [Python Tutorial].
Packages
The standard MDSplus kits come with a bundled python package.
import MDSplus
You may need to modify your PYTHONPATH or add a configuration file in order to import it.
e.g. /usr/lib/python3.X/site-packages/mdsplus.pth
/usr/local/mdsplus/python/
Additionally, we now provide a pure-python implementation of MDSplus Thin Client as an alternative option. You can install it with:
pip install mdsthin
And then import it with:
import mdsthin
For more information, see [https://github.com/MDSplus/mdsthin]
Thin Client Interface
All MDSplus APIs provide access to what we call "thin client", which allows you to execute TDI expressions on a server.
# Using the standard package
from MDSplus import Connection
# Using the mdsthin package
from mdsthin import Connection
c = Connection("server")
c.openTree("tree", shot)
data = c.get("NODE_NAME")
For more information about the connection object and the available functions, call this from python:
help(Connection)
or see the documentation for [https://github.com/MDSplus/mdsthin]
For more information on TDI, see Documentation:Reference:TDI
Object Interface
The object interface to MDSplus provides Tree and Node objects to access and store tree data. The IO is one of local-files, remote-files (distributed client), or remote-access (thick client). Regardless the API is the same.
from MDSplus import Tree
t = Tree("tree", shot)
data = t.NODE_NAME.data()
For more information on the object oriented interface, see the [Python Tutorial].