SCRIPTS MDSplus valueΒΆ

# -*-Python-*-
# Created by bgrierson at 05 Aug 2017  06:31

"""
This script shows how to get MDSplus data

"""

# Get the plasma current for DIII-D, which does not need a treename (PTDATA or MDSplus tag)
# Here treename=None is optional
mds = OMFITmdsValue(server='DIII-D', shot=163303, TDI='ip', treename=None)
# Create local variables for the data and units (if they exist)
ip_time = mds.dim_of(0)
ip_data = mds.data()
ip_time_units = mds.units_dim_of(0)
ip_units = mds.units()

printi('Retrieved signal ip')
printi('Data record length {}'.format(len(ip_time)))
printi('Data record time units "{}"'.format(ip_time_units))
printi('Data record value units "{}"'.format(ip_units))

# Get explicit tree location
mds = OMFITmdsValue(server='DIII-D', shot=163303, treename='BOLOM', TDI='.PRAD_01.POWER.BOL_U17_P')
bolo_time = mds.dim_of(0)
bolo_data = mds.data()
bolo_time_units = mds.units_dim_of(0)
bolo_units = mds.units()

printi('Retrieved signal bolo')
printi('Data record length {}'.format(len(bolo_time)))
printi('Data record time units {}'.format(bolo_time_units))
printi('Data record value units {}'.format(bolo_units))

# Proper error handling of MDSplus data
# Make the call, which will always succeed.
mds = OMFITmdsValue(server='DIII-D', shot=163303, TDI='ip', treename=None)
if mds is None:
    printe('Tree does not exist')
try:
    ip_time = mds.dim_of(0)
    ip_data = mds.data()
except IndexError:
    printe('Tree exists but data missing')