plesty.lib.monitor.common.spectrum

The newest spectrum, and every spectrum so far stacked into a map.

Classes

Spectrum

The newest spectrum a run has committed.

SpectrumMap

Every spectrum so far, stacked against whatever was swept.

Module Contents

class plesty.lib.monitor.common.spectrum.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.Plot

The 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:

plesty.lib.monitor.plots.Drawing

class plesty.lib.monitor.common.spectrum.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.Plot

Every 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:

plesty.lib.monitor.plots.Drawing