Mercurial > dive4elements > river
changeset 8978:b5600453bb8f
SINFO Calculations: do not produce result rows if some input data has missing values.
Also check for years of waterlevels in flow depth development calculation.
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Thu Apr 05 11:57:54 2018 +0200 @@ -77,8 +77,7 @@ final String location = this.riverInfoProvider.getLocation(station); row.putValue(SInfoResultType.location, location); - this.tkhCalculator.calculateTkh(station, row); - - this.rows.add(row); + if (this.tkhCalculator.calculateTkh(station, row)) + this.rows.add(row); } } \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java Thu Apr 05 11:57:54 2018 +0200 @@ -97,18 +97,26 @@ return null; // FIXME: check current/hist wst have same discharge... + // FIXME: what means 'same discharge' final BedHeightInfo currentSoundingInfo = currentSounding.getInfo(); final BedHeightInfo historicalSoundingInfo = historicalSounding.getInfo(); - // final String label = createLabel(waterlevel, minBedHeight, maxBedHeight); - - // final WKms wstKms = waterlevel.getWkms(); final int currentWstYear = currentWaterlevel.getYear(); final int historicalWstYear = historicalWaterlevel.getYear(); final int currentSoundingYear = currentSoundingInfo.getYear(); final int historicalSoundingYear = historicalSoundingInfo.getYear(); + if (currentWstYear < 0) { + problems.addProblem("flowdepthdevelopmentcalculation.missingCurrentYear", currentWaterlevel.getName()); + return null; + } + + if (historicalWstYear < 0) { + problems.addProblem("flowdepthdevelopmentcalculation.missingHistoricalYear", historicalWaterlevel.getName()); + return null; + } + // FIXME: distinguish error messages FlowDepthUtils.checkYearDifference("", currentWstYear, currentSoundingYear, problems); FlowDepthUtils.checkYearDifference("", historicalWstYear, historicalSoundingYear, problems); @@ -144,6 +152,10 @@ final double historicalWst = historicalWstProvider.getWaterlevel(station); final double historicalBedHeight = historicalSounding.getMeanBedHeight(station); + /* ignore invalid lines */ + if (Double.isNaN(currentWst) || Double.isNaN(currentBedHeight) || Double.isNaN(historicalWst) || Double.isNaN(historicalBedHeight)) + continue; + final double diffWst = (currentWst - historicalWst) * 100; final double diffBedHeight = (currentBedHeight - historicalBedHeight) * 100;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Thu Apr 05 11:57:54 2018 +0200 @@ -149,6 +149,10 @@ // REMARK: access the gauge once only during calculation final String gaugeLabel = riverInfoProvider.findGauge(station); + /* ignore invalid lines */ + if (Double.isNaN(wst) || Double.isNaN(minBedHeightValue) || Double.isNaN(maxBedHeightValue)) + continue; + final SInfoResultRow row = SInfoResultRow.create().// putValue(SInfoResultType.station, station). // putValue(SInfoResultType.flowdepthmin, minFlowDepth). //
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java Thu Apr 05 11:57:54 2018 +0200 @@ -108,7 +108,7 @@ return this.bedMeasurementsFinder.findD50(km); } - public void calculateTkh(final double km, final SInfoResultRow row) { + public boolean calculateTkh(final double km, final SInfoResultRow row) { row.putValue(SInfoResultType.station, km); @@ -117,37 +117,53 @@ final double wst = this.waterlevelProvider.getWaterlevel(km); row.putValue(SInfoResultType.waterlevel, wst); + if (Double.isNaN(wst)) + return false; final double meanBedHeight = this.bedHeightsProvider.getMeanBedHeight(km); row.putValue(SInfoResultType.meanBedHeight, meanBedHeight); + if (Double.isNaN(meanBedHeight)) + return false; final double flowDepth = wst - meanBedHeight; row.putValue(SInfoResultType.flowdepth, flowDepth); + if (Double.isNaN(flowDepth)) + return false; final double discharge = this.dischargeProvider.getDischarge(km); row.putValue(SInfoResultType.discharge, discharge); - if (Double.isNaN(discharge)) - return; if (!this.hasTkh()) - return; + return true; + + // Missing discharge or kind is only a problem if we want to calculate tkh + if (Double.isNaN(discharge)) + return false; + if (kind == null) + return false; final double d50 = getBedMeasurement(km); + row.putValue(SInfoResultType.d50, d50); if (Double.isNaN(d50)) - return; - row.putValue(SInfoResultType.d50, d50); + return false; if (!this.flowVelocitiesFinder.findKmQValues(km, discharge)) - return; + return false; final double velocity = this.flowVelocitiesFinder.getFindVmainFound(); row.putValue(SInfoResultType.velocity, velocity); + if (Double.isNaN(velocity)) + return false; final double tau = this.flowVelocitiesFinder.getFindTauFound(); row.putValue(SInfoResultType.tau, tau); + if (Double.isNaN(tau)) + return false; final double tkh = calculateTkh(wst - meanBedHeight, velocity, d50, tau); row.putValue(SInfoResultType.tkh, tkh); + if (Double.isNaN(tkh)) + return false; switch (kind) { case starr: @@ -164,6 +180,8 @@ final double flowDepthTkh = calculateFlowDepthTkh(tkh, kind, wst, meanBedHeight); row.putValue(SInfoResultType.flowdepthtkh, flowDepthTkh); + + return true; } /** @@ -202,9 +220,6 @@ 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);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Thu Apr 05 11:57:54 2018 +0200 @@ -169,9 +169,8 @@ row.putValue(SInfoResultType.gaugeLabel, riverInfoProvider.findGauge(station)); row.putValue(SInfoResultType.location, riverInfoProvider.getLocation(station)); - tkhCalculator.calculateTkh(station, row); - - rows.add(row); + if (tkhCalculator.calculateTkh(station, row)) + rows.add(row); } return new TkhCalculationResult(wstLabel, wstInfo, true, rows);
--- a/artifacts/src/main/resources/messages.properties Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/resources/messages.properties Thu Apr 05 11:57:54 2018 +0200 @@ -958,4 +958,7 @@ sinfo.export.csv.header.waterlevel.difference = \u0394WSPL sinfo.export.csv.header.mean_bed_height.difference = \u0394MSH sinfo.export.csv.header.flowdepth.current = Flie\u00dftiefe h-aktuell -sinfo.export.csv.header.flowdepth.historical = Flie\u00dftiefe h-historisch \ No newline at end of file +sinfo.export.csv.header.flowdepth.historical = Flie\u00dftiefe h-historisch + +flowdepthdevelopmentcalculation.missingCurrentYear = Failed to determine date of current watterlevel ({0}), calculation not possible. +flowdepthdevelopmentcalculation.missingHistoricalYear = Failed to determine date of historical watterlevel ({0}), calculation not possible. \ No newline at end of file
--- a/artifacts/src/main/resources/messages_de.properties Tue Apr 03 17:23:51 2018 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Thu Apr 05 11:57:54 2018 +0200 @@ -958,4 +958,7 @@ sinfo.export.csv.header.waterlevel.difference = \u0394WSPL sinfo.export.csv.header.mean_bed_height.difference = \u0394MSH sinfo.export.csv.header.flowdepth.current = Flie\u00dftiefe h-aktuell -sinfo.export.csv.header.flowdepth.historical = Flie\u00dftiefe h-historisch \ No newline at end of file +sinfo.export.csv.header.flowdepth.historical = Flie\u00dftiefe h-historisch + +flowdepthdevelopmentcalculation.missingCurrentYear = Datum des aktuellen Wasserspiegels ({0}) konnte nicht ermittelt werden, Berechnung nicht m\u00f6glich. +flowdepthdevelopmentcalculation.missingHistoricalYear = Datum des historischen Wasserspiegels ({0}) konnte nicht ermittelt werden, Berechnung nicht m\u00f6glich. \ No newline at end of file