Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9394:439699ff9b2d
Added U-Info iota (prev. salix) calculation for historical scenario
author | mschaefer |
---|---|
date | Fri, 10 Aug 2018 17:31:46 +0200 |
parents | 8ae7137b67d7 |
children | 6e7094368e97 |
comparison
equal
deleted
inserted
replaced
9393:6174daaf5e56 | 9394:439699ff9b2d |
---|---|
137 */ | 137 */ |
138 private ResultRow createRow(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { | 138 private ResultRow createRow(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { |
139 | 139 |
140 final ResultRow row = ResultRow.create(); | 140 final ResultRow row = ResultRow.create(); |
141 row.putValue(GeneralResultType.station, station); | 141 row.putValue(GeneralResultType.station, station); |
142 // Find station's gauge | 142 // Find station's gauge (obsolete version which calculates gauge-wise) |
143 // final Gauge gauge = this.riverInfoProvider.getGauge(station, true); | 143 // final Gauge gauge = this.riverInfoProvider.getGauge(station, true); |
144 // Interpolate mnw, mw, and mhw | 144 // Interpolate mnw, mw, and mhw |
145 // final double mnw = interpolateW(station, this.gaugeMnwPos.get(gauge)); | 145 // final double mnw = interpolateW(station, this.gaugeMnwPos.get(gauge)); |
146 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge)); | 146 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge)); |
147 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge)); | 147 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge)); |
154 // Calc salix-line and mw-mnw | 154 // Calc salix-line and mw-mnw |
155 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw)); | 155 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw)); |
156 row.putValue(UInfoResultType.salix_mw_mnw, calcMwmnw(mw, mnw)); | 156 row.putValue(UInfoResultType.salix_mw_mnw, calcMwmnw(mw, mnw)); |
157 // Calc scenario values (always all scenario types set, Result variant extracts the fields needed) | 157 // Calc scenario values (always all scenario types set, Result variant extracts the fields needed) |
158 final List<SalixScenario> scenarios = new ArrayList<>(); | 158 final List<SalixScenario> scenarios = new ArrayList<>(); |
159 final double[] deltaws = getDeltaWs(station, rangeScenarios); | 159 final List<Double> deltaws = getDeltaWs(station, rangeScenarios); |
160 for (int i = 0; i <= deltaws.length - 1; i++) { | 160 for (final Double deltaw : deltaws) { |
161 if (Math.abs(deltaws[i]) > 0.0001) { | 161 if (deltaw != null) { |
162 final double salix = calcSalix(mhw, mw + deltaws[i]); | 162 final double salix = calcSalix(mhw, mw + deltaw); |
163 scenarios.add(new SalixScenario((int) (deltaws[i] * 100), salix)); | 163 scenarios.add(new SalixScenario((int) (deltaw * 100), salix)); |
164 } | 164 } |
165 else { | 165 else { |
166 scenarios.add(null); | 166 scenarios.add(null); |
167 } | 167 } |
168 } | 168 } |
196 return mnw - mw; // preserving NaN or Inifinity | 196 return mnw - mw; // preserving NaN or Inifinity |
197 return Formatter.roundW(mnw).subtract(Formatter.roundW(mw)).doubleValue(); | 197 return Formatter.roundW(mnw).subtract(Formatter.roundW(mw)).doubleValue(); |
198 } | 198 } |
199 | 199 |
200 /** | 200 /** |
201 * Gets the station-specific list of delta-ws of the active scenario, at least with one 0 item in any case | 201 * Gets the station-specific list of delta-ws of the active scenario, at least with one null item in any case |
202 */ | 202 */ |
203 private double[] getDeltaWs(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { | 203 private List<Double> getDeltaWs(final double station, final NavigableMap<Double, List<Double>> rangeScenarios) { |
204 final Entry<Double, List<Double>> stationScenarios = rangeScenarios.floorEntry(station); | 204 final Entry<Double, List<Double>> stationScenarios = rangeScenarios.floorEntry(station); |
205 if (stationScenarios == null) | 205 if (stationScenarios != null) { |
206 return new double[] { 0.0 }; | 206 return stationScenarios.getValue(); |
207 | 207 } |
208 final double[] deltaws = new double[stationScenarios.getValue().size()]; | 208 final List<Double> noScen = new ArrayList<>(); |
209 for (int i = 0; i <= stationScenarios.getValue().size() - 1; i++) | 209 noScen.add(null); |
210 deltaws[i] = stationScenarios.getValue().get(i); | 210 return noScen; |
211 return deltaws; | |
212 } | 211 } |
213 } | 212 } |