Skip to content

Commit

Permalink
Merge branch 'fix-mult-traces-e4411b'
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewrankin committed Oct 5, 2016
2 parents aaae8c4 + a734b58 commit fd236a0
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ This file contains all notable changes to the [keysight][] project.

## Unreleased

## v0.5.1 - 05-Oct-16

### Fixed
- Ability to handle 1-3 traces on E4411B

## v0.5.0 - 04-Oct-16

### Added
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ Agilent/HP) test equipment.
### Development Dependencies

- [invoke][]
- [nose][]
- [unipath][]

## Support Keysight Equipment

### Spectrum Analyzers
Below are the modules available in the keysight package and the
compatible equipment for each module:

- n9340: N9340 spectrum analyzer
- e4411b: E4411B, E4402B spectrum analyzers

## Contributing

Expand Down Expand Up @@ -61,6 +72,7 @@ a pull request. [GitHub Flow][] is summarized as:
[invoke]: http://www.pyinvoke.org
[LICENSE.txt]: https://github.com/questrail/keysight/blob/develop/LICENSE.txt
[license image]: http://img.shields.io/pypi/l/keysight.svg
[nose]: http://nose.readthedocs.io/en/latest/
[numpy]: http://www.numpy.org
[pull request]: https://help.github.com/articles/using-pull-requests
[pypi ver image]: http://img.shields.io/pypi/v/keysight.svg
Expand All @@ -70,3 +82,4 @@ a pull request. [GitHub Flow][] is summarized as:
[siganalysis]: https://github.com/questrail/siganalysis
[travis image]: http://img.shields.io/travis/questrail/keysight/master.svg
[travis link]: https://travis-ci.org/questrail/keysight
[unipath]: https://github.com/mikeorr/Unipath
2 changes: 1 addition & 1 deletion keysight/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.5.0'
__version__ = '0.5.1'
20 changes: 10 additions & 10 deletions keysight/e4411b.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def read_csv_file(filename):
temp_row = mynext() # Skip blank line 12
temp_row = mynext() # Skip blank line 13
temp_row = mynext()
num_traces = len(temp_row)
num_traces = len(temp_row) - 1
header_info['num_traces'] = num_traces
temp_row = mynext()
header_info['frequency'] = temp_row[0]

Expand All @@ -79,22 +80,21 @@ def read_csv_file(filename):
elif num_traces == 2:
for row in data:
data_array.append((float(row[0]),
float(row[1]),
float(row[2])))
[float(row[1]),
float(row[2])]))
data = np.array(
data_array,
dtype={'names': ('frequency', 'amplitude1', 'amplitude2'),
'formats': ('f8', 'f8', 'f8')})
dtype={'names': ('frequency', 'amplitude'),
'formats': ('f8', '2f8')})
elif num_traces == 3:
for row in data:
data_array.append((float(row[0]),
float(row[1]),
[float(row[1]),
float(row[2]),
float(row[3])))
float(row[3])]))
data = np.array(
data_array,
dtype={'names': ('frequency', 'amplitude1',
'amplitude2', 'amplitude3'),
'formats': ('f8', 'f8', 'f8', 'f8')})
dtype={'names': ('frequency', 'amplitude'),
'formats': ('f8', '3f8')})

return (header_info, data)
2 changes: 1 addition & 1 deletion keysight/n9340.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013 The keysight developers. All rights reserved.
# Copyright (c) 2013-2016 The keysight developers. All rights reserved.
# Project site: https://github.com/questrail/keysight
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE.txt file for the project.
Expand Down
21 changes: 16 additions & 5 deletions tests/test_e4411b.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2015 The keysight developers. All rights reserved.
# Copyright (c) 2013-2016 The keysight developers. All rights reserved.
# Project site: https://github.com/questrail/keysight
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE.txt file for the project.
Expand All @@ -12,13 +12,20 @@
from __future__ import absolute_import

import unittest
import logging

from unipath import Path

from keysight import e4411b

TEST_DIR = Path(__file__).ancestor(1)

# Setup logging
logging.basicConfig(
level=logging.DEBUG,
format=' %(asctime)s - %(levelname)s - %(message)s'
)


class TestReadingCSVFiles(unittest.TestCase):

Expand All @@ -41,18 +48,22 @@ def test_header_when_reading_csv_file(self):
self.assertEqual(self.header['resolution_bw'], 100000)
self.assertEqual(self.header['video_bw'], 100000)
self.assertEqual(self.header['sweep_time'], 0.0644205)
self.assertEqual(self.header['num_traces'], 3)
self.assertEqual(self.header['num_points'], 401)

def test_data_when_reading_csv_file(self):
self.assertEqual(self.data.shape, (401,))
self.assertEqual(self.data['amplitude'].shape, (401, 3))
self.assertEqual(self.data['frequency'][0], 500000000)
self.assertEqual(self.data['amplitude'][0], 3.7123)
self.assertEqual(self.data['amplitude'][0][0], 3.7123)
self.assertEqual(self.data['amplitude'][0][1], -2147.48)
self.assertEqual(self.data['amplitude'][0][2], -2147.48)
self.assertEqual(self.data['frequency'][1], 501250000)
self.assertEqual(self.data['amplitude'][1], 3.3353)
self.assertEqual(self.data['amplitude'][1][0], 3.3353)
self.assertEqual(self.data['frequency'][-2], 998750000)
self.assertEqual(self.data['amplitude'][-2], 3.9023)
self.assertEqual(self.data['amplitude'][-2][0], 3.9023)
self.assertEqual(self.data['frequency'][-1], 1000000000)
self.assertEqual(self.data['amplitude'][-1], 3.5163)
self.assertEqual(self.data['amplitude'][-1][0], 3.5163)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tests/test_n9340.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013 The keysight developers. All rights reserved.
# Copyright (c) 2013-2016 The keysight developers. All rights reserved.
# Project site: https://github.com/questrail/keysight
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE.txt file for the project.
Expand Down

0 comments on commit fd236a0

Please sign in to comment.