Plotting Utilities#
Plotting utilities.
Top-level functions#
|
Plot Photon Transfer Curve (PTC) from a dataset containing 'mean' and 'variance' data. |
- pyxel.plotting.plot_ptc(dataset, text_base_fontsize=8, alpha_rectangle=0.05, ax=None)[source]#
Plot Photon Transfer Curve (PTC) from a dataset containing ‘mean’ and ‘variance’ data.
The PTC plot provides information about different noise regimes (read noise, shot noise, fixed pattern noise, and full well capacity) by calculating logarithmic slopes at key points and then plots these regimes along with the PTC on a log-log scale. You can find more information in [9]
The four noise regimes:
1. Read Noise Regime (slope = 0): This regime occurs in total darkness or low illumination. It is characterized by random noise, which includes contributions such as thermal noise and darj current. Read noise dominates at very low signal levels.
2. Shot Noise Regime (slope = ½): As the light levels increase, photon shot noise becomes the dominant form of noise. This regime appears as a linear segment in a log-log plot with a slope of 1/2. Shot noise is a natural consequence of the random arrival of photons, and its magnitude increases with the square root of the signal level.
3. Fixed Pattern Noise (FPN) Regime (slope = 1): At even higher light levels, fixed-pattern noise (FPN) emerges. This noises stems from variations in pixel responses and sensor inhomogeneities. In this regime, the noise scales linearly with the signal, resulting in a slope of 1 in the PTC. FPN becomes more prominent as the pixel responses begin to diverge due to non-uniformities in the sensor.
4. Full-Well Saturation Regime (slope = ∞): In the final regime, the subarray of pixels reaches saturation, referred to as the full-well regime. Here noise levels generally decrease as the pixels become saturated. A sharp deviation in noise from the expected 1/2 or 1 slope signals that the full-well condition has been reached.
- Parameters:
dataset (
Dataset
orDataTree
) – The dataset to plot. This dataset must contain a ‘mean’ and ‘variance’ variable. The dataset must also be 1D, containing only one dimension (e.g. ‘time’)text_base_fontsize (
int
,optional. Default is 8.
) – Base font size used for text annotations on the plotalpha_rectangle (
float
,optional. Default is 0.05.
) – Alpha transparency for the shaded rectangles that highlight different noise regimes.ax (
Optional[plt.Axes]
,optional. Default is None.
) – A pre-existing matplotlib axes object. If None, a new one is created.
- Returns:
matplotlib Figure
– The figure object of the PTC plot with labeled noise regimes.- Raises:
TypeError – If the provided ‘dataset’ is neither a Dataset nor a DataTree.
ValueErorr – If ‘dataset’ does not contain ‘mean’ and ‘variance’ variables or if ‘dataset’ is not 1D (i.e., contains more than one dimension)
Examples
>>> config = pyxel.load("configuration.yaml") >>> data_tree = pyxel.run_mode( ... mode=config.running_mode, ... detector=config.detector, ... pipeline=config.pipeline, ... )
>>> data_tree["/data/mean_variance/image"] <xarray.DataTree 'image'> Group: /data/mean_variance/image Dimensions: (pipeline_idx: 100) Coordinates: * pipeline_idx (pipeline_idx) int64 800B 0 1 2 3 4 5 6 ... 94 98 97 95 99 96 Data variables: mean (pipeline_idx) float64 800B 3.562 3.96 ... 5.568e+04 5.568e+04 variance (pipeline_idx) float64 800B 3.684 3.908 ... 8.099e+04
>>> plot_ptc(data_tree["/data/mean_variance/image"])