comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java @ 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.
author gernotbelger
date Thu, 05 Apr 2018 11:57:54 +0200
parents 45f1ad66560e
children b194fa64506a
comparison
equal deleted inserted replaced
8977:bf8a9df86f32 8978:b5600453bb8f
95 final BedHeightsFinder historicalSounding = loadBedHeight(histPair, calcRange, problems); 95 final BedHeightsFinder historicalSounding = loadBedHeight(histPair, calcRange, problems);
96 if (historicalSounding == null) 96 if (historicalSounding == null)
97 return null; 97 return null;
98 98
99 // FIXME: check current/hist wst have same discharge... 99 // FIXME: check current/hist wst have same discharge...
100 // FIXME: what means 'same discharge'
100 101
101 final BedHeightInfo currentSoundingInfo = currentSounding.getInfo(); 102 final BedHeightInfo currentSoundingInfo = currentSounding.getInfo();
102 final BedHeightInfo historicalSoundingInfo = historicalSounding.getInfo(); 103 final BedHeightInfo historicalSoundingInfo = historicalSounding.getInfo();
103 104
104 // final String label = createLabel(waterlevel, minBedHeight, maxBedHeight);
105
106 // final WKms wstKms = waterlevel.getWkms();
107 final int currentWstYear = currentWaterlevel.getYear(); 105 final int currentWstYear = currentWaterlevel.getYear();
108 final int historicalWstYear = historicalWaterlevel.getYear(); 106 final int historicalWstYear = historicalWaterlevel.getYear();
109 final int currentSoundingYear = currentSoundingInfo.getYear(); 107 final int currentSoundingYear = currentSoundingInfo.getYear();
110 final int historicalSoundingYear = historicalSoundingInfo.getYear(); 108 final int historicalSoundingYear = historicalSoundingInfo.getYear();
111 109
110 if (currentWstYear < 0) {
111 problems.addProblem("flowdepthdevelopmentcalculation.missingCurrentYear", currentWaterlevel.getName());
112 return null;
113 }
114
115 if (historicalWstYear < 0) {
116 problems.addProblem("flowdepthdevelopmentcalculation.missingHistoricalYear", historicalWaterlevel.getName());
117 return null;
118 }
119
112 // FIXME: distinguish error messages 120 // FIXME: distinguish error messages
113 FlowDepthUtils.checkYearDifference("", currentWstYear, currentSoundingYear, problems); 121 FlowDepthUtils.checkYearDifference("", currentWstYear, currentSoundingYear, problems);
114 FlowDepthUtils.checkYearDifference("", historicalWstYear, historicalSoundingYear, problems); 122 FlowDepthUtils.checkYearDifference("", historicalWstYear, historicalSoundingYear, problems);
115 123
116 /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */ 124 /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */
141 final double currentWst = currentWstProvider.getWaterlevel(station); 149 final double currentWst = currentWstProvider.getWaterlevel(station);
142 final double currentBedHeight = currentSounding.getMeanBedHeight(station); 150 final double currentBedHeight = currentSounding.getMeanBedHeight(station);
143 151
144 final double historicalWst = historicalWstProvider.getWaterlevel(station); 152 final double historicalWst = historicalWstProvider.getWaterlevel(station);
145 final double historicalBedHeight = historicalSounding.getMeanBedHeight(station); 153 final double historicalBedHeight = historicalSounding.getMeanBedHeight(station);
154
155 /* ignore invalid lines */
156 if (Double.isNaN(currentWst) || Double.isNaN(currentBedHeight) || Double.isNaN(historicalWst) || Double.isNaN(historicalBedHeight))
157 continue;
146 158
147 final double diffWst = (currentWst - historicalWst) * 100; 159 final double diffWst = (currentWst - historicalWst) * 100;
148 final double diffBedHeight = (currentBedHeight - historicalBedHeight) * 100; 160 final double diffBedHeight = (currentBedHeight - historicalBedHeight) * 100;
149 161
150 final double flowDepthDevelopment = diffWst - diffBedHeight; 162 final double flowDepthDevelopment = diffWst - diffBedHeight;

http://dive4elements.wald.intevation.org