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.3.0 to 0.4.0

14

History.md

@@ -0,1 +1,15 @@

# [0.4.0](https://github.com/cheminfo/ml-peak-shape-generator/compare/v0.3.0...v0.4.0) (2020-03-06)
### Bug Fixes
* documentation ([09b4ab8](https://github.com/cheminfo/ml-peak-shape-generator/commit/09b4ab89223f2c603eb76969c81f4c37823b22f8))
### Features
* returns data + fwhm ([01483ed](https://github.com/cheminfo/ml-peak-shape-generator/commit/01483ed5d8ec7ae78cd161a4aa77a588f313d86f))
# [0.3.0](https://github.com/cheminfo/ml-peak-shape-generator/compare/v0.2.0...v0.3.0) (2020-03-02)

@@ -2,0 +16,0 @@

42

lib/index.js

@@ -12,3 +12,3 @@ 'use strict';

* @param {number} [options.length = fwhm * factor] - total number of points to calculate
* @return {Float64Array} - array of Y points
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -29,10 +29,10 @@

const vector = new Float64Array(length);
const data = new Float64Array(length);
const normalConstant = 1 / Math.sqrt(2 * Math.PI) / sd;
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
normalConstant * Math.exp(-(1 / 2) * Math.pow((i - center) / sd, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}

@@ -46,3 +46,3 @@

* @param {number} [options.length = fwhm * factor] - total number of points to calculate
* @return {Float64Array} - array of Y points.
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -57,10 +57,10 @@

const normalConstant = 1 / Math.PI;
const vector = new Float64Array(length);
const data = new Float64Array(length);
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
(normalConstant * halfWidth) /
(Math.pow(i - center, 2) + Math.pow(halfWidth, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}

@@ -75,3 +75,3 @@

* @param {number} [options.length = fwhm * 3] - total number of points to calculate
* @return {number}
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -89,14 +89,18 @@

const gFactor = (1 - mu) * (1 / Math.sqrt(Math.PI) / sigma);
const vector = new Float64Array(length);
const data = new Float64Array(length);
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
lFactor / (4 * Math.pow(i - center, 2) + rootHalfWidth) +
gFactor * Math.exp(-1 * Math.pow((i - center) / sigma, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}
const GAUSSIAN = 1;
const LORENTZIAN = 2;
const PSEUDO_VOIGT = 3;
/**
* Calculate a normalized gaussian shape
* Generate a shape of the specified kind
* @param {number} [kind = 1]

@@ -106,9 +110,5 @@ * @param {object} [options = {}]

* @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
* @return {object} - {fwhm, data<Float64Array>}
*/
const GAUSSIAN = 1;
const LORENTZIAN = 2;
const PSEUDO_VOIGT = 3;
function getShape(kind = 1, options = {}) {

@@ -115,0 +115,0 @@ if (typeof kind === 'string') kind = getKind(kind);

{
"name": "ml-peak-shape-generator",
"version": "0.3.0",
"version": "0.4.0",
"description": "",

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

@@ -19,11 +19,11 @@ # ml-peak-shape-generator

// It's possible to specify the windows size with factor option
const gaussianVector = gaussian({factor: 3.5, sd: 500});
let {data, fwhm} = gaussian({factor: 3.5, sd: 500});
// or fix the number of points as Full Width at Half Maximum
const gaussianVector2 = gaussian({factor: 3.5, fwhm: 500});
let {data, fwhm} = gaussian({factor: 3.5, fwhm: 500});
// It's possible to specify the windows size with factor option
const lorenzianVector = loretzian({factor: 5, fwhm: 500});
let {data, fwhm} = loretzian({factor: 5, fwhm: 500});
// It's possible to specify the windows size with factor option
const pseudoVoigtVector = pseudoVoigt({{factor: 5, fwhm: 500}});
let {data, fwhm} = pseudoVoigt({{factor: 5, fwhm: 500}});
```

@@ -35,3 +35,3 @@

// If you want to dynamically select a shape you can use the `getShape` method.
const shape = getShape(LORENTZIAN, {factor: 3.5, sd: 500});
let {data, fwhm} = getShape(LORENTZIAN, {factor: 3.5, sd: 500});

@@ -43,3 +43,3 @@ ```

## [API Documentation](https://cheminfo.github.io/ml-peak-shape-generator/)
## [API Documentation](https://mljs.github.io/peak-shape-generator/)

@@ -52,5 +52,5 @@ ## License

[npm-url]: https://www.npmjs.com/package/ml-peak-shape-generator
[ci-image]: https://github.com/cheminfo/ml-peak-shape-generator/workflows/Node.js%20CI/badge.svg?branch=master
[ci-url]: https://github.com/cheminfo/ml-peak-shape-generator/actions?query=workflow%3A%22Node.js+CI%22
[ci-image]: https://github.com/mljs/peak-shape-generator/workflows/Node.js%20CI/badge.svg?branch=master
[ci-url]: https://github.com/mljs/peak-shape-generator/actions?query=workflow%3A%22Node.js+CI%22
[download-image]: https://img.shields.io/npm/dm/ml-peak-shape-generator.svg
[download-url]: https://www.npmjs.com/package/ml-peak-shape-generator

@@ -8,3 +8,3 @@ /**

* @param {number} [options.length = fwhm * factor] - total number of points to calculate
* @return {Float64Array} - array of Y points
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -25,10 +25,10 @@

const vector = new Float64Array(length);
const data = new Float64Array(length);
const normalConstant = 1 / Math.sqrt(2 * Math.PI) / sd;
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
normalConstant * Math.exp(-(1 / 2) * Math.pow((i - center) / sd, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}

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

/**
* 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
*/
import { gaussian } from './gaussian';

@@ -18,2 +9,11 @@ import { lorentzian } from './lorentzian';

/**
* Generate a shape of the specified kind
* @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 {object} - {fwhm, data<Float64Array>}
*/
export function getShape(kind = 1, options = {}) {

@@ -20,0 +20,0 @@ if (typeof kind === 'string') kind = getKind(kind);

@@ -7,3 +7,3 @@ /**

* @param {number} [options.length = fwhm * factor] - total number of points to calculate
* @return {Float64Array} - array of Y points.
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -18,10 +18,10 @@

const normalConstant = 1 / Math.PI;
const vector = new Float64Array(length);
const data = new Float64Array(length);
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
(normalConstant * halfWidth) /
(Math.pow(i - center, 2) + Math.pow(halfWidth, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}

@@ -8,3 +8,3 @@ /**

* @param {number} [options.length = fwhm * 3] - total number of points to calculate
* @return {number}
* @return {object} - {fwhm, data<Float64Array>}
*/

@@ -22,10 +22,10 @@

const gFactor = (1 - mu) * (1 / Math.sqrt(Math.PI) / sigma);
const vector = new Float64Array(length);
const data = new Float64Array(length);
for (let i = 0; i <= center; i++) {
vector[i] =
data[i] =
lFactor / (4 * Math.pow(i - center, 2) + rootHalfWidth) +
gFactor * Math.exp(-1 * Math.pow((i - center) / sigma, 2));
vector[length - 1 - i] = vector[i];
data[length - 1 - i] = data[i];
}
return vector;
return { data, fwhm };
}
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