File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 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 ) ;
You can’t perform that action at this time.
0 commit comments