Package Exports
- ml-peak-shape-generator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ml-peak-shape-generator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ml-peak-shape-generator
Generate various peak shapes.
The current supported kinds of shapes:
Name | Equation |
---|---|
Gaussian | |
Lorentzian | |
Pseudo Voigt |
where
Installation
$ npm i ml-peak-shape-generator
Usage
import { gaussian, lorentzian, pseudoVoigt} from 'ml-peak-shape-generator';
// It's possible to specify the windows size with factor option
let data = gaussian.getData({factor: 3.5, sd: 500});
// or fix the number of points as Full Width at Half Maximum
let data = gaussian.getData({factor: 3.5, fwhm: 500});
// It's possible to specify the windows size with factor option
let data = loretzian.getData({factor: 5, fwhm: 500});
// It's possible to specify the windows size with factor option
let data = pseudoVoigt.getData({factor: 5, fwhm: 500});
It is also possible to take an instance of each kind of shape:
import { gaussian, gaussian2D } from 'ml-peak-shape-shape';
const gaussianShape = new gaussian.Gaussian({ fwhm: 500, factor: 3.5, height: 1});
// It is possible to set a new value for fwhm and height
gaussianShape.fwhm = 300;
gaussianShape.height = 2;
// By default the height value ensure a surface/area equal 1.
const gaussian2DShape = new gaussian2D.Gaussian2D({ fwhm: 500, factor: 3.5});
// It is possible to set values for sd, fwhm and factor for each axes.
const gaussian2DShape = new gaussian2D.Gaussian2D({ fwhm: { x: 300, y: 500 }, factor: 3.5});
// It is possible to set new value for fwhm by:
gaussian2D.fwhm = { x: 300, y: 500 };
// or set the same value for both axes.
gaussian2D.fwhm = 400;
//An instance of any shape has the same methods accessible for each
//shape e.g. fct or getData, but these use the internal parameters. e.g:
const gaussianShape = new gaussian.Gaussian({ fwhm: 500 });
gaussianShape.fct(5);
gaussian.fct(5, 500);
import { getShape1D, getShape2D } from 'ml-peak-shape-generator';
// If you want to dynamically select a shape you can use the `getShapeGenerator` method. It returns a instance of required kind of shape.
let shapeGenerator = getShape1D('lorentzian', {factor: 3.5, sd: 500});
let shapeGenerator = getShape2D('gaussian2D', {factor: 3.5, sd: 500});
It is also possible to get a function that allows to calculate y for any x
import { gaussian } from 'ml-peak-shape-generator';
const func = gaussian.fct(x - mean, fwhm);