Skip to content

Commit

Permalink
Fixes prompted by linter
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLutton authored Dec 27, 2023
1 parent 8dab812 commit bf7169b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/labtoolkit/AudioAnalyser/RaSCMU200Audio.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import numpy as np
from dataclasses import dataclass

from ..IEEE488 import IEEE488
from ..Instrument import Instrument
from ..SCPI import SCPI


class RaSCMU200Audio(Instrument, SCPI):
"""."""
def __post__(self):
# if seconday
# if secondary
self.write('INITiate:AFANalyzer:PRIMary')

self.write('INITiate:AFGenerator:PRIMary')
Expand Down
86 changes: 52 additions & 34 deletions src/labtoolkit/Enviromental/hydrotherm.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
from dataclasses import dataclass

if read.startswith(b'\x02') == True:
data = bytes.decode(read)
#print(data)
# sample = b'\x0201041102330410\r'
from ..Instrument import Instrument

# sample = b'\x0201041102040606\r'
# 020.4 C
Bit = {
'D15' : data[0],
'D14' : data[1],
'D13' : data[2],
'D12' : data[3],
'D11' : data[4],
'D10' : data[5],
'D9' : data[6],
'D8' : data[7],
'D7' : data[8],
'D6' : data[9],
'D5' : data[10],
'D4' : data[11],
'D3' : data[12],
'D2' : data[13],
'D1' : data[14],
'D0' : data[15],
}
Value = {
'Humidity' : Bit['D4']+Bit['D3']+Bit['D2']+'.'+Bit['D1'],
#'Temperature' : Bit['D5']+Bit['D6']+Bit['D7']+Bit['D8'],
'Temperature' : Bit['D8']+Bit['D7']+Bit['D6']+'.'+Bit['D5'],
'Udp' : Bit['D9'],
'Ldp' : Bit['D10'],
'USym' : Bit['D11']+Bit['D12'],
'LSym' : Bit['D13'],
'CPolarity' : Bit['D14'],
}

class TBC(Instrument):
"""."""

@dataclass
class Results:
"""Class for keeping results from HydroTherm meter."""
Temperature: float
Humidity: float

def Measurement(self):
read = Instrument.read()
if read.startswith(b'\x02') == True:
data = bytes.decode(read)
#print(data)
# sample = b'\x0201041102330410\r'

# sample = b'\x0201041102040606\r'
# 020.4 C
Bit = {
'D15' : data[0],
'D14' : data[1],
'D13' : data[2],
'D12' : data[3],
'D11' : data[4],
'D10' : data[5],
'D9' : data[6],
'D8' : data[7],
'D7' : data[8],
'D6' : data[9],
'D5' : data[10],
'D4' : data[11],
'D3' : data[12],
'D2' : data[13],
'D1' : data[14],
'D0' : data[15],
}
Value = {
'Humidity' : Bit['D4']+Bit['D3']+Bit['D2']+'.'+Bit['D1'],
#'Temperature' : Bit['D5']+Bit['D6']+Bit['D7']+Bit['D8'],
'Temperature' : Bit['D8']+Bit['D7']+Bit['D6']+'.'+Bit['D5'],
'Udp' : Bit['D9'],
'Ldp' : Bit['D10'],
'USym' : Bit['D11']+Bit['D12'],
'LSym' : Bit['D13'],
'CPolarity' : Bit['D14'],
}
return self.Results(
Temperature=Value['Temperature'],
Humidity=Value['Humidity'],
)
12 changes: 5 additions & 7 deletions src/labtoolkit/FieldStrength/Narda601.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
import serial
from serial.tools import list_ports

from ..Instrument import Instrument

class Narda601(FieldStrength):

class Narda601(Instrument):
"""Narda601.
.. figure:: images/FieldStrength/Narda601.jpg
"""

def __init__(self, instrument):
"""."""
super().__init__(instrument)

def setup(self):
"""Send setup commands to probe."""
pass
Expand All @@ -41,11 +39,11 @@ def returnstr(self, binary=b'T\x00\x00\x00\x00'):
return binary[1:].decode() # Remove leading character from binary and decode


def decode_example(self):
def decode_example(self, hexes):
for hexstring in hexes:
hexstring = hexstring.replace(' ', '') # Remove spaces in hexstring
bins = binascii.unhexlify(hexstring) # encode to binary, as you would receive over serial
print('{}\t::\t{}\t::\t{}'.format(hexstring, binarytoVm(bins), bins)) # print(Hex, Value, Binary)
print('{}\t::\t{}\t::\t{}'.format(hexstring, self.binarytoVm(bins), bins)) # print(Hex, Value, Binary)


def query(self, ser, command):
Expand Down
2 changes: 2 additions & 0 deletions src/labtoolkit/Formatter/plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import matplotlib.pyplot as plt
from matplotlib.ticker import EngFormatter
import numpy as np


def plot_add_minor_min_max_labels(ax):
lo = np.inf
Expand Down
2 changes: 1 addition & 1 deletion src/labtoolkit/Formula/Units.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def dBuV_m(V_m):

@classmethod
def W_m2(V_m):
return (V/m**2) / 377
return (V_m**2) / 377

class W_m2To:

Expand Down
8 changes: 4 additions & 4 deletions src/labtoolkit/PowerAnalyser/VoltechPM100.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class VoltechPM1000P(IEEE488):

# inst = rm.open_resource('GPIB1::13::INSTR', read_termination='\n', write_termination='\n') # , , **kwargs)
def get(self):
Hz = float(inst.query(':FNC:FRQ?'))
V = float(inst.query(':FNC:VLT?'))
return v, Hz
def Measurement(self):
Hz = float(self.query(':FNC:FRQ?'))
V = float(self.query(':FNC:VLT?'))
return V, Hz

0 comments on commit bf7169b

Please sign in to comment.