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

Automatic title

parent 98e8a761
No related branches found
No related tags found
No related merge requests found
...@@ -14,5 +14,5 @@ with open("doppler.txt", "r") as f: ...@@ -14,5 +14,5 @@ with open("doppler.txt", "r") as f:
print(line, end='', flush=True) print(line, end='', flush=True)
else: else:
print(line, end='', flush=True) print(line, end='', flush=True)
if a > 1000: if a > 500:
sleep(1) sleep(1)
...@@ -39,17 +39,17 @@ last_seconds = 10 * 60 ...@@ -39,17 +39,17 @@ last_seconds = 10 * 60
class PowerPlot: class PowerPlot:
"""A power plot with two time scales""" """A power plot with two time scales"""
def __init__(self, fig): def __init__(self, fig, yname):
self.fig = fig self.fig = fig
self.ax = fig.add_subplot() self.ax = fig.add_subplot()
self.ax.set_xlabel("Time (UTC)") self.ax.set_xlabel("Time (UTC)")
self.ax.set_ylabel("Frequency") self.ax.set_ylabel(yname)
self.ax.xaxis_date() self.ax.xaxis_date()
self.min, self.max = None, None self.min, self.max = None, None
self.ax.xaxis.set_major_formatter( self.ax.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"Maximum frequency", fontsize=16) fig.suptitle(yname, fontsize=16)
fig.tight_layout() fig.tight_layout()
(self.totalplot,) = self.ax.plot([], [], ".", color="blue") (self.totalplot,) = self.ax.plot([], [], ".", color="blue")
(self.totalplothighlight,) = self.ax.plot( (self.totalplothighlight,) = self.ax.plot(
...@@ -95,26 +95,30 @@ class MyToolbar(NavigationToolbar): ...@@ -95,26 +95,30 @@ class MyToolbar(NavigationToolbar):
class PowerPlotMainWindow(QMainWindow): class PowerPlotMainWindow(QMainWindow):
"""QT Application that reads data from stdin, plots in a PowerPlot""" """QT Application that reads data from stdin, plots in a PowerPlot"""
def __init__(self): def __init__(self, col_num=1):
super().__init__() super().__init__()
self.setStyleSheet("background-color: white;") self.setStyleSheet("background-color: white;")
self.autoscale_x = True self.autoscale_x = True
self.autoscale_y = True self.autoscale_y = True
self.col_num = col_num
self.setWindowTitle("Dwingeloo Radio Telescope") self.setWindowTitle("Dwingeloo Radio Telescope")
self.setGeometry(100, 100, 800, 600) self.setGeometry(100, 100, 800, 600)
central_widget = QWidget(self) central_widget = QWidget(self)
layout = QVBoxLayout(central_widget) layout = QVBoxLayout(central_widget)
# Get metadata # Get metadata and ignore it
header_lines = [] header_lines = []
while True: while True:
line = sys.stdin.readline() line = sys.stdin.readline()
header_lines.append(line) header_lines.append(line)
if line[0] != "#": if line[0] != "#":
column_names = line.split() column_names = [name.strip() for name in line.split()]
break break
yname = column_names[self.col_num]
yname = yname.rstrip(",").capitalize()
line = sys.stdin.readline() line = sys.stdin.readline()
values = line.split(",") values = line.split(",")
first_time = datetime.utcfromtimestamp(float(values[0])) first_time = datetime.utcfromtimestamp(float(values[0]))
...@@ -125,7 +129,7 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -125,7 +129,7 @@ class PowerPlotMainWindow(QMainWindow):
self.min_range = np.arange(-last_seconds, 1, 1) self.min_range = np.arange(-last_seconds, 1, 1)
self.data = np.array([float(values[1])]) self.data = np.array([float(values[self.col_num])])
self.start_time = first_time self.start_time = first_time
self.stop_time = first_time + timedelta(hours=2) self.stop_time = first_time + timedelta(hours=2)
...@@ -149,7 +153,7 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -149,7 +153,7 @@ 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) self.powerplot = PowerPlot(fig, yname)
self.read_stdin() self.read_stdin()
self.stdin_notifier = QSocketNotifier( self.stdin_notifier = QSocketNotifier(
...@@ -166,7 +170,7 @@ class PowerPlotMainWindow(QMainWindow): ...@@ -166,7 +170,7 @@ class PowerPlotMainWindow(QMainWindow):
self.output_counter += 1 self.output_counter += 1
values = line.split(",") values = line.split(",")
time_now = float(values[0]) time_now = float(values[0])
power_now = float(values[1]) power_now = float(values[self.col_num])
self.time_dt = np.append( self.time_dt = np.append(
self.time_dt, date2num(datetime.utcfromtimestamp(time_now)) self.time_dt, date2num(datetime.utcfromtimestamp(time_now))
...@@ -210,4 +214,5 @@ if __name__ == "__main__": ...@@ -210,4 +214,5 @@ if __name__ == "__main__":
main_window = PowerPlotMainWindow() main_window = PowerPlotMainWindow()
main_window.show() main_window.show()
signal.signal(signal.SIGINT, handle_interrupt_signal) signal.signal(signal.SIGINT, handle_interrupt_signal)
sys.exit(app.exec_()) sys.exit(app.exec_())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment