Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java @ 9631:6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
author | mschaefer |
---|---|
date | Tue, 15 Oct 2019 12:26:13 +0200 |
parents | 07f02019065e |
children |
rev | line source |
---|---|
9145 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.flood_duration; | |
11 | |
12 import java.util.ArrayList; | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
13 import java.util.HashMap; |
9612 | 14 import java.util.HashSet; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
15 import java.util.List; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
16 import java.util.Map; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
17 import java.util.Set; |
9145 | 18 |
19 import org.apache.commons.lang.math.DoubleRange; | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
20 import org.dive4elements.artifacts.CallContext; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
21 import org.dive4elements.river.artifacts.WINFOArtifact; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
22 import org.dive4elements.river.artifacts.access.ComputationRangeAccess; |
9145 | 23 import org.dive4elements.river.artifacts.common.GeneralResultType; |
24 import org.dive4elements.river.artifacts.common.ResultRow; | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.Calculation; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.Calculation.Problem; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.CalculationResult; |
9252 | 28 import org.dive4elements.river.artifacts.model.WQDay; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
29 import org.dive4elements.river.artifacts.model.WQKms; |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
30 import org.dive4elements.river.artifacts.model.WstValueTable; |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
31 import org.dive4elements.river.artifacts.model.WstValueTable.QPosition; |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
32 import org.dive4elements.river.artifacts.model.WstValueTableFactory; |
9499 | 33 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
34 import org.dive4elements.river.artifacts.sinfo.common.GaugeDurationValuesFinder; |
9145 | 35 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
36 import org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureServerClientXChange.Element; |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
37 import org.dive4elements.river.exports.WaterlevelDescriptionBuilder; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
38 import org.dive4elements.river.model.Attribute.AttributeKey; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
39 import org.dive4elements.river.model.Gauge; |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
40 import org.dive4elements.river.model.sinfo.InfrastructureValue; |
9145 | 41 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
42 import gnu.trove.TDoubleArrayList; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
43 |
9145 | 44 /** |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
45 * Calculation of the result rows of the flood duration of the infrastructures in a river km range |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
46 * and selected main value durations |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
47 * |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
48 * @author Matthias Schäfer |
9145 | 49 */ |
50 final class FloodDurationCalculator { | |
51 | |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
52 private final List<ResultRow> rows = new ArrayList<>(); |
9145 | 53 |
54 private final RiverInfoProvider riverInfoProvider; | |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
55 private RiverInfoProvider riverInfoProvider2; |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
56 private final Map<Double, List<InfrastructureValue>> stationInfras; |
9145 | 57 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
58 private final CallContext context; |
9145 | 59 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
60 public FloodDurationCalculator(final CallContext context, final RiverInfoProvider riverInfoProvider) { |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
61 this.context = context; |
9145 | 62 this.riverInfoProvider = riverInfoProvider; |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
63 this.riverInfoProvider2 = null; |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
64 this.stationInfras = new HashMap<>(); |
9145 | 65 } |
66 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
67 /** |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
68 * Calculate the infrastructures flood duration result rows |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
69 */ |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
70 public void execute(final Calculation problems, final String label, final DoubleRange calcRange, final AttributeKey riverside, |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
71 final List<Element> infrastructureChoices, final boolean withWspl, final WINFOArtifact winfo, final FloodDurationCalculationResults results) { |
9145 | 72 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
73 // Find all gauges of the calc range, and create the duration finders |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
74 final Map<Gauge, GaugeDurationValuesFinder> durFinders = new HashMap<>(); |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
75 for (final Gauge gauge : this.riverInfoProvider.getGauges()) { |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
76 durFinders.put(gauge, GaugeDurationValuesFinder.loadValues(gauge, problems)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
77 } |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
78 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
79 // Find all infrastructures within the calc range |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
80 final Set<String> choices = new HashSet<>(); |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
81 for (final Element ifch : infrastructureChoices) |
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
82 choices.add(ifch.getGroupLabel() + "\t" + ifch.getTypeLabel()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
83 final List<InfrastructureValue> infras = InfrastructureValue.getValues(this.riverInfoProvider.getRiver(), calcRange.getMinimumDouble(), |
9625
07f02019065e
Nachtrag Pos. 20: infrastructure query added, calculation updated for extended access class
mschaefer
parents:
9620
diff
changeset
|
84 calcRange.getMaximumDouble(), riverside, choices); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
85 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
86 // Merge all stations (range/step, borders of gauge ranges, infrastructures) |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
87 // final Map<Double, InfrastructureValue> allStations = new HashMap<>(); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
88 this.stationInfras.clear(); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
89 // final Map<Double, InfrastructureValue> secondBank = new HashMap<>(); // any second infrastructure in case of |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
90 // both-banks-option |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
91 addRangeStations(winfo); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
92 addGaugeLimits(durFinders.keySet(), calcRange.getMinimumDouble(), calcRange.getMaximumDouble()); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
93 addInfrastructures(infras); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
94 final double[] stationsSorted = sortStations(this.stationInfras.keySet()); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
95 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
96 // Calculate W and Q for all stations and the selected discharge states/waterlevels |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
97 final WQKms[] wqkmsArray = calculateWsts(winfo, withWspl, stationsSorted, problems); |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
98 // final WaterlevelData waterlevel = new WaterlevelData(wqkmsArray[0], -1, false, true); |
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
99 // this.riverInfoProvider2 = this.riverInfoProvider.forWaterlevel(waterlevel); |
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
100 this.riverInfoProvider2 = this.riverInfoProvider.forReferenceRange(calcRange, false); |
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
101 // this.riverInfoProvider2.cleanupGaugesAtStart(calcRange); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
102 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
103 // Determine discharge state labels of the waterlevels |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
104 updateWstLabels(wqkmsArray, winfo, problems); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
105 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
106 final Map<Gauge, List<Double>> gaugeWstDurations = new HashMap<>(); |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
107 if (withWspl) |
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
108 calcGaugeWstDurations(winfo, new ArrayList<>(durFinders.keySet()), gaugeWstDurations, durFinders); |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
109 |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
110 // Load base wst table (river).wst |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
111 // (should be in cache since already used in calculateWaterlevels (winfo.computeWaterlevelData) |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
112 final WstValueTable wst = WstValueTableFactory.getTable(this.riverInfoProvider2.getRiver()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
113 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
114 final Set<FloodDurationInfrastructureChoice> infrastructures = new HashSet<>(); |
9612 | 115 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
116 // Create the result rows, and calculate and add the flood durations etc. |
9631
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
117 ResultRow row; |
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
118 boolean starting; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
119 for (int i = 0; i <= stationsSorted.length - 1; i++) { |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
120 final Gauge gauge = this.riverInfoProvider2.getGauge(stationsSorted[i], true); |
9631
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
121 row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i); |
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
122 starting = true; |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
123 if (this.stationInfras.containsKey(stationsSorted[i])) { |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
124 for (final InfrastructureValue infra : this.stationInfras.get(stationsSorted[i])) { |
9631
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
125 if (!starting) |
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
126 row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i); |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
127 calculateInfrastructure(row, gauge, infra, wst, durFinders, infrastructures); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
128 this.rows.add(row); |
9631
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
129 starting = false; |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
130 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
131 } |
9631
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
132 if (starting) |
6ecd1a28017f
Nachtrag Pos. 20: Q theme for height chart added, calculator corrected (rows for km without any infrastructure)
mschaefer
parents:
9625
diff
changeset
|
133 this.rows.add(row); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
134 } |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
135 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
136 // Get the labels of the selected waterlevels |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
137 final String[] wstLabels = new String[wqkmsArray.length]; |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
138 for (int i = 0; i <= wqkmsArray.length - 1; i++) |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
139 wstLabels[i] = wqkmsArray[i].getName(); |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
140 |
9612 | 141 results.addResult(new FloodDurationCalculationResult(label, wstLabels, this.rows, withWspl, infrastructures), problems); |
9252 | 142 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
143 |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
144 /** |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9265
diff
changeset
|
145 * Calculates the duration curve for a station |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
146 * (other than the version 3.2.1 W-Info Dauerlinie the wst column positions |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
147 * are taken from the Q values of the gauge's Q-D-table) |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
148 */ |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9265
diff
changeset
|
149 public WQDay calcWQDays(final Calculation problems, final double station, final WINFOArtifact winfo) { |
9252 | 150 |
9534
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
151 final CalculationResult res = winfo.getDurationCurveData(); |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
152 final WQDay wqday = (WQDay) res.getData(); |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
153 if (wqday == null) |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
154 return null; |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
155 |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
156 final int[] odays = new int[wqday.size()]; |
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
157 for (int i = 0; i <= odays.length - 1; i++) |
9594
225e48df608c
Softwaretests...20181219 6.1: overflow day compute with 365.25 instead of 365.0
mschaefer
parents:
9534
diff
changeset
|
158 odays[i] = 365 - wqday.getDay(i); // TODO Eigentlich 365.25, ist aber mit getDay als int sinnlos |
9534
b380a5693514
Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge);
mschaefer
parents:
9528
diff
changeset
|
159 return new WQDay(odays, wqday.getWs(), wqday.getQs()); |
9145 | 160 } |
161 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
162 /** |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
163 * Adds to a stations map all stations corresponding to the active range and step |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
164 */ |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
165 private void addRangeStations(final WINFOArtifact winfo) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
166 for (final double station : new ComputationRangeAccess(winfo).getKms()) |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
167 this.stationInfras.put(Double.valueOf(station), new ArrayList<InfrastructureValue>()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
168 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
169 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
170 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
171 * Adds to a stations map all range limits of the gauges within the calc range |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
172 */ |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
173 private void addGaugeLimits(final Set<Gauge> gauges, final double fromKm, final double toKm) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
174 for (final Gauge gauge : gauges) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
175 final Double kmA = Double.valueOf(gauge.getRange().getA().doubleValue()); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
176 final Double kmB = Double.valueOf(gauge.getRange().getB().doubleValue()); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
177 if (kmA > fromKm - 0.0001) |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
178 this.stationInfras.put(kmA, new ArrayList<InfrastructureValue>()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
179 if (kmB < toKm + 0.0001) |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
180 this.stationInfras.put(kmB, new ArrayList<InfrastructureValue>()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
181 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
182 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
183 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
184 /** |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
185 * Adds all infrastructures of a station to the station map |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
186 */ |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
187 private void addInfrastructures(final List<InfrastructureValue> infrastructures) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
188 for (final InfrastructureValue infrastructure : infrastructures) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
189 final Double station = infrastructure.getStation(); |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
190 if (this.stationInfras.containsKey(station)) |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
191 this.stationInfras.get(station).add(infrastructure); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
192 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
193 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
194 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
195 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
196 * Returns a double array with a sorted stations set |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
197 */ |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
198 private double[] sortStations(final Set<Double> stations) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
199 final TDoubleArrayList sorted = new TDoubleArrayList(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
200 for (final Double station : stations) |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
201 sorted.add(station.doubleValue()); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
202 sorted.sort(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
203 return sorted.toNativeArray(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
204 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
205 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
206 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
207 * Calculates an array of w-q-longitudinal sections for all artifact W/Q options |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
208 */ |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
209 private WQKms[] calculateWsts(final WINFOArtifact winfo, final boolean withWspl, final double[] stations, final Calculation problems) { |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
210 // First run may take long, further runs are faster since WstValueTable is in cache then |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
211 // (So funktioniert computeWaterlevelData wohl: |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
212 // Es sucht die Spalte(n) zum Bezugspegel-Q in der W-Q-Tabelle ({river}.wst in Wst etc.), |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
213 // interpoliert die horizontale Tabellenposition (Q) und dann die vertikale Tabellenposition der station; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
214 // das ergibt das W einer station für einen Abflusszustand; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
215 // bei Vorgabe eines Pegel-W wird vorher anhand der W-Q-Tabelle des Pegels ({gauge}.at in DischargeTable) das Q |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
216 // interpoliert; |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
217 // bei Vorgabe eines W auf freier Strecke wird wohl vorher noch die .wst-Interpolation eingesetzt, um das Q zu bekommen. |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
218 |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
219 if (!withWspl) |
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
220 return new WQKms[] {}; |
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
221 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
222 final CalculationResult wstsData = winfo.computeWaterlevelData(stations); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
223 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
224 /* copy all problems */ |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
225 final Calculation winfoProblems = wstsData.getReport(); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
226 final List<Problem> problems2 = winfoProblems.getProblems(); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
227 if (problems2 != null) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
228 for (final Problem problem : problems2) { |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
229 problems.addProblem(problem); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
230 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
231 } |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
232 return (WQKms[]) wstsData.getData(); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
233 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
234 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
235 /** |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
236 * Determines the waterlevel/discharge state labels for the selected Q or W values and sets them in the WQKms array |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
237 */ |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
238 private void updateWstLabels(final WQKms[] wqkmsArray, final WINFOArtifact winfo, final Calculation problems) { |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
239 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9215
diff
changeset
|
240 for (int i = 0; i <= wqkmsArray.length - 1; i++) |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
241 wqkmsArray[i].setName(buildWQDescription(wqkmsArray[i], winfo)); |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
242 } |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
243 |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
244 /** |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
245 * Builds the description label of a waterlevel |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
246 */ |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
247 private String buildWQDescription(final WQKms wqkms, final WINFOArtifact winfo) { |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
248 |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
249 final WaterlevelDescriptionBuilder descBuilder = new WaterlevelDescriptionBuilder(winfo, this.context); |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
250 // TODO Zwischen numerischem Q-Wert und Dauerzahl-Hauptwert (0..364) unterscheiden |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
251 final String description = descBuilder.getDesc(wqkms); |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
252 if (!description.isEmpty() && Character.isDigit(description.charAt(0))) { |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
253 if (winfo.isQ()) |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
254 return "Q=" + description; |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
255 else |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
256 return "W=" + description; |
9312 | 257 } else |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
258 return description; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
259 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
260 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
261 /** |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
262 * Calculates the flood durations of the Qs of the waterlevels/discharge states for a map of gauges |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
263 */ |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
264 private void calcGaugeWstDurations(final WINFOArtifact winfo, final List<Gauge> gauges, final Map<Gauge, List<Double>> gaugeWstDurations, |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
265 final Map<Gauge, GaugeDurationValuesFinder> durFinders) { |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
266 |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
267 final double[] gaugeKms = new double[gauges.size()]; |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
268 for (int i = 0; i <= gauges.size() - 1; i++) { |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
269 gaugeKms[i] = gauges.get(i).getStation().doubleValue(); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
270 gaugeWstDurations.put(gauges.get(i), new ArrayList<Double>()); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
271 } |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
272 final CalculationResult wstsData = winfo.computeWaterlevelData(gaugeKms); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
273 final WQKms[] wsts = (WQKms[]) wstsData.getData(); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
274 for (int i = 0; i <= gauges.size() - 1; i++) { |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
275 final GaugeDurationValuesFinder durFinder = durFinders.get(gauges.get(i)); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
276 for (int j = 0; j <= wsts.length - 1; j++) { |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
277 final double d = durFinder.getDuration(wsts[j].getQ(i)); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
278 gaugeWstDurations.get(gauges.get(i)).add(Double.valueOf(underflowDaysToOverflowDays(d))); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
279 } |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
280 } |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
281 } |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
282 |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
283 /** |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
284 * Create a result row for a station, and add w-q-values as selected |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
285 */ |
9398
929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
mschaefer
parents:
9376
diff
changeset
|
286 private ResultRow createRow(final Double station, final WQKms[] wqkmsArray, final List<Double> gaugeDurations, final int kmIndex) { |
9145 | 287 |
288 final ResultRow row = ResultRow.create(); | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
289 row.putValue(GeneralResultType.station, station); |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
290 row.putValue(SInfoResultType.infrastructuregroup, null); // is replaced later for an infrastructure type |
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
291 row.putValue(SInfoResultType.infrastructuretype, null); // is replaced later for an infrastructure part |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
292 row.putValue(SInfoResultType.floodDuration, Double.NaN); // is replaced later for an infrastructure |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
293 |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
294 final String gaugeLabel = this.riverInfoProvider2.findGauge(station); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9312
diff
changeset
|
295 row.putValue(GeneralResultType.gaugeLabel, gaugeLabel); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
296 |
9528
55c187a0a31e
Fixed: consistent gauge assignment with downstream gauge as reference gauge for calc range starting at a gauge range limit
mschaefer
parents:
9499
diff
changeset
|
297 final String location = this.riverInfoProvider2.getLocation(station); |
9312 | 298 row.putValue(GeneralResultType.location, location); |
9145 | 299 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
300 final List<DurationWaterlevel> wsts = new ArrayList<>(wqkmsArray.length); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
301 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
302 for (int i = 0; i <= wqkmsArray.length - 1; i++) { |
9357
5ce50640688c
S-Info flood duration: fixed error report output name, changed duration from int to double, added formatter
mschaefer
parents:
9318
diff
changeset
|
303 final DurationWaterlevel dw = new DurationWaterlevel(wqkmsArray[i].getW(kmIndex), gaugeDurations.get(i), wqkmsArray[i].getQ(kmIndex), |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
304 wqkmsArray[i].getName()); |
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
305 wsts.add(dw); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
306 } |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
307 row.putValue(SInfoResultType.customMultiRowColWaterlevel, wsts); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
308 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
309 return row; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
310 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
311 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
312 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
313 * Calculate the result row fields for one infrastructure |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
314 */ |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
315 private void calculateInfrastructure(final ResultRow row, final Gauge gauge, final InfrastructureValue infrastructure, final WstValueTable wst, |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
316 final Map<Gauge, GaugeDurationValuesFinder> durFinders, final Set<FloodDurationInfrastructureChoice> infrastructures) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
317 |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
318 // Interpolate the infrastructure height in the wst table to get the corresponding Q |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
319 final Calculation problems = new Calculation(); |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
320 final double[] qs = wst.findQsForW(infrastructure.getStation().doubleValue(), infrastructure.getHeight().doubleValue(), problems); |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
321 // TODO Fehlerbehandlung (kein Q gefunden) |
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
322 final double q = (qs.length >= 1) ? qs[0] : Double.NaN; |
9308
9055afc19ec6
Fixed capturing invalid heights/discharges in S-Info flood duration calculation
mschaefer
parents:
9298
diff
changeset
|
323 // Set the result row |
9055afc19ec6
Fixed capturing invalid heights/discharges in S-Info flood duration calculation
mschaefer
parents:
9298
diff
changeset
|
324 row.putValue(SInfoResultType.riverside, infrastructure.getAttributeKey()); |
9055afc19ec6
Fixed capturing invalid heights/discharges in S-Info flood duration calculation
mschaefer
parents:
9298
diff
changeset
|
325 row.putValue(SInfoResultType.floodDischarge, q); |
9055afc19ec6
Fixed capturing invalid heights/discharges in S-Info flood duration calculation
mschaefer
parents:
9298
diff
changeset
|
326 row.putValue(SInfoResultType.infrastructureHeight, infrastructure.getHeight()); |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
327 row.putValue(SInfoResultType.infrastructuregroup, infrastructure.getInfrastructure().getGroup().getName()); |
9308
9055afc19ec6
Fixed capturing invalid heights/discharges in S-Info flood duration calculation
mschaefer
parents:
9298
diff
changeset
|
328 row.putValue(SInfoResultType.infrastructuretype, infrastructure.getInfrastructure().getType().getName()); |
9612 | 329 |
9286
bcbae86ce7b3
Improved flood duration curve calculation as specified by BfG
mschaefer
parents:
9269
diff
changeset
|
330 // Determine the relative column position of the Q of the infrastructure height |
9269
83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents:
9266
diff
changeset
|
331 final QPosition qPos = wst.getQPosition(infrastructure.getStation().doubleValue(), q); |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
332 if (qPos != null) { |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
333 // Get the Q for the found column position for the station of the gauge |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
334 final double qGauge = wst.getQ(qPos, gauge.getStation().doubleValue()); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
335 // Interpolate the Q-D-table of the gauge |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
336 final double dur = underflowDaysToOverflowDays(durFinders.get(gauge).getDuration(qGauge)); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
337 // Set D in the result row |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
338 row.putValue(SInfoResultType.floodDuration, dur); |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
339 } |
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
340 final FloodDurationInfrastructureChoice groupType = new FloodDurationInfrastructureChoice(row); |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
341 infrastructures.add(groupType); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
342 } |
9145 | 343 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
344 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
345 * Translates underflow duration into overflow duration |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
346 */ |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9176
diff
changeset
|
347 private double underflowDaysToOverflowDays(final double underflowDays) { |
9594
225e48df608c
Softwaretests...20181219 6.1: overflow day compute with 365.25 instead of 365.0
mschaefer
parents:
9534
diff
changeset
|
348 return 365.25 - underflowDays; |
9145 | 349 } |
350 } |