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
0
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 4.1.3 to 4.1.4

7

CHANGELOG.md
# Changelog
### [4.1.4](https://www.github.com/mljs/peak-shape-generator/compare/v4.1.3...v4.1.4) (2024-09-26)
### Bug Fixes
* correct fwhm for generalized lorentzian ([#78](https://www.github.com/mljs/peak-shape-generator/issues/78)) ([515b882](https://www.github.com/mljs/peak-shape-generator/commit/515b8828c06f0d4babd42275881a4c47c74de021))
### [4.1.3](https://www.github.com/mljs/peak-shape-generator/compare/v4.1.2...v4.1.3) (2024-09-24)

@@ -4,0 +11,0 @@

14

lib-esm/shapes/1d/generalizedLorentzian/GeneralizedLorentzian.js
import { ROOT_THREE } from '../../../util/constants';
/**
* This shape is a linear combination of rational function (n|n+2), for n = 0 (lorentzian function) and n = 2
* the parameter that combines those two functions is `gamma` and it is called the kurtosis parameter, it is an
* implementation of generalized lorentzian shape published by Stanislav Sykora in the SMASH 2010. DOI:10.3247/SL3nmr10.006
* @link http://www.ebyte.it/stan/Talk_ML_UserMeeting_SMASH_2010_GeneralizedLorentzian.html
*/
export class GeneralizedLorentzian {

@@ -39,3 +45,3 @@ constructor(options = {}) {

export const calculateGeneralizedLorentzianHeight = ({ fwhm = 1, gamma = 1, area = 1, }) => {
return area / fwhm / (3.14159 - 0.420894 * gamma) / 2;
return (area / fwhm / (3.14159 - 0.420894 * gamma)) * 2;
};

@@ -47,6 +53,6 @@ /**

const { fwhm = 500, height = 1, gamma = 1 } = options;
return 2 * height * fwhm * (3.14159 - 0.420894 * gamma);
return (height * fwhm * (3.14159 - 0.420894 * gamma)) / 2;
};
export const generalizedLorentzianFct = (x, fwhm, gamma) => {
const u = (x / 2 / fwhm) ** 2;
const u = ((2 * x) / fwhm) ** 2;
return (1 - gamma) / (1 + u) + (gamma * (1 + u / 2)) / (1 + u + u ** 2);

@@ -70,3 +76,3 @@ };

let { fwhm = 500, gamma = 1 } = shape;
let { length, factor = getGeneralizedLorentzianFactor(), height = 1, } = options;
let { length, factor = getGeneralizedLorentzianFactor(), height = calculateGeneralizedLorentzianHeight({ fwhm, area: 1, gamma }), } = options;
if (!length) {

@@ -73,0 +79,0 @@ length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);

@@ -39,3 +39,3 @@ import type { GetData1DOptions } from '../GetData1DOptions';

/**
* The halft width between the inflection points or standard deviation.
* The half width between the inflection points or standard deviation.
* If it is defined the fwhm would be re-assigned.

@@ -42,0 +42,0 @@ */

@@ -29,2 +29,8 @@ import type { GetData1DOptions } from '../GetData1DOptions';

}
/**
* This shape is a linear combination of rational function (n|n+2), for n = 0 (lorentzian function) and n = 2
* the parameter that combines those two functions is `gamma` and it is called the kurtosis parameter, it is an
* implementation of generalized lorentzian shape published by Stanislav Sykora in the SMASH 2010. DOI:10.3247/SL3nmr10.006
* @link http://www.ebyte.it/stan/Talk_ML_UserMeeting_SMASH_2010_GeneralizedLorentzian.html
*/
export declare class GeneralizedLorentzian implements Shape1DClass {

@@ -31,0 +37,0 @@ /**

@@ -5,2 +5,8 @@ "use strict";

const constants_1 = require("../../../util/constants");
/**
* This shape is a linear combination of rational function (n|n+2), for n = 0 (lorentzian function) and n = 2
* the parameter that combines those two functions is `gamma` and it is called the kurtosis parameter, it is an
* implementation of generalized lorentzian shape published by Stanislav Sykora in the SMASH 2010. DOI:10.3247/SL3nmr10.006
* @link http://www.ebyte.it/stan/Talk_ML_UserMeeting_SMASH_2010_GeneralizedLorentzian.html
*/
class GeneralizedLorentzian {

@@ -44,3 +50,3 @@ constructor(options = {}) {

const calculateGeneralizedLorentzianHeight = ({ fwhm = 1, gamma = 1, area = 1, }) => {
return area / fwhm / (3.14159 - 0.420894 * gamma) / 2;
return (area / fwhm / (3.14159 - 0.420894 * gamma)) * 2;
};

@@ -53,7 +59,7 @@ exports.calculateGeneralizedLorentzianHeight = calculateGeneralizedLorentzianHeight;

const { fwhm = 500, height = 1, gamma = 1 } = options;
return 2 * height * fwhm * (3.14159 - 0.420894 * gamma);
return (height * fwhm * (3.14159 - 0.420894 * gamma)) / 2;
};
exports.getGeneralizedLorentzianArea = getGeneralizedLorentzianArea;
const generalizedLorentzianFct = (x, fwhm, gamma) => {
const u = (x / 2 / fwhm) ** 2;
const u = ((2 * x) / fwhm) ** 2;
return (1 - gamma) / (1 + u) + (gamma * (1 + u / 2)) / (1 + u + u ** 2);

@@ -81,3 +87,3 @@ };

let { fwhm = 500, gamma = 1 } = shape;
let { length, factor = (0, exports.getGeneralizedLorentzianFactor)(), height = 1, } = options;
let { length, factor = (0, exports.getGeneralizedLorentzianFactor)(), height = (0, exports.calculateGeneralizedLorentzianHeight)({ fwhm, area: 1, gamma }), } = options;
if (!length) {

@@ -84,0 +90,0 @@ length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);

{
"name": "ml-peak-shape-generator",
"version": "4.1.3",
"version": "4.1.4",
"description": "Generate various peak shapes",

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

@@ -48,3 +48,3 @@ import {

/**
* The halft width between the inflection points or standard deviation.
* The half width between the inflection points or standard deviation.
* If it is defined the fwhm would be re-assigned.

@@ -51,0 +51,0 @@ */

@@ -33,2 +33,8 @@ import { ROOT_THREE } from '../../../util/constants';

/**
* This shape is a linear combination of rational function (n|n+2), for n = 0 (lorentzian function) and n = 2
* the parameter that combines those two functions is `gamma` and it is called the kurtosis parameter, it is an
* implementation of generalized lorentzian shape published by Stanislav Sykora in the SMASH 2010. DOI:10.3247/SL3nmr10.006
* @link http://www.ebyte.it/stan/Talk_ML_UserMeeting_SMASH_2010_GeneralizedLorentzian.html
*/
export class GeneralizedLorentzian implements Shape1DClass {

@@ -96,3 +102,3 @@ /**

}) => {
return area / fwhm / (3.14159 - 0.420894 * gamma) / 2;
return (area / fwhm / (3.14159 - 0.420894 * gamma)) * 2;
};

@@ -107,3 +113,3 @@

const { fwhm = 500, height = 1, gamma = 1 } = options;
return 2 * height * fwhm * (3.14159 - 0.420894 * gamma);
return (height * fwhm * (3.14159 - 0.420894 * gamma)) / 2;
};

@@ -116,3 +122,3 @@

) => {
const u = (x / 2 / fwhm) ** 2;
const u = ((2 * x) / fwhm) ** 2;
return (1 - gamma) / (1 + u) + (gamma * (1 + u / 2)) / (1 + u + u ** 2);

@@ -152,3 +158,3 @@ };

factor = getGeneralizedLorentzianFactor(),
height = 1,
height = calculateGeneralizedLorentzianHeight({ fwhm, area: 1, gamma }),
} = options;

@@ -155,0 +161,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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