Skip to content

Commit

Permalink
Validtime station plots fully work
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Nov 29, 2023
1 parent 2d2de62 commit 17f19df
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class MatsMiddleCommon {

let prevFve = null;
const sumVals = [0, 0, 0, 0];
for (let i = 0; i < ctc.sub_data.length; i++) {
for (let i = 0; i < ctc.sub_data.length; i += 1) {
const sdiToks = ctc.sub_data[i].split(";");

if (i === 0) {
prevFve = sdiToks[0];
[prevFve] = sdiToks;
}
if (prevFve === sdiToks[0]) {
sumVals[0] += Number(sdiToks[1]);
Expand All @@ -99,7 +99,7 @@ class MatsMiddleCommon {
rv.sub_data.push(
`${sdiToks[0]};${sumVals[0]};${sumVals[1]};${sumVals[2]};${sumVals[3]}`
);
prevFve = sdiToks[0];
[prevFve] = sdiToks;
sumVals[0] = Number(sdiToks[1]);
sumVals[1] = Number(sdiToks[2]);
sumVals[2] = Number(sdiToks[3]);
Expand All @@ -114,6 +114,47 @@ class MatsMiddleCommon {
return rv;
};

sumUpSums = (sum) => {
const rv = JSON.parse(JSON.stringify(sum));

rv.sub_data = [];

let prevFve = null;
const sumVals = [0, 0, 0, 0, 0, 0];
for (let i = 0; i < sum.sub_data.length; i += 1) {
const sdiToks = sum.sub_data[i].split(";");

if (i === 0) {
[prevFve] = sdiToks;
}
if (prevFve === sdiToks[0]) {
sumVals[0] += Number(sdiToks[1]);
sumVals[1] += Number(sdiToks[2]);
sumVals[2] += Number(sdiToks[3]);
sumVals[3] += Number(sdiToks[4]);
sumVals[4] += Number(sdiToks[5]);
sumVals[5] += Number(sdiToks[6]);
} else {
rv.sub_data.push(
`${sdiToks[0]};${sumVals[0]};${sumVals[1]};${sumVals[2]};${sumVals[3]};${sumVals[4]};${sumVals[5]}`
);
[prevFve] = sdiToks;
sumVals[0] = Number(sdiToks[1]);
sumVals[1] = Number(sdiToks[2]);
sumVals[2] = Number(sdiToks[3]);
sumVals[3] = Number(sdiToks[4]);
sumVals[4] = Number(sdiToks[5]);
sumVals[5] = Number(sdiToks[6]);
}
if (i === sum.sub_data.length - 1) {
rv.sub_data.push(
`${sdiToks[0]};${sumVals[0]};${sumVals[1]};${sumVals[2]};${sumVals[3]};${sumVals[4]};${sumVals[5]}`
);
}
}
return rv;
};

computeCtcForStations(
fve,
threshold,
Expand Down
Loading

0 comments on commit 17f19df

Please sign in to comment.