Skip to content
Snippets Groups Projects
Commit b2f12b2d authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Remove one plot

parent 368f2c1a
No related branches found
No related tags found
No related merge requests found
...@@ -46,56 +46,35 @@ class PowerPlot: ...@@ -46,56 +46,35 @@ class PowerPlot:
def __init__(self, fig, freq): def __init__(self, fig, freq):
self.fig = fig self.fig = fig
self.ax1 = fig.add_subplot(2, 1, 1) self.ax = fig.add_subplot()
self.ax2 = fig.add_subplot(2, 1, 2) self.ax.set_xlabel("time (s)")
self.ax1.set_xlabel("time (s)") self.ax.set_ylabel("power (uncalibrated)")
self.ax1.set_ylabel("power (uncalibrated)") self.ax.xaxis_date()
self.ax2.set_xlabel("time (UTC)") self.min, self.max = None, None
self.ax2.set_ylabel("power (uncalibrated)") self.ax.xaxis.set_major_formatter(
self.ax2.xaxis_date()
self.min1, self.max1 = None, None
self.min2, self.max2 = None, None
self.ax2.xaxis.set_major_formatter(
FuncFormatter(lambda x, pos: f"{num2date(x):%H:%M}") FuncFormatter(lambda x, pos: f"{num2date(x):%H:%M}")
) )
fig.suptitle(f"Sgr A Occultation ({freq:.0f} MHz)", fontsize=16) fig.suptitle(f"Sgr A Occultation ({freq:.0f} MHz)", fontsize=16)
fig.tight_layout() fig.tight_layout()
(self.zoomplot,) = self.ax1.plot([], [], "-", color="blue") (self.totalplot,) = self.ax.plot([], [], "-", color="blue")
(self.zoomplothighlight,) = self.ax1.plot( (self.totalplothighlight,) = self.ax.plot(
[], [], ".", color="red", markersize=10
)
(self.totalplot,) = self.ax2.plot([], [], "-", color="blue")
(self.totalplothighlight,) = self.ax2.plot(
[], [], ".", color="red", markersize=10 [], [], ".", 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): def set_totalplot_values(self, xdata, ydata):
self.totalplot.set_data(xdata, ydata) self.totalplot.set_data(xdata, ydata)
self.totalplothighlight.set_data(xdata[-1], ydata[-1]) self.totalplothighlight.set_data(xdata[-1], ydata[-1])
if self.min2 is None or ydata[-1] < self.min2: if self.min is None or ydata[-1] < self.min:
self.min2 = ydata[-1] self.min = ydata[-1]
if self.max2 is None or ydata[-1] > self.max2: if self.max is None or ydata[-1] > self.max:
self.max2 = ydata[-1] self.max = ydata[-1]
self.ax2.autoscale_view(True, True, True) self.ax.autoscale_view(True, True, True)
def do_autoscale_y(self): def do_autoscale_y(self):
self.ax1.set_ylim( self.ax.set_ylim(
self.min1 - (self.max1 - self.min1) * 0.1 - 0.1, self.min - (self.max - self.min) * 0.1 - 0.1,
self.max1 + (self.max1 - self.min1) * 0.1 + 0.1, self.max + (self.max - self.min) * 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,
) )
...@@ -191,7 +170,6 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -191,7 +170,6 @@ class PowerPlotMainWindow(QMainWindow):
# fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope") # fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope")
self.powerplot = PowerPlot(fig, freq) self.powerplot = PowerPlot(fig, freq)
self.powerplot.ax1.set_xlim(-last_seconds - 1, 5)
self.read_stdin() self.read_stdin()
self.stdin_notifier = QSocketNotifier( self.stdin_notifier = QSocketNotifier(
...@@ -219,14 +197,12 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -219,14 +197,12 @@ class PowerPlotMainWindow(QMainWindow):
self.last_x_buffer = np.roll(self.last_x_buffer, -1) self.last_x_buffer = np.roll(self.last_x_buffer, -1)
self.last_x_buffer[-1] = power_now 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) self.powerplot.set_totalplot_values(self.time_dt, self.data)
now = time.time() now = time.time()
if self.autoscale_x: if self.autoscale_x:
self.powerplot.ax2.set_xlim(self.start_time, self.stop_time) self.powerplot.ax.set_xlim(self.start_time, self.stop_time)
self.powerplot.ax1.set_xlim(-last_seconds, 5)
if self.autoscale_y: if self.autoscale_y:
self.powerplot.do_autoscale_y() self.powerplot.do_autoscale_y()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment