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:
print(line, end='', flush=True)
else:
print(line, end='', flush=True)
if a > 1000:
if a > 500:
sleep(1)
......@@ -39,17 +39,17 @@ last_seconds = 10 * 60
class PowerPlot:
"""A power plot with two time scales"""
def __init__(self, fig):
def __init__(self, fig, yname):
self.fig = fig
self.ax = fig.add_subplot()
self.ax.set_xlabel("Time (UTC)")
self.ax.set_ylabel("Frequency")
self.ax.set_ylabel(yname)
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"Maximum frequency", fontsize=16)
fig.suptitle(yname, fontsize=16)
fig.tight_layout()
(self.totalplot,) = self.ax.plot([], [], ".", color="blue")
(self.totalplothighlight,) = self.ax.plot(
......@@ -95,26 +95,30 @@ class MyToolbar(NavigationToolbar):
class PowerPlotMainWindow(QMainWindow):
"""QT Application that reads data from stdin, plots in a PowerPlot"""
def __init__(self):
def __init__(self, col_num=1):
super().__init__()
self.setStyleSheet("background-color: white;")
self.autoscale_x = True
self.autoscale_y = True
self.col_num = col_num
self.setWindowTitle("Dwingeloo Radio Telescope")
self.setGeometry(100, 100, 800, 600)
central_widget = QWidget(self)
layout = QVBoxLayout(central_widget)
# Get metadata
# Get metadata and ignore it
header_lines = []
while True:
line = sys.stdin.readline()
header_lines.append(line)
if line[0] != "#":
column_names = line.split()
column_names = [name.strip() for name in line.split()]
break
yname = column_names[self.col_num]
yname = yname.rstrip(",").capitalize()
line = sys.stdin.readline()
values = line.split(",")
first_time = datetime.utcfromtimestamp(float(values[0]))
......@@ -125,7 +129,7 @@ class PowerPlotMainWindow(QMainWindow):
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.stop_time = first_time + timedelta(hours=2)
......@@ -149,7 +153,7 @@ class PowerPlotMainWindow(QMainWindow):
# fig.canvas.manager.set_window_title("Dwingeloo Radio Telescope")
self.powerplot = PowerPlot(fig)
self.powerplot = PowerPlot(fig, yname)
self.read_stdin()
self.stdin_notifier = QSocketNotifier(
......@@ -166,7 +170,7 @@ class PowerPlotMainWindow(QMainWindow):
self.output_counter += 1
values = line.split(",")
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, date2num(datetime.utcfromtimestamp(time_now))
......@@ -210,4 +214,5 @@ if __name__ == "__main__":
main_window = PowerPlotMainWindow()
main_window.show()
signal.signal(signal.SIGINT, handle_interrupt_signal)
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