diff --git a/measure.py b/measure.py index 64aa9a11112e0d221c2e81a22177fe8db1f01c30..ea0b50f827affeccd02a9e69d90f6640062efb01 100644 --- a/measure.py +++ b/measure.py @@ -62,9 +62,7 @@ class OhmPiHardware: def _read_values(self, sampling_rate, append=False): # noqa if not append: self._clear_values() - _readings = [] - else: - _readings = self.readings.tolist() + _readings = [] sample = 0 self.tx_sync.wait() start_time = datetime.datetime.utcnow() @@ -74,7 +72,7 @@ class OhmPiHardware: sample+=1 sleep_time = start_time + datetime.timedelta(seconds = sample * sampling_rate / 1000) - lap time.sleep(np.min([0, np.abs(sleep_time.total_seconds())])) - self.readings = np.array(_readings) + self.readings = np.hstack([self.readings, np.array(_readings)]) def _compute_tx_volt(self, best_tx_injtime=0.1, strategy='vmax', tx_volt=5, vab_max=voltage_max, vmn_min=voltage_min): @@ -157,7 +155,7 @@ class OhmPiHardware: self.tx.polarity = polarity lengths = [cycle_length/2]*2*cycles # TODO: delete me print(f'vab_square_wave lengths: {lengths}') - self._vab_pulses(vab, lengths, sampling_rate, append) + self._vab_pulses(vab, lengths, sampling_rate, append=append) def _vab_pulse(self, vab, length, sampling_rate=None, polarity=None, append=False): """ Gets VMN and IAB from a single voltage pulse diff --git a/test_measure_with_ohmpi_card_3_15.py b/test_measure_with_ohmpi_card_3_15.py index 73fb9e515a86018ee1a4075208be47e4d743a2be..966140bf771b730928f0d21823844086354704d4 100644 --- a/test_measure_with_ohmpi_card_3_15.py +++ b/test_measure_with_ohmpi_card_3_15.py @@ -14,7 +14,7 @@ print(f'sampling rate: {k.rx.sampling_rate:.1f} ms, mean sample spacing: {np.mea # Test #2: print('\n\nTesting vab_square_wave') -k.vab_square_wave(vab=12, length=1., sampling_rate=k.rx.sampling_rate, cycles=3) +k.vab_square_wave(vab=12, cycle_length=2., sampling_rate=k.rx.sampling_rate, cycles=3) r = k.readings[:,2]/k.readings[:,1] print(f'Mean resistance: {np.mean(r):.3f} Ohms, Dev. {100*np.std(r)/np.mean(r):.1f} %') print(f'sampling rate: {k.rx.sampling_rate:.1f} ms, mean sample spacing: {np.mean(np.diff(k.readings[:,0]))*1000.:.1f} ms')