Skip to content

Commit d26fcd9

Browse files
committed
chore: use camelCase for variable name
1 parent 432ad5f commit d26fcd9

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/gsd.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ export function gsd(x, yIn, options = {}) {
6161
}
6262
// If the max difference between delta x is less than 5%, then,
6363
// we can assume it to be equally spaced variable
64-
let Y = y;
64+
let yData = y;
6565
let dY, ddY;
6666
const { windowSize, polynomial } = sgOptions;
6767

6868
if (equalSpaced) {
6969
if (smoothY) {
70-
Y = SG(y, x[1] - x[0], {
70+
yData = SG(y, x[1] - x[0], {
7171
windowSize,
7272
polynomial,
7373
derivative: 0,
@@ -85,7 +85,7 @@ export function gsd(x, yIn, options = {}) {
8585
});
8686
} else {
8787
if (smoothY) {
88-
Y = SG(y, x, {
88+
yData = SG(y, x, {
8989
windowSize,
9090
polynomial,
9191
derivative: 0,
@@ -102,32 +102,32 @@ export function gsd(x, yIn, options = {}) {
102102
derivative: 2,
103103
});
104104
}
105-
// console.log('this is 2', y)
106-
const X = x;
107-
const dx = x[1] - x[0];
105+
106+
const xData = x;
107+
const dX = x[1] - x[0];
108108
let maxDdy = 0;
109109
let maxY = 0;
110-
for (let i = 0; i < Y.length; i++) {
110+
for (let i = 0; i < yData.length; i++) {
111111
if (Math.abs(ddY[i]) > maxDdy) {
112112
maxDdy = Math.abs(ddY[i]);
113113
}
114-
if (Math.abs(Y[i]) > maxY) {
115-
maxY = Math.abs(Y[i]);
114+
if (Math.abs(yData[i]) > maxY) {
115+
maxY = Math.abs(yData[i]);
116116
}
117117
}
118118

119119
let lastMax = null;
120120
let lastMin = null;
121-
let minddY = new Array(Y.length - 2);
122-
let intervalL = new Array(Y.length);
123-
let intervalR = new Array(Y.length);
124-
let broadMask = new Array(Y.length - 2);
121+
let minddY = new Array(yData.length - 2);
122+
let intervalL = new Array(yData.length);
123+
let intervalR = new Array(yData.length);
124+
let broadMask = new Array(yData.length - 2);
125125
let minddYLen = 0;
126126
let intervalLLen = 0;
127127
let intervalRLen = 0;
128128
let broadMaskLen = 0;
129129
// By the intermediate value theorem We cannot find 2 consecutive maximum or minimum
130-
for (let i = 1; i < Y.length - 1; ++i) {
130+
for (let i = 1; i < yData.length - 1; ++i) {
131131
// filter based on derivativeThreshold
132132
// console.log('pasa', y[i], dY[i], ddY[i]);
133133
if (Math.abs(dY[i]) > derivativeThreshold) {
@@ -137,10 +137,10 @@ export function gsd(x, yIn, options = {}) {
137137
(dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])
138138
) {
139139
lastMin = {
140-
x: X[i],
140+
x: xData[i],
141141
index: i,
142142
};
143-
if (dx > 0 && lastMax !== null) {
143+
if (dX > 0 && lastMax !== null) {
144144
intervalL[intervalLLen++] = lastMax;
145145
intervalR[intervalRLen++] = lastMin;
146146
}
@@ -152,10 +152,10 @@ export function gsd(x, yIn, options = {}) {
152152
(dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])
153153
) {
154154
lastMax = {
155-
x: X[i],
155+
x: xData[i],
156156
index: i,
157157
};
158-
if (dx < 0 && lastMin !== null) {
158+
if (dX < 0 && lastMin !== null) {
159159
intervalL[intervalLLen++] = lastMax;
160160
intervalR[intervalRLen++] = lastMin;
161161
}
@@ -165,7 +165,7 @@ export function gsd(x, yIn, options = {}) {
165165
// Minimum in second derivative
166166
if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {
167167
// TODO should we change this to have 3 arrays ? Huge overhead creating arrays
168-
minddY[minddYLen++] = i; // ( [X[i], Y[i], i] );
168+
minddY[minddYLen++] = i; // ( [xData[i], yData[i], i] );
169169
broadMask[broadMaskLen++] = Math.abs(ddY[i]) <= broadRatio * maxDdy;
170170
}
171171
}
@@ -179,7 +179,7 @@ export function gsd(x, yIn, options = {}) {
179179
let lastK = -1;
180180
let possible, frequency, distanceJ, minDistance, gettingCloser;
181181
for (let j = 0; j < minddY.length; ++j) {
182-
frequency = X[minddY[j]];
182+
frequency = xData[minddY[j]];
183183
possible = -1;
184184
let k = lastK + 1;
185185
minDistance = Number.MAX_VALUE;
@@ -202,11 +202,11 @@ export function gsd(x, yIn, options = {}) {
202202
}
203203

204204
if (possible !== -1) {
205-
if (Math.abs(Y[minddY[j]]) > minMaxRatio * maxY) {
205+
if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {
206206
signals[signalsLen++] = {
207207
index: minddY[j],
208208
x: frequency,
209-
y: (Y[minddY[j]] + yCorrection.b) / yCorrection.m,
209+
y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m,
210210
width: Math.abs(intervalR[possible].x - intervalL[possible].x), // widthCorrection
211211
soft: broadMask[j],
212212
};
@@ -215,8 +215,8 @@ export function gsd(x, yIn, options = {}) {
215215
signals[signalsLen - 1].right = intervalR[possible];
216216

217217
if (heightFactor) {
218-
let yLeft = Y[intervalL[possible].index];
219-
let yRight = Y[intervalR[possible].index];
218+
let yLeft = yData[intervalL[possible].index];
219+
let yRight = yData[intervalR[possible].index];
220220
signals[signalsLen - 1].height =
221221
heightFactor * (signals[signalsLen - 1].y - (yLeft + yRight) / 2);
222222
}
@@ -226,7 +226,7 @@ export function gsd(x, yIn, options = {}) {
226226
signals.length = signalsLen;
227227

228228
if (realTopDetection) {
229-
determineRealTop(signals, X, Y);
229+
determineRealTop(signals, xData, yData);
230230
}
231231

232232
// Correct the values to fit the original spectra data

0 commit comments

Comments
 (0)