spectrum-generator
generate a spectrum from discrete peaks
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.1%) to scientific vocabulary
Keywords
Repository
generate a spectrum from discrete peaks
Basic Info
- Host: GitHub
- Owner: cheminfo
- License: mit
- Language: TypeScript
- Default Branch: main
- Homepage: https://cheminfo.github.io/spectrum-generator/
- Size: 2.16 MB
Statistics
- Stars: 2
- Watchers: 5
- Forks: 4
- Open Issues: 2
- Releases: 46
Topics
Metadata Files
README.md
spectrum-generator
Generates a spectrum from discrete peaks. The shape of the peaks can be customized.
The shape is generated using ml-peak-shape-generator and you may use all the corresponding options of getShape.
Installation
$ npm i spectrum-generator
Usage
generateSpectrum
```js import { generateSpectrum } from 'spectrum-generator';
const peaks = [ [4, 10], [20, 30], [236, 1], [569, 76], ]; const spectrum = generateSpectrum(peaks, { generator: { from: 0, to: 1000, nbPoints: 10001, }, shape: { kind: 'gaussian', // default value is gaussian }, }); ```
Example to generate a high resolution spectrum using lorentzian peaks shape
```js import { generateSpectrum } from 'spectrum-generator';
const peaks = [ [1, 10], [2, 30], [3, 1], [4, 76], ];
/* Peaks can also be introduced as: - const peaks = [{x:1,y:10},{x:2,y:30},{x:3,y:1},{x:4,y:76}] - const peaks = {x:[1,2,3,4], y:[10,30,1,76]} - const peaks = [ [1,10,5], [2,30,10] ] // third argument is the peak fwhm */
const spectrum = generateSpectrum(peaks, { generator: { from: 0, to: 10, nbPoints: 1001, }, shape: { kind: 'lorentzian', }, }); ```
genrateSpectrum with baseline
js
const spectrum = generateSpectrum([{ x: 5, y: 100 }], {
generator: {
from: 0,
to: 10,
nbPoints: 51,
peakWidthFct: () => 2,
},
baseline: (x) => x / 10,
});
genereateSpectrum with noise
Generate with some noise
js
const spectrum = generateSpectrum([{ x: 5, y: 100 }], {
generator: {
from: 0,
to: 10,
nbPoints: 51,
peakWidthFct: () => 2,
},
noise: {
percent: 10,
distribution: 'uniform',
},
});
class SpectrumGenerator
```js import { SpectrumGenerator } from 'spectrum-generator';
const generator = new SpectrumGenerator(); generator.addPeak([5, 20]); generator.addPeak({ x: 5, y: 20 }); // we may either add an array of 2 elements or an object with x,y values generator.addPeak([30, 56]); generator.addPeaks([ {x: 40, y: 12}, // it can also be an array of 2 elements {x: 10, y:1}, ]); const spectrum = generator.getSpectrum();
generator.reset();
generator.addPeak({x: 10, y: 50}], { // customize peaks shape width: 0.1, // width of peak is FWHM factor: 10, // 10 times fwhm. Lorentzian are rather flat shape: { kind: 'lorentzian', } });
generator.addPeak({x: 10, y: 50, width: 2}) // specifiy the peak width. This is the peak width half height (FWHM)
generator.addPeak({x: 10, y: 50}], { // customize peaks shape width: 0.1, shape: { kind: 'gaussian', } }); const otherSpectrum = generator.getSpectrum(); ```
API Documentation
License
```
```
Owner
- Name: Cheminfo
- Login: cheminfo
- Kind: organization
- Website: https://www.cheminfo.org/
- Repositories: 242
- Profile: https://github.com/cheminfo
Citation (CITATION.cff)
cff-version: 1.2.0
message: 'If you use this software, please cite it as below.'
title: 'Javascript library allowing to generate spectra using gaussian or lorentzian shapes'
abstract: 'Based on peaks position, height, width and shape this library will create a spectrum containing a define number of points'
repository-artifact: http://cheminfo.github.io/spectra-generator/
repository-code: https://github.com/cheminfo/spectra-generator
authors:
- family-names: 'Patiny'
given-names: 'Luc'
orcid: 'https://orcid.org/0000-0002-4943-2643'
- family-names: 'Bolaños'
given-names: 'Alejandro'
affiliation: 'Universidad del Valle, Cali, Colombia'
orcid: 'https://orcid.org/0000-0001-5933-5524'
- family-names: 'Zasso'
given-names: 'Michaël'
affiliation: 'Zakodium Sàrl, Switzerland'
orcid: 'https://orcid.org/0000-0001-5295-2159'
- family-names: 'Patiny'
given-names: 'Océane'
orcid: 'https://orcid.org/0000-0002-8203-126X'
license: MIT
keywords:
- Spectrum generation
- Nuclear magnetic resonance-
- Gaussian
- Lorentzian
doi: 10.5281/zenodo.5172776
GitHub Events
Total
- Create event: 5
- Issues event: 2
- Release event: 3
- Delete event: 4
- Issue comment event: 9
- Push event: 16
- Pull request event: 5
- Fork event: 1
Last Year
- Create event: 5
- Issues event: 2
- Release event: 3
- Delete event: 4
- Issue comment event: 9
- Push event: 16
- Pull request event: 5
- Fork event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 12
- Total pull requests: 79
- Average time to close issues: 3 months
- Average time to close pull requests: 13 days
- Total issue authors: 4
- Total pull request authors: 6
- Average comments per issue: 1.08
- Average comments per pull request: 1.09
- Merged pull requests: 73
- Bot issues: 0
- Bot pull requests: 2
Past Year
- Issues: 0
- Pull requests: 6
- Average time to close issues: N/A
- Average time to close pull requests: 26 days
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jobo322 (5)
- lpatiny (5)
- wadjih-bencheikh18 (1)
- targos (1)
Pull Request Authors
- cheminfo-bot (46)
- jobo322 (26)
- lpatiny (6)
- targos (2)
- dependabot[bot] (2)
- RicardoSilvestr (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 2,934 last-month
- Total dependent packages: 9
- Total dependent repositories: 23
- Total versions: 58
- Total maintainers: 4
npmjs.org: spectrum-generator
generate a spectrum from discrete peaks
- Homepage: https://github.com/cheminfo/spectrum-generator#readme
- License: MIT
-
Latest release: 8.1.1
published 6 months ago
Rankings
Maintainers (4)
Dependencies
- @types/d3-random ^3.0.1 development
- @types/jest ^27.4.1 development
- cheminfo-build ^1.1.11 development
- cheminfo-types ^1.1.0 development
- eslint ^8.14.0 development
- eslint-config-cheminfo-typescript ^10.4.0 development
- jest ^27.5.1 development
- jest-matcher-deep-close-to ^3.0.2 development
- ml-savitzky-golay-generalized ^4.0.1 development
- prettier ^2.6.2 development
- rimraf ^3.0.2 development
- ts-jest ^27.1.4 development
- typescript ^4.6.4 development
- ml-peak-shape-generator ^4.1.1
- ml-spectra-processing ^11.5.0
- actions/checkout v2 composite
- actions/setup-node v2 composite
- zakodium/lactame-action v1 composite
- JamesIves/github-pages-deploy-action releases/v4 composite
- actions/checkout v2 composite
- actions/setup-node v2 composite
- zakodium/typedoc-action v2 composite