comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculator.java @ 9430:e8b1255fc89e

Added calculation of salix hw5 and salix line w
author mschaefer
date Mon, 20 Aug 2018 09:41:07 +0200
parents bd5f5d2220fa
children 515643b2c49a
comparison
equal deleted inserted replaced
9429:bd5f5d2220fa 9430:e8b1255fc89e
50 private final RiverInfoProvider riverInfoProvider; 50 private final RiverInfoProvider riverInfoProvider;
51 51
52 private final Map<Gauge, QPosition> gaugeMwPos; 52 private final Map<Gauge, QPosition> gaugeMwPos;
53 private final Map<Gauge, QPosition> gaugeMnwPos; 53 private final Map<Gauge, QPosition> gaugeMnwPos;
54 private final Map<Gauge, QPosition> gaugeMhwPos; 54 private final Map<Gauge, QPosition> gaugeMhwPos;
55 private final Map<Gauge, QPosition> gaugeHw5Pos;
55 private QPosition refGaugeMwPos; 56 private QPosition refGaugeMwPos;
56 private QPosition refGaugeMnwPos; 57 private QPosition refGaugeMnwPos;
57 private QPosition refGaugeMhwPos; 58 private QPosition refGaugeMhwPos;
59 private QPosition refGaugeHw5Pos;
58 private Gauge firstGauge; 60 private Gauge firstGauge;
59 61
60 private Calculation problems; 62 private Calculation problems;
61 63
62 private WstValueTable wst; 64 private WstValueTable wst;
64 public SalixLineCalculator(final RiverInfoProvider riverInfoProvider) { 66 public SalixLineCalculator(final RiverInfoProvider riverInfoProvider) {
65 this.riverInfoProvider = riverInfoProvider; 67 this.riverInfoProvider = riverInfoProvider;
66 this.gaugeMwPos = new HashMap<>(); 68 this.gaugeMwPos = new HashMap<>();
67 this.gaugeMnwPos = new HashMap<>(); 69 this.gaugeMnwPos = new HashMap<>();
68 this.gaugeMhwPos = new HashMap<>(); 70 this.gaugeMhwPos = new HashMap<>();
71 this.gaugeHw5Pos = new HashMap<>();
69 } 72 }
70 73
71 /** 74 /**
72 * Calculate the salix line result rows 75 * Calculate the salix line result rows
73 */ 76 */
101 */ 104 */
102 private void fetchGaugeMainValuePositions() { 105 private void fetchGaugeMainValuePositions() {
103 this.gaugeMwPos.clear(); 106 this.gaugeMwPos.clear();
104 this.gaugeMnwPos.clear(); 107 this.gaugeMnwPos.clear();
105 this.gaugeMhwPos.clear(); 108 this.gaugeMhwPos.clear();
109 this.gaugeHw5Pos.clear();
110
106 this.firstGauge = null; 111 this.firstGauge = null;
107 for (final Gauge gauge : this.riverInfoProvider.getGauges()) { 112 for (final Gauge gauge : this.riverInfoProvider.getGauges()) {
108 this.gaugeMwPos.put(gauge, null); 113 this.gaugeMwPos.put(gauge, null);
109 this.gaugeMnwPos.put(gauge, null); 114 this.gaugeMnwPos.put(gauge, null);
110 this.gaugeMhwPos.put(gauge, null); 115 this.gaugeMhwPos.put(gauge, null);
116 this.gaugeHw5Pos.put(gauge, null);
111 final double gaugeKm = gauge.getStation().doubleValue(); 117 final double gaugeKm = gauge.getStation().doubleValue();
112 for (final MainValue mv : MainValue.getValuesOfGaugeAndType(gauge, MainValueTypeKey.Q)) { 118 for (final MainValue mv : MainValue.getValuesOfGaugeAndType(gauge, MainValueTypeKey.Q)) {
113 if (mv.getMainValue().getName().equalsIgnoreCase("mq")) 119 if (mv.getMainValue().getName().equalsIgnoreCase("mq"))
114 this.gaugeMwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); 120 this.gaugeMwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
115 else if (mv.getMainValue().getName().equalsIgnoreCase("mnq")) 121 else if (mv.getMainValue().getName().equalsIgnoreCase("mnq"))
116 this.gaugeMnwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); 122 this.gaugeMnwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
117 else if (mv.getMainValue().getName().equalsIgnoreCase("mhq")) 123 else if (mv.getMainValue().getName().equalsIgnoreCase("mhq"))
118 this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue())); 124 this.gaugeMhwPos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
125 else if (mv.getMainValue().getName().equalsIgnoreCase("hq5"))
126 this.gaugeHw5Pos.put(gauge, this.wst.getQPosition(gaugeKm, mv.getValue().doubleValue()));
119 } 127 }
120 if (this.firstGauge == null) { 128 if (this.firstGauge == null) {
121 this.refGaugeMwPos = this.gaugeMwPos.get(gauge); 129 this.refGaugeMwPos = this.gaugeMwPos.get(gauge);
122 this.refGaugeMnwPos = this.gaugeMnwPos.get(gauge); 130 this.refGaugeMnwPos = this.gaugeMnwPos.get(gauge);
123 this.refGaugeMhwPos = this.gaugeMhwPos.get(gauge); 131 this.refGaugeMhwPos = this.gaugeMhwPos.get(gauge);
132 this.refGaugeHw5Pos = this.gaugeHw5Pos.get(gauge);
124 this.firstGauge = gauge; 133 this.firstGauge = gauge;
125 } 134 }
126 } 135 }
127 if (this.refGaugeMwPos == null) 136 if (this.refGaugeMwPos == null)
128 this.problems.addProblem("uinfo_salix_calc.warning.missing_mq"); 137 this.problems.addProblem("uinfo_salix_calc.warning.missing_mq");
148 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge)); 157 // final double mw = interpolateW(station, this.gaugeMwPos.get(gauge));
149 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge)); 158 // final double mhw = interpolateW(station, this.gaugeMhwPos.get(gauge));
150 final double mnw = interpolateW(station, this.refGaugeMnwPos); 159 final double mnw = interpolateW(station, this.refGaugeMnwPos);
151 final double mw = interpolateW(station, this.refGaugeMwPos); 160 final double mw = interpolateW(station, this.refGaugeMwPos);
152 final double mhw = interpolateW(station, this.refGaugeMhwPos); 161 final double mhw = interpolateW(station, this.refGaugeMhwPos);
162 final double hw5 = interpolateW(station, this.refGaugeHw5Pos);
153 row.putValue(UInfoResultType.waterlevelMNW, mnw); 163 row.putValue(UInfoResultType.waterlevelMNW, mnw);
154 row.putValue(UInfoResultType.waterlevelMW, mw); 164 row.putValue(UInfoResultType.waterlevelMW, mw);
155 row.putValue(UInfoResultType.waterlevelMHW, mhw); 165 row.putValue(UInfoResultType.waterlevelMHW, mhw);
156 // TODO: hier noch den W(HQ5) 166 row.putValue(UInfoResultType.waterlevelMH5, hw5);
157 row.putValue(UInfoResultType.waterlevelMH5, Double.NaN);
158 167
159 // Calc salix-line and mw-mnw 168 // Calc salix-line and mw-mnw
160 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw)); 169 row.putValue(UInfoResultType.salixline, calcSalix(mhw, mw));
161 row.putValue(UInfoResultType.salix_mw_mnw, calcMwmnw(mw, mnw)); 170 row.putValue(UInfoResultType.salix_mw_mnw, calcMwmnw(mw, mnw));
171 row.putValue(UInfoResultType.salixw, mhw - SALIX_DISTANCE.doubleValue());
162 // Calc scenario values (always all scenario types set, Result variant extracts the fields needed) 172 // Calc scenario values (always all scenario types set, Result variant extracts the fields needed)
163 final List<SalixScenario> scenarios = new ArrayList<>(); 173 final List<SalixScenario> scenarios = new ArrayList<>();
164 final List<Double> deltaws = getDeltaWs(station, rangeScenarios); 174 final List<Double> deltaws = getDeltaWs(station, rangeScenarios);
165 for (final Double deltaw : deltaws) { 175 for (final Double deltaw : deltaws) {
166 if (deltaw != null) { 176 if (deltaw != null) {
167 final double salix = calcSalix(mhw, mw + deltaw); 177 final double salix = calcSalix(mhw, mw + deltaw);
168 scenarios.add(new SalixScenario((int) (deltaw * 100), salix)); 178 scenarios.add(new SalixScenario((int) (deltaw * 100), salix, mhw + deltaw - SALIX_DISTANCE.doubleValue()));
169 } 179 }
170 else { 180 else {
171 scenarios.add(null); 181 scenarios.add(null);
172 } 182 }
173 } 183 }

http://dive4elements.wald.intevation.org