Skip to content

Commit

Permalink
Add docstring stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLutton committed Dec 27, 2023
1 parent 9d6b79e commit fbd6a87
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 11 deletions.
5 changes: 5 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
pandas
numpy

scipy

sphinx
sphinx-rtd-theme

27 changes: 24 additions & 3 deletions docs/conf.py → docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
# extensions = ["myst_parser"]
# extensions = []
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autodoc', # Core library for html generation from docstrings
'sphinx.ext.coverage',
'sphinx.ext.napoleon'
'sphinx.ext.napoleon',
'sphinx.ext.autosummary', # Create neat summary tables

]
autosummary_generate = True # Turn on sphinx.ext.autosummary


templates_path = ['_templates']
Expand All @@ -34,6 +37,24 @@
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']


import labtoolkit
class stubinst:
...
def query(self, *args, **kwargs):
...
return ''
def close(self, *args, **kwargs):
...

class stubrm:
...
def open_resource(self, *args, **kwargs):
return stubinst()

em = labtoolkit.Enumerate(resourcemanager=stubrm(), resources=[''])
em.driver_load_all()
118 changes: 118 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,127 @@ Welcome to LabToolkit's documentation!
Auto Module
===========


.. automodule:: labtoolkit
:members:


.. automodule:: labtoolkit.Formula.Audio
:members:

.. automodule:: labtoolkit.Formula.IQ
:members:

.. automodule:: labtoolkit.Formula.RI
:members:


.. automodule:: labtoolkit.Formula.Units
:members:

.. automodule:: labtoolkit.Attenuator.MI2187
:members:

.. automodule:: labtoolkit.Attenuator.MIWave5nn
:members:


.. automodule:: labtoolkit.AudioAnalyser.HP8903B
:members:

.. automodule:: labtoolkit.DigitalMultimeter.HP34401A
:members:
.. automodule:: labtoolkit.DigitalMultimeter.HP3457A
:members:
.. automodule:: labtoolkit.FieldStrength.LumiloopLSProbe
:members:
.. automodule:: labtoolkit.FieldStrength.Narda601
:members:
.. automodule:: labtoolkit.FieldStrength.WandelGoltermannEMC20
:members:
.. automodule:: labtoolkit.FilterRF.AgilentN9039A
:members:
.. automodule:: labtoolkit.FrequencyCounter.HP53132A
:members:
.. automodule:: labtoolkit.FrequencyCounter.Racal1992
:members:
.. automodule:: labtoolkit.ModulationMeter.HP8901B
:members:
.. automodule:: labtoolkit.ModulationMeter.MI2305
:members:
.. automodule:: labtoolkit.NetworkAnalyser.AgilentE8357A
:members:
.. automodule:: labtoolkit.NetworkAnalyser.AnritsuShockline
:members:
.. automodule:: labtoolkit.NetworkAnalyser.HP4395A
:members:
.. automodule:: labtoolkit.NetworkAnalyser.Wiltron360
:members:
.. automodule:: labtoolkit.Oscilloscope.KeysightInfiniiVisionX
:members:
.. automodule:: labtoolkit.Oscilloscope.TektronixTDS7104
:members:
.. automodule:: labtoolkit.PowerMeter.AgilentE4418B
:members:
.. automodule:: labtoolkit.PowerMeter.ELVA1DPM
:members:
.. automodule:: labtoolkit.PowerMeter.HP437B
:members:
.. automodule:: labtoolkit.PowerMeter.RohdeSchwarzNRVS
:members:
.. automodule:: labtoolkit.PowerMeter.VDIPM5B
:members:
.. automodule:: labtoolkit.PowerSourceDC.AgilentN7972A
:members:
.. automodule:: labtoolkit.PowerSourceDC.HP59501B
:members:
.. automodule:: labtoolkit.PowerSourceDC.TTIPL330P
:members:
.. automodule:: labtoolkit.SignalGenerator.SCPISignalGenerator
:members:
.. automodule:: labtoolkit.SignalGenerator.AgilentE4438C
:members:
.. automodule:: labtoolkit.SignalGenerator.AnritsuMG369nAB
:members:
.. automodule:: labtoolkit.SignalGenerator.AnritsuMG3710A
:members:
.. automodule:: labtoolkit.SignalGenerator.Agilent83650B
:members:
.. automodule:: labtoolkit.SignalGenerator.HP83752B
:members:
.. automodule:: labtoolkit.SignalGenerator.HP85645A
:members:
.. automodule:: labtoolkit.SignalGenerator.HP8657A
:members:
.. automodule:: labtoolkit.SignalGenerator.HP866nX
:members:
.. automodule:: labtoolkit.SignalGenerator.MarconiInstruments203N
:members:
.. automodule:: labtoolkit.SignalGenerator.RohdeSchwarzSHM52
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.AdvantestR3172
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.AgilentE44nn
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.AnritsuMS266nC
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.HPGreenScreen
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.AgilentE4406A
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.KeysightN90nnB
:members:
.. automodule:: labtoolkit.SpectrumAnalyser.RaSESW
:members:
.. automodule:: labtoolkit.Switch.HP3488A
:members:
.. automodule:: labtoolkit.Switch.Keithley79996
:members:
.. automodule:: labtoolkit.WaveformGenerator.HP33120A
:members:



