From b60c45d3e1ba7402a0c435d77dc71831d0923228 Mon Sep 17 00:00:00 2001 From: Samuelopez-ansys Date: Mon, 4 Nov 2024 10:33:17 +0100 Subject: [PATCH 1/2] Fix get trace data --- .../antenna_results/antenna_results_menu.py | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py index 9e0dcb0c..738d95b7 100644 --- a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py +++ b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py @@ -379,20 +379,22 @@ def theta_cut_combobox_clicked(self): self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta, "Theta", "Phi") def __plot_2d_cut(self, graph_obj, data, cut, cut_name, sweep): - lines = data.ax.get_lines() - x_data = lines[-1].get_xdata() - y_data = lines[-1].get_ydata() - graph_obj.plot( - x_data, - y_data, - pen=self.line_color - ) - graph_obj.setTitle("Realized gain at {} {}".format(cut_name, cut)) - graph_obj.setLabel( - "left", - "Realized Gain", - ) - graph_obj.setLabel( - "bottom", - sweep, - ) + if data: + trace_name = data.trace_names[0] + cartesian_data = data.traces[trace_name].cartesian_data + x_data = cartesian_data[0] + y_data = cartesian_data[1] + graph_obj.plot( + x_data, + y_data, + pen=self.line_color + ) + graph_obj.setTitle("Realized gain at {} {}".format(cut_name, cut)) + graph_obj.setLabel( + "left", + "Realized Gain", + ) + graph_obj.setLabel( + "bottom", + sweep, + ) From 3a42984d017cf8a98aa708734027581c54d703a0 Mon Sep 17 00:00:00 2001 From: Samuelopez-ansys Date: Mon, 4 Nov 2024 11:00:13 +0100 Subject: [PATCH 2/2] Fix get trace data --- .../antenna_results/antenna_results_menu.py | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py index 738d95b7..7a4b1432 100644 --- a/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py +++ b/src/ansys/aedt/toolkits/antenna/ui/windows/antenna_results/antenna_results_menu.py @@ -315,8 +315,8 @@ def antenna_results_finished(self): output_file=None, show=False, is_polar=False) - - self.__plot_2d_cut(self.farfield_2d_phi_graph, data, phi[0], "Phi", "Theta") + if data: + self.__plot_2d_cut(self.farfield_2d_phi_graph, data, phi[0], "Phi", "Theta") data = self.farfield_data.plot_cut(quantity="RealizedGain", primary_sweep="phi", @@ -328,8 +328,8 @@ def antenna_results_finished(self): output_file=None, show=False, is_polar=False) - - self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta[0], "Theta", "Phi") + if data: + self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta[0], "Theta", "Phi") # 3D Plot background_hex = self.main_window.ui.themes["app_color"]["bg_one"] @@ -358,7 +358,8 @@ def phi_cut_combobox_clicked(self): overlap = self.phi_cut_overlap.isChecked() if not overlap: self.farfield_2d_phi_graph.clear() - self.__plot_2d_cut(self.farfield_2d_phi_graph, data, phi, "Phi", "Theta") + if data: + self.__plot_2d_cut(self.farfield_2d_phi_graph, data, phi, "Phi", "Theta") def theta_cut_combobox_clicked(self): if self.farfield_data: @@ -376,25 +377,25 @@ def theta_cut_combobox_clicked(self): overlap = self.theta_cut_overlap.isChecked() if not overlap: self.farfield_2d_theta_graph.clear() - self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta, "Theta", "Phi") + if data: + self.__plot_2d_cut(self.farfield_2d_theta_graph, data, theta, "Theta", "Phi") def __plot_2d_cut(self, graph_obj, data, cut, cut_name, sweep): - if data: - trace_name = data.trace_names[0] - cartesian_data = data.traces[trace_name].cartesian_data - x_data = cartesian_data[0] - y_data = cartesian_data[1] - graph_obj.plot( - x_data, - y_data, - pen=self.line_color - ) - graph_obj.setTitle("Realized gain at {} {}".format(cut_name, cut)) - graph_obj.setLabel( - "left", - "Realized Gain", - ) - graph_obj.setLabel( - "bottom", - sweep, - ) + trace_name = data.trace_names[0] + cartesian_data = data.traces[trace_name].cartesian_data + x_data = cartesian_data[0] + y_data = cartesian_data[1] + graph_obj.plot( + x_data, + y_data, + pen=self.line_color + ) + graph_obj.setTitle("Realized gain at {} {}".format(cut_name, cut)) + graph_obj.setLabel( + "left", + "Realized Gain", + ) + graph_obj.setLabel( + "bottom", + sweep, + )