Skip to content

Commit

Permalink
fix: autoRanges detection for HR spectra
Browse files Browse the repository at this point in the history
Not sure this is optimal and those parameters may still evolve
  • Loading branch information
lpatiny committed Feb 3, 2022
1 parent 7d49943 commit bc9f475
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
"check-types": "tsc --noEmit",
"compile": "tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"clean-lib": "rimraf lib lib-cjs",
"dev": "vite --host localhost --port 3000 --strictPort --open",
"dev": "vite --host localhost --port 4000 --strictPort --open",
"eslint": "eslint . --cache",
"eslint-fix": "npm run eslint -- --fix",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
Expand Down
7 changes: 6 additions & 1 deletion src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts
Expand Up @@ -44,12 +44,17 @@ export default function autoRangesDetection(
}

if (originFrequency) {
let ws = Math.max(Math.round(1 / originFrequency / (x[1] - x[0])), 5);
// we calculate the number of points per Hz
let pointsPerHz = 1 / originFrequency / (x[1] - x[0]);
// we can consider a peak with of 0.5 Hz for the windowSize
let ws = Math.max(Math.round(pointsPerHz / 2), 5);
peakPickingOptions.sgOptions = {
windowSize: ws - (ws % 2) + 1,
polynomial: 3,
};
}
peakPickingOptions.smoothY = undefined;
peakPickingOptions.sgOptions = undefined;

const ranges = xyAutoRangesPicking(
{ x, y: re },
Expand Down

0 comments on commit bc9f475

Please sign in to comment.