Skip to content

Commit 9d58f8a

Browse files
committed
test: add example on 1e6 points
1 parent e5c361f commit 9d58f8a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

examples/big/1e6.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

examples/big/bigTest.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
// run file using ts-node examples/big/bigTest.js
3+
4+
5+
import { readFileSync } from 'fs'
6+
import { join } from 'path'
7+
8+
import { xMaxValue, xMinValue } from 'ml-spectra-processing'
9+
10+
import { gsd } from '../../src/index.ts'
11+
12+
console.time('loading')
13+
const data = JSON.parse(readFileSync(join(__dirname, '1e6.json'), 'utf8'))
14+
console.timeEnd('loading')
15+
console.log('Number peaks: ', data.x.length)
16+
console.time('gsd')
17+
const peaks = gsd(data, {
18+
minMaxRatio: 0.00025, // Threshold to determine if a given peak should be considered as a noise
19+
realTopDetection: true,
20+
smoothY: false,
21+
sgOptions: { windowSize: 7, polynomial: 3 },
22+
})
23+
console.timeEnd('gsd')
24+
25+
console.log('Min Y:', xMinValue(peaks.map((peak) => peak.y)))
26+
console.log('Max Y:', xMaxValue(peaks.map((peak) => peak.y)))
27+
28+
console.log('Nb peaks:', peaks.length);

0 commit comments

Comments
 (0)