changeset 9421:53e26734e4d2

Fixed NaN handling in salix historical scenarion calculation, added problem report
author mschaefer
date Fri, 17 Aug 2018 11:13:31 +0200
parents 2c8ba17b807e
children a299f32e4a71
files artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 4 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Fri Aug 17 09:41:40 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Fri Aug 17 11:13:31 2018 +0200
@@ -166,7 +166,16 @@
         rangeScenarios.put(Double.valueOf(calcRange.getLowerKm() - 0.0001), nulls);
         for (final Double station : stations) {
             rangeScenarios.put(station, new ArrayList<Double>());
-            rangeScenarios.get(station).add(Double.valueOf(bedHeightDifference(station.doubleValue(), currentFinders, historicalFinder)));
+            final double delta = bedHeightDifference(station, currentFinders, historicalFinder);
+            if (Double.isNaN(delta)) {
+                rangeScenarios.get(station).add(null);
+                if (!this.problems.hasProblems()) {
+                    final String msg = Resources.getMsg(this.context.getMeta(), "uinfo_salix_calc.warning.missing_bedheights");
+                    this.problems.addProblem(station, msg);
+                }
+            }
+            else
+                rangeScenarios.get(station).add(Double.valueOf(delta));
         }
         rangeScenarios.put(Double.valueOf(partTo + 0.0001), nulls);
     }
@@ -181,7 +190,12 @@
             if (!Double.isNaN(currentMSH))
                 break;
         }
-        return Formatter.roundFlowDepth(historicalFinder.getMeanBedHeight(station)).subtract(Formatter.roundFlowDepth(currentMSH)).doubleValue();
+        if (Double.isNaN(currentMSH))
+            return Double.NaN;
+        final double historicalMSH = historicalFinder.getMeanBedHeight(station);
+        if (Double.isNaN(historicalMSH))
+            return Double.NaN;
+        return Formatter.roundFlowDepth(historicalMSH).subtract(Formatter.roundFlowDepth(currentMSH)).doubleValue();
     }
 
     /**
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Fri Aug 17 09:41:40 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Fri Aug 17 11:13:31 2018 +0200
@@ -387,7 +387,7 @@
 
     /**
      * Decimal half even rounding of a flow depth value
-     * (throws an exception for NaN or Infinity)
+     * (ATTENTION: throws an exception for NaN or Infinity!)
      */
     public static BigDecimal roundFlowDepth(final double value) {
         return BigDecimal.valueOf(value).setScale(FLOWDEPTH_MAX_DIGITS, RoundingMode.HALF_EVEN);
@@ -399,7 +399,7 @@
 
     /**
      * Decimal half even rounding of a W value
-     * (throws an exception for NaN or Infinity)
+     * (ATTENTION: throws an exception for NaN or Infinity!)
      */
     public static BigDecimal roundW(final double value) {
         return BigDecimal.valueOf(value).setScale(WATERLEVEL_W_MAX_DIGITS, RoundingMode.HALF_EVEN);
--- a/artifacts/src/main/resources/messages.properties	Fri Aug 17 09:41:40 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Fri Aug 17 11:13:31 2018 +0200
@@ -1183,7 +1183,8 @@
 uinfo_facet_salix_rank.description = Bewertungsschema
 uinfo_salix_calc.warning.missing_mq = MQ (MW) missing at reference gauge, no calculation possible
 uinfo_salix_calc.warning.missing_mhq = MHQ (MHW) missing at reference gauge, no salix calculation possible 
-uinfo_salix_calc.warning.missing_mnq = MNQ (MNW) missing at reference gauge, no (MW-MNW) calculation possible 
+uinfo_salix_calc.warning.missing_mnq = MNQ (MNW) missing at reference gauge, no (MW-MNW) calculation possible
+uinfo_salix_calc.warning.missing_bedheights = missing bed height values in the scenario range 
 
 predefineddepthevol.total.title = Gesamt: {0}
 predefineddepthevol.peryear.title = J\u00e4hrlich: {0}
--- a/artifacts/src/main/resources/messages_de.properties	Fri Aug 17 09:41:40 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Fri Aug 17 11:13:31 2018 +0200
@@ -1184,6 +1184,7 @@
 uinfo_salix_calc.warning.missing_mq = MQ (MW) fehlt am Bezugspegel, Berechnung nicht m\u00f6glich
 uinfo_salix_calc.warning.missing_mhq = MHQ (MHW) fehlt am Bezugspegel, Berechnung des Iota nicht m\u00f6glich
 uinfo_salix_calc.warning.missing_mnq = MNQ (MNW) fehlt am Bezugspegel, Berechnung von (MW-MNW) nicht m\u00f6glich
+uinfo_salix_calc.warning.missing_bedheights = Im Teilabschnitt fehlen Sohlh\u00f6hen 
 
 predefineddepthevol.total.title = Gesamt: {0}
 predefineddepthevol.peryear.title = J\u00e4hrlich: {0}

http://dive4elements.wald.intevation.org