omfit-mds 2020.12.2.22.59
omfit_mds
Requires Python: >=3.6

**MDS** files used as part of the OMFIT project: https://omfit.io/

Provides:
=========
* OMFITmdsValue
* OMFITmds
* OMFITmdsObjects
* OMFITmdsConnection
* MDSplusConnection
* translate_MDSserver
* tunneled_MDSserver
* MDSplus
* create_model_tree_from_OMFITobject
* solveMDSserver
* OMFITmdsCache
* interpret_signal

Requires:
=========
* numpy>=1.12
* scipy>=1.0
* uncertainties>=3
* xarray>=0.10.8
* omfit_data==2020.12.2.22.59
* omfit_commonclasses==2020.12.2.22.59

Authors:
=========
https://omfit.io/contributors.html

Documentation:
==============
OMFITmdsValue
-------------

    This class provides access to MDS+ value and allows execution of any TDI commands.
    The MDS+ value data, dim_of units, error can be accessed by the methods defined in this class.
    This class is capable of ssh-tunneling if necessary to reach the MDSplus server.
    Tunneling is set based on OMFIT['MainSettings']['SERVER']

    :param server: MDS+ server or Tokamak device (e.g. `atlas.gat.com` or `DIII-D`)

    :param treename: MDS+ tree (None or string)

    :param shot: MDS+ shot (integer or string)

    :param TDI: TDI command to be executed

    :param quiet: print if no data is found

    :param caching: if False turns off caching system, else behaviour is set by OMFITmdsCache

    :param timeout: int
        Timeout setting passed to MDSplus.Connection.get(), in ms. -1 seems to disable timeout.
        Only works for newer MDSplus versions, such as 7.84.8.

    >> tmp=OMFITmdsValue(server='DIII-D', treename='ELECTRONS', shot=145419, TDI='\\ELECTRONS::TOP.PROFILE_FITS.ZIPFIT.EDENSFIT')
    >> x=tmp.dim_of(0)
    >> y=tmp.data()
    >> pyplot.plot(x,y.T)

    To resample data on the server side, which can be much faster when dealing with large data and slow connections,
    provide t_start, t_end, and dt in the system's time units (ms or s). For example, to get stored energy from EFIT01
    from 0 to 5000 ms at 50 ms intervals (DIII-D uses time units of ms; some other facilities like KSTAR use seconds):

    >> wmhd = OMFITmdsValue(server='DIII-D', shot=154749, treename='EFIT01', TDI=r'resample(\WMHD, 0, 5000, 50)')

    The default resample function uses linear interpolation. To override it and use a different method, see
    http://www.mdsplus.org/index.php/Documentation:Users:LongPulseExtensions#Overriding_Re-sampling_Procedures

    To access DIII-D PTDATA, set `treename=None` and use the `TDI` keyword to pass signal to be retrieved.
    Note: PTDATA `ical` option can be passed by setting the `shot` keyword as a string with the shot number followed by the ical option separated by comma. e.g. shot='145419,1'

    >> tmp=OMFITmdsValue('DIII-D', treename=None, shot=145419, TDI='ip')
    >> x=tmp.dim_of(0)
    >> y=tmp.data()
    >> pyplot.plot(x,y)
    

OMFITmds
--------

    This class returns the structure of an MDS+ tree.
    Objects within this tree are OMFITmdsValue objects

    :param server: string
        MDS+ server or Tokamak device (e.g. `atlas.gat.com` or `DIII-D`)

    :param treename: string
        MDS+ tree

    :param shot: int
        MDS+ shot

    :param subtree: string
        subtree

    :param caching: bool
        OMFITmdsValue use caching system or not

    :param quiet: bool
        print when retrieving data from MDS+
    

OMFITmdsObjects
---------------
N/A

OMFITmdsConnection
------------------

    This class that provides a convenient interface to the OMFITmdsConnectionBaseClass
    Specifically it allows specifiying series of commands (mdsvalue, write, write_dataset, tcl, test_connection)
    without having to re-type the server for each command.
    

