Ejemplo n.º 1
0
def get_mds_active_probes(shot, tunnel=True):
    """
    Get the probes that were active during the shot. Used in main function.
        shot: the shot you want
    """

    # MDSplus connection to atlas where the data is store on the "LANGMUIR" tree.
    if tunnel:
        conn = mds.Connection("localhost")
    else:
        conn = mds.Connection('atlas.gat.com')
    conn.openTree("LANGMUIR", shot)

    tmin = conn.get("\LANGMUIR::TOP.TMIN").data()
    tmax = conn.get("\LANGMUIR::TOP.TMAX").data()
    runid = conn.get("\LANGMUIR::TOP.RUNID").data()

    mds_index = []
    found_probes = []
    for mds_pnum in range(1, 85):

        # Make sure probe name is in correct formart: 001, 002, ... , 084, 085.
        if mds_pnum < 10:
            probe = "00" + str(mds_pnum)
        else:
            probe = "0" + str(mds_pnum)

        # The complete path name to the lp. PNUM is the probe number, which does
        # not match its number in mdsplus (001 - 085).
        pname = "\LANGMUIR::TOP.PROBE_" + probe + ".PNUM"

        # Get the actual probe number if it is there. Not all MDS probes are used.
        try:
            check_pnum = conn.get(pname).data()
        except:
            pass
            #print "No data in probe " + str(probe) + "."

        # It will be '0' or blank if the MDS entry isn;t used. Otherwise it will
        # have the actual probe number in it.
        if check_pnum > 0:
            print("Probe " + str(check_pnum) + " is MDS probe " +
                  str(mds_pnum))
            mds_index.append(mds_pnum)
            found_probes.append(check_pnum)

    number_of_probes = len(found_probes)
    print("Found data for " + str(number_of_probes) + " probes.")

    # Store in dictionary and return it.
    active = {}
    active["tmin"] = tmin
    active["tmax"] = tmax
    active["runid"] = runid
    active["probes"] = found_probes
    active["mds_index"] = mds_index

    return active
Ejemplo n.º 2
0
def get_mds_lp_data(shot, mds_index, tunnel=True):
    """
    Get LP data for a single probe. Used in main function.
        shot: the shot you want
        mds_index: a number 1-85 that corresponds to the mds node. These do not
            match the probe number (which is PNUM).
    """

    # MDS connection required through atlas tunnel.
    if tunnel:
        conn = mds.Connection("localhost")
    else:
        conn = mds.Connection("atlas.gat.com")
    conn.openTree("LANGMUIR", shot)

    # Use correct form of probe name.
    if mds_index < 10:
        probe = "00" + str(mds_index)
    else:
        probe = "0" + str(mds_index)

    pname = "\LANGMUIR::TOP.PROBE_" + probe

    # All the data stored in a dictionary. All the data is in the subtree
    # indicated in pname. Just specify the node and grab the data.
    lp_data = {}
    lp_data["time"] = conn.get(pname + ":TIME").data()
    lp_data["rprobe"] = conn.get(pname + ":R").data()
    lp_data["zprobe"] = conn.get(pname + ":Z").data()
    lp_data["label"] = conn.get(pname + ":LABEL").data()
    lp_data["ntimes"] = conn.get(pname + ":NTIMES").data()
    lp_data["pnum"] = conn.get(pname + ":PNUM").data()
    lp_data["isat"] = conn.get(pname + ":ISAT").data()
    lp_data["jsat"] = conn.get(pname + ":JSAT").data()
    lp_data["temp"] = conn.get(pname + ":TEMP").data()
    lp_data["dens"] = conn.get(pname + ":DENS").data()
    lp_data["pot"] = conn.get(pname + ":POT").data()
    lp_data["psin"] = conn.get(pname + ":PSIN").data()
    lp_data["angle"] = conn.get(pname + ":ANGLE").data()
    lp_data["area"] = conn.get(pname + ":AREA").data()
    lp_data["delrsepout"] = conn.get(pname + ":DELRSEPOUT").data()
    lp_data["delrsepin"] = conn.get(pname + ":DELRSEPIN").data()
    lp_data["delzsepout"] = conn.get(pname + ":DELZSEPOUT").data()
    lp_data["delzsepin"] = conn.get(pname + ":DELZSEPIN").data()
    lp_data["csq"] = conn.get(pname + ":CSQ").data()
    lp_data["res_err"] = conn.get(pname + ":RES_ERR").data()
    lp_data["heatflux"] = conn.get(pname + ":HEATFLUX").data()
    lp_data["pnum"] = conn.get(pname + ":PNUM").data()

    #print "Data stored for probe " + str(lp_data["pnum"]) + " (MDS index " + str(mds_index) + ")."

    return lp_data
Ejemplo n.º 3
0
def dl_dbs_ch(shot: int, pname: 'pointname') -> ('signal', 'time'):
    import MDSplus
    conn = MDSplus.Connection("atlas.gat.com")
    print(f"Starting {shot}'s {pname}...")
    dat = np.array(conn.get(r"_s=ptdata($,$)", pname, shot))
    del conn
    return dat, pname
Ejemplo n.º 4
0
def get_dict_of_lps(shot):
    """
    Run this function to get the Langmuir probe data in a dictionary
    of dictionaries. Each entry will be all the probe data in the form
    of a dictionary (it just sound confusing in word it isn't really
    that weird).

    shot: the shot you want the data for.
    """

    start = time.time()

    # MDS connection required through atlas tunnel.
    conn = mds.Connection("atlas.gat.com")
    conn.openTree("LANGMUIR", shot)

    # Get a dictionary with the probe active during this shot.
    active = get_mds_active_probes(conn, shot)
    print()

    # Get a dictionary of each probe data, then store it all in one big dictionary.
    lps = {}
    for mds_index in active["mds_index"]:
        lp_data = get_mds_lp_data(conn, shot, mds_index)
        probe_name = "probe " + str(lp_data["pnum"])
        lps[probe_name] = lp_data
        print("Data stored for " + str(probe_name) + " (MDS index " +
              str(mds_index) + ").")

    end = time.time()

    elapsed = end - start
    print("Time elapsed: " + str(elapsed))
    return lps
Ejemplo n.º 5
0
def run(shot, tag, units, mult=1):
    conn = mds.Connection('localhost')
    ga_obj = gadata(tag, shot, connection=conn)
    time = ga_obj.xdata
    value = ga_obj.zdata * mult

    fig = pp.pplot(time,
                   value,
                   fmt='-',
                   xlabel='Time (ms)',
                   ylabel=tag.upper() + ' (' + units + ')',
                   xrange=[0, 6000])
    minmax = input(
        'Enter time min/max for analysis range (separated by commas): ').split(
            ',')

    min_idx = np.where(time > float(minmax[0]))[0][0]
    max_idx = np.where(time > float(minmax[1]))[0][0]

    avg_value = np.mean(value[min_idx:max_idx])

    # Convert from kW to MW.
    print('Average {}: {:.3f} {}'.format(tag.upper(), avg_value, units))

    return ga_obj
Ejemplo n.º 6
0
def plot_bolo(shot, tmin=2000, tmax=5000, exclude_chords=[]):
    bolo_dict = {}
    bolo_zdata = None
    conn = MDSplus.Connection('localhost')
    fig = plt.figure()
    ax1 = fig.add_subplot(111)
    for chord in range(1, 25):
        print('Chord {}'.format(chord))
        point_name = 'BOL_U' + format(chord, '02d') + '_P'
        bolo_data = gadata(point_name, shot=shot, connection=conn)
        min_idx = np.where(bolo_data.xdata < tmin)[0][0]
        max_idx = np.where(bolo_data.xdata > tmax)[0][0]
        if bolo_zdata is None:
            bolo_zdata = np.zeros((24, max_idx - min_idx))

        if chord in exclude_chords:
            continue
        #print(bolo_data.zdata[min_idx:max_idx])
        bolo_zdata[chord-1] = bolo_data.zdata[min_idx:max_idx]
    # Flip bolo_zdata upside down so that topmost chord (24) is on the top in the graph.
    bolo_zdata = np.flipud(bolo_zdata)
    ax1.pcolor(bolo_zdata)
    fig.show()

    return bolo_zdata
