scale image, cleanup
This commit is contained in:
parent
96b2f204e4
commit
efc7ca9e32
2
dmi.py
2
dmi.py
|
@ -14,7 +14,7 @@ def main():
|
||||||
freq_base = 1088230e3
|
freq_base = 1088230e3
|
||||||
block_size = 4096
|
block_size = 4096
|
||||||
|
|
||||||
gui = GUI(block_size)
|
gui = GUI(freq_sample, freq_base, block_size)
|
||||||
try:
|
try:
|
||||||
induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
|
induction = InductionHeater("/dev/ttyUSB0", 350e3, 445e3)
|
||||||
induction.start()
|
induction.start()
|
||||||
|
|
4
gui.py
4
gui.py
|
@ -48,11 +48,11 @@ class ParentComm:
|
||||||
|
|
||||||
|
|
||||||
class GUI:
|
class GUI:
|
||||||
def __init__(self, block_size):
|
def __init__(self, freq_sample, freq_base, block_size):
|
||||||
self.impl = ParentComm()
|
self.impl = ParentComm()
|
||||||
self.impl.create_subprocess([sys.executable,
|
self.impl.create_subprocess([sys.executable,
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), "gui_impl.py"),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), "gui_impl.py"),
|
||||||
str(block_size)])
|
str(freq_sample), str(freq_base), str(block_size)])
|
||||||
|
|
||||||
def update_beat_spectrum(self, data):
|
def update_beat_spectrum(self, data):
|
||||||
obj = {"action": "update_beat_spectrum", "data": data}
|
obj = {"action": "update_beat_spectrum", "data": data}
|
||||||
|
|
28
gui_impl.py
28
gui_impl.py
|
@ -4,32 +4,31 @@ import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from quamash import QEventLoop, QtWidgets
|
from quamash import QEventLoop, QtWidgets, QtCore
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from sipyco.pipe_ipc import AsyncioChildComm
|
from sipyco.pipe_ipc import AsyncioChildComm
|
||||||
from sipyco import pyon
|
from sipyco import pyon
|
||||||
|
|
||||||
|
|
||||||
class SpectrogramWidget(pg.PlotWidget):
|
class SpectrogramWidget(pg.PlotWidget):
|
||||||
def __init__(self, block_size):
|
def __init__(self, freq_sample, freq_base, block_size):
|
||||||
super(SpectrogramWidget, self).__init__()
|
super(SpectrogramWidget, self).__init__()
|
||||||
|
|
||||||
self.block_size = block_size
|
depth = 100
|
||||||
|
self.img_array = np.zeros((depth, block_size))
|
||||||
|
|
||||||
self.img = pg.ImageItem()
|
self.img = pg.ImageItem()
|
||||||
self.addItem(self.img)
|
self.addItem(self.img)
|
||||||
|
|
||||||
self.img_array = np.zeros((100, block_size))
|
self.img.setImage(self.img_array, autoLevels=True)
|
||||||
|
|
||||||
pos = np.array([0., 1., 0.5, 0.25, 0.75])
|
pos = np.array([0., 1., 0.5, 0.25, 0.75])
|
||||||
color = np.array([[0,255,255,255], [255,255,0,255], [0,0,0,255], (0, 0, 255, 255), (255, 0, 0, 255)], dtype=np.ubyte)
|
color = np.array([[0,255,255,255], [255,255,0,255], [0,0,0,255], (0, 0, 255, 255), (255, 0, 0, 255)], dtype=np.ubyte)
|
||||||
cmap = pg.ColorMap(pos, color)
|
cmap = pg.ColorMap(pos, color)
|
||||||
lut = cmap.getLookupTable(0.0, 1.0, 256)
|
lut = cmap.getLookupTable(0.0, 1.0, 256)
|
||||||
|
|
||||||
self.img.setLookupTable(lut)
|
self.img.setLookupTable(lut)
|
||||||
self.img.setLevels([-50,40])
|
|
||||||
|
self.img.setRect(QtCore.QRectF(0.0, freq_base-freq_sample/2, float(depth), freq_sample))
|
||||||
self.show()
|
|
||||||
|
|
||||||
def update(self, block):
|
def update(self, block):
|
||||||
self.img_array = np.roll(self.img_array, -1, 0)
|
self.img_array = np.roll(self.img_array, -1, 0)
|
||||||
|
@ -62,7 +61,9 @@ class IPCClient(AsyncioChildComm):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
block_size = int(sys.argv[1])
|
freq_sample = float(sys.argv[1])
|
||||||
|
freq_base = float(sys.argv[2])
|
||||||
|
block_size = int(sys.argv[3])
|
||||||
|
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
loop = QEventLoop(app)
|
loop = QEventLoop(app)
|
||||||
|
@ -72,7 +73,8 @@ def main():
|
||||||
ipc = IPCClient(os.getenv("NOPTICA2_IPC"))
|
ipc = IPCClient(os.getenv("NOPTICA2_IPC"))
|
||||||
loop.run_until_complete(ipc.connect())
|
loop.run_until_complete(ipc.connect())
|
||||||
try:
|
try:
|
||||||
main_widget = SpectrogramWidget(block_size)
|
main_widget = SpectrogramWidget(freq_sample, freq_base, block_size)
|
||||||
|
main_widget.setWindowTitle("NOPTICA Wavemeter")
|
||||||
main_widget.show()
|
main_widget.show()
|
||||||
ipc.set_close_cb(main_widget.close)
|
ipc.set_close_cb(main_widget.close)
|
||||||
asyncio.ensure_future(ipc.listen(main_widget))
|
asyncio.ensure_future(ipc.listen(main_widget))
|
||||||
|
|
Loading…
Reference in New Issue