Mercurial > gemma
changeset 4357:e8af2ed8666e
refactor classification of Nash sutcliffe for better readability
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 09 Sep 2019 16:12:43 +0200 |
parents | 5356fd2ea3f6 |
children | a7196b55c064 |
files | client/src/lib/classifications.js |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/lib/classifications.js Mon Sep 09 15:54:48 2019 +0200 +++ b/client/src/lib/classifications.js Mon Sep 09 16:12:43 2019 +0200 @@ -12,6 +12,9 @@ * Raimund Renkert <raimund.renkert@intevation.de> * Markus Kottländer <markus.kottlaender@intevation.de> */ + +/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/ + import store from "@/store/index"; const getGauge = f => { @@ -32,18 +35,21 @@ }; const calcForecastVsRealityForNSC = nsc => { - if (nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0)) { + const hasSamples = + nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0); + if (hasSamples) { + const [nsc24h, _, nsc72h] = nsc.coeffs; // 24h < configured value if ( - nsc.coeffs[0].samples && - nsc.coeffs[0].value < + nsc24h.samples && + nsc24h.value < store.state.application.config.gm_forecast_vs_reality_nsc_24h ) return "DANGER"; // 72h < configured value if ( - nsc.coeffs[2].samples && - nsc.coeffs[2].value < + nsc72h.samples && + nsc72h.value < store.state.application.config.gm_forecast_vs_reality_nsc_72h ) return "WARNING";