Ejemplo n.º 7
0
def current_shot():
    global _AURORA
    try:
        return int(_AURORA.get('current_shot("mst")'))
    except:
        _AURORA = mds.Connection('aurora.physics.wisc.edu')
        return int(_AURORA.get('current_shot("mst")'))
Ejemplo n.º 8
0
    def getBtVac(self):
        """Returns vacuum toroidal field on-axis. We use MDSplus.Connection
        for a proper use of the TDI function tcv_eq()

        Returns:
            BtVac (Array): [nt] array of vacuum toroidal field.

        Raises:
            ValueError: if module cannot retrieve data from MDS tree.
        """
        if self._btaxv is None:
            try:
                # constant is due to a detailed measurements on the vacuum vessel major radius
                # introduce to be consistent with TDI function tcv_eq.fun
                RMaj = 0.88 / 0.996  # almost 0.88 m
                # open a connection
                conn = MDSplus.Connection('tcvdata.epfl.ch')
                conn.openTree('tcv_shot', self._shot)
                bt = conn.get('tcv_eq("BZERO")').data()[0] / RMaj
                btTime = conn.get('dim_of(tcv_eq("BZERO"))').data()
                conn.closeTree(self._tree, self._shot)
                # we need to interpolate on the time basis of LIUQE
                self._btaxv = scipy.interp(self.getTimeBase(), btTime, bt)
                self._defaultUnits['_btaxv'] = 'T'
            except:
                raise ValueError('data retrieval failed.')
        return self._btaxv.copy()
Ejemplo n.º 9
0
def data(signal, shot, **kw):

    if 'tree' in kw:
        tree = kw['tree']
    else:
        tree = 'east'

    cn = mds.Connection('mds.ipp.ac.cn')
    cn.openTree(tree, shot)
    x = cn.get('\\' + signal).copy()
    t = cn.get('dim_of(' + '\\' + signal + ')').copy()
    cn.closeAllTrees()
    t = np.array(t, dtype=np.float64)
    x = np.array(x, dtype=np.float64)

    if 'timerange' in kw:
        timerange = kw['timerange']
        index = np.where((t >= np.min(timerange)) & (t <= np.max(timerange)))
        t = t[index]
        x = x[index]

    judge = signal[0:2]
    if judge == "G1":
        temp = x
        x = 10**(temp * 1.667 - 9.333)

    elif judge == "PA" or judge == "PJ":
        temp = x
        x = 2e3 * temp

    elif judge == "PP" or judge == "PD":
        temp = x
        x = 2e4 * temp

    if 'medfilt' in kw:
        n = kw['medfilt']
        x = sig.medfilt(x, n)

    if 'move' in kw:
        move = kw['move']
        t = t - move

    if 'smooth' in kw:
        win = kw['smooth'][0]
        k = kw['smooth'][1]
        x = sig.savgol_filter(x, win, k)

    if 'log' in kw:
        if kw['log'] == 10:
            x = np.log10(x)
        elif kw['log'] == 2:
            x = np.log2(x)
        else:
            x = np.log(x)

    if 'zoom' in kw:
        n = kw['zoom']
        x = n * x

    return t, x
Ejemplo n.º 10
0
def dl_dbs_t(shot: int) -> None:
    import MDSplus
    conn = MDSplus.Connection('atlas.gat.com')
    dat = np.array(conn.get(f"_s=ptdata2('d1a', {shot})"))
    t = np.array(conn.get("dim_of(_s)"))
    print(f"Shot {shot}'s d1a and time received.")
    del conn
    return dat, t
Ejemplo n.º 11
0
def check_open_tree(shot_number, server, tree):
    try:
        con = mds.Connection(server)
        con.openTree(tree, shot_number)
        return True
    except (mds.MdsIpException, mds.TreeFOPENR, mds.TdiMISS_ARG) as e:
        logger.warning('Error opening shot %d' % shot_number)
        return False
Ejemplo n.º 12
0
 def __init__(self, name='nstxu', shotlist=None, xp=None, date=None):
     self._shots = {}  # shot dictionary with shot number (int) keys
     self._classlist = {}
     self._name = machineAlias(name)
     self._logbook = Logbook(name=self._name, root=self)
     event_server = EVENT_SERVERS[self._name]
     self._eventConnection = mds.Connection('{}:{}'.format(
         event_server['hostname'], event_server['port']))
     if len(self._connections) is 0:
         mds_server = MDS_SERVERS[self._name]
         for _ in range(2):
             connection = mds.Connection('{}:{}'.format(
                 mds_server['hostname'], mds_server['port']))
             connection.tree = None
             self._connections.append(connection)
     self.s0 = Shot(0, root=self, parent=self)
     if shotlist or xp or date:
         self.addshot(shotlist=shotlist, xp=xp, date=date)
Ejemplo n.º 13
0
def plot_avg_bolo(shots, tmin=2000, tmax=5000, exclude_chords=[]):
    conn = MDSplus.Connection('localhost')
    all_bolo = None
    shot_count = 0

    for shot in shots:
        print("Shot {}".format(shot))

        # Get data for this shot.
        bolo_zdata = None
        for chord in range(1, 25):
            point_name = 'BOL_U' + format(chord, '02d') + '_P'
            bolo_data = gadata(point_name, shot=shot, connection=conn)

            # Restrict the data to the desired time range. Only need to find
            # once since each chord shares the same time index.
            if bolo_zdata is None:
                min_idx = np.where(bolo_data.xdata < tmin)[0][0]
                max_idx = np.where(bolo_data.xdata > tmax)[0][0]
                bolo_zdata = np.zeros((24, max_idx - min_idx))

            # Don't include the bad chords.
            if chord in exclude_chords:
                continue

            # Put this chord into the array for this shot.
            bolo_zdata[chord-1] = bolo_data.zdata[min_idx:max_idx]

        # Now flip the bolo_zdata so the topmost chord is the top row (for plotting).
        #bolo_zdata = np.flipud(bolo_zdata)

        # Create the array to hold all the data now.
        if all_bolo is None:
            all_bolo = np.zeros((len(shots), 24, max_idx-min_idx))

        # Put this shot's bolo data into the array.
        all_bolo[shot_count] = bolo_zdata
        shot_count += 1

    # Now that we have all the data for each shot in a 3D array, average along
    # the axis to make this a 2D array of the average data.
    avg_bolo = np.mean(all_bolo, axis=0)
    avg_bolo_x = np.linspace(tmin, tmax, len(avg_bolo[0]))
    avg_bolo_y = np.arange(0, 25, 1)

    # Plot it up.
    fig = plt.figure(figsize=(7,5))
    ax1 = fig.add_subplot(111)
    ax1.pcolor(avg_bolo_x, avg_bolo_y, avg_bolo)
    ax1.set_xlim([tmin, tmax])
    ax1.set_xlabel('Time (ms)')
    ax1.set_ylabel('Chord')
    fig.tight_layout()
    fig.show()

    return avg_bolo
Ejemplo n.º 14
0
def data1(signal, shot, tree='east'):

    cn = mds.Connection('mds.ipp.ac.cn')
    cn.openTree(tree, shot)
    x = cn.get('\\' + signal).copy()

    cn.closeAllTrees()

    x = np.array(x, dtype=np.float64)

    return x
Ejemplo n.º 15
0
def _retrieve_signal(shot_number, server, tree, xstring, ystring, name, color):
    try:
        con = mds.Connection(server)
        con.openTree(tree, shot_number)
        logger.debug("Retrieving data for %s" % name)
        data = retrieve_data(con, xstring, ystring, name, color)
        return data

    except (mds.MdsIpException, mds.TreeFOPENR, mds.TdiMISS_ARG) as e:
        logger.warning('Random MDSplus error in retrieve_signal')
        return
Ejemplo n.º 16
0
 def __init__(self, name='nstxu', shotlist=None, xp=None, date=None):
     self._shots = {}  # shot dictionary with shot number (int) keys
     self._classlist = {}
     self._name = machineAlias(name)
     if VERBOSE: print('{}.__init__'.format(self._name))
     self._logbook = Logbook(name=self._name, root=self)
     self._eventConnection = mds.Connection(EVENT_SERVERS[self._name])
     if len(self._connections) is 0:
         if VERBOSE: print('{}.__init__  Precaching MDS connections...'.
                           format(self._name))
         for _ in range(2):
             try:
                 connection = mds.Connection(MDS_SERVERS[self._name])
                 connection.tree = None
                 self._connections.append(connection)
             except:
                 msg = 'MDSplus connection to {} failed'.format(
                     MDS_SERVERS[self._name])
                 raise FdpError(msg)
         if VERBOSE: print('{}.__init__  Finished MDS'.format(self._name))
     self.s0 = Shot(0, root=self, parent=self)
     if shotlist or xp or date:
         self.addshot(shotlist=shotlist, xp=xp, date=date)
Ejemplo n.º 17
0
def flat_top(shot):

    # Load densv2 tag data.
    conn = mds.Connection('localhost')
    ga_obj = gadata('densv2', shot, connection=conn)
    time = ga_obj.xdata
    dens = ga_obj.zdata

    # Plot and ask for the flat top range.
    fig = pp.pplot(time, dens, fmt='-',  xlabel='Time (ms)', ylabel=r'$\mathrm{\bar{n_e}\ (m^{-3})}$')
    minmax = input('Enter time min/max for analysis range (separated by commas): ').split(',')

    # Return requested time range for use in TS function (min, max).
    return int(minmax[0]), int(minmax[1])
Ejemplo n.º 18
0
 def getshots(expt_path,lower,upper):
     if expt_path.find('::')>=0:
         # path is referring to remote tree
         server,path = expt_path.split('::',2)
         # check if thick or distributed
         path = "*"  if len(path)==0 else '"'+path+'"'
         # handle None for upper and lower
         if lower is None: lower = "*"
         if upper is None: upper = "*"
         # fetch data from server
         return MDSplus.Connection(server).get('getShotDb("%s",%s,%s,%s)'%(expt,path,str(lower),str(upper)),).data().tolist()
     start = expt+'_'
     files = [f[len(expt):-5].split('_') for f in os.listdir(expt_path) if f.endswith('.tree') and f.startswith(start)]
     return [int(f[1]) for f in files if len(f)==2 and f[1]!='model']
Ejemplo n.º 19
0
def get_current_shot(server, tree):
    try:
        con = mds.Connection(server)
        con.openTree(tree, 0)
        current_shot = int(con.get("$SHOT"))
        return current_shot
    except mds.mdsExceptions.TreeNOCURRENT as e:
        logger.warning('TreeNOCURRENT in get_current_shot')
        return
    except (mds.MdsIpException, mds.TreeFOPENR, mds.TdiMISS_ARG) as e:
        logger.warning('Random MDSplus error in get_current_shot')
        return
    except ValueError as e:
        logger.warning('ValueError in get_current_shot')
        return
Ejemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        super(MDSPlusAcquisition, self).__init__(*args, **kwargs)

        self.server_mode = None

        if hasattr(self, 'server'):
            if self.server.startswith('http'):
                self.server_mode = 'http'
            else:
                self.connection = MDSplus.Connection(self.server)
                self.server_mode = 'mds'

        for attr_name, attr_value in self.__dict__.items():
            if attr_name.endswith('_path'):
                os.environ['%s' % (attr_name)] = attr_value
