aboutsummaryrefslogtreecommitdiff
path: root/tektronix.py
diff options
context:
space:
mode:
authorAnthony LaTorre <devnull@localhost>2013-03-29 16:26:48 -0500
committerAnthony LaTorre <devnull@localhost>2013-03-29 16:26:48 -0500
commita4cd35856a49f6921716c3cb4873c76ca14fb5f0 (patch)
tree61ba69348666295181867a214f0e2acc555500d3 /tektronix.py
parentfead99f7bf747f295b24020cd533d2dd4b3eddd7 (diff)
downloadlecrunch-a4cd35856a49f6921716c3cb4873c76ca14fb5f0.tar.gz
lecrunch-a4cd35856a49f6921716c3cb4873c76ca14fb5f0.tar.bz2
lecrunch-a4cd35856a49f6921716c3cb4873c76ca14fb5f0.zip
catch keyboard interrupt and resize datasets
Diffstat (limited to 'tektronix.py')
-rw-r--r--tektronix.py44
1 files changed, 26 insertions, 18 deletions
diff --git a/tektronix.py b/tektronix.py
index 3cd266d..4fed50f 100644
--- a/tektronix.py
+++ b/tektronix.py
@@ -241,31 +241,39 @@ if __name__ == '__main__':
fastframe_count = int(scope.query('horizontal:fastframe:count?'))
i = 0
- while i < options.nevents:
- print '\rsaving event: %i' % (i+1),
- sys.stdout.flush()
+ try:
+ while i < options.nevents:
+ print '\rsaving event: %i' % (i+1),
+ sys.stdout.flush()
- scope.acquire()
+ scope.acquire()
- if fastframe_state:
- n = min(fastframe_count,options.nevents-i)
- else:
- n = 1
+ if fastframe_state:
+ n = min(fastframe_count,options.nevents-i)
+ else:
+ n = 1
- for channel in active_channels:
- dataset = f['channel%i' % channel]
+ for channel in active_channels:
+ dataset = f['channel%i' % channel]
- data = scope.get_waveform(channel, dataset.dtype)
+ data = scope.get_waveform(channel, dataset.dtype)
- if fastframe_state:
- data = data.reshape((fastframe_count,-1))
- dataset[i:i+n] = data[:n]
- else:
- dataset[i] = data
+ if fastframe_state:
+ data = data.reshape((fastframe_count,-1))
+ dataset[i:i+n] = data[:n]
+ else:
+ dataset[i] = data
- i += n
+ i += n
+ except KeyboardInterrupt:
+ print
+ print 'resizing datasets...'
- print
+ for channel in active_channels:
+ dataset = f['channel%i' % channel]
+ dataset.resize((i,dataset.shape[1]))
+ else:
+ print
elapsed = time.time() - t0