plesty.pow_pl.viz
Watch a power-PL run — live, replayed, or rendered to a video.
uv run python -m plesty.pow_pl.viz monitor # follow the newest run
uv run python -m plesty.pow_pl.viz monitor --replay 2 --record run.mp4
uv run python -m plesty.pow_pl.viz render --run D104-C_QD01_20261012
Everything about watching — which run, where the share is mounted, live or
replayed, a window of its own or embedded in the bench console — is
plesty.lib.monitor.Viz’s. The manifest names this module as the
experiment’s viewer (viz), so the bench opens it on the runs it starts.
Four views follow the run: the newest spectrum; every spectrum so far against
the wave-plate angle, in counts per second so the exposures of one angle
compare; the excitation power against the angle; and the integrated emission
against the power on log–log axes with its running exponent k — the number
the analysis after the sweep (analysis) reports for the whole range.
What is this experiment’s own is read_spectrum(): a record names the file
the spectrometer wrote, and turning it into columns is the one thing no shared
view can do. Watching is passive: the views read committed records and the
spectra they point at, and write nothing.
Attributes
Classes
Integrated emission against power on log–log axes, with the running exponent. |
|
The library's map, of every spectrum in counts per second without cosmic rays. |
Functions
|
Replace single-pixel spikes (cosmic rays) by the mean of their neighbours. |
|
Turn the file a record names into the columns the views want. |
|
Pixels inside band, or every pixel when no band is given. |
|
Power (µW) and integrated emission (counts/s) of every spectrum so far. |
Module Contents
- plesty.pow_pl.viz.SPIKE_THRESHOLD = 20.0
- plesty.pow_pl.viz.MIN_POINTS = 4
- plesty.pow_pl.viz.remove_spikes(counts: numpy.ndarray) numpy.ndarray
Replace single-pixel spikes (cosmic rays) by the mean of their neighbours.
A spike stands more than
SPIKE_THRESHOLDnoise levels above the brighter of its two neighbours and more than twice that neighbour; the peak of an emission line fails the second test, so lines pass unchanged.- Parameters:
counts (numpy.ndarray) – One spectrum.
- Returns:
The spectrum with single-pixel spikes replaced.
- Return type:
numpy.ndarray
- plesty.pow_pl.viz.read_spectrum(row: Any, run: Any) dict[str, Any]
Turn the file a record names into the columns the views want.
Called once per row and cached, so the views load each spectrum once between them.
- Parameters:
row (Any) – One committed record.
run (Any) – The run it belongs to;
run.localtranslates the acquiring host’s path onto this machine.
- Returns:
wavelength;countsas recorded;rate, the spectrum without cosmic rays in counts per second; andpower_uw. Nothing for a row that names no spectrum.- Return type:
dict[str, Any]
- plesty.pow_pl.viz._band(wavelength: numpy.ndarray, band: Sequence[float] | None) numpy.ndarray
Pixels inside band, or every pixel when no band is given.
- Parameters:
wavelength (numpy.ndarray)
band (Optional[Sequence[float]])
- Return type:
numpy.ndarray
- plesty.pow_pl.viz.integrated(data: Any) tuple[numpy.ndarray, numpy.ndarray]
Power (µW) and integrated emission (counts/s) of every spectrum so far.
The same reduction as the analysis: each spectrum minus its background (the median of
analysis.background_nm, or of the whole spectrum), summed overanalysis.region_nm(or every pixel).- Parameters:
data (Any) – The run’s
RunData.- Returns:
Two arrays, one value per spectrum that has a power.
- Return type:
tuple[numpy.ndarray, numpy.ndarray]
- class plesty.pow_pl.viz.PowerLaw(title: str = '', *, name: str = '', weight: float | None = None, area: str = '')
Bases:
plesty.lib.monitor.PlotIntegrated emission against power on log–log axes, with the running exponent.
Name the view.
- Parameters:
title (str) – Overrides the class attribute.
name (str) – Layout key; defaults to the title.
weight (Optional[float]) – Overrides the class attribute.
area (str) – Overrides the class attribute.
- title = 'Integrated emission against power'
- draw(data: Any) list[Any]
Every spectrum so far as a point, and the fitted line once there are enough.
- Parameters:
data (Any)
- Return type:
list[Any]
- class plesty.pow_pl.viz.RateMap(values: str = 'counts', row: str = '', *, x: str = 'wavelength', title: str = '', name: str = '', weight: float | None = None, area: str = '', color: str = 'violet', scale: str = 'sqrt', x_label: str = 'Wavelength (nm)', y_label: str = '')
Bases:
plesty.lib.monitor.common.SpectrumMapThe library’s map, of every spectrum in counts per second without cosmic rays.
Per second, because each angle may be measured at several exposures; without cosmic rays, because the colour scale runs from the lowest value to the highest and one ray would leave every emission line dark.
Stack values across rows, against row.
- Parameters:
values (str) – Field holding each row’s array.
row (str) – Field holding the swept coordinate, for the axis; empty numbers the rows instead.
x (str) – Field holding the sample axis, shared by every row — so the map is drawn in the same units as the spectrum above it.
"", or a field no row carries, numbers the samples.title (str) – What the view is called.
name (str) – Layout key.
weight (Optional[float]) – Relative size.
area (str) – Which side of the window it starts on.
color (str) – Palette token the colour map is built from.
scale (str) –
"sqrt"or"linear".x_label (str) – Axis label of the sample axis.
y_label (str) – Axis label of the swept axis.
- block(data: Any) Any
Stack the per-second spectra rather than the recorded counts.
- Parameters:
data (Any)
- Return type:
Any
- plesty.pow_pl.viz.viz