Skip to content

Commit

Permalink
fix: fwhm didn't work for pseudovoigt
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed May 3, 2022
1 parent 06adc6b commit 9b8e0b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/utils/__tests__/appendShapeAndFWHM.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,31 @@ describe('appendShapeAndFWHM', () => {
},
]);
});
it('pseudovoigt shape', () => {
let result = appendShapeAndFWHM(
[
{
x: 5,
y: 10,
width: 5,
index: 1,
inflectionPoints: {
from: { x: 0, index: 0 },
to: { x: 0, index: 0 },
},
},
],
{ shape: { kind: 'pseudoVoigt', mu: 0.5 } },
);
expect(result).toMatchCloseTo([
{
x: 5,
y: 10,
width: 5,
index: 1,
shape: { kind: 'pseudoVoigt', fwhm: 5.443525056288687, mu: 0.5 },
inflectionPoints: { from: { x: 0, index: 0 }, to: { x: 0, index: 0 } },
},
]);
});
});
4 changes: 2 additions & 2 deletions src/utils/appendShapeAndFWHM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export function appendShapeAndFWHM<T extends { width: number }>(
} = {},
) {
let { shape = { kind: 'gaussian' } } = options;
let widthToFWHM = getShape1D(shape).widthToFWHM;
let shapeInstance = getShape1D(shape);
return peaks.map((peak) => ({
...peak,
shape: { fwhm: widthToFWHM(peak.width), ...shape },
shape: { fwhm: shapeInstance.widthToFWHM(peak.width), ...shape },
}));
}

0 comments on commit 9b8e0b6

Please sign in to comment.