@@ -109,17 +109,17 @@ GraphSpectrumCalc.dataLoadFrequency = function() {
109109GraphSpectrumCalc . dataLoadPSD = function ( analyserZoomY ) {
110110 const flightSamples = this . _getFlightSamplesFreq ( false ) ;
111111
112- let points_per_segment = 512 ;
112+ let pointsPerSegment = 512 ;
113113 const multipler = Math . floor ( 1 / analyserZoomY ) ; // 0. ... 10
114114 if ( multipler == 0 ) {
115- points_per_segment = 256 ;
115+ pointsPerSegment = 256 ;
116116 } else if ( multipler > 1 ) {
117- points_per_segment *= 2 ** Math . floor ( multipler / 2 ) ;
117+ pointsPerSegment *= 2 ** Math . floor ( multipler / 2 ) ;
118118 }
119- points_per_segment = Math . min ( points_per_segment , flightSamples . samples . length ) ;
120- const overlap_count = points_per_segment / 2 ;
119+ pointsPerSegment = Math . min ( pointsPerSegment , flightSamples . samples . length ) ;
120+ const overlapCount = pointsPerSegment / 2 ;
121121
122- const psd = this . _psd ( flightSamples . samples , this . _blackBoxRate , points_per_segment , overlap_count ) ;
122+ const psd = this . _psd ( flightSamples . samples , this . _blackBoxRate , pointsPerSegment , overlapCount ) ;
123123 let min = 1e6 ,
124124 max = - 1e6 ;
125125 for ( const value of psd ) {
@@ -525,9 +525,9 @@ GraphSpectrumCalc._normalizeFft = function(fftOutput, fftLength) {
525525/**
526526 * Compute PSD for data samples by Welch method follow Python code
527527 */
528- GraphSpectrumCalc . _psd = function ( samples , fs , n_per_seg , n_overlap , scaling = 'density' ) {
528+ GraphSpectrumCalc . _psd = function ( samples , samplesRate , pointsPerSegment , overlapCount , scaling = 'density' ) {
529529// Compute FFT for samples segments
530- const fftOutput = this . _fft_segmented ( samples , n_per_seg , n_overlap ) ;
530+ const fftOutput = this . _fft_segmented ( samples , pointsPerSegment , overlapCount ) ;
531531
532532 const dataCount = fftOutput [ 0 ] . length ;
533533 const segmentsCount = fftOutput . length ;
@@ -536,14 +536,14 @@ GraphSpectrumCalc._psd = function(samples, fs, n_per_seg, n_overlap, scaling =
536536// Compute power scale coef
537537 let scale = 1 ;
538538 if ( userSettings . analyserHanning ) {
539- const window = Array ( n_per_seg ) . fill ( 1 ) ;
540- this . _hanningWindow ( window , n_per_seg ) ;
539+ const window = Array ( pointsPerSegment ) . fill ( 1 ) ;
540+ this . _hanningWindow ( window , pointsPerSegment ) ;
541541 if ( scaling == 'density' ) {
542542 let skSum = 0 ;
543543 for ( const value of window ) {
544544 skSum += value ** 2 ;
545545 }
546- scale = 1 / ( fs * skSum ) ;
546+ scale = 1 / ( samplesRate * skSum ) ;
547547 } else if ( scaling == 'spectrum' ) {
548548 let sum = 0 ;
549549 for ( const value of window ) {
@@ -552,9 +552,9 @@ GraphSpectrumCalc._psd = function(samples, fs, n_per_seg, n_overlap, scaling =
552552 scale = 1 / sum ** 2 ;
553553 }
554554 } else if ( scaling == 'density' ) {
555- scale = 1 / n_per_seg ;
555+ scale = 1 / pointsPerSegment ;
556556 } else if ( scaling == 'spectrum' ) {
557- scale = 1 / n_per_seg ** 2 ;
557+ scale = 1 / pointsPerSegment ** 2 ;
558558 }
559559
560560// Compute average for scaled power
0 commit comments