agepy.spec.coincidence.CoincMap

class CoincMap(data, xedges, yedges)

Bases: object

Plot a coincedence map and its projections on the x and y axes.

Parameters:
data: numpy.ndarray

2d array of shape (m,n) containing the coincidence map. In most cases this will be the output of numpy.histogram2d().

xedges: numpy.ndarray

1d array of shape (m+1) containing the bin edges of the x-axis.

yedges: numpy.ndarray

1d array of shape (n+1) containing the bin edges of the y-axis.

Attributes:
data: numpy.ndarray

Access the 2D histogram data.

xedges: numpy.ndarray

Access the bin edges of the x-axis.

yedges: numpy.ndarray

Access the bin edges of the y-axis.

roi: tuple of tuples

Region of interest. Should be set using set_roi().

fig: matplotlib.figure.Figure

Matplotlib Figure object. Created by the plot() method.

ax: Sequence of matplotlib.axes.Axes

Sequence of matplotlib Axes objects containing the coincidence map, the projection on the x-axis and the projection on the y-axis and the colorbar.

Examples

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from agepy import ageplot
>>> ageplot.use("age")

Create some simple example data:

>>> xyrange = ((0, 2), (0, 2))
>>> n = 10000
>>> rng = np.random.default_rng(42)
>>> x = rng.normal(0.8, 0.2, size=n)
>>> y = rng.normal(1.2, 0.4, size=n)
>>> H, xedges, yedges = np.histogram2d(x, y, bins=50, range=xyrange)

Create a CoincMap object and plot the data:

>>> from agepy.spec.coincidence import CoincMap
>>> coinc = CoincMap(H, xedges, yedges)
>>> coinc.plot(figsize=(4.8, 4.8))
>>> # Start an interactive session with coinc.interactive()
../_images/agepy-spec-coincidence-CoincMap-1.hires.png

Methods

interactive

Start an interactive PyQt session to view the data and add an ROI.

plot

Create a matplotlib figure with the coincidence map and its projections on the x and y axes.

set_roi

Set the region of interest (ROI) for the plot.

update

Update the plot with the current data and ROI settings.

interactive()

Start an interactive PyQt session to view the data and add an ROI.

plot(xlabel='early electron kinetic energy', ylabel='late electron kinetic energy', title=None, figsize=None, cmap='YlOrRd', norm=None, vmin=1, vmax=None, num=None)

Create a matplotlib figure with the coincidence map and its projections on the x and y axes. The figure is stored in the attribute fig and the axes in ax.

Parameters:
xlabel, ylabelpython:str, optional

Labels of the x and y axes. Default: “early electron kinetic energy”, “late electron kinetic energy”

titlepython:str, optional

Title of the figure. Default: None

figsizepython:tuple, optional

Figure size in inches. Default: None

cmapmatplotlib.colors.Colormap or python:str, optional

Colormap passed to matplotlib.pyplot.pcolormesh(). Default: ‘YlOrRd’

normpython:str or matplotlib.colors.Normalize or python:None, optional

Normalization passed to matplotlib.pyplot.pcolormesh(). Default: None

vmin, vmaxpython:float, optional
Minimum and maximum value for the colormap passed to

matplotlib.pyplot.pcolormesh(). Default: 1, None

num: int or str or matplotlib.figure.Figure, optional

Figure identifier passed to matplotlib.pyplot.figure().

set_roi(xmin, xmax, ymin, ymax)

Set the region of interest (ROI) for the plot.

Parameters:
xmin, xmaxpython:float

Minimum and maximum value for the x-axis.

ymin, ymaxpython:float

Minimum and maximum value for the y-axis.

Return type:

None

update()

Update the plot with the current data and ROI settings.