diff --git a/power_plot.py b/power_plot.py index 0322c763d5b590dfb5508e04818eadc3b9b3d5ee..b1124feee5c8f474eeadd6c6110813b9e944e92b 100755 --- a/power_plot.py +++ b/power_plot.py @@ -46,56 +46,35 @@ class PowerPlot: def __init__(self, fig, freq): self.fig = fig - self.ax1 = fig.add_subplot(2, 1, 1) - self.ax2 = fig.add_subplot(2, 1, 2) - self.ax1.set_xlabel("time (s)") - self.ax1.set_ylabel("power (uncalibrated)") - self.ax2.set_xlabel("time (UTC)") - self.ax2.set_ylabel("power (uncalibrated)") - self.ax2.xaxis_date() - self.min1, self.max1 = None, None - self.min2, self.max2 = None, None - self.ax2.xaxis.set_major_formatter( + self.ax = fig.add_subplot() + self.ax.set_xlabel("time (s)") + self.ax.set_ylabel("power (uncalibrated)") + self.ax.xaxis_date() + self.min, self.max = None, None + self.ax.xaxis.set_major_formatter( FuncFormatter(lambda x, pos: f"{num2date(x):%H:%M}") ) fig.suptitle(f"Sgr A Occultation ({freq:.0f} MHz)", fontsize=16) fig.tight_layout() - (self.zoomplot,) = self.ax1.plot([], [], "-", color="blue") - (self.zoomplothighlight,) = self.ax1.plot( - [], [], ".", color="red", markersize=10 - ) - (self.totalplot,) = self.ax2.plot([], [], "-", color="blue") - (self.totalplothighlight,) = self.ax2.plot( + (self.totalplot,) = self.ax.plot([], [], "-", color="blue") + (self.totalplothighlight,) = self.ax.plot( [], [], ".", color="red", markersize=10 ) - def set_zoomplot_values(self, xdata, ydata): - self.zoomplot.set_data(xdata, ydata) - self.zoomplothighlight.set_data(xdata[-1], ydata[-1]) - self.min1 = np.nanmin(ydata) - self.max1 = np.nanmax(ydata) - if np.isnan(self.min1) or np.isnan(self.max1): - self.min1 = None - self.max1 = None - self.ax1.autoscale_view(True, True, True) def set_totalplot_values(self, xdata, ydata): self.totalplot.set_data(xdata, ydata) self.totalplothighlight.set_data(xdata[-1], ydata[-1]) - if self.min2 is None or ydata[-1] < self.min2: - self.min2 = ydata[-1] - if self.max2 is None or ydata[-1] > self.max2: - self.max2 = ydata[-1] - self.ax2.autoscale_view(True, True, True) + if self.min is None or ydata[-1] < self.min: + self.min = ydata[-1] + if self.max is None or ydata[-1] > self.max: + self.max = ydata[-1] + self.ax.autoscale_view(True, True, True) def do_autoscale_y(self): - self.ax1.set_ylim( - self.min1 - (self.max1 - self.min1) * 0.1 - 0.1, - self.max1 + (self.max1 - self.min1) * 0.1 + 0.1, - ) - self.ax2.set_ylim( - self.min2 - (self.max2 - self.min2) * 0.1 - 0.1, - self.max2 + (self.max2 - self.min2) * 0.1 + 0.1, + self.ax.set_ylim( + self.min - (self.max - self.min) * 0.1 - 0.1, + self.max + (self.max - self.min) * 0.1 + 0.1, ) @@ -191,7 +170,6 @@ class PowerPlotMainWindow(QMainWindow): # fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope") self.powerplot = PowerPlot(fig, freq) - self.powerplot.ax1.set_xlim(-last_seconds - 1, 5) self.read_stdin() self.stdin_notifier = QSocketNotifier( @@ -219,14 +197,12 @@ class PowerPlotMainWindow(QMainWindow): self.last_x_buffer = np.roll(self.last_x_buffer, -1) self.last_x_buffer[-1] = power_now - self.powerplot.set_zoomplot_values(self.min_range, self.last_x_buffer) self.powerplot.set_totalplot_values(self.time_dt, self.data) now = time.time() if self.autoscale_x: - self.powerplot.ax2.set_xlim(self.start_time, self.stop_time) - self.powerplot.ax1.set_xlim(-last_seconds, 5) + self.powerplot.ax.set_xlim(self.start_time, self.stop_time) if self.autoscale_y: self.powerplot.do_autoscale_y()