Commit 9f69a4b0 authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Fixes calls to protected methods or attributes

Showing with 45 additions and 12 deletions
+45 -12
...@@ -363,6 +363,18 @@ class TxAbstract(ABC): ...@@ -363,6 +363,18 @@ class TxAbstract(ABC):
assert value > 0. assert value > 0.
self._injection_duration = value self._injection_duration = value
@property
def latency(self):
""" Gets the Tx latency """
return self._latency
@latency.setter
def latency(self, value):
""" Sets the Tx latency """
assert isinstance(value, float)
assert value >= 0.
self._latency = value
@property @property
def polarity(self): def polarity(self):
return self._polarity return self._polarity
...@@ -453,6 +465,17 @@ class RxAbstract(ABC): ...@@ -453,6 +465,17 @@ class RxAbstract(ABC):
self._bias = kwargs.pop('bias', 0.) self._bias = kwargs.pop('bias', 0.)
self._vmn_hardware_offset = kwargs.pop('vmn_hardware_offset', 0.) self._vmn_hardware_offset = kwargs.pop('vmn_hardware_offset', 0.)
@property
def bias(self):
""" Gets the RX bias """
return self._bias
@bias.setter
def bias(self, value):
""" Sets the Rx bias """
assert isinstance(value, float)
self._bias = value
@property @property
def gain(self): def gain(self):
return self._gain return self._gain
...@@ -472,6 +495,18 @@ class RxAbstract(ABC): ...@@ -472,6 +495,18 @@ class RxAbstract(ABC):
def gain_auto(self): def gain_auto(self):
pass pass
@property
def latency(self):
""" Gets the Rx latency """
return self._latency
@latency.setter
def latency(self, value):
""" Sets the Rx latency """
assert isinstance(value, float)
assert value >= 0.
self._latency = value
def reset_gain(self): def reset_gain(self):
self.gain = 1. self.gain = 1.
...@@ -498,6 +533,5 @@ class RxAbstract(ABC): ...@@ -498,6 +533,5 @@ class RxAbstract(ABC):
@property @property
@abstractmethod @abstractmethod
def voltage(self): def voltage(self):
""" Gets the voltage VMN in Volts """ Gets the voltage VMN in Volts """
"""
pass pass
...@@ -271,7 +271,7 @@ class OhmPiHardware: ...@@ -271,7 +271,7 @@ class OhmPiHardware:
if not append or self._start_time is None: if not append or self._start_time is None:
self._start_time = datetime.datetime.utcnow() self._start_time = datetime.datetime.utcnow()
# TODO: Check if replacing the following two options by a reset_buffer method of TX would be OK # TODO: Check if replacing the following two options by a reset_buffer method of TX would be OK
time.sleep(np.max([self.rx._latency, self.tx._latency])) # if continuous mode time.sleep(np.max([self.rx.latency, self.tx.latency])) # if continuous mode
# _ = self.rx.voltage # if not continuous mode # _ = self.rx.voltage # if not continuous mode
while self.tx_sync.is_set(): while self.tx_sync.is_set():
...@@ -395,9 +395,9 @@ class OhmPiHardware: ...@@ -395,9 +395,9 @@ class OhmPiHardware:
return new_vab return new_vab
def _compute_tx_volt(self, pulse_duration=0.1, strategy='vmax', tx_volt=5., vab_max=None, def compute_tx_volt(self, pulse_duration=0.1, strategy='vmax', tx_volt=5., vab_max=None,
iab_max=None, vmn_max=None, vmn_min=voltage_min, polarities=(1, -1), delay=0.05, iab_max=None, vmn_max=None, vmn_min=voltage_min, polarities=(1, -1), delay=0.05,
p_max=None, diff_vab_lim=2.5, n_steps=4): p_max=None, diff_vab_lim=2.5, n_steps=4):
# TODO: Optimise how to pass iab_max, vab_max, vmn_min # TODO: Optimise how to pass iab_max, vab_max, vmn_min
# TODO: Update docstring # TODO: Update docstring
"""Estimates best Tx voltage based on different strategies. """Estimates best Tx voltage based on different strategies.
...@@ -467,7 +467,6 @@ class OhmPiHardware: ...@@ -467,7 +467,6 @@ class OhmPiHardware:
k = 0 k = 0
vab_list = np.zeros(n_steps + 1) * np.nan vab_list = np.zeros(n_steps + 1) * np.nan
vab_list[k] = vab vab_list[k] = vab
# self.tx.turn_on() # self.tx.turn_on()
switch_pwr_off, switch_tx_pwr_off = False, False # TODO: check if these should be moved in kwargs switch_pwr_off, switch_tx_pwr_off = False, False # TODO: check if these should be moved in kwargs
...@@ -562,7 +561,7 @@ class OhmPiHardware: ...@@ -562,7 +561,7 @@ class OhmPiHardware:
warnings.resetwarnings() warnings.resetwarnings()
def calibrate_rx_bias(self): def calibrate_rx_bias(self):
self.rx._bias += (np.mean(self.readings[self.readings[:, 2] == 1, 4]) self.rx.bias += (np.mean(self.readings[self.readings[:, 2] == 1, 4])
+ np.mean(self.readings[self.readings[:, 2] == -1, 4])) / 2. + np.mean(self.readings[self.readings[:, 2] == -1, 4])) / 2.
def vab_square_wave(self, vab, cycle_duration, sampling_rate=None, cycles=3, polarity=1, duty_cycle=1., def vab_square_wave(self, vab, cycle_duration, sampling_rate=None, cycles=3, polarity=1, duty_cycle=1.,
......
...@@ -527,7 +527,7 @@ class OhmPi(object): ...@@ -527,7 +527,7 @@ class OhmPi(object):
bypass_check = kwargs['bypass_check'] if 'bypass_check' in kwargs.keys() else False bypass_check = kwargs['bypass_check'] if 'bypass_check' in kwargs.keys() else False
d = {} d = {}
if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id): if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id):
tx_volt = self._hw._compute_tx_volt(tx_volt=tx_volt, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, iab_max=iab_max) # TODO: use tx_volt and vmn_max instead of hardcoded values tx_volt = self._hw.compute_tx_volt(tx_volt=tx_volt, strategy=strategy, vmn_max=vmn_max, vab_max=vab_max, iab_max=iab_max) # TODO: use tx_volt and vmn_max instead of hardcoded values
time.sleep(0.5) # to wait for pwr discharge time.sleep(0.5) # to wait for pwr discharge
self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle) self._hw.vab_square_wave(tx_volt, cycle_duration=injection_duration*2/duty_cycle, cycles=nb_stack, duty_cycle=duty_cycle)
if 'delay' in kwargs.keys(): if 'delay' in kwargs.keys():
...@@ -556,7 +556,7 @@ class OhmPi(object): ...@@ -556,7 +556,7 @@ class OhmPi(object):
"nbStack": nb_stack, "nbStack": nb_stack,
"Tx [V]": tx_volt, "Tx [V]": tx_volt,
"CPU temp [degC]": self._hw.ctl.cpu_temperature, "CPU temp [degC]": self._hw.ctl.cpu_temperature,
"Nb samples [-]": len(self._hw.readings[x,2]), # TODO: use only samples after a delay in each pulse "Nb samples [-]": len(self._hw.readings[x, 2]), # TODO: use only samples after a delay in each pulse
"fulldata": self._hw.readings[:, [0, -2, -1]], "fulldata": self._hw.readings[:, [0, -2, -1]],
"I_std [%]": I_std, "I_std [%]": I_std,
"Vmn_std [%]": Vmn_std, "Vmn_std [%]": Vmn_std,
...@@ -812,7 +812,7 @@ class OhmPi(object): ...@@ -812,7 +812,7 @@ class OhmPi(object):
'rsdata': { 'rsdata': {
'A': int(quad[0]), 'A': int(quad[0]),
'B': int(quad[1]), 'B': int(quad[1]),
'rs': np.round(rab,3), # in kOhm 'rs': np.round(rab, 3), # in kOhm
} }
} }
self.data_logger.info(json.dumps(msg)) self.data_logger.info(json.dumps(msg))
...@@ -1030,7 +1030,7 @@ class OhmPi(object): ...@@ -1030,7 +1030,7 @@ class OhmPi(object):
# define a parser for the "ohmpi" format # define a parser for the "ohmpi" format
def ohmpiParser(fname): def ohmpiParser(fname):
df = pd.read_csv(fname) df = pd.read_csv(fname)
df = df.rename(columns={'A':'a', 'B':'b', 'M':'m', 'N':'n'}) df = df.rename(columns={'A': 'a', 'B': 'b', 'M': 'm', 'N': 'n'})
df['vp'] = df['Vmn [mV]'] df['vp'] = df['Vmn [mV]']
df['i'] = df['I [mA]'] df['i'] = df['I [mA]']
df['resist'] = df['vp']/df['i'] df['resist'] = df['vp']/df['i']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment