Skip to content

Commit af54384

Browse files
committed
Impoved PSD heat map charts vertical slider control: the avaiable dBm range shift value are -30, -20, -10, 0, 10, 20 dBm
1 parent 16b2fd1 commit af54384

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/graph_spectrum_calc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ GraphSpectrumCalc._normalizeFft = function(fftOutput) {
627627

628628
/**
629629
* Compute PSD for data samples by Welch method follow Python code
630+
* It is good to use power at 2 values for pointsPerSegment.
631+
* For short data length, set pointsPerSegment same samples.length to extend samples count for power at 2 value inside _fft_segmented
630632
*/
631633
GraphSpectrumCalc._psd = function(samples, pointsPerSegment, overlapCount, scaling = 'density') {
632634
// Compute FFT for samples segments
@@ -716,6 +718,8 @@ GraphSpectrumCalc._psd = function(samples, pointsPerSegment, overlapCount, scal
716718

717719
/**
718720
* Compute FFT for samples segments by lenghts as pointsPerSegment with overlapCount overlap points count
721+
* It is good to use power at 2 values for pointsPerSegment.
722+
* For short data length, set pointsPerSegment same samples.length to extend samples count for power at 2 value inside _fft_segmented
719723
*/
720724
GraphSpectrumCalc._fft_segmented = function(samples, pointsPerSegment, overlapCount) {
721725
const samplesCount = samples.length;

src/graph_spectrum_plot.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,11 @@ GraphSpectrumPlot._drawHeatMap = function (drawPSD = false) {
510510
const fftColorScale = 100 / (this._zoomY * SCALE_HEATMAP);
511511

512512
//Compute the dbm range shift from zoomY as[-30, -20, -10, 0, +10, +20]
513-
let dBmRangeShift = Math.floor(1 / this._zoomY) - 1; // -1 ... 9
514-
if (dBmRangeShift > 0) {
515-
dBmRangeShift = -10 * Math.round(dBmRangeShift / 3); //-10, -20, -30
516-
} else if (dBmRangeShift < 0) {
517-
dBmRangeShift = -10 * Math.round(dBmRangeShift * 2); //+20
513+
let dBmRangeShift = 0;
514+
if (this._zoomY <= 1) { // [10 ... 0.1]
515+
dBmRangeShift = -10 * Math.round((1 / this._zoomY - 1) / 3); //0, -10, -20, -30
516+
} else {
517+
dBmRangeShift = 10 * Math.round((this._zoomY - 1) / 9 * 2); // 0, 10, 20
518518
}
519519
const dBmValueMin = MIN_DBM_VALUE + dBmRangeShift,
520520
dBmValueMax = MAX_DBM_VALUE + dBmRangeShift;

0 commit comments

Comments
 (0)