Skip to content

Commit

Permalink
Merge branch 'development' into cb_ceiling_middle_tier_DieOff
Browse files Browse the repository at this point in the history
  • Loading branch information
gopa-noaa committed Aug 7, 2023
2 parents 5214f31 + ac827b0 commit 41d8a23
Show file tree
Hide file tree
Showing 16 changed files with 673 additions and 352 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,10 @@ const _getFlattenedResultData = function (rk, p, np) {
// for each curve
// if the curve label is a reserved word do not process the curve (its a zero or max curve)
var reservedWords = Object.values(matsTypes.ReservedWords);
if (reservedWords.indexOf(data[ci].label) >= 0) {
if (
reservedWords.indexOf(data[ci].label) >= 0 ||
data[ci].label.includes(matsTypes.ReservedWords.noSkill)
) {
continue; // don't process the zero or max curves
}
var stats = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const ReservedWords = {
perfectReliability: "Perfect Reliability",
perfectForecast: "Perfect Forecast",
noSkill: "No Skill",
noSkillNoLabel: "No Skill No Label",
constantBias: "Constant Bias",
constantCSI: "Constant CSI",
centerLine: "X=Y",
Expand Down
77 changes: 72 additions & 5 deletions meteor_packages/mats-common/imports/startup/client/select_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,24 @@ const refresh = function (event, paramName) {
elem.selectedIndex = 0;
}
}
const selectedText =
elem.selectedIndex >= 0
? elem.options[elem.selectedIndex].text
: matsTypes.InputTypes.unused;
let selectedText;
if (param.multiple) {
selectedText =
elem.selectedIndex >= 0
? $(elem.selectedOptions)
.map(function () {
return this.value;
})
.get()
: matsTypes.InputTypes.unused;
if (selectedText.includes(",")) selectedText = selectedText.split(",");
} else {
selectedText =
elem.selectedIndex >= 0
? elem.options[elem.selectedIndex].text
: matsTypes.InputTypes.unused;
}

const brothers = [];
for (var i = 0; i < elems.length; i++) {
if (elems[i].id.indexOf(name) >= 0 && elems[i].id !== elem.id)
Expand Down Expand Up @@ -547,11 +561,47 @@ const refresh = function (event, paramName) {
$(`select[name="${name}"]`).empty().append(optionsAsString);
// reset the selected index if it had been set prior (the list may have changed so the index may have changed)
let selectedOptionIndex;
let selectedOptionOverlap = [];
if (selectedText === "initial") {
selectedOptionIndex = myOptions.indexOf(param.default);
if (param.multiple && param.default instanceof Array) {
selectedOptionOverlap = _.intersection(param.default, myOptions);
selectedOptionIndex = selectedOptionOverlap.length > 0 ? 0 : -1;
} else {
selectedOptionIndex = myOptions.indexOf(param.default);
}
} else if (name === "plot-type") {
// the met apps have a hidden plot-type selector that needs to match the current selected plot type
selectedOptionIndex = myOptions.indexOf(matsPlotUtils.getPlotType());
} else if (param.multiple) {
if (param.name === "probability-bins") {
// the prob bins behave differently with different kernels, so unfortuately we have to have translation code here
if (
_.intersection(selectedText, [
"20",
"30",
"40",
"50",
"60",
"70",
"80",
"90",
]).length > 0 &&
_.intersection(myOptions, ["2", "3", "4", "5", "6", "7", "8", "9"]).length >
0
) {
selectedText = selectedText.map((x) => String(Number(x) / 10));
}
if (
_.intersection(selectedText, ["2", "3", "4", "5", "6", "7", "8", "9"])
.length > 0 &&
_.intersection(myOptions, ["20", "30", "40", "50", "60", "70", "80", "90"])
.length > 0
) {
selectedText = selectedText.map((x) => String(Number(x) * 10));
}
}
selectedOptionOverlap = _.intersection(selectedText, myOptions);
selectedOptionIndex = selectedOptionOverlap.length > 0 ? 0 : -1;
} else {
selectedOptionIndex = myOptions.indexOf(selectedText);
}
Expand Down Expand Up @@ -600,6 +650,23 @@ const refresh = function (event, paramName) {
elem.options[elem.selectedIndex].text
);
}
} else if (param.multiple && selectedOptionOverlap.length > 0) {
// need to manually select all the desired options
for (let idx = 0; idx < elem.options.length; idx += 1) {
elem.options[idx].selected = "";
}
for (
let overlapIdx = 0;
overlapIdx < selectedOptionOverlap.length;
overlapIdx += 1
) {
for (let idx = 0; idx < elem.options.length; idx += 1) {
if (elem.options[idx].value === selectedOptionOverlap[overlapIdx]) {
elem.options[idx].selected = "selected";
}
}
}
matsParamUtils.setValueTextForParamName(name, selectedOptionOverlap);
} else {
elem.selectedIndex = selectedOptionIndex;
elem &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import { matsPlotUtils, matsCollections, matsTypes } from "meteor/randyp:mats-common";

// adds a horizontal black line along a specific y value
const getHorizontalValueLine = function (xmax, xmin, yValue, textPos, cLabel) {
const getHorizontalValueLine = function (
xmax,
xmin,
yValue,
textPos,
cLabel,
color,
weight
) {
const textLabel = yValue % 1 === 0 ? yValue.toString() : yValue.toFixed(2);

return {
Expand Down Expand Up @@ -34,19 +42,28 @@ const getHorizontalValueLine = function (xmax, xmin, yValue, textPos, cLabel) {
ymax: yValue,
line: {
dash: "solid",
color: "rgb(0,0,0)",
width: 1,
color,
width: weight,
},
marker: {
symbol: "circle",
},
showlegend: false,
hoverinfo: "none",
visible: true,
};
};

// adds a vertical black line along a specific x value
const getVerticalValueLine = function (ymax, ymin, xValue, textPos, cLabel) {
const getVerticalValueLine = function (
ymax,
ymin,
xValue,
textPos,
cLabel,
color,
weight
) {
const textLabel = xValue % 1 === 0 ? xValue.toString() : xValue.toFixed(2);

return {
Expand Down Expand Up @@ -74,14 +91,15 @@ const getVerticalValueLine = function (ymax, ymin, xValue, textPos, cLabel) {
ymax,
line: {
dash: "solid",
color: "rgb(0,0,0)",
width: 1,
color,
width: weight,
},
marker: {
symbol: "circle",
},
showlegend: false,
hoverinfo: "none",
visible: true,
};
};

Expand All @@ -93,7 +111,9 @@ const getLinearValueLine = function (
ymin,
textLabel,
textPos,
cLabel
cLabel,
color,
weight
) {
return {
label: cLabel,
Expand All @@ -106,7 +126,11 @@ const getLinearValueLine = function (
y: [ymin, (ymin + ymax) / 2, ymax],
error_x: [null, null, null],
error_y: [null, null, null],
text: ["", textLabel, ""],
text: [
"",
textLabel.includes(matsTypes.ReservedWords.noSkillNoLabel) ? "" : textLabel,
"",
],
textposition: textPos,
subVals: [],
subSecs: [],
Expand All @@ -122,14 +146,15 @@ const getLinearValueLine = function (
ymax,
line: {
dash: "solid",
color: "rgb(0,0,0)",
width: 1,
color,
width: weight,
},
marker: {
symbol: "circle",
},
showlegend: false,
hoverinfo: "none",
visible: true,
};
};

Expand All @@ -141,7 +166,9 @@ const getDashedLinearValueLine = function (
ymin,
textLabel,
textPos,
cLabel
cLabel,
color,
weight
) {
return {
label: cLabel,
Expand Down Expand Up @@ -169,19 +196,29 @@ const getDashedLinearValueLine = function (
ymax,
line: {
dash: "dot",
color: "rgb(0,0,0)",
width: 1,
color,
width: weight,
},
marker: {
symbol: "circle",
},
showlegend: false,
hoverinfo: "none",
visible: true,
};
};

// adds a linear line
const getCurveLine = function (xvals, yvals, textVals, textLabel, textPos, cLabel) {
const getCurveLine = function (
xvals,
yvals,
textVals,
textLabel,
textPos,
cLabel,
color,
weight
) {
return {
label: cLabel,
curveId: cLabel,
Expand All @@ -207,14 +244,15 @@ const getCurveLine = function (xvals, yvals, textVals, textLabel, textPos, cLabe
ymax: Math.max(yvals),
line: {
dash: "solid",
color: "rgb(0,0,0)",
width: 1,
color,
width: weight,
},
marker: {
symbol: "circle",
},
showlegend: false,
hoverinfo: "none",
visible: true,
};
};

Expand Down
Loading

0 comments on commit 41d8a23

Please sign in to comment.