Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java @ 8940:82998242ba84
Preparing for additional outputs of SINFO-Tkh
author | gernotbelger |
---|---|
date | Tue, 06 Mar 2018 18:51:18 +0100 |
parents | d9dbf0b74bc2 |
children | 5d5d482da3e9 |
comparison
equal
deleted
inserted
replaced
8939:2970368ae1e3 | 8940:82998242ba84 |
---|---|
16 import org.apache.commons.math.FunctionEvaluationException; | 16 import org.apache.commons.math.FunctionEvaluationException; |
17 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; | 17 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; |
18 import org.dive4elements.river.artifacts.model.WKms; | 18 import org.dive4elements.river.artifacts.model.WKms; |
19 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; | 19 import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; |
20 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder; | 20 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.DischargeValuesFinder; |
21 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind; | |
22 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.Tkh; | 21 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.Tkh; |
23 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; | 22 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; |
24 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; | 23 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; |
25 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | 24 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; |
26 import org.dive4elements.river.utils.DoubleUtil; | 25 import org.dive4elements.river.utils.DoubleUtil; |
78 // FIXME: check out of range of waterlevel? | 77 // FIXME: check out of range of waterlevel? |
79 final double wst = this.wstInterpolator.value(station); | 78 final double wst = this.wstInterpolator.value(station); |
80 | 79 |
81 final Tkh tkh = calculateTkh(station, wst); | 80 final Tkh tkh = calculateTkh(station, wst); |
82 | 81 |
83 final double meanBedHeight = tkh.getMeanBedHeight(); | |
84 | |
85 final double flowDepth = wst - meanBedHeight; | |
86 final double flowDepthTkh = calculateFlowDepthTkh(tkh, wst, meanBedHeight); | |
87 | |
88 // REMARK: access the location once only during calculation | 82 // REMARK: access the location once only during calculation |
89 final String location = this.riverInfoProvider.getLocation(station); | 83 final String location = this.riverInfoProvider.getLocation(station); |
90 | 84 |
91 // REMARK: access the gauge once only during calculation | 85 // REMARK: access the gauge once only during calculation |
92 final String gaugeLabel = this.riverInfoProvider.findGauge(station); | 86 final String gaugeLabel = this.riverInfoProvider.findGauge(station); |
93 | 87 |
94 this.rows.add(new FlowDepthRow(flowDepth, flowDepthTkh, tkh, this.wstLabel, gaugeLabel, this.bedHeightLabel, location)); | 88 this.rows.add(new FlowDepthRow(tkh, this.wstLabel, gaugeLabel, this.bedHeightLabel, location)); |
95 } | 89 } |
96 catch (final FunctionEvaluationException e) { | 90 catch (final FunctionEvaluationException e) { |
97 /* should only happen if out of range */ | 91 /* should only happen if out of range */ |
98 e.printStackTrace(); | 92 e.printStackTrace(); |
99 /* simply ignore */ | 93 /* simply ignore */ |
102 | 96 |
103 private Tkh calculateTkh(final double station, final double wst) throws FunctionEvaluationException { | 97 private Tkh calculateTkh(final double station, final double wst) throws FunctionEvaluationException { |
104 if (this.tkhCalculator == null) { | 98 if (this.tkhCalculator == null) { |
105 final double discharge = this.dischargeProvider.getDischarge(station); | 99 final double discharge = this.dischargeProvider.getDischarge(station); |
106 final double meanBedHeight = this.bedHeight.getMeanBedHeight(station); | 100 final double meanBedHeight = this.bedHeight.getMeanBedHeight(station); |
107 return new Tkh(station, wst, meanBedHeight, discharge); | 101 final double flowDepth = wst - meanBedHeight; |
102 return new Tkh(station, wst, meanBedHeight, flowDepth, discharge); | |
108 } | 103 } |
109 | 104 |
110 return this.tkhCalculator.getTkh(station, wst); | 105 return this.tkhCalculator.getTkh(station, wst); |
111 } | 106 } |
112 | |
113 private double calculateFlowDepthTkh(final Tkh tkh, final double wst, final double meanBedHeight) { | |
114 final double tkhValue = tkh.getTkh(); | |
115 final SoilKind tkhKind = tkh.getKind(); | |
116 | |
117 if (Double.isNaN(tkhValue) || tkhKind == null) | |
118 return Double.NaN; | |
119 | |
120 switch (tkhKind) { | |
121 case starr: | |
122 return wst - (meanBedHeight + tkhValue / 100); | |
123 | |
124 case mobil: | |
125 default: | |
126 return wst - (meanBedHeight + tkhValue / 200); | |
127 } | |
128 } | |
129 } | 107 } |