{"id":19266983,"url":"https://github.com/mljs/peak-shape-generator","last_synced_at":"2025-04-21T19:32:25.158Z","repository":{"id":40560263,"uuid":"240598778","full_name":"mljs/peak-shape-generator","owner":"mljs","description":"Generate various peak shapes.","archived":false,"fork":false,"pushed_at":"2024-09-26T03:14:09.000Z","size":2063,"stargazers_count":1,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T15:41:43.698Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"https://mljs.github.io/peak-shape-generator/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-14T21:07:47.000Z","updated_at":"2024-09-26T03:13:24.000Z","dependencies_parsed_at":"2022-08-09T23:10:33.853Z","dependency_job_id":null,"html_url":"https://github.com/mljs/peak-shape-generator","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpeak-shape-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpeak-shape-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpeak-shape-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fpeak-shape-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/peak-shape-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703191,"owners_count":21148118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-09T20:08:51.973Z","updated_at":"2025-04-21T19:32:25.151Z","avatar_url":"https://github.com/mljs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-peak-shape-generator\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![npm download][download-image]][download-url]\n\nGenerate various peak shapes.\n\nThe current supported kinds of shapes:\n\n| Name         |                                                                                                                           Equation                                                                                                                            |\n| ------------ | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n| Gaussian     |                                                          \u003cimg src=\"https://tex.cheminfo.org/?tex=y%5Ccdot%20exp%5Cleft%5B-%5Cfrac%7B1%7D%7B2%7D%5Cfrac%7B%5Cdelta%7D%7B%5Csigma%5E2%7D%5Cright%5D\"/\u003e                                                          |\n| Lorentzian   |                                                                       \u003cimg src=\"https://tex.cheminfo.org/?tex=y%5Ccdot%5Cfrac%7B%5Comega%5E2%7D%7B4%5Cdelta%20%2B%20%5Comega%5E2%7D\"/\u003e                                                                        |\n| Pseudo Voigt | \u003cimg src=\"https://tex.cheminfo.org/?tex=y%20%5Ccdot%5Cleft%5Bx_g%5Ccdot%20exp%5Cleft%5B-%5Cfrac%7B1%7D%7B2%7D%5Cfrac%7B%5Cdelta%7D%7B%5Csigma%5E2%7D%5Cright%5D%20%2B%20x_l%5Ccdot%5Cfrac%7B%5Comega%5E2%7D%7B4%5Cdelta%20%2B%20%5Comega%5E2%7D%5Cright%5D\"/\u003e |\n\nwhere\n\n| \u003cimg src=\"https://tex.cheminfo.org/?tex=%5Cdelta%20%3D%20%5Cleft(t%20-%20x%5Cright)%5E2%0A\"/\u003e | \u003cimg src=\"https://tex.cheminfo.org/?tex=%5Csigma%20%3D%20%5Cfrac%7BFWHM%7D%7B2%5Csqrt%7B2%20%5Ccdot%20ln(2)%7D%7D\"/\u003e | \u003cimg src=\"https://tex.cheminfo.org/?tex=%5Comega%20%3D%20FWHM\"/\u003e |\n| --------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------- |\n\n## Installation\n\n`$ npm i ml-peak-shape-generator`\n\nThis package allows to calculate various shapes. By default they will have a height of 1.\n\n![demo.png](demo.png)\n\nYou see the resulting functions using this [playground](https://codesandbox.io/s/lorentzian-u1upg0?file=/Example.tsx)\n\n## Usage\n\n```js\nimport {\n  getGaussianData,\n  getLorentzianData,\n  getPseudoVoigtData,\n} from 'ml-peak-shape-generator';\n\n// It's possible to specify the windows size with factor option\nlet data = getGaussianData({ sd: 500 }, { factor: 3.5 });\n// or fix the number of points as Full Width at Half Maximum\nlet data = getGaussianData({ fwhm: 500 }, { factor: 3.5 });\n\n// It's possible to specify the windows size with factor option\nlet data = getLorentzianData({ fwhm: 500 }, { factor: 5 });\n\n// It's possible to specify the windows size with factor option\nlet data = getPseudoVoigtData({ fwhm: 500 }, { factor: 5 });\n```\n\nIt is also possible to take an instance of each kind of shape:\n\n```js\nimport { Gaussian, gaussianFct, Gaussian2D } from 'ml-peak-shape-shape';\n\nconst gaussianShape = new Gaussian({ fwhm: 500 });\n// It is possible to set a new value for fwhm\ngaussianShape.fwhm = 300;\n\n// By default the height value ensure a volume equal 1.\nconst gaussian2DShape = new Gaussian2D({ fwhm: 500 });\n\n// It is possible to set values for sd, fwhm and factor for each axes.\nconst gaussian2DShape = new Gaussian2D({ fwhm: { x: 300, y: 500 } });\n\n// It is possible to set new value for fwhm by:\ngaussian2D.fwhm = { x: 300, y: 500 };\n// or set the same value for both axes.\ngaussian2D.fwhm = 400;\n\n//An instance of any shape has the same methods accessible for each\n//shape e.g. fct or getData, but these use the internal parameters. e.g:\n\nconst gaussianShape = new Gaussian({ fwhm: 500 });\ngaussianShape.fct(5);\ngaussianFct(5, 500);\n// getData\ngaussianShape.getData({ factor: 3.5 });\n```\n\n```js\nimport { getShape1D, getShape2D } from 'ml-peak-shape-generator';\n\n// If you want to dynamically select a shape you can use the `getShapeGenerator` method. It returns a instance of required kind of shape.\n\nlet shapeGenerator = getShape1D({ kind: 'lorentzian', sd: 500 });\nlet shapeGenerator = getShape2D({ kind: 'gaussian', sd: 500 });\n```\n\nIt is also possible to get a function that allows to calculate y for any x\n\n```js\nimport { gaussianFct } from 'ml-peak-shape-generator';\nconst func = gaussianFct(x - mean, fwhm);\n```\n\n## [API Documentation](https://mljs.github.io/peak-shape-generator/)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ml-peak-shape-generator.svg\n[npm-url]: https://www.npmjs.com/package/ml-peak-shape-generator\n[ci-image]: https://github.com/mljs/peak-shape-generator/workflows/Node.js%20CI/badge.svg?branch=main\n[ci-url]: https://github.com/mljs/peak-shape-generator/actions?query=workflow%3A%22Node.js+CI%22\n[codecov-image]: https://img.shields.io/codecov/c/github/mljs/peak-shape-generator.svg\n[codecov-url]: https://codecov.io/gh/mljs/peak-shape-generator\n[download-image]: https://img.shields.io/npm/dm/ml-peak-shape-generator.svg\n[download-url]: https://www.npmjs.com/package/ml-peak-shape-generator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fpeak-shape-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fpeak-shape-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fpeak-shape-generator/lists"}