Socket
Socket
Sign inDemoInstall

ml-peak-shape-generator

Package Overview
Dependencies
1
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ml-peak-shape-generator

Generate various peak shapes


Version published
Weekly downloads
1K
increased by29.03%
Maintainers
5
Install size
144 kB
Created
Weekly downloads
 

Changelog

Source

4.1.2 (2022-08-06)

Bug Fixes

  • export shape types (222296f)
  • getLorenztianFactor function. close #70 (#71) (49dcc32)

Readme

Source

ml-peak-shape-generator

NPM version build status Test coverage npm download

Generate various peak shapes.

The current supported kinds of shapes:

NameEquation
Gaussian
Lorentzian
Pseudo Voigt

where

Installation

$ npm i ml-peak-shape-generator

This package allows to calculate various shapes. By default they will have a height of 1.

demo.png

You see the resulting functions using this playground

Usage

import {
  getGaussianData,
  getLorentzianData,
  getPseudoVoigtData,
} from 'ml-peak-shape-generator';

// It's possible to specify the windows size with factor option
let data = getGaussianData({ sd: 500 }, { factor: 3.5 });
// or fix the number of points as Full Width at Half Maximum
let data = getGaussianData({ fwhm: 500 }, { factor: 3.5 });

// It's possible to specify the windows size with factor option
let data = getLorentzianData({ fwhm: 500 }, { factor: 5 });

// It's possible to specify the windows size with factor option
let data = getPseudoVoigtData({ fwhm: 500 }, { factor: 5 });

It is also possible to take an instance of each kind of shape:

import { Gaussian, gaussianFct, Gaussian2D } from 'ml-peak-shape-shape';

const gaussianShape = new Gaussian({ fwhm: 500 });
// It is possible to set a new value for fwhm
gaussianShape.fwhm = 300;

// By default the height value ensure a volume equal 1.
const gaussian2DShape = new Gaussian2D({ fwhm: 500 });

// It is possible to set values for sd, fwhm and factor for each axes.
const gaussian2DShape = new Gaussian2D({ fwhm: { x: 300, y: 500 } });

// 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({ fwhm: 500 });
gaussianShape.fct(5);
gaussianFct(5, 500);
// getData
gaussianShape.getData({ factor: 3.5 });
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({ kind: 'lorentzian', sd: 500 });
let shapeGenerator = getShape2D({ kind: 'gaussian', sd: 500 });

It is also possible to get a function that allows to calculate y for any x

import { gaussianFct } from 'ml-peak-shape-generator';
const func = gaussianFct(x - mean, fwhm);

API Documentation

License

MIT

Keywords

FAQs

Last updated on 06 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc