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.
- 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.
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]