Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [nidmm (NI-DMM)](#nidmm-ni-dmm)
- [nifgen (NI-FGEN)](#nifgen-ni-fgen)
- [nimodinst (NI-ModInst)](#nimodinst-ni-modinst)
- [nirfsa (NI-RFSA)](#nirfsa-ni-rfsa)
- [nirfsg (NI-RFSG)](#nirfsg-ni-rfsg)
- [niscope (NI-SCOPE)](#niscope-ni-scope)
- [nise (NI Switch Executive)](#nise-ni-switch-executive)
Expand Down Expand Up @@ -1724,6 +1725,16 @@
- Initial release
---

### nirfsa (NI-RFSA)

- [Unreleased](#nirfsa-unreleased)

#### [nirfsa] Unreleased
- Added
- All methods and attributes which are part of first release
- Changed
- Removed

### nirfsg (NI-RFSG)

- [Unreleased](#nirfsg-unreleased)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2017-2022, National Instruments Corporation.
NI-Digital Pattern Driver, NI-DMM, NI-DCPower, NI-FGEN, NI-RFSG, NI-SCOPE, NI-SWITCH, NI Switch Executive,
NI-Digital Pattern Driver, NI-DMM, NI-DCPower, NI-FGEN, NI-RFSA, NI-RFSG, NI-SCOPE, NI-SWITCH, NI Switch Executive,
NI-ModInst, NI-TClk are trademarks of National Instruments.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ Driver specific installation instructions can be found on **Read the Docs**:
* `nidmm <https://nidmm.readthedocs.io/en/latest/nidmm.html#installation>`_
* `nifgen <https://nifgen.readthedocs.io/en/latest/nifgen.html#installation>`_
* `nimodinst <https://nimodinst.readthedocs.io/en/latest/nimodinst.html#installation>`_
* `nirfsa <https://nirfsa.readthedocs.io/en/latest/nirfsa.html#installation>`_
* `nirfsg <https://nirfsg.readthedocs.io/en/latest/nirfsg.html#installation>`_
* `niscope <https://niscope.readthedocs.io/en/latest/niscope.html#installation>`_
* `nise <https://nise.readthedocs.io/en/latest/nise.html#installation>`_
Expand Down Expand Up @@ -591,6 +592,7 @@ Documentation is available on **Read the Docs**:
- https://nidmm.readthedocs.io
- https://nifgen.readthedocs.io
- https://nimodinst.readthedocs.io
- https://nirfsa.readthedocs.io
- https://nirfsg.readthedocs.io
- https://niscope.readthedocs.io
- https://nise.readthedocs.io
Expand Down
2 changes: 1 addition & 1 deletion build/templates/conf.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ api_name = f"{config['driver_name']} Python API"
api_name_no_spaces_or_hyphens = api_name.replace(" ", "").replace("-", "")
api_name_no_spaces_or_hyphens_lower = api_name_no_spaces_or_hyphens.lower()

all_modules = {'nidcpower', 'nidigital', 'nidmm', 'nifgen', 'nimodinst', 'nirfsg', 'niscope', 'niswitch', 'nise', 'nitclk'}
all_modules = {'nidcpower', 'nidigital', 'nidmm', 'nifgen', 'nimodinst', 'nirfsa', 'nirfsg', 'niscope', 'niswitch', 'nise', 'nitclk'}
module_name = config['module_name']
external_modules = all_modules - {module_name}
%>\
Expand Down
1 change: 1 addition & 0 deletions docs/_static/documentation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Documentation is available on **Read the Docs**:
- https://nidmm.readthedocs.io
- https://nifgen.readthedocs.io
- https://nimodinst.readthedocs.io
- https://nirfsa.readthedocs.io
- https://nirfsg.readthedocs.io
- https://niscope.readthedocs.io
- https://nise.readthedocs.io
Expand Down
1 change: 1 addition & 0 deletions docs/_static/installation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Driver specific installation instructions can be found on **Read the Docs**:
* `nidmm <https://nidmm.readthedocs.io/en/latest/nidmm.html#installation>`_
* `nifgen <https://nifgen.readthedocs.io/en/latest/nifgen.html#installation>`_
* `nimodinst <https://nimodinst.readthedocs.io/en/latest/nimodinst.html#installation>`_
* `nirfsa <https://nirfsa.readthedocs.io/en/latest/nirfsa.html#installation>`_
* `nirfsg <https://nirfsg.readthedocs.io/en/latest/nirfsg.html#installation>`_
* `niscope <https://niscope.readthedocs.io/en/latest/niscope.html#installation>`_
* `nise <https://nise.readthedocs.io/en/latest/nise.html#installation>`_
Expand Down
8 changes: 8 additions & 0 deletions docs/_static/nirfsa_documentation.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _documentation-section:

Documentation
=============

Documentation is available `here <http://nirfsa.readthedocs.io>`_.


22 changes: 22 additions & 0 deletions docs/_static/nirfsa_usage.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Usage
------

The following is a basic example of using the **nirfsa** module to open a session to an RF Signal Analyzer and perform a spectrum acquisition.

.. code-block:: python

import nirfsa

# Configure the session
with nirfsa.Session(resource_name='5841', id_query=False, reset_device=False, options='Simulate=1, DriverSetup=Model:5841') as rfsa_session:
rfsa_session.acquisition_type = nirfsa.AcquisitionType.IQ

rfsa_session.reference_level = -10
rfsa_session.iq_carrier_frequency = 1e9

iq_data_array = np.zeros(1024, dtype=np.complex128)

wfm_info = rfsa_session.read_iq_single_record_into(iq_data_array)
# Perform measurements...

`Other usage examples can be found on GitHub. <https://github.com/ni/nimi-python/tree/master/src/nirfsa/examples>`_
1 change: 1 addition & 0 deletions docs/nidcpower/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nidigital/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nidmm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup(app):
'nidigital': ('https://nidigital.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nifgen/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup(app):
'nidigital': ('https://nidigital.readthedocs.io/en/latest/', None),
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nimodinst/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def setup(app):
'nidigital': ('https://nidigital.readthedocs.io/en/latest/', None),
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nirfsg/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
'niswitch': ('https://niswitch.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/niscope/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
'niswitch': ('https://niswitch.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nise/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'niswitch': ('https://niswitch.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/niswitch/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
1 change: 1 addition & 0 deletions docs/nitclk/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def setup(app):
'nidmm': ('https://nidmm.readthedocs.io/en/latest/', None),
'nifgen': ('https://nifgen.readthedocs.io/en/latest/', None),
'nimodinst': ('https://nimodinst.readthedocs.io/en/latest/', None),
'nirfsa': ('https://nirfsa.readthedocs.io/en/latest/', None),
'nirfsg': ('https://nirfsg.readthedocs.io/en/latest/', None),
'niscope': ('https://niscope.readthedocs.io/en/latest/', None),
'nise': ('https://nise.readthedocs.io/en/latest/', None),
Expand Down
2 changes: 1 addition & 1 deletion generated/nifake/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This is the MIT license: http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2017-2022, National Instruments Corporation.
NI-Digital Pattern Driver, NI-DMM, NI-DCPower, NI-FGEN, NI-RFSG, NI-SCOPE, NI-SWITCH, NI Switch Executive,
NI-Digital Pattern Driver, NI-DMM, NI-DCPower, NI-FGEN, NI-RFSA, NI-RFSG, NI-SCOPE, NI-SWITCH, NI Switch Executive,
NI-ModInst, NI-TClk are trademarks of National Instruments.

Permission is hereby granted, free of charge, to any person obtaining a copy of this
Expand Down
60 changes: 60 additions & 0 deletions src/nirfsa/custom_types/coefficient_info_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import ctypes
import nirfsa._visatype


# This class is an internal ctypes implementation detail that corresponds to
# niRFSA_coefficientInfo in the C API
class struct_niRFSA_coefficientInfo(ctypes.Structure): # noqa N801
_pack_ = 8
_fields_ = [
('offset', nirfsa._visatype.ViReal64),
('gain', nirfsa._visatype.ViReal64),
('reserved1', nirfsa._visatype.ViReal64),
('reserved2', nirfsa._visatype.ViReal64),
]

def __init__(self, data=None, offset=0.0, gain=0.0,
reserved1=0.0, reserved2=0.0):
super(ctypes.Structure, self).__init__()
if data is not None:
self.offset = data.offset
self.gain = data.gain
self.reserved1 = data.reserved1
self.reserved2 = data.reserved2
else:
self.offset = offset
self.gain = gain
self.reserved1 = reserved1
self.reserved2 = reserved2


class CoefficientInfo:
"""Python-friendly wrapper for niRFSA coefficient info."""

def __init__(self, data=None, offset=0.0, gain=0.0):
if data is not None:
self.offset = data.offset
self.gain = data.gain
else:
self.offset = offset
self.gain = gain

def _create_copy(self, target_class):
try:
return target_class(
offset=self.offset,
gain=self.gain,
)
except TypeError:
return target_class(data=self)

def __repr__(self):
return "{}.{}(offset={}, gain={})".format(
self.__class__.__module__,
self.__class__.__qualname__,
self.offset,
self.gain,
)

def __str__(self):
return self.__repr__()
112 changes: 112 additions & 0 deletions src/nirfsa/custom_types/spectrum_info_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import ctypes
import nirfsa._visatype


# This class is an internal ctypes implementation detail that corresponds to
# niRFSA_spectrumInfo in the C API
class struct_niRFSA_spectrumInfo(ctypes.Structure): # noqa N801
_pack_ = 8
_fields_ = [
('initial_frequency', nirfsa._visatype.ViReal64),
('frequency_increment', nirfsa._visatype.ViReal64),
('number_of_spectral_lines', nirfsa._visatype.ViInt32),
('reserved1', nirfsa._visatype.ViReal64),
('reserved2', nirfsa._visatype.ViReal64),
('reserved3', nirfsa._visatype.ViReal64),
('reserved4', nirfsa._visatype.ViReal64),
('reserved5', nirfsa._visatype.ViReal64),
]

def __init__(self, data=None, initial_frequency=0.0, frequency_increment=0.0,
number_of_spectral_lines=0, reserved1=0.0, reserved2=0.0,
reserved3=0.0, reserved4=0.0, reserved5=0.0):
super(ctypes.Structure, self).__init__()
if data is not None:
self.initial_frequency = data.initial_frequency
self.frequency_increment = data.frequency_increment
self.number_of_spectral_lines = data.number_of_spectral_lines
self.reserved1 = data.reserved1
self.reserved2 = data.reserved2
self.reserved3 = data.reserved3
self.reserved4 = data.reserved4
self.reserved5 = data.reserved5
else:
self.initial_frequency = initial_frequency
self.frequency_increment = frequency_increment
self.number_of_spectral_lines = number_of_spectral_lines
self.reserved1 = reserved1
self.reserved2 = reserved2
self.reserved3 = reserved3
self.reserved4 = reserved4
self.reserved5 = reserved5


class SpectrumInfo:
"""Python-friendly wrapper for niRFSA spectrum info."""

def __init__(self, data=None, initial_frequency=0.0, frequency_increment=0.0,
number_of_spectral_lines=0, reserved1=0.0, reserved2=0.0,
reserved3=0.0, reserved4=0.0, reserved5=0.0):
if data is not None:
self.initial_frequency = data.initial_frequency
self.frequency_increment = data.frequency_increment
self.number_of_spectral_lines = data.number_of_spectral_lines
self.reserved1 = data.reserved1
self.reserved2 = data.reserved2
self.reserved3 = data.reserved3
self.reserved4 = data.reserved4
self.reserved5 = data.reserved5
else:
self.initial_frequency = initial_frequency
self.frequency_increment = frequency_increment
self.number_of_spectral_lines = number_of_spectral_lines
self.reserved1 = reserved1
self.reserved2 = reserved2
self.reserved3 = reserved3
self.reserved4 = reserved4
self.reserved5 = reserved5

def _create_copy(self, target_class):
try:
return target_class(
initial_frequency=self.initial_frequency,
frequency_increment=self.frequency_increment,
number_of_spectral_lines=self.number_of_spectral_lines,
reserved1=self.reserved1,
reserved2=self.reserved2,
reserved3=self.reserved3,
reserved4=self.reserved4,
reserved5=self.reserved5,
)
except TypeError:
return target_class(data=self)

def __repr__(self):
return "{}.{}(initial_frequency={}, frequency_increment={}, number_of_spectral_lines={}, reserved1={}, reserved2={}, reserved3={}, reserved4={}, reserved5={})".format(
self.__class__.__module__,
self.__class__.__qualname__,
self.initial_frequency,
self.frequency_increment,
self.number_of_spectral_lines,
self.reserved1,
self.reserved2,
self.reserved3,
self.reserved4,
self.reserved5,
)

def __str__(self):
return self.__repr__()


def _populate_samples_info(spectrum_info, sample_data):
'''Chunk up flat array of sample_data and copy each chunk into individual SpectrumInfo instance

Args:
spectrum_info (SpectrumInfo): SpectrumInfo class instance

sample_data (Iterable of float): Spectrum sample data
'''
start = 0
end = start + spectrum_info.number_of_spectral_lines
spectrum_info.samples = sample_data[start:end]
Loading