#!/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()