Skip to content

Commit

Permalink
feat: add baseline and correctedIntegral in ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Oct 9, 2024
1 parent fc699d5 commit 5319de5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ describe('updateRangesInfo', () => {
label: 'A',
from: 0,
to: 3,
baseline: 4.5,
correctedIntegration: 0,
deltaX: 3,
integration: 4.5,
maxPoint: { x: 3, y: 3, index: 3 },
minPoint: { x: 0, y: 0, index: 0 },
Expand All @@ -40,6 +43,9 @@ describe('updateRangesInfo', () => {
label: 'B',
from: 4,
to: 6,
baseline: 8,
correctedIntegration: 1,
deltaX: 2,
integration: 9,
maxPoint: { x: 5, y: 5, index: 5 },
minPoint: { x: 4, y: 4, index: 4 },
Expand Down
3 changes: 3 additions & 0 deletions src/spectrum/updateRangesInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export function updateRangesInfo(spectrum, ranges = []) {
fromIndex: xFindClosestIndex(spectrum.normalized.x, range.from),
toIndex: xFindClosestIndex(spectrum.normalized.x, range.to),
};
range.deltaX = spectrum.normalized.x[fromToIndex.toIndex] - spectrum.normalized.x[fromToIndex.fromIndex];
range.baseline = (spectrum.normalized.y[fromToIndex.toIndex] + spectrum.normalized.y[fromToIndex.fromIndex]) * range.deltaX / 2;
range.integration = xyIntegration(spectrum.normalized, fromToIndex);
range.correctedIntegration = range.integration - range.baseline;
range.maxPoint = xyMaxYPoint(spectrum.normalized, fromToIndex);
range.minPoint = xyMinYPoint(spectrum.normalized, fromToIndex);
range.x = spectrum.normalized.x.slice(
Expand Down

0 comments on commit 5319de5

Please sign in to comment.