Peak functions

The escape.core.peak module provides functors for several commonly used peak functions:

  • Gaussian peak (height and area-normalized)

  • Lorentzian peak (height and area-normalized)

  • Pseudo-Voigt peak (height and area-normalized)

  • Pearson VII peak

  • Split Gaussian peak (asymmetric)

Usage notes

All peak functions accept flexible input types for their arguments:

  • Variables (variable_obj): Converted to identity functors automatically

  • Functors (functor_obj): Used directly

  • Parameters (parameter_obj): Used directly or converted to constant functors when mixed with functor arguments

  • Numeric values (int, float, str): Converted to parameters automatically

If all arguments are parameter-like (parameter_obj, int, float, str), the function returns a parameter_obj. If any argument is functor-like (variable_obj, functor_obj), the function returns a functor_obj.

Examples

Create a Gaussian peak with all parameter inputs:

>>> x = esc.par("x", 1)
>>> h = esc.par("h", 10)
>>> c = esc.par("c", 0)
>>> w = esc.par("w", 1)
>>> g = esc.gaussian(x, h, c, w)
>>> type(g)
  <class 'escape.core.objects.parameter_obj'>

Create a Gaussian peak with variable x:

>>> x = esc.var("x")
>>> h = esc.par("h", 10)
>>> c = esc.par("c", 0)
>>> w = esc.par("w", 1)
>>> g = esc.gaussian(x, h, c, w, name="My Gaussian")
>>> type(g)
  <class 'escape.core.objects.functor_obj'>
>>> g.variables()
  [variable(name='x')]

Create a Gaussian peak with all variable inputs:

>>> x = esc.var("x")
>>> h = esc.var("h")
>>> c = esc.var("c")
>>> w = esc.var("w")
>>> g = esc.gaussian(x, h, c, w)
>>> type(g)
  <class 'escape.core.objects.functor_obj'>
escape.core.peak.gaussian(x: InputType, height: InputType, centroid: InputType, fwhm: InputType, name: str = 'Gaussian', notes: str = '') functor_obj | parameter_obj

Create a height-normalized Gaussian peak function.

The Gaussian peak is a symmetric bell-shaped curve.

Args:

x: Independent variable (variable, functor, parameter, or numeric) height: Peak height at maximum centroid: Peak center position fwhm: Full width at half maximum name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.agaussian(x: InputType, area: InputType, centroid: InputType, fwhm: InputType, name: str = 'Area Gaussian', notes: str = '') functor_obj | parameter_obj

Create an area-normalized Gaussian peak function.

The Gaussian peak is a symmetric bell-shaped curve defined by its integrated area, center position and width.

Args:

x: Independent variable (variable, functor, parameter, or numeric) area: Total integrated area of the peak centroid: Peak center position fwhm: Full width at half maximum name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.lorentzian(x: InputType, height: InputType, centroid: InputType, fwhm: InputType, name: str = 'Lorentzian', notes: str = '') functor_obj | parameter_obj

Create a height-normalized Lorentzian peak function.

The Lorentzian peak is a symmetric curve with broader tails than a Gaussian, defined by its height, center position and width.

Args:

x: Independent variable (variable, functor, parameter, or numeric) height: Peak height at maximum centroid: Peak center position fwhm: Full width at half maximum name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.alorentzian(x: InputType, area: InputType, centroid: InputType, fwhm: InputType, name: str = 'Area Lorentzian', notes: str = '') functor_obj | parameter_obj

Create an area-normalized Lorentzian peak function.

The Lorentzian peak is a symmetric curve with broader tails than a Gaussian, defined by its integrated area, center position and width.

Args:

x: Independent variable (variable, functor, parameter, or numeric) area: Total integrated area of the peak centroid: Peak center position fwhm: Full width at half maximum name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.pvoigt(x: InputType, height: InputType, centroid: InputType, fwhm: InputType, eta: InputType, name: str = 'Pseudo-Voigt', notes: str = '') functor_obj | parameter_obj

Create a height-normalized pseudo-Voigt peak function.

The pseudo-Voigt function is a linear combination of Gaussian and Lorentzian peaks that approximates the true Voigt function. This version is normalized by peak height.

Args:

x: Independent variable (variable, functor, parameter, or numeric) height: Peak height at maximum centroid: Peak center position fwhm: Full width at half maximum eta: Mixing parameter between Gaussian (eta=0) and Lorentzian (eta=1) name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.apvoigt(x: InputType, area: InputType, centroid: InputType, fwhm: InputType, eta: InputType, name: str = 'Area Pseudo-Voigt', notes: str = '') functor_obj | parameter_obj

Create an area-normalized pseudo-Voigt peak function.

The pseudo-Voigt function is a linear combination of Gaussian and Lorentzian peaks that approximates the true Voigt function. This version is normalized by area.

Args:

x: Independent variable (variable, functor, parameter, or numeric) area: Total integrated area of the peak centroid: Peak center position fwhm: Full width at half maximum eta: Mixing parameter between Gaussian (eta=0) and Lorentzian (eta=1) name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.pearson7(x: InputType, height: InputType, centroid: InputType, fwhm: InputType, shape: InputType, name: str = 'Pearson VII', notes: str = '') functor_obj | parameter_obj

Create a height-normalized Pearson VII peak function.

The Pearson VII peak is a flexible peak shape that can vary between Gaussian and Lorentzian profiles based on a shape parameter.

Args:

x: Independent variable (variable, functor, parameter, or numeric) height: Peak height at maximum centroid: Peak center position fwhm: Full width at half maximum shape: Shape parameter controlling peak tails name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible

escape.core.peak.split_gaussian(x: InputType, height: InputType, centroid: InputType, fwhm_left: InputType, fwhm_right: InputType, name: str = 'Split Gaussian', notes: str = '') functor_obj | parameter_obj

Create a split Gaussian peak function with different widths on left and right sides.

This asymmetric Gaussian peak allows different widths on each side of the peak center.

Args:

x: Independent variable (variable, functor, parameter, or numeric) height: Peak height at maximum centroid: Peak center position fwhm_left: Full width at half maximum for left side fwhm_right: Full width at half maximum for right side name: Name for the functor. Ignored if returned object is a parameter notes: Optional notes for the functor

Returns:

A functor_obj or parameter_obj depending on input types

Raises:

TypeError: If input argument types are incompatible