plesty.lib.monitor.common
The plots most experiments want, so most experiments write none.
spectrum— a spectrum, and a stack of them as a map.series— one field against another, over the rows.
These are the same views in every lab, and an experiment that only needs them adds them by name.
from plesty.lib.monitor import Viz
from plesty.lib.monitor.common import Series, Spectrum, SpectrumMap
viz = Viz("Polarization PL", experiment="pol_pl", reads=read_spectrum)
viz.add_plot(Spectrum(weight=3))
viz.add_plot(SpectrumMap(row="hwp_deg", y_label="HWP angle (deg)", weight=3))
Each is an ordinary Plot: it reads the
run’s data and returns drawables, with nothing privileged about it. An
experiment that wants one of these nearly — the same map with its cosmic
rays removed — subclasses it and overrides one method, or writes its own plot
and loses nothing.
What they have in common is that they name fields, not channels. Which column holds the counts is the experiment’s business and is said once, here, rather than declared in a schema the view then has to be matched against.
Submodules
Classes
One field against another, a point per committed row. |
|
The newest spectrum a run has committed. |
|
Every spectrum so far, stacked against whatever was swept. |
Package Contents
- class plesty.lib.monitor.common.Series(y: str, x: str = '', *, title: str = '', name: str = '', weight: float | None = None, area: str = '', color: str = 'mint', x_label: str = '', y_label: str = '', marker: bool = True)
Bases:
plesty.lib.monitor.plots.PlotOne field against another, a point per committed row.
The ordinary view of a sweep whose steps each produce a number: a power against an angle, a count rate against a wavelength.
Draw y against x over the rows.
- Parameters:
y (str) – Field holding the value.
x (str) – Field holding the position; empty numbers the rows.
title (str) – What the view is called; defaults to the field names.
name (str) – Layout key.
weight (Optional[float]) – Relative size.
area (str) – Which side of the window it starts on.
color (str) – Palette token.
x_label (str) – Axis label; defaults to the field name.
y_label (str) – Axis label; defaults to the field name.
marker (bool) – Mark each point as well as joining them.
- title = 'Series'
- x = ''
- y
- color = 'mint'
- x_label = 'Step'
- y_label
- marker = True
- draw(data: Any) plesty.lib.monitor.plots.Drawing
Draw the series, leaving out rows that carry no value.
- Parameters:
data (Any) – The run’s data.
- Returns:
One curve, or nothing before the first value.
- Return type:
- class plesty.lib.monitor.common.Spectrum(y: str = 'counts', x: str = 'wavelength', *, title: str = '', name: str = '', weight: float | None = None, area: str = '', color: str = 'cyan', x_label: str = 'Wavelength (nm)', y_label: str = 'Counts')
Bases:
plesty.lib.monitor.plots.PlotThe newest spectrum a run has committed.
- Variables:
x – Field holding the axis — the wavelengths, or whatever it is measured against.
y – Field holding the values.
- Parameters:
y (str)
x (str)
title (str)
name (str)
weight (Optional[float])
area (str)
color (str)
x_label (str)
y_label (str)
Draw the newest y against x.
- Parameters:
y (str) – Field holding the values.
x (str) – Field holding the axis.
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 for the curve.
x_label (str) – Axis label including the unit.
y_label (str) – Axis label including the unit.
- title = 'Spectrum'
- x = 'wavelength'
- y = 'counts'
- color = 'cyan'
- x_label = 'Wavelength (nm)'
- y_label = 'Counts'
- draw(data: Any) plesty.lib.monitor.plots.Drawing
Draw the newest row carrying the values.
The newest row carrying them, not simply the newest row: a plan’s steps are not all alike, and a sweep that ends in an analysis would otherwise blank this view the moment it finished.
- Parameters:
data (Any) – The run’s data.
- Returns:
One curve, or nothing before the first spectrum.
- Return type:
- class plesty.lib.monitor.common.SpectrumMap(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.plots.PlotEvery spectrum so far, stacked against whatever was swept.
Drawn on a square-root colour scale by default: emission lines differ in brightness by more than ten times, and on a linear scale the weak ones share the background’s colour. The colour bar stays labelled in the image’s own values either way.
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.
- title = 'Spectral map'
- values = 'counts'
- row = ''
- x = 'wavelength'
- color = 'violet'
- scale = 'sqrt'
- x_label = 'Wavelength (nm)'
- y_label = 'Row'
- block(data: Any) numpy.ndarray
Return the stack to draw, without its coordinate.
Overridden by an experiment that wants the same map of something it has cleaned up first — the usual reason to subclass this rather than write a plot of one’s own.
- Parameters:
data (Any) – The run’s data.
- Returns:
Shape
(rows, samples).- Return type:
numpy.ndarray
- draw(data: Any) plesty.lib.monitor.plots.Drawing
Draw the stack, or nothing before there is one.
- Parameters:
data (Any) – The run’s data.
- Returns:
One image, or nothing.
- Return type: