Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.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 | 3b79e8afca7e |
children | bf2fd9c58ac4 |
rev | line source |
---|---|
3992
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.sq; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 public class SieveArray |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 public static final double EPSILON = 1e-8; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 public static final double [] SIEVE_DIAMETERS = { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 100d, 63d, 31.5d, 16d, |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 8d, 4d, 2d, 1d, |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 0.5d, 0.25d, 0.125d, 0.063d |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 }; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
12 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 protected double [] loads; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 protected double [] normLoads; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 public SieveArray() { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 loads = new double[SIEVE_DIAMETERS.length+1]; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
18 normLoads = new double[SIEVE_DIAMETERS.length+1]; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 public void doSieving(Sieve s) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 double diameter = s.getDiameter(); |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 for (int i = 0; i < SIEVE_DIAMETERS.length; ++i) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 if (diameter >= SIEVE_DIAMETERS[i]) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 loads[i] += s.getLoad(); |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 return; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 loads[loads.length-1] += s.getLoad(); |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
34 public double totalLoad() { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
35 double sum = 0d; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
36 for (double load: loads) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
37 sum += load; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
39 return sum; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
41 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
42 public void calculateNormLoads() { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
43 double total = totalLoad(); |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
44 if (Math.abs(total) < EPSILON) { |
4001
ab3a4ad82ae1
S(Q) accumulated same diameter meassurements per bank distance.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3992
diff
changeset
|
45 System.arraycopy(loads, 0, normLoads, 0, loads.length); |
3992
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
46 return; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 total = 1d/total; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
49 for (int i = 0; i < normLoads.length; ++i) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 normLoads[i] = total*loads[i]; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
53 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
54 /** |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
55 * Gets the loads for this instance. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 * |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 * @return The loads. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 */ |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
59 public double[] getLoads() { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
60 return this.loads; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
62 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
63 /** |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
64 * Gets the loads for this instance. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 * |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
66 * @param index The index to get. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 * @return The loads. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
68 */ |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
69 public double getLoads(int index) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
70 return this.loads[index]; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
72 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
73 /** |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
74 * Gets the normLoads for this instance. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
75 * |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
76 * @return The normLoads. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
77 */ |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
78 public double[] getNormLoads() { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
79 return this.normLoads; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
82 /** |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
83 * Gets the normLoads for this instance. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
84 * |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 * @param index The index to get. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 * @return The normLoads. |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 */ |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
88 public double getNormLoads(int index) { |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 return this.normLoads[index]; |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
4004
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
91 |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
92 public double sandNormFraction() { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
93 double sum = 0d; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
94 for (int i = 8; i < normLoads.length; ++i) { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
95 sum += normLoads[i]; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
96 } |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
97 return sum; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
98 } |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
99 |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
100 public double coarseNormFraction() { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
101 double sum = 0d; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
102 for (int i = 0; i < 4; ++i) { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
103 sum += normLoads[i]; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
104 } |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
105 return sum; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
106 } |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
107 |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
108 public double gravelNormFraction() { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
109 double sum = 0d; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
110 for (int i = 4; i < 8; ++i) { |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
111 sum += normLoads[i]; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
112 } |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
113 return sum; |
3b79e8afca7e
S(Q) calculate effective width
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4001
diff
changeset
|
114 } |
3992
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 } |
a9c93b7c9da1
Simpify the S(Q) fraction sieving stuff.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |