Source code :: main

[Return]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python2
# -*- coding: utf-8 -*-



from pygolem_lite import  Shot
from numpy import vstack
from pygolem_lite.modules import save_adv_par
import time, os, sys

def getdata():
    Data = Shot()
    CD_trigger = Data['tcd']
    #print CD_trigger
    #exit()

    from  isf_read import isf_read
    channel_matrix = []
    t = None
    for ch in ['ch1', 'ch2', 'ch3', 'ch4']:
        try:
            (data,tvec,header) = isf_read(ch+'.isf')
        except IOError:
            print 'file %s was not found'%(ch+'.isf')
            continue

	config = ""
	config += 'Time resolution:' + str(1/header.x_increment * 1e-6) + ' MHz\n'
	config += 'Bit depth:' + str(header.bit_num) + ' bit\n'
	config += "Range:" + str(0.5*header.y_multipt_const*2**header.bit_num) + header.y_unit + '\n'
	config += 'Setting:'+header.setting + '\n'

	f = open(ch + '.cfg', 'w')
	f.write(config)
	f.close()
	os.remove(ch+'.isf')

	t = tvec+CD_trigger
	channel_matrix.append(data)
        print  CD_trigger, t[0],t[-1]
        attr = [d for d in dir(header) if d[0]!= '_']
        for a in attr:
            print a, ':', getattr(header, a)

    print t
    #exit()
    save_adv_par('tektronix3014', t, vstack(channel_matrix).T)

    print "done"
    
	
def graphs(file_type):

    import matplotlib   
    matplotlib.rcParams['backend'] = 'Agg'
    matplotlib.rc('font',  size='10')
    matplotlib.rc('text', usetex=True)  # FIXME !! nicer but slower !!!

    name = "Tektronix"
    
    from pygolem_lite.modules import get_data, paralel_multiplot,saveconst,multiplot


    for i in range(1, 4+1):
        ch_name = 'ch%i' % i
        output_name = 'graph%i' % i
        out = get_data(ch_name, ch_name, 'U [V]', reduction = False)
        paralel_multiplot(out, name , output_name,  (9,3), 100, 'vertical', file_type )
        # integrated
        out = get_data(ch_name, ch_name, "U t [Vs]" , integrated=True )
        paralel_multiplot(out, name + ' Integrated' , output_name + '_intgr', (9,3), 100,  'vertical', file_type)

    
    #os.system("convert -resize 150x120\!  graph1.png icon.png")
    
    # icon
    #out = get_data('ch2', '', '', xlabel = "")
    #paralel_multiplot(out, "" , 'icon', (4,3), 40)
    saveconst('status', 0)


def main():
    try:
	if sys.argv[1] ==  "acquisition":
	    getdata()
	elif sys.argv[1] ==  "plots":
	    graphs('png')
    except IOError:
	print "Missing Tektronix data "
    

if __name__ == "__main__":
    main()

Navigation