Ejemplo n.º 21
0
 def __init__(self, stream, hostspec=_b._server):
     self._con = _mds.Connection(hostspec)
     if len(stream)>12:
         raise Exception('The name of the stream cannot be longer than 12 charaters. '+stream)
     self._stream = stream.upper()
     try:
         self._addNode()
         print('"'+self._stream+'" signal created.')
     except Exception as exc:
         sexc = str(exc)
         if sexc.startswith('%TREE-W-ALREADY_THERE'):
             print('"'+self._stream+'" signal found.')
         elif sexc.startswith('%TREE-E-FOPENW'):
             raise(Exception('"'+self._tree+'" tree not found.'))
         else:
             raise exc
Ejemplo n.º 22
0
def latestShotNumber(serverAddress=_settings._SERVER_ADDRESS,
                     port=_settings._SERVER_PORT):
    """
	Gets the latest shot number from the tree
	
	Parameters
	----------
	
	Returns
	-------
	shot_num : int
		latest shot number
	"""

    conn = _mds.Connection('%s:%d' % (serverAddress, port))
    shot_num = conn.get('current_shot("hbtep2")')
    return int(shot_num)
Ejemplo n.º 23
0
    def __init__(self, shot, tree, server):
        """
        Parameters
        ----------
        shot : int
            Shot number.
        tree : str
            MDSplus tree name.
        server : str
            Address of the MDSplus server
        """
        self.shot = shot
        self.tree = tree
        self.server = server

        self._conn = mds.Connection(server)
        self._conn.openTree(tree, shot)
Ejemplo n.º 24
0
def read_mds(host, tree, shot, signals=None):
    """ Connect to host and read the signals from the MDS tree of the specified
    shot.
    """
    assert isinstance(host, str)
    assert isinstance(tree, str)
    assert isinstance(shot, int)

    signals = signals if signals else _SIGNALS

    conn = mds.Connection(host)
    conn.openTree(tree, shot)

    darrays = {}
    for signal in signals:
        darrays[_name(signal)] = _read_one_signal(conn, signal)

    conn.closeTree(tree, shot)

    return xray.Dataset(darrays)
Ejemplo n.º 25
0
 def read_channel(self, chan, save_locally=1):
     """Try to read bin data from the channel specified, first locally, then from MDSPlus"""
     # dict to exchange between number and name of channel.
     channels = {1: 'K', 2: 'Ka', 3: 'ref', 4: 'time'}
     bands = {'K': 1, 'Ka': 2, 'ref': 3, 'time': 4}
     try:
         channel = channels[chan]
     except KeyError:
         channel = chan
         chan = bands[channel]
     if (chan == 4) & (self.mode == "ff"):
         print("no channel 4, data for fixed frequency shots")
         return
     try:
         self.arq = path.join(self.shot_folder,
                              '%s_%s.bin' % (self.shot, chan))
         self.bindata[channel] = np.fromfile(self.arq, np.int16)
         print("binary file: %s\n#Samples: %s" %
               (self.arq, len(self.bindata[channel])))
     except IOError:
         print("no local data, connecting to MDSPlus")
         signals = {
             1: '\\KBAND.SIGNAL',
             2: '\\KABAND.SIGNAL',
             3: '\\MIRNOV.SIGNAL',
             4: '\\TRIGGER.SIGNAL'
         }
         try:
             # Local MDSplus Server
             tree = mds.Tree('tcabr_ref', self.shot)
             self.bindata[channel] = tree.getNode(signals[chan]).data()
         except:
             # External MDSplus Server
             conn = mds.Connection('tcabrcl.if.usp.br')
             conn.openTree('tcabr_ref', self.shot)
             self.bindata[channel] = np.array(conn.get(signals[chan]))
             conn.closeAllTrees()
         if save_locally == 1:
             self.save_channel(chan)
             self.save_info_file()
     self.datasize = len(self.bindata[channel])
