# Plot

class listmode.plot.Axis(axis_info, det_cfg, time_slice=None)

  Axis info is a class handling a single data axis in a plot. Axis takes care of binning, calibration, tick spacing and labeling of the plot. For this to happen, Axis needs not only axis configuration but also detector configuration to know about the data it is showing.

  Axis is not meant to be used directly. It is a part of Plot.

  update(data)

    Histogram is updated with the filtered selected data in a list called datas.

    Parameters

      data – Numpy array of data values.

    Returns

class listmode.plot.Filter1d(axes)

  Filter collects the histogram. It defines its range by the axes.

  update(datas)

    Histogram is updated with the filtered selected data in a list called datas.

    Parameters

      datas – List of numpy arrays of data values.

    Returns

class listmode.plot.Filter2d(axes)

  In 2d-filter the __init__ and _build are overridden to handle two axes.

class listmode.plot.Gate(gate_info, det_cfg, cal, bitmask=False)

  Gate is a simple class defining a single filter for data streamed through it’s update method. It is defined by gate_info dictionary with following keys: “channel”: The channel the gate is for. “dtype”: The data type the gate is for. “range”: A list of ranges defining where the gate is passing through (if null or coincident) or blocking (if

  > anticoincident). Each range is a list of start and stop values in calibrated units.

  “coinc”: Defines coincidence (positive integer), anticoincidence (negative integer) or null coincidence. A null

    gate will still limit the plot axis and is thus implicitly handled as coincident if it is defined for one of the plot axes.

  update(data_dict, mask)

    Update runs the data_dict through the gate selection and modifies the input mask.

    Parameters

      - data_dict – Full data dict of the chunk

      - mask – A mask defining events that pass. The mask is modified in-place.

    Returns

class listmode.plot.Plot(canvas_cfg, det_cfg, time_slice=None, plot_idx=0)

  Plot is a manager class for handling a histogram to plot. A plot itself is a combination of its axes and its filter. Axes objects are responsible for the calibration, limits and unit labels of the plot. A plot is filled by feeding it with data chunks via its update-method. Filter is the actual histogramming function collecting output of each chunk. Plot class can return the data and axes information as numpy array via get_data-method and title, legend and axis label strings via its get_plot_labels-method.

  Plot configuration dictionary defines the data in the plot as well as the plotting parameters, such as labels, scales etc. The Plot class uses only the information in plot_cfg list and the name of the config. Only one plot can be defined per Plot object. However multiple plots can be stacked into the plot_cfg list of the plot configuration. If all of the plots are 1d and have same axes they can be plotted into a single figure.

  Creating figures and handling how to stack plots into figures is done explicitly by the user. Two Plot instances can be compared for equality to help with stacking. The comparison returns True only if the two plots can be shown in the same axes.

  get_data(calibrate=True)

    Returns the histogram as numpy array along with bins for each axis and text for legend/export filename.

    Parameters

      calibrate – Return calibrated bins

    Returns

  get_plot_labels(calibrate=True)

    Returns title legend and axis labels.

    Parameters

      calibrate –

    Returns

  update(data_dict)

    Update method runs the relevant data through all the gates to produce a final mask and runs the masked data into axes (for axis limit updates) and filter (for histogramming).

    Parameters

      data_dict –

    Returns

listmode.plot.data_plot(data, plot_list, time_slice=None, calibrate=True, plot=False)

  Demo function to produce data from a plot config dictionary.

listmode.plot.get_ticks(max_x, numticks=30)

  Tries to divide the numticks to the axis in a smart way. Probably not used atm.

  Parameters

    - max_x –

    - numticks –

  Returns

    The ticks in a numpy array