ml-peak-shape-generator
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -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; |
{ | ||
"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'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13764
10
234
53