Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java @ 4357:11cf29eb002c
FacetTypes: New type: exreme_wq_curve_base (for the Stuetz-Q-Poits).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 11:58:11 +0100 |
parents | 22cd60315e08 |
children | ca18d8d06218 |
rev | line source |
---|---|
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.minfo; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
3 import gnu.trove.TDoubleArrayList; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
4 |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import java.util.LinkedList; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import java.util.List; |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
7 import java.util.Map; |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import org.apache.log4j.Logger; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.access.BedQualityAccess; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.model.Calculation; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.model.CalculationResult; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.artifacts.model.DateRange; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.backend.SedDBSessionHolder; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 public class BedQualityCalculation extends Calculation { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 private static final Logger logger = Logger |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 .getLogger(BedQualityCalculation.class); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 protected String river; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 protected double from; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 protected double to; |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
26 protected List<String> bedDiameter; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
27 protected List<String> bedloadDiameter; |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 protected List<DateRange> ranges; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 public BedQualityCalculation() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 public CalculationResult calculate(BedQualityAccess access) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 logger.info("BedQualityCalculation.calculate"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 String river = access.getRiver(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 Double from = access.getFrom(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 Double to = access.getTo(); |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
39 List<String> bedDiameter = access.getBedDiameter(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
40 List<String> bedloadDiameter = access.getBedloadDiameter(); |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 List<DateRange> ranges = access.getDateRanges(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 if (river == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 // TODO: i18n |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 addProblem("minfo.missing.river"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 if (from == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 // TODO: i18n |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 addProblem("minfo.missing.from"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 if (to == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 // TODO: i18n |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 addProblem("minfo.missing.to"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 if (ranges == null) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 // TODO: i18n |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 addProblem("minfo.missing.periods"); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 if (!hasProblems()) { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 this.river = river; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 this.from = from; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 this.to = to; |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 this.ranges = ranges; |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
68 this.bedDiameter = bedDiameter; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
69 this.bedloadDiameter = bedloadDiameter; |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 SedDBSessionHolder.acquire(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 try { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 return internalCalculate(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 finally { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 SedDBSessionHolder.release(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 return new CalculationResult(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 protected CalculationResult internalCalculate() { |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 List<BedQualityResult> results = new LinkedList<BedQualityResult>(); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 // Calculate for all time periods. |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 for (DateRange dr : ranges) { |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
88 QualityMeasurements loadMeasurements = |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3784
diff
changeset
|
89 QualityMeasurementFactory.getBedloadMeasurements( |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
90 river, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
91 from, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
92 to, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
93 dr.getFrom(), |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
94 dr.getTo()); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
95 QualityMeasurements bedMeasurements = |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
96 QualityMeasurementFactory.getBedMeasurements( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
97 river, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
98 from, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
99 to, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
100 dr.getFrom(), |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
101 dr.getTo()); |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
102 BedQualityResult result = new BedQualityResult(); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
103 result.setDateRange(dr); |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
104 if (bedDiameter != null) { |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
105 result.add(calculateBedParameter(bedMeasurements, dr)); |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
106 for (String bd : bedDiameter) { |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
107 BedDiameterResult bedResult = |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
108 calculateBed(bedMeasurements, bd, dr); |
3772
5a8f8fd5310c
The usual wipe after for ill configured Eclipses.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3769
diff
changeset
|
109 |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
110 // Avoid adding empty result sets. |
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
111 if (!bedResult.isEmpty()) { |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
112 result.add(bedResult); |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
113 } |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
114 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
115 } |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
116 if (bedloadDiameter != null) { |
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
117 for (String bld : bedloadDiameter) { |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
118 BedloadDiameterResult loadResult = |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
119 calculateBedload(loadMeasurements, bld, dr); |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
120 result.add(loadResult); |
3780
7fa38f8bcd8d
Avoid NPE if the user selects onlyone sort of characteristic diameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3772
diff
changeset
|
121 } |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
122 } |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
123 results.add(result); |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 return new CalculationResult( |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 results.toArray(new BedQualityResult[results.size()]), this); |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
130 private BedParametersResult calculateBedParameter( |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
131 QualityMeasurements qm, |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
132 DateRange dr |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
133 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
134 List<Double> kms = qm.getKms(); |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
135 QualityMeasurements capFiltered = filterCapMeasurements(qm); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
136 QualityMeasurements subFiltered = filterSubMeasurements(qm); |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
137 TDoubleArrayList location = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
138 TDoubleArrayList porosityCap = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
139 TDoubleArrayList porositySub = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
140 TDoubleArrayList densityCap = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
141 TDoubleArrayList densitySub = new TDoubleArrayList(); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3784
diff
changeset
|
142 |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
143 for(double km : kms) { |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
144 double[] pCap = calculatePorosity(capFiltered, km); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
145 double[] pSub = calculatePorosity(subFiltered, km); |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
146 double[] dCap = calculateDensity(capFiltered, pCap); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
147 double[] dSub = calculateDensity(subFiltered, pSub); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
148 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
149 double pCapRes = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
150 double pSubRes = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
151 double dCapRes = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
152 double dSubRes = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
153 for (int i = 0; i < pCap.length; i++) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
154 pCapRes += pCap[i]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
155 dCapRes += dCap[i]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
156 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
157 for (int i = 0; i < pSub.length; i++) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
158 pSubRes += pSub[i]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
159 dSubRes += dSub[i]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
160 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
161 location.add(km); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
162 porosityCap.add((pCapRes / pCap.length) * 100 ); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
163 porositySub.add((pSubRes / pSub.length) * 100); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
164 densityCap.add((dCapRes / dCap.length) / 1000); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
165 densitySub.add((dSubRes / dSub.length) / 1000); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3784
diff
changeset
|
166 |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
167 } |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
168 |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
169 return new BedParametersResult( |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
170 location, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
171 porosityCap, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
172 porositySub, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
173 densityCap, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
174 densitySub); |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
177 protected BedDiameterResult calculateBed( |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
178 QualityMeasurements qm, |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
179 String diameter, |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
180 DateRange range |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
181 ) { |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
182 List<Double> kms = qm.getKms(); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
183 TDoubleArrayList location = new TDoubleArrayList(); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
184 TDoubleArrayList avDiameterCap = new TDoubleArrayList(); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
185 TDoubleArrayList avDiameterSub = new TDoubleArrayList(); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
186 for (double km : kms) { |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
187 //Filter cap and sub measurements. |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
188 QualityMeasurements capFiltered = filterCapMeasurements(qm); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
189 QualityMeasurements subFiltered = filterSubMeasurements(qm); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
190 |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
191 List<QualityMeasurement> cm = capFiltered.getMeasurements(km); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
192 List<QualityMeasurement> sm = subFiltered.getMeasurements(km); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
193 |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
194 double avCap = calculateAverage(cm, diameter); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
195 double avSub = calculateAverage(sm, diameter); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
196 location.add(km); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
197 avDiameterCap.add(avCap); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
198 avDiameterSub.add(avSub); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
199 } |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
200 return new BedDiameterResult( |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
201 diameter, |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
202 avDiameterCap, |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
203 avDiameterSub, |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
204 location); |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
205 } |
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
206 |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
207 private double[] calculateDensity( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
208 QualityMeasurements capFiltered, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
209 double[] porosity |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
210 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
211 double[] density = new double[porosity.length]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
212 for (int i = 0; i < porosity.length; i++) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
213 density[i] = (1 - porosity[i]) * 2650; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
214 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
215 return density; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
216 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
217 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
218 private double[] calculatePorosity( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
219 QualityMeasurements capFiltered, |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
220 double km |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
221 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
222 List<QualityMeasurement> list = capFiltered.getMeasurements(km); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
223 double[] results = new double[list.size()]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
224 int i = 0; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
225 for (QualityMeasurement qm : list) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
226 double deviation = calculateDeviation(qm); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
227 double p = calculateP(qm); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
228 double porosity = 0.353 - 0.068 * deviation + 0.146 * p; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
229 results[i] = porosity; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
230 i++; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
231 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
232 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
233 return results; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
234 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
235 |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
236 protected BedloadDiameterResult calculateBedload( |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
237 QualityMeasurements qm, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
238 String diameter, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
239 DateRange range |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
240 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
241 List<Double> kms = qm.getKms(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
242 TDoubleArrayList location = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
243 TDoubleArrayList avDiameter = new TDoubleArrayList(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
244 for (double km : kms) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
245 List<QualityMeasurement> measurements = qm.getMeasurements(km); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
246 double mid = calculateAverage(measurements, diameter); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
247 location.add(km); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
248 avDiameter.add(mid); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
249 } |
3784
9f9d5ada96ca
Merged revisions 5498-5499 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3780
diff
changeset
|
250 return new BedloadDiameterResult( |
3769
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
251 diameter, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
252 avDiameter, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
253 location, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
254 range); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
255 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
256 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
257 protected double calculateAverage( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
258 List<QualityMeasurement> list, |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
259 String diameter |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
260 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
261 double av = 0; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
262 for (QualityMeasurement qm : list) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
263 av += qm.getDiameter(diameter); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
264 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
265 return av/list.size(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
266 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
267 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
268 protected QualityMeasurements filterCapMeasurements( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
269 QualityMeasurements qms |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
270 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
271 List<QualityMeasurement> result = new LinkedList<QualityMeasurement>(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
272 for (QualityMeasurement qm : qms.getMeasurements()) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
273 if (qm.getDepth1() == 0d && qm.getDepth2() <= 0.3) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
274 result.add(qm); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
275 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
276 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
277 return new QualityMeasurements(result); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
278 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
279 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
280 protected QualityMeasurements filterSubMeasurements( |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
281 QualityMeasurements qms |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
282 ) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
283 List<QualityMeasurement> result = new LinkedList<QualityMeasurement>(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
284 for (QualityMeasurement qm : qms.getMeasurements()) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
285 if (qm.getDepth1() > 0d && qm.getDepth2() <= 0.5) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
286 result.add(qm); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
287 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
288 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
289 return new QualityMeasurements(result); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
290 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
291 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
292 public double calculateDeviation(QualityMeasurement qm) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
293 Map<String, Double> dm = qm.getAllDiameter(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
294 double phiM = 0; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
295 double[] phis = new double[dm.size()]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
296 double[] ps = new double[dm.size()]; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
297 int i = 0; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
298 for (String key : dm.keySet()) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
299 double d = dm.get(key); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
300 double phi = -Math.log(d)/Math.log(2); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
301 phis[i] = phi; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
302 double p = calculateWeight(qm, key); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
303 ps[i] = p; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
304 phiM += phi * p; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
305 i++; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
306 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
307 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
308 double sig = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
309 for (i = 0; i < dm.size(); i++) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
310 sig += ps[i] * Math.exp(phis[i] - phiM); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
311 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
312 double deviation = Math.sqrt(sig); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
313 return deviation; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
314 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
315 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
316 protected double calculateP(QualityMeasurement qm) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
317 return calculateWeight(qm, "dmin"); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
318 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
319 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
320 public double calculateWeight(QualityMeasurement qm, String diameter) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
321 Map<String, Double> dm = qm.getAllDiameter(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
322 double value = qm.getDiameter(diameter); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
323 |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
324 double sum = 0d; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
325 for (Double d : dm.values()) { |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
326 sum =+ d.doubleValue(); |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
327 } |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
328 double weight = sum/100*value; |
728ecd2afa20
Implemented bed quality calculation in minfo module.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3760
diff
changeset
|
329 return weight; |
3760
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
330 } |
312870fded7e
Added result objects for minfo bed quality calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
331 } |