Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-peak-shape-generator

Package Overview
Dependencies
Maintainers
6
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-peak-shape-generator - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

src/getShape.js

9

History.md

@@ -0,1 +1,10 @@

# [0.1.0](https://github.com/cheminfo/ml-peak-shape-generator/compare/v0.0.1...v0.1.0) (2020-03-02)
### Features
* add getShape ([10264f5](https://github.com/cheminfo/ml-peak-shape-generator/commit/10264f5387cfa50b0e2938ee2c1df2b96a8abeb5))
## 0.0.1 (2020-02-29)

@@ -2,0 +11,0 @@

@@ -100,4 +100,34 @@ 'use strict';

/**
* Calculate a normalized gaussian shape
* @param {number} [kind = 1]
* @param {object} [options = {}]
* @param {number} [options.fwhm = 500] - number of points in Full Width at Half Maximum, Standard deviation will be computed as fwhm / 2 / sqrt(2 ln(2))
* @param {number} [options.factor = 3] - factor of standard deviation to increase the window size, the vector size is 2 * factor * sd
* @return {Float64Array} - array of Y points
*/
const GAUSSIAN = 1;
const LORENTZIAN = 2;
const PSEUDO_VOIGT = 3;
function getShape(kind = 1, options = {}) {
switch (kind) {
case 1:
return gaussian(options);
case 2:
return lorentzian(options);
case 3:
return pseudoVoigt(options);
default:
throw new Error(`Unknown shape kind: ${kind}`);
}
}
exports.GAUSSIAN = GAUSSIAN;
exports.LORENTZIAN = LORENTZIAN;
exports.PSEUDO_VOIGT = PSEUDO_VOIGT;
exports.gaussian = gaussian;
exports.getShape = getShape;
exports.lorentzian = lorentzian;
exports.pseudoVoigt = pseudoVoigt;

2

package.json
{
"name": "ml-peak-shape-generator",
"version": "0.0.1",
"version": "0.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -16,19 +16,27 @@ # ml-peak-shape-generator

```js
import { gaussian, lorentzian, pseudoVoigt } from 'ml-peak-shape-generator';
import { gaussian, lorentzian, pseudoVoigt} from 'ml-peak-shape-generator';
let gaussianVector;
// It's possible to specify the windows size with factor option
gaussianVector = gaussian({factor: 3.5, sd: 500});
const gaussianVector = gaussian({factor: 3.5, sd: 500});
// or fix the number of points as Full Width at Half Maximum
gaussianVector = gaussian({factor: 3.5, fwhm: 500});
const gaussianVector2 = gaussian({factor: 3.5, fwhm: 500});
let lorentzianVector;
// It's possible to specify the windows size with factor option
lorenzianVector = loretzian({factor: 5, fwhm: 500});
const lorenzianVector = loretzian({factor: 5, fwhm: 500});
let pseudoVoigtVector;
// It's possible to specify the windows size with factor option
pseudoVoigtVector = pseudoVoigt({{factor: 5, fwhm: 500}});
const pseudoVoigtVector = pseudoVoigt({{factor: 5, fwhm: 500}});
```
```js
import { getShape, GAUSSIAN, LORENTZIAN, PSEUDO_VOIGT} from 'ml-peak-shape-generator';
// If you want to dynamically select a shape you can use the `getShape` method.
const shape = getShape(LORENTZIAN, {factor: 3.5, sd: 500});
```
## [API Documentation](https://cheminfo.github.io/ml-peak-shape-generator/)

@@ -35,0 +43,0 @@

@@ -1,5 +0,4 @@

import { gaussian } from './gaussian';
import { lorentzian } from './lorentzian';
import { pseudoVoigt } from './pseudoVoigt';
export { gaussian, lorentzian, pseudoVoigt };
export * from './gaussian';
export * from './lorentzian';
export * from './pseudoVoigt';
export * from './getShape';
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc