Skip to content

Commit

Permalink
Made METexpress regions more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Apr 16, 2024
1 parent 33233cb commit 8c6a990
Show file tree
Hide file tree
Showing 23 changed files with 151 additions and 26 deletions.
2 changes: 1 addition & 1 deletion MATScommon
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_contour.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ dataContour = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_dieoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataDieoff = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ dataHistogram = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ dataProfile = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ dataSeries = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataSimpleScatter = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-anomalycor/server/dataFunctions/data_validtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataValidTime = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
14 changes: 12 additions & 2 deletions apps/met-anomalycor/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ const doCurveParams = function () {
throw new Error(err.message);
}

const regionValuesMap = matsDataUtils.readableStandardRegions();
const regionValueKeys = Object.keys(regionValuesMap);

try {
for (let k = 0; k < myDBs.length; k += 1) {
thisDB = myDBs[k];
Expand Down Expand Up @@ -464,6 +467,12 @@ const doCurveParams = function () {
.map(Function.prototype.call, String.prototype.trim);
for (let j = 0; j < regionsArr.length; j += 1) {
regionsArr[j] = regionsArr[j].replace(/'|\[|\]/g, "");
if (regionValueKeys.indexOf(regionsArr[j]) !== -1) {
regionsArr[j] = regionValuesMap[regionsArr[j]];
} else {
regionValuesMap[regionsArr[j]] = regionsArr[j];
regionValueKeys.push(regionsArr[j]);
}
}

const sources = rows[i].truths;
Expand Down Expand Up @@ -924,8 +933,8 @@ const doCurveParams = function () {
)[0]
];
let regionDefault;
if (regionOptions.indexOf("FULL") !== -1) {
regionDefault = "FULL";
if (regionOptions.indexOf("FULL: Full Domain") !== -1) {
regionDefault = "FULL: Full Domain";
} else if (regionOptions.indexOf("G002") !== -1) {
regionDefault = "G002";
} else {
Expand All @@ -938,6 +947,7 @@ const doCurveParams = function () {
type: matsTypes.InputTypes.select,
optionsMap: regionModelOptionsMap,
options: regionOptions,
valuesMap: regionValuesMap,
superiorNames: ["database", "data-source", "plot-type", "statistic", "variable"],
controlButtonCovered: true,
unique: false,
Expand Down
7 changes: 6 additions & 1 deletion apps/met-surface/server/dataFunctions/data_contour.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ dataContour = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-surface/server/dataFunctions/data_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ dataHistogram = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-surface/server/dataFunctions/data_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ dataSeries = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-surface/server/dataFunctions/data_simple_scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataSimpleScatter = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-surface/server/dataFunctions/data_validtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ dataValidTime = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
14 changes: 12 additions & 2 deletions apps/met-surface/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ const doCurveParams = function () {
throw new Error(err.message);
}

const regionValuesMap = matsDataUtils.readableStandardRegions();
const regionValueKeys = Object.keys(regionValuesMap);

try {
for (let k = 0; k < myDBs.length; k += 1) {
thisDB = myDBs[k];
Expand Down Expand Up @@ -490,6 +493,12 @@ const doCurveParams = function () {
.map(Function.prototype.call, String.prototype.trim);
for (let j = 0; j < regionsArr.length; j += 1) {
regionsArr[j] = regionsArr[j].replace(/'|\[|\]/g, "");
if (regionValueKeys.indexOf(regionsArr[j]) !== -1) {
regionsArr[j] = regionValuesMap[regionsArr[j]];
} else {
regionValuesMap[regionsArr[j]] = regionsArr[j];
regionValueKeys.push(regionsArr[j]);
}
}

const sources = rows[i].truths;
Expand Down Expand Up @@ -950,8 +959,8 @@ const doCurveParams = function () {
)[0]
];
let regionDefault;
if (regionOptions.indexOf("FULL") !== -1) {
regionDefault = "FULL";
if (regionOptions.indexOf("FULL: Full Domain") !== -1) {
regionDefault = "FULL: Full Domain";
} else if (regionOptions.indexOf("G002") !== -1) {
regionDefault = "G002";
} else if (regionOptions.indexOf("CONUS") !== -1) {
Expand All @@ -966,6 +975,7 @@ const doCurveParams = function () {
type: matsTypes.InputTypes.select,
optionsMap: regionModelOptionsMap,
options: regionOptions,
valuesMap: regionValuesMap,
superiorNames: ["database", "data-source", "plot-type", "statistic", "variable"],
controlButtonCovered: true,
unique: false,
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_contour.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ dataContour = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_dieoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ dataDieoff = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ dataHistogram = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataProfile = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ dataSeries = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ dataSimpleScatter = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
7 changes: 6 additions & 1 deletion apps/met-upperair/server/dataFunctions/data_validtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ dataValidTime = function (plotParams, plotFunction) {
if (regions.length > 0) {
regions = regions
.map(function (r) {
return `'${r}'`;
return `'${Object.keys(
matsCollections.region.findOne({ name: "region" }).valuesMap
).find(
(key) =>
matsCollections.region.findOne({ name: "region" }).valuesMap[key] === r
)}'`;
})
.join(",");
regionsClause = `and h.vx_mask IN(${regions})`;
Expand Down
14 changes: 12 additions & 2 deletions apps/met-upperair/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ const doCurveParams = function () {
throw new Error(err.message);
}

const regionValuesMap = matsDataUtils.readableStandardRegions();
const regionValueKeys = Object.keys(regionValuesMap);

try {
for (let k = 0; k < myDBs.length; k += 1) {
thisDB = myDBs[k];
Expand Down Expand Up @@ -492,6 +495,12 @@ const doCurveParams = function () {
.map(Function.prototype.call, String.prototype.trim);
for (let j = 0; j < regionsArr.length; j += 1) {
regionsArr[j] = regionsArr[j].replace(/'|\[|\]/g, "");
if (regionValueKeys.indexOf(regionsArr[j]) !== -1) {
regionsArr[j] = regionValuesMap[regionsArr[j]];
} else {
regionValuesMap[regionsArr[j]] = regionsArr[j];
regionValueKeys.push(regionsArr[j]);
}
}

const sources = rows[i].truths;
Expand Down Expand Up @@ -952,8 +961,8 @@ const doCurveParams = function () {
)[0]
];
let regionDefault;
if (regionOptions.indexOf("FULL") !== -1) {
regionDefault = "FULL";
if (regionOptions.indexOf("FULL: Full Domain") !== -1) {
regionDefault = "FULL: Full Domain";
} else if (regionOptions.indexOf("G002") !== -1) {
regionDefault = "G002";
} else if (regionOptions.indexOf("CONUS") !== -1) {
Expand All @@ -968,6 +977,7 @@ const doCurveParams = function () {
type: matsTypes.InputTypes.select,
optionsMap: regionModelOptionsMap,
options: regionOptions,
valuesMap: regionValuesMap,
superiorNames: ["database", "data-source", "plot-type", "statistic", "variable"],
controlButtonCovered: true,
unique: false,
Expand Down

0 comments on commit 8c6a990

Please sign in to comment.