plesty.lib.monitor.common ========================= .. py:module:: plesty.lib.monitor.common .. autoapi-nested-parse:: The plots most experiments want, so most experiments write none. * :mod:`~plesty.lib.monitor.common.spectrum` — a spectrum, and a stack of them as a map. * :mod:`~plesty.lib.monitor.common.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. .. code-block:: python 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 :class:`~plesty.lib.monitor.plots.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 ---------- .. toctree:: :maxdepth: 1 /reference/plesty/lib/monitor/common/series/index /reference/plesty/lib/monitor/common/spectrum/index Classes ------- .. autoapisummary:: plesty.lib.monitor.common.Series plesty.lib.monitor.common.Spectrum plesty.lib.monitor.common.SpectrumMap Package Contents ---------------- .. py:class:: Series(y: str, x: str = '', *, title: str = '', name: str = '', weight: Optional[float] = None, area: str = '', color: str = 'mint', x_label: str = '', y_label: str = '', marker: bool = True) Bases: :py:obj:`plesty.lib.monitor.plots.Plot` One 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. :param y: Field holding the value. :param x: Field holding the position; empty numbers the rows. :param title: What the view is called; defaults to the field names. :param name: Layout key. :param weight: Relative size. :param area: Which side of the window it starts on. :param color: Palette token. :param x_label: Axis label; defaults to the field name. :param y_label: Axis label; defaults to the field name. :param marker: Mark each point as well as joining them. .. py:attribute:: title :value: 'Series' .. py:attribute:: x :value: '' .. py:attribute:: y .. py:attribute:: color :value: 'mint' .. py:attribute:: x_label :value: 'Step' .. py:attribute:: y_label .. py:attribute:: marker :value: True .. py:method:: draw(data: Any) -> plesty.lib.monitor.plots.Drawing Draw the series, leaving out rows that carry no value. :param data: The run's data. :returns: One curve, or nothing before the first value. .. py:class:: Spectrum(y: str = 'counts', x: str = 'wavelength', *, title: str = '', name: str = '', weight: Optional[float] = None, area: str = '', color: str = 'cyan', x_label: str = 'Wavelength (nm)', y_label: str = 'Counts') Bases: :py:obj:`plesty.lib.monitor.plots.Plot` The newest spectrum a run has committed. :ivar x: Field holding the axis — the wavelengths, or whatever it is measured against. :ivar y: Field holding the values. Draw the newest *y* against *x*. :param y: Field holding the values. :param x: Field holding the axis. :param title: What the view is called. :param name: Layout key. :param weight: Relative size. :param area: Which side of the window it starts on. :param color: Palette token for the curve. :param x_label: Axis label including the unit. :param y_label: Axis label including the unit. .. py:attribute:: title :value: 'Spectrum' .. py:attribute:: x :value: 'wavelength' .. py:attribute:: y :value: 'counts' .. py:attribute:: color :value: 'cyan' .. py:attribute:: x_label :value: 'Wavelength (nm)' .. py:attribute:: y_label :value: 'Counts' .. py:method:: 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. :param data: The run's data. :returns: One curve, or nothing before the first spectrum. .. py:class:: SpectrumMap(values: str = 'counts', row: str = '', *, x: str = 'wavelength', title: str = '', name: str = '', weight: Optional[float] = None, area: str = '', color: str = 'violet', scale: str = 'sqrt', x_label: str = 'Wavelength (nm)', y_label: str = '') Bases: :py:obj:`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*. :param values: Field holding each row's array. :param row: Field holding the swept coordinate, for the axis; empty numbers the rows instead. :param x: 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. :param title: What the view is called. :param name: Layout key. :param weight: Relative size. :param area: Which side of the window it starts on. :param color: Palette token the colour map is built from. :param scale: ``"sqrt"`` or ``"linear"``. :param x_label: Axis label of the sample axis. :param y_label: Axis label of the swept axis. .. py:attribute:: title :value: 'Spectral map' .. py:attribute:: values :value: 'counts' .. py:attribute:: row :value: '' .. py:attribute:: x :value: 'wavelength' .. py:attribute:: color :value: 'violet' .. py:attribute:: scale :value: 'sqrt' .. py:attribute:: x_label :value: 'Wavelength (nm)' .. py:attribute:: y_label :value: 'Row' .. py:method:: 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. :param data: The run's data. :returns: Shape ``(rows, samples)``. .. py:method:: draw(data: Any) -> plesty.lib.monitor.plots.Drawing Draw the stack, or nothing before there is one. :param data: The run's data. :returns: One image, or nothing.