From 165d2fc2281798452c3f192b58fd2712e84bf1dd Mon Sep 17 00:00:00 2001 From: Dmitry Butyugin Date: Sat, 3 Apr 2021 23:45:42 +0200 Subject: [PATCH] resonance_tester: Fixed multi-point resonance testing Signed-off-by: Dmitry Butyugin --- klippy/extras/resonance_tester.py | 7 +++++-- klippy/extras/shaper_calibrate.py | 2 +- scripts/calibrate_shaper.py | 4 ++-- scripts/graph_accelerometer.py | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/klippy/extras/resonance_tester.py b/klippy/extras/resonance_tester.py index df557f93..55fa5583 100644 --- a/klippy/extras/resonance_tester.py +++ b/klippy/extras/resonance_tester.py @@ -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') diff --git a/klippy/extras/shaper_calibrate.py b/klippy/extras/shaper_calibrate.py index 71e5e489..3c6065de 100644 --- a/klippy/extras/shaper_calibrate.py +++ b/klippy/extras/shaper_calibrate.py @@ -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): diff --git a/scripts/calibrate_shaper.py b/scripts/calibrate_shaper.py index bd2d4308..5bbc9eea 100755 --- a/scripts/calibrate_shaper.py +++ b/scripts/calibrate_shaper.py @@ -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) diff --git a/scripts/graph_accelerometer.py b/scripts/graph_accelerometer.py index 93dd413b..472530d3 100755 --- a/scripts/graph_accelerometer.py +++ b/scripts/graph_accelerometer.py @@ -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):