QScanner#
- class QPolargraph.QScanner.QScanner(*args, configdir=None, fake=False, pattern=None, **kwargs)[source]#
Bases:
QMainWindowApplication framework for a polargraph scanner.
Builds the UI programmatically, wires up a
QPolargraphWidgetand aQScanPatternWidget, and provides a livepyqtgraphdisplay of the scan trajectory and current belt geometry. Intended to be subclassed for experiment-specific scanner applications.Class Attributes#
- SCAN_PATTERNtype
QScanPatternsubclass to instantiate as the scan pattern. Default:PolarScan. Subclasses override this to select a different scan pattern:class QMyScanner(QScanner): SCAN_PATTERN = RasterScan
- SCAN_WIDGETtype
QScanPatternWidgetsubclass to instantiate as the scan controls widget. Default:QScanPatternWidget. Subclasses override this to provide a custom controls widget:class QMyScanner(QScanner): SCAN_WIDGET = TarzanScanWidget
Properties#
- configdirstr
Directory for storing instrument configuration. Defaults to
~/.<ClassName>where ClassName is the name of the concrete subclass: each subclass gets its own config directory.
- Signals()#
- -------
- dataReady(dict)#
Emitted at each position during a scan. The base class emits
{'t': float, 'x': float, 'y': float}wheretis atime.monotonic()timestamp [s] andx,yare Cartesian coordinates [m]. Subclasses may override_onDataReady()to merge in additional measurement fields before emitting. Because_onDataReadyruns on the GUI thread, instrument reads there should be fast and non-blocking; for tight timing call the instrument inside_onMeasure()instead (runs in the polargraph device thread):def _onDataReady(self, pos: np.ndarray) -> None: self.dataReady.emit( {'t': float(pos[2]), 'x': float(pos[0]), 'y': float(pos[1])} | self.instrument.acquire())
A sequence of emitted dicts can be collected directly into a
pandas.DataFrame:rows = [] scanner.dataReady.connect(rows.append) # after scan: df = pd.DataFrame(rows)
- dataReady#
- SCAN_WIDGET#
alias of
QScanPatternWidget
- toggleScan()[source]#
Emit the toggle signal to start, pause, or resume the scan.
Routes through
_toggleso the call is delivered as aQueuedConnectionwhen the scan pattern lives in a worker thread (real hardware), or as aDirectConnectionin tests.- Return type:
- plotData(x, y, hue, saturation=1.0)[source]#
Add scatter points to the data plot.
- Parameters:
x (array-like) – Horizontal coordinates [m].
y (array-like) – Vertical coordinates [m].
hue (array-like) – Color values in
[0, 1](HSV hue).saturation (array-like, optional) – Saturation values in
[0, 1](HSV saturation). Default: 1.0 (fully saturated). Low saturation appears white, high saturation gives the pure hue color.
- Return type:
- classmethod example()[source]#
Launch the scanner application.
Creates a
QApplication, instantiates the scanner, shows it, and runs the event loop. Intended to be called from__main__in subclass modules:if __name__ == '__main__': QMyScanner.example()
Accepts the following command-line flags:
- Return type:
-f/--fakeForce use of the fake instrument.
-r/--rasterUse
RasterScan.-p/--polarUse
PolarScan(default).-t/--tarzanUse
TarzanScan.