From 197e29d515d69914f04bbcb8d8ea8ee9965ed603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnker?= Date: Tue, 21 Nov 2023 10:33:33 +0100 Subject: [PATCH] =?UTF-8?q?start=20fixing=20qint=20mode=20Signed-off-by:?= =?UTF-8?q?=20Christian=20M=C3=BCnker=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyfda/plot_widgets/plot_impz.py | 37 +++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/pyfda/plot_widgets/plot_impz.py b/pyfda/plot_widgets/plot_impz.py index 154699f55..08b07a119 100644 --- a/pyfda/plot_widgets/plot_impz.py +++ b/pyfda/plot_widgets/plot_impz.py @@ -888,24 +888,49 @@ def draw(self, arg=None): logger.error("Response should have been calculated by now!") return - self.scale_i = self.scale_o = 1 + self.scale_i = self.scale_iq = self.scale_o = 1 self.fx_min = -1. self.fx_max = 1. if fb.fil[0]['fx_sim']: # fixpoint simulation enabled -> scale stimulus and response try: - if self.ui.but_fx_scale.isChecked(): + if fb.fil[0]['qfrmt'] == 'qint': # display stimulus and response as integer values: # - multiply stimulus and response by 2 ** WF self.scale_i = 1 << fb.fil[0]['fxqc']['QI']['WF'] + self.scale_iq = 1 self.scale_o = 1 << fb.fil[0]['fxqc']['QO']['WF'] self.fx_min = - (1 << fb.fil[0]['fxqc']['QO']['WI']\ + fb.fil[0]['fxqc']['QO']['WF'] + 1) self.fx_max = -self.fx_min - 1 - else: + elif fb.fil[0]['qfrmt'] == 'qfrac': # display values scaled as "real world (float) values" + self.scale_i = 1 + self.scale_iq = 1 + self.scale_o = 1 + # self.fx_min = - (1 << fb.fil[0]['fxqc']['QO']['WI']\ + # + fb.fil[0]['fxqc']['QO']['WF'] + 1) + # self.fx_max = -self.fx_min - 1 self.fx_min = -(1 << fb.fil[0]['fxqc']['QO']['WI']) self.fx_max = -self.fx_min - 1. / (1 << fb.fil[0]['fxqc']['QO']['WF']) + logger.warning(f"{self.scale_i} - {self.scale_o}") + + # if self.ui.but_fx_scale.isChecked(): + # # display stimulus and response as integer values: + # # - multiply stimulus and response by 2 ** WF + # self.scale_i = 1 << fb.fil[0]['fxqc']['QI']['WF'] + # self.scale_o = 1 << fb.fil[0]['fxqc']['QO']['WF'] + # self.fx_min = - (1 << fb.fil[0]['fxqc']['QO']['WI']\ + # + fb.fil[0]['fxqc']['QO']['WF'] + 1) + # self.fx_max = -self.fx_min - 1 + # if fb.fil[0]['qfrmt'] == 'qfrac': + # self.scale_iq = 1 << fb.fil[0]['fxqc']['QI']['WF'] + # elif fb.fil[0]['qfrmt'] == 'qint': + # self.scale_iq = 1 + # else: + # # display values scaled as "real world (float) values" + # self.fx_min = -(1 << fb.fil[0]['fxqc']['QO']['WI']) + # self.fx_max = -self.fx_min - 1. / (1 << fb.fil[0]['fxqc']['QO']['WF']) except AttributeError as e: logger.error("Attribute error: {0}".format(e)) @@ -1149,7 +1174,7 @@ def draw_time(self, N_start=0, N_end=0): # fixpoint simulation enabled -> scale stimulus and response if fb.fil[0]['fx_sim'] and hasattr(self, 'x_q'): - x_q = self.x_q[self.ui.N_start:N_end] * self.scale_i + x_q = self.x_q[self.ui.N_start:N_end] * self.scale_iq if self.ui.but_log_time.isChecked(): x_q = np.maximum(20 * np.log10(abs(x_q)), self.ui.bottom_t) @@ -1622,9 +1647,9 @@ def draw_freq(self): if plt_stimulus_q: Pxq = np.sum(np.square(np.abs(self.X_q))) * P_scale if fb.fil[0]['freqSpecsRangeType'] == 'half' and not freq_resp: - X_q = calc_ssb_spectrum(self.X_q) * self.scale_i * scale_impz + X_q = calc_ssb_spectrum(self.X_q) * self.scale_iq * scale_impz else: - X_q = self.X_q * self.scale_i * scale_impz + X_q = self.X_q * self.scale_iq * scale_impz if plt_response: Py = np.sum(np.square(np.abs(self.Y * self.scale_o))) * P_scale