plesty.pol_pl.viz
Watch a polarization-PL run — live, replayed, or rendered to a video.
uv run python -m plesty.pol_pl.viz monitor # follow the newest run
uv run python -m plesty.pol_pl.viz monitor --replay 2 --record run.mp4
uv run python -m plesty.pol_pl.viz render --run pol_pl_20260915-160124
Everything about watching — which run, where the share is mounted, live or
replayed, a window of its own or embedded in a console that has this module
installed — is plesty.lib.monitor.Viz’s. This module says only what
this experiment’s records mean and what to draw from them.
Three views follow the run: the newest spectrum with every tracked line marked, all spectra so far against the half-wave-plate angle, and the fine structure of the current dot — each line’s shift against the angle while the sweep is measured, then the analysis’s own fits and splittings.
Two of them are shipped, not written here. The spectrum and the fine structure
come from plesty.fss.monitor, whose analyzer measures the splitting, so
this module tells them which of its record fields hold the sweep and nothing
else. Only the map is local, and only because it drops cosmic rays first.
What is genuinely this experiment’s is read_spectrum(): a record names
the file the spectrometer wrote, and turning that path into columns is the one
thing no shared view can do for it.
Watching is passive: these read the records the experiment already committed and the spectra they point at, and write nothing.
Attributes
Classes
The library's map, of the spectra with their cosmic rays taken out. |
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. |
Module Contents
- plesty.pol_pl.viz.SPIKE_THRESHOLD = 20.0
- plesty.pol_pl.viz.remove_spikes(counts: numpy.ndarray) numpy.ndarray
Replace single-pixel spikes (cosmic rays) by the mean of their neighbours.
The map’s colour scale runs from the lowest count to the highest, so one cosmic ray of tens of thousands of counts would leave every emission line black. A spike is a pixel standing 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 — its neighbours are nearly as bright — so lines pass unchanged. The noise is estimated robustly from the pixel-to-pixel differences.- Parameters:
counts (numpy.ndarray) – One spectrum.
- Returns:
The spectrum with single-pixel spikes replaced.
- Return type:
numpy.ndarray
- plesty.pol_pl.viz.read_spectrum(row: Any, run: Any) dict[str, Any]
Turn the file a record names into the columns the views want.
A record carries the path of the spectrum the spectrometer wrote, not the array — that is what keeps a measurement off the network. This is called once per row and cached, so the three views load each spectrum once between them.
Read with
SpectrumData.load()— the same reader the analysis uses — for LightField.speand for.npzspectra saved bySpectrumData.save. A stack of frames is summed per pixel.- 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, andcleanwith the cosmic rays taken out — the map wants the second, the spectrum view the first.- Return type:
dict[str, Any]
- class plesty.pol_pl.viz.CleanedMap(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 the spectra with their cosmic rays taken out.
Only the map drops them: its colour scale runs from the lowest count to the highest, so one ray of tens of thousands of counts would leave every emission line black. The spectrum view above shows every count as recorded.
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 cleaned spectra rather than the recorded ones.
- Parameters:
data (Any)
- Return type:
Any
- plesty.pol_pl.viz.viz
- plesty.pol_pl.viz.lines