epyr.lineshapes.lineshape_class

Unified Lineshape class for EPR spectroscopy

Provides a single interface for all lineshape types with consistent API.

Functions

create_gaussian([width])

Create Gaussian lineshape

create_lorentzian([width])

Create Lorentzian lineshape

create_pseudo_voigt([width, alpha])

Create pseudo-Voigt lineshape

create_voigt(gaussian_width, ...)

Create Voigt lineshape

Classes

Lineshape([shape_type, width, alpha, ...])

Unified lineshape class for EPR spectroscopy.

class epyr.lineshapes.lineshape_class.Lineshape(shape_type='gaussian', width=1.0, alpha=1.0, derivative=0, phase=0.0, normalize=True)[source]

Unified lineshape class for EPR spectroscopy.

This class provides a consistent interface for generating all types of EPR lineshapes including Gaussian, Lorentzian, Voigt, and pseudo-Voigt profiles with support for derivatives, phase rotation, and convolution.

Parameters:

shape_typestr, default=’gaussian’

Type of lineshape (‘gaussian’, ‘lorentzian’, ‘voigt’, ‘pseudo_voigt’)

widthfloat or tuple

Full width at half maximum - For single shapes: float - For Voigt: (gaussian_width, lorentzian_width) - For pseudo-Voigt: float (both components use same width)

alphafloat, default=1.0

Shape parameter for pseudo-Voigt (1=Gaussian, 0=Lorentzian)

derivativeint, default=0

Derivative order (0, 1, 2, or -1 for integral)

phasefloat, default=0.0

Phase rotation in radians (0=absorption, π/2=dispersion)

normalizebool, default=True

Whether to maintain area normalization

Examples:

>>> # Create Gaussian lineshape
>>> gauss = Lineshape('gaussian', width=5.0)
>>> x = np.linspace(-10, 10, 100)
>>> y = gauss(x, center=0)
>>>
>>> # Lorentzian with first derivative
>>> lorentz_deriv = Lineshape('lorentzian', width=4.0, derivative=1)
>>> y_deriv = lorentz_deriv(x, center=2)
>>>
>>> # Voigt profile with different widths
>>> voigt = Lineshape('voigt', width=(3.0, 2.0))
>>> y_voigt = voigt(x, center=0)
>>>
>>> # Pseudo-Voigt 50/50 mix
>>> pv = Lineshape('pseudo_voigt', width=5.0, alpha=0.5)
>>> y_pv = pv(x, center=0)
SUPPORTED_SHAPES = {'gaussian': <function gaussian>, 'general': <function lshape>, 'lorentzian': <function lorentzian>, 'pseudo_voigt': <function pseudo_voigt>, 'voigt': <function voigtian>}
__init__(shape_type='gaussian', width=1.0, alpha=1.0, derivative=0, phase=0.0, normalize=True)[source]
Parameters:
__call__(x, center, **override_params)[source]

Generate lineshape at specified points.

Parameters:

xarray

Abscissa points

centerfloat

Peak center position

**override_paramsdict

Parameters to override for this call only

Returns:

array

Lineshape values

Parameters:
Return type:

ndarray

absorption(x, center)[source]

Generate pure absorption lineshape

Parameters:
Return type:

ndarray

dispersion(x, center)[source]

Generate pure dispersion lineshape

Parameters:
Return type:

ndarray

derivative(x, center, order=1)[source]

Generate derivative lineshape

Parameters:
Return type:

ndarray

both_components(x, center)[source]

Generate both absorption and dispersion components.

Returns:

tuple

(absorption, dispersion) arrays

Parameters:
Return type:

Tuple[ndarray, ndarray]

set_width(width)[source]

Create new Lineshape with different width

Parameters:

width (float | Tuple[float, float])

Return type:

Lineshape

set_alpha(alpha)[source]

Create new Lineshape with different alpha (for pseudo-Voigt)

Parameters:

alpha (float)

Return type:

Lineshape

set_derivative(derivative)[source]

Create new Lineshape with different derivative order

Parameters:

derivative (int)

Return type:

Lineshape

set_phase(phase)[source]

Create new Lineshape with different phase

Parameters:

phase (float)

Return type:

Lineshape

info()[source]

Get lineshape information

Return type:

Dict[str, Any]

__repr__()[source]

String representation

Return type:

str

__str__()[source]

Human-readable string

Return type:

str

Parameters:
epyr.lineshapes.lineshape_class.create_gaussian(width=1.0, **kwargs)[source]

Create Gaussian lineshape

Parameters:

width (float)

Return type:

Lineshape

epyr.lineshapes.lineshape_class.create_lorentzian(width=1.0, **kwargs)[source]

Create Lorentzian lineshape

Parameters:

width (float)

Return type:

Lineshape

epyr.lineshapes.lineshape_class.create_voigt(gaussian_width, lorentzian_width, **kwargs)[source]

Create Voigt lineshape

Parameters:
Return type:

Lineshape

epyr.lineshapes.lineshape_class.create_pseudo_voigt(width=1.0, alpha=0.5, **kwargs)[source]

Create pseudo-Voigt lineshape

Parameters:
Return type:

Lineshape