Skip to content

Commit

Permalink
fix: generalizedLorentzian shape supported (#86)
Browse files Browse the repository at this point in the history
* fix: generalizedLorentzian shape supported

* chore: test case
  • Loading branch information
jobo322 authored Sep 27, 2024
1 parent c1c97d3 commit a2f4dc8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"typescript": "^5.4.2"
},
"dependencies": {
"ml-peak-shape-generator": "^4.1.2",
"ml-spectra-processing": "^14.2.0"
"ml-peak-shape-generator": "^4.1.4",
"ml-spectra-processing": "^14.5.0"
}
}
37 changes: 37 additions & 0 deletions src/__tests__/generateSpectrum.shape.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,41 @@ describe('generateSpectrum', () => {
const gaussian = new Gaussian({ fwhm: 0.5 });
expect(spectrum.y[index]).toBe(gaussian.fct(0.06));
});

it('Those two peak shape should be a pure lorentzian', () => {
const lorentzianPeak: Peak1D[] = [
{
x: 0,
y: 1,
shape: { kind: 'lorentzian', fwhm: 0.5 },
},
];

const spectrum = generateSpectrum(lorentzianPeak, {
generator: {
from: -0.1,
to: 0.1,
nbPoints: 51,
shape: { kind: 'gaussian' },
},
});

const generalizedLorentzianPeak: Peak1D[] = [
{
x: 0,
y: 1,
shape: { kind: 'generalizedLorentzian', fwhm: 0.5, gamma: 0 },
},
];
const spectrum2 = generateSpectrum(generalizedLorentzianPeak, {
generator: {
from: -0.1,
to: 0.1,
nbPoints: 51,
shape: { kind: 'gaussian' },
},
});

expect(spectrum.y).toStrictEqual(spectrum2.y);
});
});

0 comments on commit a2f4dc8

Please sign in to comment.