Indices and tables
==================

Expand Down
1 change: 1 addition & 0 deletions src/labtoolkit/AudioAnalyser/RaSCMU200Audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AFResults:
# THD: float MIA

def Measurement(self):
"""."""
# print(inst.query('FETCh:AFANalyzer:PRIMary:STATus?'))
data = self.query_ascii_values('READ:SCALar:AFANalyzer:PRIMary?', container=np.array)
return self.AFResults(*data)
8 changes: 8 additions & 0 deletions src/labtoolkit/FilterRF/AgilentN9039A.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AgilentN9039A(IEEE488, SCPI):
"""."""

def status(self):
"""."""
return {
'Gain': self.gain,
'Attenuation': self.attenuation,
Expand All @@ -19,6 +20,7 @@ def status(self):
}

def states(self):
"""."""
return {
'Gain': [0, 1],
'Attenuation': [10.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5, 50.0, 52.5, 55.0, 57.5],
Expand Down Expand Up @@ -52,6 +54,7 @@ def attenuation(self, attenuation):

@property
def feed(self):
"""."""
return self.query(':SERV:FEED?')

@feed.setter
Expand All @@ -62,6 +65,7 @@ def feed(self, feed):

@property
def path(self):
"""."""
return self.query(':SERV:FEED:PATH?')

@path.setter
Expand All @@ -72,6 +76,7 @@ def path(self, path): # BYP, FILT

@property
def filterbank(self):
"""."""
return self.query(':SERV:PROD:PATH?')

@filterbank.setter
Expand All @@ -84,6 +89,7 @@ def filterbank(self, path): # COND, RAD, OFF

@property
def conducted(self):
"""."""
return self.query(':SERV:PROD:FILT:COND:BAND?')

@conducted.setter
Expand All @@ -92,6 +98,7 @@ def conducted(self, index): # COND0 to COND11

@property
def radiated(self):
"""."""
return self.query(':SERV:PROD:FILT:RAD:BAND?')

@radiated.setter
Expand All @@ -100,6 +107,7 @@ def radiated(self, index): # RAD0 to RAD8

@property
def center(self):
"""."""
return self.query_float(':SERV:FREQ:CENT?')

@center.setter
Expand Down
9 changes: 9 additions & 0 deletions src/labtoolkit/Formula/IQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ class IQTo:

@staticmethod
def Magnitude(data):
"""."""
# https://www.rohde-schwarz.com/tr/faq/how-to-read-iq-data-from-spectrum-analyzer-and-convert-to-dbm-values-faq_78704-781632.html
# 3.46423039446e-4, 4.35582856881e-4
return sqrt(data.real**2 + data.imag**2)

@classmethod
def Watts(cls, data):
"""."""
return cls.Mag(data.real, data.imag)**2 / 50

@classmethod
def dBm(cls, data):
"""."""
# return 10 * log10(cls.Watts(I, Q) / 0.001)
return 10 * log10(10 * (data.real**2 + data.imag**2))
# https://www.tek.com/en/blog/calculating-rf-power-iq-samples
Expand All @@ -35,18 +38,22 @@ def dBm(cls, data):

@staticmethod
def Phase(data):
"""."""
return arctan2(data.imag, data.real) # Phase Angle Rad

@classmethod
def Phase_deg(cls, data):
"""."""
return cls.Phase(data) * 180 / pi # Phase Angle Deg

@staticmethod
def Complex(I, Q):
"""."""
return I + 1j * Q

@classmethod
def AM_Demod(cls, data):
"""."""
mag = cls.Magnitude(data)
maxima = mag.max()
minima = mag.min()
Expand All @@ -72,6 +79,7 @@ def AM_Demod(cls, data):

@classmethod
def AM_Demod_with_lowpass(cls, mag):
"""."""
# mag = cls.Magnitude(data)
#mag = butter_lowpass_filter(mag, 10e3, fs=50000, order=5)[25:]
# return mag
Expand All @@ -97,6 +105,7 @@ def AM_Demod_with_lowpass(cls, mag):

@classmethod
def FM_audio_Demod(cls, data):
"""."""
# IQ = cls.Complex(I, Q)

# https://witestlab.poly.edu/blog/capture-and-decode-fm-radio/
Expand Down
Loading

0 comments on commit fbd6a87

Please sign in to comment.