Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java @ 8911:37ff7f435912
SINFO Flowdepth: more error checks, d50 interpolation, avoid negative tkh
author | mschaefer |
---|---|
date | Fri, 23 Feb 2018 09:30:24 +0100 |
parents | 0a900d605d52 |
children | e3519c3e7a0a |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Thu Feb 22 18:46:37 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Fri Feb 23 09:30:24 2018 +0100 @@ -154,8 +154,14 @@ } BedQualityD50KmValueFinder bedMeasurementsFinder = null; - if (doCalcTkh) + if (doCalcTkh) { bedMeasurementsFinder = loadBedMeasurements(river, calcRange, sounding.getYear().intValue()); + if (bedMeasurementsFinder == null) { + final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingSoilKind", null, label); + problems.addProblem(message); + doCalcTkh = false; + } + } final String bedHeightLabel = bedHeight.getDescription(); final String wstLabel = wstKms.getName(); @@ -165,7 +171,13 @@ DoubleRange qRange = null; if (doCalcTkh) { qInterpolator = DoubleUtil.getLinearInterpolator(((QKms) wstKms).allKms(), ((QKms) wstKms).allQs()); - qRange = new DoubleRange( ((QKms) wstKms).allQs().min(), ((QKms) wstKms).allQs().max()); + if (qInterpolator != null) + qRange = new DoubleRange( ((QKms) wstKms).allQs().min(), ((QKms) wstKms).allQs().max()); + else { + final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingQ", null, label); + problems.addProblem(message); + doCalcTkh = false; + } } // FIXME: sort by station first, but in what direction? @@ -180,13 +192,21 @@ SoilKindKmValueFinder soilKindFinder = null; if (doCalcTkh) { soilKindFinder = new SoilKindKmValueFinder(); - soilKindFinder.loadValues(river, calcRange); + if (!soilKindFinder.loadValues(river, calcRange)) { + doCalcTkh = false; + final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingSoilKind", null, label); + problems.addProblem(message); + } } FlowVelocityModelKmValueFinder flowVelocitiesFinder = null; if (doCalcTkh) { flowVelocitiesFinder = new FlowVelocityModelKmValueFinder(); - flowVelocitiesFinder.loadValues(river, calcRange, qRange); + if (!flowVelocitiesFinder.loadValues(river, calcRange, qRange)) { + doCalcTkh = false; + final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingVelocity", null, label); + problems.addProblem(message); + } } for (final BedHeightValue bedHeightValue : sortedValues) { @@ -219,11 +239,13 @@ else discharge = Double.NaN; - // FIXME: calculate tkh + // Calculate tkh double tkh = 0; if (doCalcTkh) { - double d50 = bedMeasurementsFinder.findD50(km); - if (Double.isNaN(d50)) { + double d50 = Double.NaN; + try { + d50 = bedMeasurementsFinder.findD50(km); + } catch (Exception e) { final String message = Resources.getMsg(this.context.getMeta(), "sinfo_calc_flow_depth.warning.missingD50", null, label); problems.addProblem(km, message); //FIXME: cumulate problems to one message? @@ -231,6 +253,8 @@ if (!Double.isNaN(d50)) { if (flowVelocitiesFinder.findKmQValues(km, discharge)) { tkh = calculateTkh(wst - meanBedHeight, flowVelocitiesFinder.getFindVmainFound(), d50, flowVelocitiesFinder.getFindTauFound()); + if (!Double.isNaN(tkh) && (tkh < 0)) + tkh = 0; /* log.debug(String.format("calculateTkh km %.3f q %.0f w %.2f mbh %.2f vm %.1f tau %.1f d50(mm) %.1f tkh(cm) %.1f", km, discharge, wst, meanBedHeight, flowVelocitiesFinder.getFindVmainFound(), flowVelocitiesFinder.getFindTauFound(), d50*1000, tkh)); */ }