MDSplusConnection
-----------------

    Return a low-level MDSplus.Connection object to the specified MDS+ server
    taking care of establising a tunneled connection if necessary

    :param server: MDS+ server to connect to (also interprets machine names)

    :param cached: whether to return an existing connection to the MDS+ server if one already exists

    :param quiet: verbose or not

    :return: MDSplus.Connection object
    

translate_MDSserver
-------------------

    This function maps mnemonic names to real MDS+ servers

    :param server: mnemonic MDS+ name (eg. device name, like DIII-D)

    :param treename: this is to allow selection of a server depending on the treename that is accessed
    

tunneled_MDSserver
------------------
N/A

MDSplus
-------

MDSplus
==========

Provides a object oriented interface to the MDSplus data system.

Information about the B{I{MDSplus Data System}} can be found at U{the MDSplus Homepage<http://www.mdsplus.org>}
@authors: Tom Fredian(MIT/USA), Gabriele Manduchi(CNR/IT), Josh Stillerman(MIT/USA)
@copyright: 2008
@license: GNU GPL





create_model_tree_from_OMFITobject
----------------------------------

    Create new nodes OMFIT.code.filename.<filename.keys()> on server

    :param code: The string describing the code or workflow, e.g. "ONETWO" (less than twelve characters)

    :param filename: The canonical name of the file "statefile" or "input.profiles"

    :param sample: An OMFIT object, which will be traversed to a single level to create nodes

    :param server: The MDS+ server (OMFIT serverish)

    :param tree: In which MDS+ tree to create the model trees

    :param clear_code: Whether to clear the code node
    

solveMDSserver
--------------
N/A

OMFITmdsCache
-------------

    Utility function to manage OMFIT MDS+ cache

    :param cachesDir: directory to use for off-line storage of data
                      If `True` it defaults to OMFIT['MainSettings']['SETUP']['cachesDir']
                      If `False`, then off-line MDS+ caching is disabled
                      If a string, then that value is used

    :param limit: limit number of elements for in-memory caching

    NOTE: off-line caching can be achieved via:

    >> # off-line caching controlled by OMFIT['MainSettings']['SETUP']['cachesDir']
    >> OMFIT['MainSettings']['SETUP']['cachesDir'] = '/path/to/where/MDS/cache/data/resides'
    >> OMFITmdsCache(cachesDir=True)
    >>
    >> # off-line caching for this OMFIT session to specific folder
    >> OMFITmdsCache(cachesDir='/path/to/where/MDS/cache/data/resides')
    >>
    >> # purge off-line caching (clears directory based on `cachesDir`)
    >> OMFITmdsCache().purge()
    >>
    >> # disable off-line caching for this OMFIT session
    >> OMFITmdsCache(cachesDir=False)
    >>
    >> # disable default off-line caching
    >> OMFIT['MainSettings']['SETUP']['cachesDir']=False
    

interpret_signal
----------------

    Interprets a signal like abc * def by making multiple MDSplus calls.

    MDSplus might be able to interpret expressions like abc*def by itself,
    but sometimes this doesn't work (such as when the data are really in PTDATA?)

    You might also have already cached or want to cache abc and def locally
    because you need them for other purposes.

    :param server: string
        The name of the MDSplus server to connect to

    :param shot: int
        Shot number to query

    :param treename: string or None
        Name of the MDSplus tree. None is for connecting to PTDATA at DIII-D.

    :param tdi: string
        A pointname or expression containing pointnames
        Use 'testytest' as a fake pointname to avoid connecting to MDSplus during testing

    :param scratch: dict-like [optional]
        Catch intermediate quantities for debugging by providing a dict

    :return: (array, array, string/None, string/None)
        x: independent variable
        y: dependent variable as a function of x
        units: units of y or None if not found
        xunits: units of x or None if not found