fix graph and white background added
This commit is contained in:
@@ -4,14 +4,13 @@ from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
|
||||
from PyQt6.QtCore import QRectF
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
|
||||
from python_app.models.collection_identity import collection_key
|
||||
from python_app.models.dataset_model import ResultCollection
|
||||
from python_app.models.gui_profile_schema import GuiBscanStateModel
|
||||
from python_app.gui.controllers.renderers.common import build_lut, create_plot
|
||||
from python_app.gui.controllers.renderers.common import build_lut, create_plot, image_rect
|
||||
|
||||
|
||||
def _result_tail(
|
||||
@@ -109,16 +108,18 @@ def bscan_levels(sweeps: np.ndarray, axis_mode: str) -> tuple[float, float]:
|
||||
return -max_abs, max_abs
|
||||
|
||||
|
||||
_TITLE = "B-scan S21"
|
||||
|
||||
|
||||
class BscanRenderer:
|
||||
"""Own the heatmap and its per-combination arrays; input history stays external."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.widget = create_plot()
|
||||
self.widget = create_plot(_TITLE)
|
||||
self.widget.setLabel("bottom", "Sweep #")
|
||||
self.widget.setLabel("left", "Range", units="m")
|
||||
item = self.widget.getPlotItem()
|
||||
assert item is not None
|
||||
item.getViewBox().invertY(False)
|
||||
item.getViewBox().enableAutoRange(x=False, y=False)
|
||||
self.image = pg.ImageItem(axisOrder="row-major")
|
||||
item.addItem(self.image)
|
||||
@@ -139,24 +140,28 @@ class BscanRenderer:
|
||||
history = self.history_by_combo.get(key) if key is not None else None
|
||||
depth = self.depth_axis_by_combo.get(key) if key is not None else None
|
||||
if not history or depth is None:
|
||||
self.image.clear()
|
||||
self._show_empty()
|
||||
return False
|
||||
sweeps = apply_mean_ascan_subtraction(history, enabled=settings.subtract_mean_ascan)
|
||||
depth_min, depth_max = float(np.min(depth)), float(np.max(depth))
|
||||
count = sweeps.shape[0]
|
||||
rect = image_rect(np.arange(1, count + 1), depth)
|
||||
self.image.setImage(sweeps.T, autoLevels=False)
|
||||
self.image.setRect(QRectF(.5, depth_min, float(count), max(depth_max - depth_min, 1e-6)))
|
||||
self.image.setRect(rect)
|
||||
self.image.setLookupTable(bscan_lookup_table(settings.axis))
|
||||
self.image.setLevels(bscan_levels(sweeps, settings.axis))
|
||||
item = self.widget.getPlotItem()
|
||||
assert item is not None
|
||||
item.getViewBox().setRange(xRange=(.5, .5 + count), yRange=(depth_min, depth_max), padding=.02)
|
||||
item.getViewBox().setRange(rect, padding=.02)
|
||||
assert key is not None
|
||||
self.widget.setTitle(f"B-scan S21 in{key[0]}/out{key[1]} | sweeps={count}")
|
||||
self.widget.setTitle(f"{_TITLE} in{key[0]}/out{key[1]} | sweeps={count}")
|
||||
return True
|
||||
|
||||
def clear(self) -> None:
|
||||
self.history_by_combo.clear()
|
||||
self.depth_axis_by_combo.clear()
|
||||
self.signature = None
|
||||
self._show_empty()
|
||||
|
||||
def _show_empty(self) -> None:
|
||||
self.image.clear()
|
||||
self.widget.setTitle(_TITLE)
|
||||
|
||||
Reference in New Issue
Block a user