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
#!/usr/bin/python2
# -*- coding: utf-8 -*-




import time, os, sys

def getdata():
    from  isf_read import isf_read
    for ch in ['ch1', 'ch2']:
	(data,tvec,header) = isf_read(ch+'.isf')


	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')


    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


    # integrated
    out = get_data('ch1', 'ch 0', "U t [Vs]" ,xlim=[0,40], integrated=True )
    paralel_multiplot(out, name + ' Integrated' , 'graph2', (9,3), 100,  'vertical', file_type)


    # integrated
    out = get_data('ch2', 'ch 1', "U t [Vs]" ,xlim=[0,40], integrated=True )
    paralel_multiplot(out, name + ' Integrated' , 'graph4', (9,3), 100,  'vertical', file_type)

    out = get_data('ch2', 'ch 1', 'U [V]'  ,xlim=[0,40], reduction = False)
    paralel_multiplot(out, name , 'graph3',  (9,3) )
        
    # graph all
    out = get_data('ch1', 'ch 0', 'U [V]' ,xlim=[0,40] , reduction = False)
    multiplot(out, name , 'graph1',  (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 Tektonix data "
    

if __name__ == "__main__":
    main()

Navigation