Skip to content

Commit

Permalink
Various scorecard bug fixes (#1181)
Browse files Browse the repository at this point in the history
This PR fixes the following bugs (from the release notes):
* Fixed bug where upper air scorecards would never come up.
* Fixed bug where scorecard colors ignored user selection.
* Fixed bug where scorecards would return no data for AMDAR retros.
* Fixed bug where scorecards would sometimes use the wrong database and
level when
    switching to a specific timeseries.
* Fixed bug where scorecards would sometimes display too many regions or
forecast
    lead times.
  • Loading branch information
JeffHamiltonNOAA committed Apr 23, 2024
2 parents dadf12e + 4036a08 commit 9030d67
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 47 deletions.
2 changes: 1 addition & 1 deletion METexpress
Submodule METexpress updated 1 files
+1 −1 MATScommon
36 changes: 7 additions & 29 deletions apps/scorecard/server/dataFunctions/processScorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ const dealWithUATables = function (
// get obs partial sums from the GFS
secondaryModelOption = `, ${databaseValue}.GFS_Areg${regionValue} as m1`;
}
// RAOB tables don't have phases, but we use the clause to facilitate the table join
// facilitate the table join
updatedQueryTemplate = updatedQueryTemplate.replace(
/\{\{phaseClause\}\}/g,
/\{\{joinClause\}\}/g,
"AND m0.date = m1.date AND m0.hour = m1.hour AND m0.mb10 = m1.mb10"
);
} else {
// AMDAR tables have all partial sums so we can get them all from the main table
updatedQueryTemplate = updatedQueryTemplate.replace(/m1/g, "m0");
// AMDAR tables have phases
updatedQueryTemplate = updatedQueryTemplate.replace(
/\{\{phaseClause\}\}/g,
"AND m0.up_dn = 2"
);
// no need to join
updatedQueryTemplate = updatedQueryTemplate.replace(/\{\{joinClause\}\}/g, "");
}
// either add the m1 clause to the template or remove the secondary model option entirely
updatedQueryTemplate = updatedQueryTemplate.replace(
Expand Down Expand Up @@ -179,28 +176,6 @@ processScorecard = function (plotParams, plotFunction) {
dateRange = plotParams.dates;
}

// get the union of the fcst-length arrays of all the curves
const fcstLengthsSet = new Set();
plotParams.curves.forEach(function (curve) {
if (!curve["forecast-length"]) {
fcstLengthsSet.add("0");
} else {
curve["forecast-length"].forEach(function (fcl) {
fcstLengthsSet.add(fcl);
});
}
});
const fcstLengths = Array.from(fcstLengthsSet);

// get the union of all the regions of all the curves
const regionsSet = new Set();
plotParams.curves.forEach(function (curve) {
curve.region.forEach(function (r) {
regionsSet.add(r);
});
});
const regions = Array.from(regionsSet);

// create an id for the document
let idDateRange = dateRange.replace(/ /g, "_");
idDateRange = idDateRange.replace(/:/g, "_");
Expand Down Expand Up @@ -386,6 +361,9 @@ processScorecard = function (plotParams, plotFunction) {

// create the empty object for this block
const { label } = curve;
const fcstLengths =
curve["forecast-length"] === undefined ? [] : curve["forecast-length"];
const regions = curve.region === undefined ? [] : curve.region;

// duplicate the curve so we're not modifying a function parameter, which the linter doesn't like
const scorecardCurve = curve;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ SELECT unix_timestamp(m0.date)+3600*m0.hour AS avtime,
AND m0.hour IN({{validTimes}})
AND m0.fcst_len = {{forecastLength}}
AND m0.mb10*10 = {{level}}
{{phaseClause}}
{{joinClause}}
GROUP BY avtime
ORDER BY avtime;
6 changes: 3 additions & 3 deletions apps/scorecard/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ const doPlotParams = function () {
type: matsTypes.InputTypes.radioGroup,
options: ["RedGreen", "RedBlue"],
controlButtonCovered: false,
default: "RedGreen",
default: "RedBlue",
controlButtonVisibility: "block",
displayOrder: 1,
displayPriority: 1,
Expand Down Expand Up @@ -574,7 +574,7 @@ const doPlotParams = function () {
controlButtonCovered: true,
controlButtonText: " ",
controlButtonFA: "fa-sm fa-solid fa-caret-up",
default: "#00ff00",
default: "#0000ff",
controlButtonVisibility: "block",
displayOrder: 4,
displayPriority: 1,
Expand All @@ -599,7 +599,7 @@ const doPlotParams = function () {
controlButtonCovered: true,
controlButtonText: " ",
controlButtonFA: "fa-xl fa-solid fa-caret-up",
default: "#00ff00",
default: "#0000ff",
controlButtonVisibility: "block",
displayOrder: 5,
displayPriority: 1,
Expand Down

0 comments on commit 9030d67

Please sign in to comment.