spectrochempy.simulate_peaks#
- simulate_peaks(template, peaks)[source]#
Simulate an additive spectrum of separable peaks on a coordinate grid.
- Parameters:
template (NDDataset) – Nonempty dataset supplying the shape, coordinates, mask and intensity units. Each axis must have a finite, real numeric coordinate. Where multiple coordinates exist, use the default one. Sample intensities in the template are ignored.
peaks (sequence of mapping) – Each mapping has a signed scalar
heightand anaxesmapping keyed by all template dimension names. For each axis specifymodel(“gaussian” or “lorentzian”),centerandwidth(positive full width at half maximum). Scalars use the corresponding template units. Pint quantities are converted, with widths treated as intervals. An empty sequence gives a zero spectrum. General profiles use{"model": model, "parameters": {...}}. Built-ins also includevoigt,pseudovoigt,saturation_recoveryandexponential_decay. A callable receives numerical coordinates and keyword parameters and must return a dimensionless real vector matching the coordinate. Custom parameter quantities retain their declared numerical units.
- Returns:
NDDataset – Simulated intensities with detached coordinates, mask and provenance.
Notes
Each contribution is its height times the product of unit-height axis profiles, summed in the supplied peak order. The height is defined at the continuous center and may differ from the sampled maximum. Masked locations are simulated as well and remain masked in the output. For general profiles,
heightis the coefficient multiplying the product of axis profiles; callable profiles are not normalized implicitly. Voigt uses Gaussian sigmaratio * width / sqrt(8 * log(2))and Lorentzian HWHM(1-ratio) * width / 2, normalized at the continuous center. This width parameter is not the convolved Voigt FWHM.Examples
>>> import spectrochempy as scp >>> grid = scp.NDDataset([0, 0, 0], coordset=[scp.Coord([-1, 0, 1])]) >>> peak = { ... "height": -2, ... "axes": {"x": {"model": "lorentzian", "center": 0, "width": 2}}, ... } >>> scp.simulate_peaks(grid, [peak]).data.tolist() [-1.0, -2.0, -1.0]
Examples using spectrochempy.simulate_peaks#
Fit spectral components and recovery times jointly