Ready-Made Plots

Some plots are the same in every lab: the newest spectrum, all spectra of a scan as a map, one value against another. plesty.lib.monitor.common has them, so an experiment that needs only these writes no plot of its own:

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))
viz.add_plot(Series("power_w", x="hwp_deg", y_label="Power (W)"))

read_spectrum turns each row’s spectrum file into wavelength and counts fields; see reads: rows that name a file.

Each is told which fields of the rows to use, so the names in your records are up to you.

Spectrum

The newest spectrum the run has saved, as a line.

Argument

Default

Meaning

y

"counts"

the field holding the values

x

"wavelength"

the field holding the axis; without it, the samples are numbered

x_label, y_label

"Wavelength (nm)", "Counts"

the axis labels

SpectrumMap

Every spectrum so far, stacked into an image against what was scanned. It uses a square-root colour scale by default, because emission lines can differ in brightness by more than ten times, and on a linear scale the weak ones disappear into the background.

Argument

Default

Meaning

values

"counts"

the field holding each spectrum

row

none

the field that was scanned, such as an angle; without it, the rows are numbered

x

"wavelength"

the field holding the axis

scale

"sqrt"

"sqrt" or "linear"

x_label, y_label

"Wavelength (nm)", the row field ("Row" without one)

the axis labels

To map something you have cleaned up first, such as the spectra with cosmic rays removed, subclass SpectrumMap and override block(data), which returns the 2-D array to draw.

Series

One field against another, one point per row.

Argument

Default

Meaning

y

required

the field holding the value

x

none

the field holding the position; without it, the rows are numbered

marker

True

draw a marker on each point

x_label, y_label

the field names ("Step" without x)

the axis labels

Arguments they all take

title, name and weight mean the same as for @viz.plot (see A viewer), and color is a palette name (see The drawables).

Each is an ordinary Plot: to change one, subclass it, or write your own plot instead (see Three ways to write a plot).