comparison client/src/lib/classifications.js @ 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 767a6500a666
children a66275cf4490
comparison
equal deleted inserted replaced
4356:5356fd2ea3f6 4357:e8af2ed8666e
10 * 10 *
11 * Author(s): 11 * Author(s):
12 * Raimund Renkert <raimund.renkert@intevation.de> 12 * Raimund Renkert <raimund.renkert@intevation.de>
13 * Markus Kottländer <markus.kottlaender@intevation.de> 13 * Markus Kottländer <markus.kottlaender@intevation.de>
14 */ 14 */
15
16 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/
17
15 import store from "@/store/index"; 18 import store from "@/store/index";
16 19
17 const getGauge = f => { 20 const getGauge = f => {
18 if (f.getId().indexOf("bottlenecks") > -1) { 21 if (f.getId().indexOf("bottlenecks") > -1) {
19 const GaugeProxy = (function(feature) { 22 const GaugeProxy = (function(feature) {
30 } 33 }
31 return f; 34 return f;
32 }; 35 };
33 36
34 const calcForecastVsRealityForNSC = nsc => { 37 const calcForecastVsRealityForNSC = nsc => {
35 if (nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0)) { 38 const hasSamples =
39 nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0);
40 if (hasSamples) {
41 const [nsc24h, _, nsc72h] = nsc.coeffs;
36 // 24h < configured value 42 // 24h < configured value
37 if ( 43 if (
38 nsc.coeffs[0].samples && 44 nsc24h.samples &&
39 nsc.coeffs[0].value < 45 nsc24h.value <
40 store.state.application.config.gm_forecast_vs_reality_nsc_24h 46 store.state.application.config.gm_forecast_vs_reality_nsc_24h
41 ) 47 )
42 return "DANGER"; 48 return "DANGER";
43 // 72h < configured value 49 // 72h < configured value
44 if ( 50 if (
45 nsc.coeffs[2].samples && 51 nsc72h.samples &&
46 nsc.coeffs[2].value < 52 nsc72h.value <
47 store.state.application.config.gm_forecast_vs_reality_nsc_72h 53 store.state.application.config.gm_forecast_vs_reality_nsc_72h
48 ) 54 )
49 return "WARNING"; 55 return "WARNING";
50 // both > configured value 56 // both > configured value
51 return "OK"; 57 return "OK";