phasorpy.experimental#

Experimental functions.

The phasorpy.experimental module provides functions related to phasor analysis for evaluation. The functions may be removed or moved to other modules in future releases.

phasorpy.experimental.anscombe_transform(data, /, **kwargs)[source]#

Return Anscombe variance-stabilizing transformation.

The Anscombe transformation normalizes the standard deviation of noisy, Poisson-distributed data. It can be used to transform unnormalized phasor coordinates to approximate standard Gaussian distributions.

Parameters:
  • data (array_like) – Noisy Poisson-distributed data to be transformed.

  • **kwargs – Optional arguments passed to numpy universal functions.

Returns:

Anscombe-transformed data with variance of approximately 1.

Return type:

ndarray

Notes

The Anscombe transformation according to [1]:

\[z = 2 \cdot \sqrt{x + 3 / 8}\]

References

Examples

>>> z = anscombe_transform(numpy.random.poisson(10, 10000))
>>> numpy.allclose(numpy.std(z), 1.0, atol=0.1)
True
phasorpy.experimental.anscombe_transform_inverse(data, /, *, approx=False, **kwargs)[source]#

Return inverse Anscombe transformation.

Parameters:
  • data (array_like) – Anscombe-transformed data.

  • approx (bool, optional, default: False) – Return approximation of exact unbiased inverse.

  • **kwargs

    Optional arguments passed to numpy universal functions.

Returns:

Inverse Anscombe-transformed data.

Return type:

ndarray

Notes

The inverse Anscombe transformation according to [1]:

\[x = (z / 2.0)^2 - 3 / 8\]

The approximate inverse Anscombe transformation according to [2] and [3]:

\[x = 1/4 \cdot z^2 + 1/4 \cdot \sqrt{3/2} \cdot z^{-1} - 11/8 \cdot z^{-2} + 5/8 \cdot \sqrt{3/2} \cdot z^{-3} - 1/8\]

References

Examples

>>> x = numpy.random.poisson(10, 100)
>>> x2 = anscombe_transform_inverse(anscombe_transform(x))
>>> numpy.allclose(x, x2, atol=1e-3)
True
phasorpy.experimental.signal_from_dho(wavelength, origin, sigma, hr_factor, vib_frequency, *, scale=1.0, offset=0.0, absorption=False, **kwargs)[source]#

Return normalized fluorescence emission or absorption at wavelengths.

Using the area-normalized Displaced Harmonic Oscillator (DHO) model to approximate the absorption or fluorescence emission spectrum of a fluorophore with a single vibrational mode.

Parameters:
  • wavelength (array_like) – Wavelength at which to calculate emission intensity in nm.

  • origin (array_like) – Center wavelength of 0->0 electronic origin transition in nm. Typically in the range 400 to 700 nm.

  • sigma (array_like) – Gaussian spectral broadening factor in \(cm^{-1}\). Typically in the range 200 to 600 \(cm^{-1}\).

  • hr_factor (array_like) – Huang-Rhys structural coupling/displacement parameter (dimensionless). Typically in the range 0.1 to 2.0.

  • vib_frequency (array_like) – Vibrational spacing frequency in \(cm^{-1}\). Typically in the range 1000 to 1600 \(cm^{-1}\).

  • scale (array_like, optional, default: 1.0) – Factor multiplied to normalized DHO intensity.

  • offset (array_like, optional, default: 0.0) – Offset added after scaling.

  • absorption (bool, optional) – If True, return absorption intensity instead of fluorescence emission.

  • **kwargs

    Optional arguments passed to numpy universal functions.

Returns:

intensity – Absorption or fluorescence emission intensities.

Return type:

ndarray

Notes

The intensity in wavenumber space \(I(\nu)\) is calculated from the \(0\rightarrow0\) electronic origin \(\nu_0 = 10^7 / \lambda_0\), the Gaussian spectral broadening factor \(\sigma\), the Huang-Rhys factor \(S\), and the vibrational frequency \(\nu_{\text{vib}}\) using the DHO model with \(N = 5\) vibronic terms:

\[I(\nu) = \frac{1}{\sigma\sqrt{2\pi}} \sum_{n=0}^{N} \frac{S^n e^{-S}}{n!} \exp\left( - \frac{(\nu - \nu_n)^2}{2\sigma^2} \right)\]

where \(\nu_n = \nu_0 - n \cdot \nu_{\text{vib}}\) for emission (red-shifted sidebands) and \(\nu_n = \nu_0 + n \cdot \nu_{\text{vib}}\) for absorption (blue-shifted sidebands).

Calculations are performed in wavenumber \(\nu\) space and transformed to wavelength \(\lambda\) space using the Jacobian:

\[I(\lambda) = I(\nu) \cdot \left| \frac{d\nu}{d\lambda} \right| = I(\nu) \cdot \frac{10^7}{\lambda^2}\]

The returned signal can be affine-transformed for measured spectra:

\[I_{\text{out}}(\lambda) = I(\lambda) \cdot \text{scale} + \text{offset}\]

Examples

Approximate the fluorescence emission spectrum of Fluorescein:

>>> signal_from_dho(
...     wavelength=numpy.linspace(450, 650, 100),
...     origin=518,
...     sigma=500,
...     hr_factor=0.4,
...     vib_frequency=1200,
... )
array([..., 0.0001434, 0.0001329, 0.0001228])