resonance_tester: Fixed multi-point resonance testing

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
Dmitry Butyugin 2021-04-03 23:45:42 +02:00 committed by KevinOConnor
parent bf01d6d1f8
commit 165d2fc228
4 changed files with 10 additions and 7 deletions

View File

@ -178,7 +178,10 @@ class ResonanceTester:
"%s-axis accelerometer measured no data" % (
chip_axis,))
new_data = helper.process_accelerometer_data(chip_values)
data = data.join(new_data) if data else new_data
if data is None:
data = new_data
else:
data.add_data(new_data)
if csv_output:
csv_name = self.save_calibration_data('resonances', name_suffix,
helper, axis, data)
@ -251,7 +254,7 @@ class ResonanceTester:
if calibration_data[axis] is None:
calibration_data[axis] = new_data
else:
calibration_data[axis].join(new_data)
calibration_data[axis].add_data(new_data)
configfile = self.printer.lookup_object('configfile')

View File

@ -142,7 +142,7 @@ class CalibrationData:
self._psd_map = {'x': self.psd_x, 'y': self.psd_y, 'z': self.psd_z,
'all': self.psd_sum}
self.data_sets = 1
def join(self, other):
def add_data(self, other):
np = self.numpy
joined_data_sets = self.data_sets + other.data_sets
for psd, other_psd in zip(self._psd_list, other._psd_list):

View File

@ -45,12 +45,12 @@ def calibrate_shaper(datas, csv_output, max_smoothing):
if isinstance(datas[0], CalibrationData):
calibration_data = datas[0]
for data in datas[1:]:
calibration_data.join(data)
calibration_data.add_data(data)
else:
# Process accelerometer data
calibration_data = helper.process_accelerometer_data(datas[0])
for data in datas[1:]:
calibration_data.join(helper.process_accelerometer_data(data))
calibration_data.add_data(helper.process_accelerometer_data(data))
calibration_data.normalize_to_frequencies()
shaper, all_shapers = helper.find_best_shaper(
calibration_data, max_smoothing, print)

View File

@ -82,7 +82,7 @@ def calc_specgram(data, axis):
def plot_frequency(datas, lognames, max_freq):
calibration_data = calc_freq_response(datas[0], max_freq)
for data in datas[1:]:
calibration_data.join(calc_freq_response(data, max_freq))
calibration_data.add_data(calc_freq_response(data, max_freq))
freqs = calibration_data.freq_bins
psd = calibration_data.psd_sum[freqs <= max_freq]
px = calibration_data.psd_x[freqs <= max_freq]
@ -158,7 +158,7 @@ def write_frequency_response(datas, output):
helper = ShaperCalibrate(printer=None)
calibration_data = helper.process_accelerometer_data(datas[0])
for data in datas[1:]:
calibration_data.join(helper.process_accelerometer_data(data))
calibration_data.add_data(helper.process_accelerometer_data(data))
helper.save_calibration_data(output, calibration_data)
def write_specgram(psd, freq_bins, time, output):