From 9e60aa397eba2e3aa3420b34e9ef6e995e769d8c Mon Sep 17 00:00:00 2001 From: Christopher Montalban Date: Tue, 5 Mar 2024 11:44:34 -0300 Subject: [PATCH] Change from 'fig.canvas.set_window_title' to 'fig.canvas.manager.set_window_title' for plotting using the 'Qt5Agg' backend --- goodman_pipeline/core/core.py | 24 ++++++++++----------- goodman_pipeline/spectroscopy/redspec.py | 2 +- goodman_pipeline/spectroscopy/wavelength.py | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/goodman_pipeline/core/core.py b/goodman_pipeline/core/core.py index d6caf652..d99c5159 100644 --- a/goodman_pipeline/core/core.py +++ b/goodman_pipeline/core/core.py @@ -1547,7 +1547,7 @@ def get_lines_in_lamp(ccd, plots=False): if plots: # pragma: no cover plt.close('all') fig, ax = plt.subplots() - fig.canvas.set_window_title('Lines Detected') + fig.canvas.manager.set_window_title('Lines Detected') mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -2743,7 +2743,7 @@ def recenter_lines(data, lines, plots=False): new_center.append(centroid) if plots: # pragma: no cover fig, ax = plt.subplots(1, 1) - fig.canvas.set_window_title('Lines Detected in Lamp') + fig.canvas.manager.set_window_title('Lines Detected in Lamp') ax.axhline(median, color='b') ax.plot(range(len(data)), @@ -3135,7 +3135,7 @@ def trace(ccd, z1 = np.mean(ccd.data) - 0.5 * np.std(ccd.data) z2 = np.median(ccd.data) + np.std(ccd.data) fig, ax = plt.subplots() - fig.canvas.set_window_title(ccd.header['GSP_FNAM']) + fig.canvas.manager.set_window_title(ccd.header['GSP_FNAM']) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -3247,7 +3247,7 @@ def trace_targets(ccd, target_list, sampling_step=5, pol_deg=2, nfwhm=5, z1 = np.mean(ccd.data) - 0.5 * np.std(ccd.data) z2 = np.median(ccd.data) + np.std(ccd.data) fig, ax = plt.subplots() - fig.canvas.set_window_title(ccd.header['GSP_FNAM']) + fig.canvas.manager.set_window_title(ccd.header['GSP_FNAM']) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4286,7 +4286,7 @@ def __call__(self, plt.switch_backend('Qt5Agg') fig, ax = plt.subplots() - fig.canvas.set_window_title(self.file_name) + fig.canvas.manager.set_window_title(self.file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4363,7 +4363,7 @@ def fit_background(self, spatial_profile=None, file_name=None, plots=False): if plots or self.plots: # pragma: no cover fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4380,7 +4380,7 @@ def fit_background(self, spatial_profile=None, file_name=None, plots=False): plt.show() fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4451,7 +4451,7 @@ def subtract_background(self, spatial_profile=None, background_model=None, plt.close() fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4527,7 +4527,7 @@ def get_peaks(self, plt.ioff() fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) ax.set_title('All detected Peaks') @@ -4623,7 +4623,7 @@ def filter_peaks(self, plt.ioff() fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4742,7 +4742,7 @@ def _fit_gaussian(fitter, if plots: # pragma: no cover fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() @@ -4813,7 +4813,7 @@ def _fit_moffat(fitter, if plots: # pragma: no cover fig, ax = plt.subplots() - fig.canvas.set_window_title(file_name) + fig.canvas.manager.set_window_title(file_name) mng = plt.get_current_fig_manager() mng.window.showMaximized() diff --git a/goodman_pipeline/spectroscopy/redspec.py b/goodman_pipeline/spectroscopy/redspec.py index 54bad0b3..5473846e 100755 --- a/goodman_pipeline/spectroscopy/redspec.py +++ b/goodman_pipeline/spectroscopy/redspec.py @@ -487,7 +487,7 @@ def _run(self, ax.set_ylabel("Intensity (ADU)") ax.set_xlabel("Dispersion Axis (Pixels)") - fig.canvas.set_window_title( + fig.canvas.manager.set_window_title( 'Extracted Data: Target Center ~ ' '{:.2f}'.format(single_profile_center)) diff --git a/goodman_pipeline/spectroscopy/wavelength.py b/goodman_pipeline/spectroscopy/wavelength.py index d57739ad..96cb1eb7 100644 --- a/goodman_pipeline/spectroscopy/wavelength.py +++ b/goodman_pipeline/spectroscopy/wavelength.py @@ -536,7 +536,7 @@ def _automatic_wavelength_solution(self, self.i_fig = None if self.i_fig is None: self.i_fig = plt.figure() - self.i_fig.canvas.set_window_title( + self.i_fig.canvas.manager.set_window_title( 'Automatic Wavelength Solution') self.ax1 = self.i_fig.add_subplot(111) self.ax1.set_rasterization_zorder(1) @@ -695,7 +695,7 @@ def _save_science_data(self, '{:s}\n{:s}'.format(object_name, grating) fig, ax1 = plt.subplots(1) - fig.canvas.set_window_title(ccd.header['GSP_FNAM']) + fig.canvas.manager.set_window_title(ccd.header['GSP_FNAM']) # ax1 = fig.add_subplot(111) mng = plt.get_current_fig_manager()