Ejemplo n.º 26
0
def get_connection(shot, tree='mst'):
    """Get an MDSplus connection object connected to the appropriate 
    server and having the given tree and shot opened. 
    """
    svr = get_server_for_shot(shot)
    conn, tree_, shot_ = _get_svr_cached(svr)

    if conn is None:
        conn = mds.Connection(svr)

    if tree != tree_ or shot != shot_:
        try:
            # This throws an exception if there are no open trees.
            conn.closeAllTrees()
        except:
            pass
        conn.openTree(tree, shot)

    _update_svr_cache(svr, conn, tree, shot)

    return conn
Ejemplo n.º 27
0
    def getIpMeas(self):
        """returns magnetics-measured plasma current.

        Returns:
            IpMeas (Array): [nt] array of measured plasma current.

        Raises:
            ValueError: if module cannot retrieve data from MDS tree.
        """
        if self._IpMeas is None:
            try:
                conn = MDSplus.Connection('tcvdata.epfl.ch')
                conn.openTree('tcv_shot', self._shot)
                ip = conn.get('tcv_ip()').data()
                ipTime = conn.get('dim_of(tcv_ip())').data()
                conn.closeTree(self._tree, self._shot)
                self._IpMeas = scipy.interp(self.getTimeBase(), ipTime, ip)
                self._defaultUnits['_IpMeas'] = 'A'
            except:
                raise ValueError('data retrieval failed.')
        return self._IpMeas.copy()
Ejemplo n.º 28
0
def getRsep(startTime=2500, endTime=5000, server='atlas.gat.com'):

    MDSplusCONN = mds.Connection(server)

    # Lines from Zeke's code.
    parmDICT = loadg.read_g_file_mds(shot,
                                     time,
                                     connection=MDSplusCONN,
                                     write2file=False)
    Rs, Zs = np.meshgrid(parmDICT['R'], parmDICT['Z'])
    Zes = np.copy(parmDICT['lcfs'][:, 1][13:-12])
    Res = np.copy(parmDICT['lcfs'][:, 0][13:-12])
    f_Rs = scinter.interp1d(Zes, Res, assume_sorted=False)

    # R_Sep for each z location of the three probes.
    rSep = {}
    rSep['a'] = f_Rs(-0.18)
    rSep['b'] = f_Rs(-0.1546)
    rSep['c'] = f_Rs(-0.2054)

    print "Rsep: " + str(rSep['a'])
Ejemplo n.º 29
0
def avg_ped(shot, tmin, tmax):
    conn = mds.Connection('localhost')

    def get_avg(tag):
        ped_obj = gadata(tag, shot, connection=conn)
        min_idx = np.where(ped_obj.xdata > tmin)[0].min()
        max_idx = np.where(ped_obj.xdata < tmax)[0].max()
        avg_ped = ped_obj.zdata[min_idx:max_idx].mean()
        return avg_ped

    avg_neped = get_avg('prmtan_neped')
    avg_teped = get_avg('prmtan_teped')
    avg_peped = get_avg('prmtan_peped')
    avg_tribot = get_avg('tribot')
    avg_tritop = get_avg('tritop')
    #avg_gasa   = get_avg('gasa')

    print('ne ped: {:.3e}'.format(avg_neped))
    print('Te ped: {:.3f}'.format(avg_teped))
    print('Pe ped: {:.3f}'.format(avg_peped))
    print('Min. tri: {:.3f}'.format(min(avg_tribot, avg_tritop)))
Ejemplo n.º 30
0
    def _initRemoteMDSConnection(shotno,
                                 serverAddress=_settings._SERVER_ADDRESS,
                                 port=_settings._SERVER_PORT):
        """
		Initiate remote connection with MDSplus HBT-EP tree
		
		Parameters
		----------
		shotno : int
			The shotnumber to store the data
		serverAddress : str
			The network/internet address of the server
		port : int
			The port of the server
		
		Returns
		-------
		conn : MDSplus.connection
			connection class to mdsplus tree on the server for the specific shotno
		"""
        conn = _mds.Connection('%s:%d' % (serverAddress, port))
        conn.openTree('hbtep2', int(shotno))
        return conn