1
0
Fork 0

Merge pull request #1 from xmichaelx/main

Basic interactivity support
merge-requests/2/head
Cees Bassa 2022-06-18 18:47:56 +02:00 committed by GitHub
commit d32d57e2db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -1,15 +1,29 @@
#!/usr/bin/env python3
import sys
import numpy as np
from strf.rfio import Spectrogram
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from matplotlib.backend_bases import MouseButton
def on_press(event):
handle(event.key, event.xdata, event.ydata)
sys.stdout.flush()
def on_click(event):
if event.button is MouseButton.MIDDLE:
handle("MIDDLE", event.xdata, event.ydata)
sys.stdout.flush()
def handle(key, x, y):
print(f"pressed {key} over x={x} y={y}")
sys.stdout.flush()
if __name__ == "__main__":
# Settings
path = "data"
prefix = "2021-08-04T20:48:35"
prefix = "2021-08-04T20_48_35"
ifile = 50
nsub = 1800
@ -40,4 +54,6 @@ if __name__ == "__main__":
ax.set_ylabel(f"Frequency (MHz) - {fcen * 1e-6:g} MHz")
fig.canvas.mpl_connect('key_press_event', on_press)
fig.canvas.mpl_connect('button_press_event', on_click)
plt.show()