Example #1
0
            return

        if not program in sps.getspeclist():
            print '%s not found. No plotting' % program
            return

        if not array in sps.getarraylist(program):
            print '%s not found in %s. No plotting' % (array, program)
            return

        if not array_ENV in sps.getarraylist(program):
            print '%s not found in %s. No plotting' % (array_ENV, program)
            return

        try:
            mem = sps.attach(program, array)
            mem_ENV = sps.attach(program, array_ENV)
        except Exception, e:
            print 'sps.attach error: %s. No plotting' % str(e)
            return

        # reconstruct the environment
        i, env = 0, {}
        while mem_ENV[i][0] != '':
            line = mem_ENV[i].tostring()
            eq, end = line.index('='), line.index('\x00')
            k, v = line[:eq], line[eq + 1:end]
            env[k] = v
            i += 1

        labels = env['axistitles'].split(' ')
Example #2
0
    def plot(self):
        try:
            import sps
        except Exception:
            print('sps module not available. No plotting')
            return

        try:
            import pylab
        except Exception:
            print("pylab not available (try running 'spock -pylab'). "
                  "No plotting")
            return

        door = genutils.get_door()

        try:
            env = dict(door.getEnvironmentObj().read().value)
        except Exception as e:
            print('Unable to read environment. No plotting')
            print(str(e))
            return

        program = door.getNormalName().replace('/', '').replace('_', '')
        try:
            array = env['ActiveMntGrp'].replace('/', '').replace(
                '_', '').upper() + "0D"
            array_ENV = '%s_ENV' % array
        except:
            print('ActiveMntGrp not defined. No plotting')
            return

        if not program in sps.getspeclist():
            print('%s not found. No plotting' % program)
            return

        if not array in sps.getarraylist(program):
            print('%s not found in %s. No plotting' % (array, program))
            return

        if not array_ENV in sps.getarraylist(program):
            print('%s not found in %s. No plotting' % (array_ENV, program))
            return

        try:
            mem = sps.attach(program, array)
            mem_ENV = sps.attach(program, array_ENV)
        except Exception as e:
            print('sps.attach error: %s. No plotting' % str(e))
            return

        # reconstruct the environment
        i, env = 0, {}
        while mem_ENV[i][0] != '':
            line = mem_ENV[i].tostring()
            eq, end = line.index('='), line.index('\x00')
            k, v = line[:eq], line[eq + 1:end]
            env[k] = v
            i += 1

        labels = env['axistitles'].split(' ')

        col_nb = len(labels)

        if col_nb < 4:
            print('No data columns available in sps')
            return

        rows = int(env['nopts'])

        m = mem.transpose()

        x = m[1][:rows]
        colors = 'bgrcmyk'
        col_nb = min(col_nb, len(colors) + 3)
        # skip point_nb, motor and timer columns
        for i in range(3, col_nb):
            y = m[i][:rows]
            line, = pylab.plot(x, y, label=labels[i])
            line.linestyle = '-'
            line.linewidth = 1
            line.color = colors[i - 3]
        pylab.legend()
Example #3
0
            return

        if not program in sps.getspeclist():
            print '%s not found. No plotting' % program
            return

        if not array in sps.getarraylist(program):
            print '%s not found in %s. No plotting' % (array, program)
            return

        if not array_ENV in sps.getarraylist(program):
            print '%s not found in %s. No plotting' % (array_ENV, program)
            return

        try:
            mem = sps.attach(program, array)
            mem_ENV = sps.attach(program, array_ENV)
        except Exception, e:
            print 'sps.attach error: %s. No plotting' % str(e)
            return

        # reconstruct the environment
        i, env = 0, {}
        while mem_ENV[i][0] != '':
            line = mem_ENV[i].tostring()
            eq, end = line.index('='), line.index('\x00')
            k, v = line[:eq], line[eq + 1:end]
            env[k] = v
            i += 1