@@ -87,4 +87,44 @@ describe('calibrateX', () => {
8787 Float64Array . from ( [ 1 , 1 , 1 , 1 , 700 , 1 , 5 , 1 , 1 , 1 , 1 , 1 , 1 ] ) ,
8888 ) ;
8989 } ) ;
90+
91+ it ( '2 peaks' , ( ) => {
92+ let data = {
93+ x : Float64Array . from ( [
94+ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 ,
95+ 20 ,
96+ ] ) ,
97+ y : Float64Array . from ( [
98+ 1 , 1 , 1 , 1 , 1 , 700 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 700 , 1 , 1 , 1 , 1 , 1 ,
99+ ] ) ,
100+ } ;
101+
102+ let gsdOptions = {
103+ minMaxRatio : 0.4 ,
104+ realTopDetection : true ,
105+ smoothY : true ,
106+ sgOptions : {
107+ windowSize : 5 ,
108+ polynomial : 3 ,
109+ } ,
110+ } ;
111+
112+ let shifted = calibrateX ( data , {
113+ targetX : 6 ,
114+ gsd : gsdOptions ,
115+ nbPeaks : 2 ,
116+ } ) ;
117+ // because we look for the real maximum it is not exactly 2
118+ expect ( shifted . data . x ) . toMatchCloseTo (
119+ Float64Array . from ( [
120+ - 4 , - 3 , - 2 , - 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 ,
121+ 16 ,
122+ ] ) ,
123+ ) ;
124+ expect ( shifted . data . y ) . toStrictEqual (
125+ Float64Array . from ( [
126+ 1 , 1 , 1 , 1 , 1 , 700 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 700 , 1 , 1 , 1 , 1 , 1 ,
127+ ] ) ,
128+ ) ;
129+ } ) ;
90130} ) ;
0 commit comments