diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java @ 8940:82998242ba84

Preparing for additional outputs of SINFO-Tkh
author gernotbelger
date Tue, 06 Mar 2018 18:51:18 +0100
parents 9c02733a1b3c
children 5d5d482da3e9
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java	Tue Mar 06 17:14:56 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java	Tue Mar 06 18:51:18 2018 +0100
@@ -140,6 +140,8 @@
 
         final double meanBedHeight = this.bedHeightsProvider.getMeanBedHeight(km);
 
+        final double flowDepth = wst - meanBedHeight;
+
         final double discharge = getDischarge(km);
         if (Double.isNaN(discharge)) {
 
@@ -150,22 +152,25 @@
             // TODO: nochmal gemeinsam überlegen welche probleme wir loggen, an dieser stelle müsste man ggf. die station
             // mitausgeben
 
-            return new Tkh(km, wst, meanBedHeight, Double.NaN, kind, Double.NaN, Double.NaN, Double.NaN);
+            return new Tkh(km, wst, meanBedHeight, flowDepth, Double.NaN, kind);
         }
 
         final double d50 = getBedMeasurement(km);
         if (Double.isNaN(d50))
-            return new Tkh(km, wst, meanBedHeight, discharge, kind, Double.NaN, Double.NaN, Double.NaN);
+            return new Tkh(km, wst, meanBedHeight, flowDepth, discharge, kind);
 
         if (!this.flowVelocitiesFinder.findKmQValues(km, discharge)) {
             // TODO: ggf. station in Fehlermeldung?
             final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingVelocity", null, this.problemLabel);
             this.problems.addProblem(km, message);
             // FIXME: cumulate problems to one message?
-            return new Tkh(km, wst, meanBedHeight, discharge, kind, Double.NaN, Double.NaN, Double.NaN);
+            return new Tkh(km, wst, meanBedHeight, flowDepth, discharge, kind);
         }
 
-        final double tkh = calculateTkh(wst - meanBedHeight, this.flowVelocitiesFinder.getFindVmainFound(), d50, this.flowVelocitiesFinder.getFindTauFound());
+        final double velocity = this.flowVelocitiesFinder.getFindVmainFound();
+        final double tau = this.flowVelocitiesFinder.getFindTauFound();
+
+        final double tkh = calculateTkh(wst - meanBedHeight, velocity, d50, tau);
         double tkhUp;
         double tkhDown;
         switch (kind) {
@@ -181,7 +186,9 @@
             break;
         }
 
-        return new Tkh(km, wst, meanBedHeight, discharge, kind, tkh, tkhUp, tkhDown);
+        final double flowDepthTkh = calculateFlowDepthTkh(tkhUp, kind, wst, meanBedHeight);
+
+        return new Tkh(km, wst, meanBedHeight, flowDepth, flowDepthTkh, discharge, kind, tkh, tkhUp, tkhDown, velocity, d50, tau);
     }
 
     /**
@@ -217,4 +224,19 @@
 
         return tkh;
     }
+
+    private double calculateFlowDepthTkh(final double tkhValue, final SoilKind tkhKind, final double wst, final double meanBedHeight) {
+
+        if (Double.isNaN(tkhValue) || tkhKind == null)
+            return Double.NaN;
+
+        switch (tkhKind) {
+        case starr:
+            return wst - (meanBedHeight + tkhValue / 100);
+
+        case mobil:
+        default:
+            return wst - (meanBedHeight + tkhValue / 200);
+        }
+    }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org