Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java @ 4655:cd44d28d0fbc
Move the access to artifact data to the Access object
Use BedHeightAccess class to receive the data from the artifact. This abstracts
the data access from the actual artifact.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 11 Dec 2012 09:44:04 +0100 |
parents | 3cda41b5eb23 |
children | 345f3bba6f15 |
rev | line source |
---|---|
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.fixings; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
3 import de.intevation.artifacts.common.utils.StringUtils; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
4 |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.artifacts.access.FixAccess; |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.math.fitting.Function; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.artifacts.model.Calculation; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.model.CalculationResult; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.model.FixingsColumn; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.model.FixingsColumnFactory; |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
14 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
15 import de.intevation.flys.artifacts.model.FixingsOverview.Fixing.Filter; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
16 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
17 import de.intevation.flys.artifacts.model.FixingsOverview.Fixing; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
18 import de.intevation.flys.artifacts.model.FixingsOverview.IdsFilter; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
19 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.artifacts.model.FixingsOverview; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.artifacts.model.FixingsOverviewFactory; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.artifacts.model.Parameters; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.utils.DoubleUtil; |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
25 import de.intevation.flys.utils.KMIndex; |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 import java.util.ArrayList; |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
28 import java.util.Date; |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
29 import java.util.HashMap; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
30 import java.util.List; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
31 import java.util.Map; |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 import org.apache.log4j.Logger; |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 |
3437
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
35 public abstract class FixCalculation |
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
36 extends Calculation |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 { |
2786
f9e62e76ee1f
FixA: Return correct data structure from calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2783
diff
changeset
|
38 private static Logger log = Logger.getLogger(FixCalculation.class); |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
40 public static final double EPSILON = 1e-4; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
41 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
42 public static final String [] STANDARD_COLUMNS = { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
43 "km", "chi_sqr", "max_q", "std-dev" |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
44 }; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
45 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
46 protected static class FitResult { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
47 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
48 protected Parameters parameters; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
49 protected KMIndex<QWD []> referenced; |
3729
e727e3ebdf85
Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3604
diff
changeset
|
50 protected KMIndex<QWI []> outliers; |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
51 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
52 public FitResult() { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
53 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
54 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
55 public FitResult( |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
56 Parameters parameters, |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
57 KMIndex<QWD []> referenced, |
3729
e727e3ebdf85
Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3604
diff
changeset
|
58 KMIndex<QWI []> outliers |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
59 ) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
60 this.parameters = parameters; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
61 this.referenced = referenced; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
62 this.outliers = outliers; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
63 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
64 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
65 public Parameters getParameters() { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
66 return parameters; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
67 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
68 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
69 public KMIndex<QWD []> getReferenced() { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
70 return referenced; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
71 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
72 |
3729
e727e3ebdf85
Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3604
diff
changeset
|
73 public KMIndex<QWI []> getOutliers() { |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
74 return outliers; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
75 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
76 } // class FitResult |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
77 |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
78 /** Helper class to bundle the meta information of a column |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
79 * and the real data. |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
80 */ |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
81 protected static class Column { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
82 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
83 protected Fixing.Column meta; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
84 protected FixingsColumn data; |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
85 protected int index; |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
86 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
87 public Column() { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
88 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
89 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
90 public Column(Fixing.Column meta, FixingsColumn data, int index) { |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
91 this.meta = meta; |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
92 this.data = data; |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
93 this.index = index; |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
94 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
95 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
96 public Date getDate() { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
97 return meta.getStartTime(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
98 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
99 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
100 public String getDescription() { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
101 return meta.getDescription(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
102 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
103 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
104 public int getIndex() { |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
105 return index; |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
106 } |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
107 |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
108 public boolean getQW( |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
109 double km, |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
110 double [] qs, |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
111 double [] ws, |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
112 int index |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
113 ) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
114 qs[index] = data.getQ(km); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
115 return data.getW(km, ws, index); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
116 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
117 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
118 public boolean getQW(double km, double [] wq) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
119 data.getW(km, wq, 0); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
120 if (Double.isNaN(wq[0])) return false; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
121 wq[1] = data.getQ(km); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
122 return !Double.isNaN(wq[1]); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
123 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
124 } // class Column |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
125 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
126 /** |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
127 * Helper class to find the data belonging to meta info more quickly. |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
128 */ |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
129 protected static class ColumnCache { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
130 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
131 protected Map<Integer, Column> columns; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
132 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
133 public ColumnCache() { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
134 columns = new HashMap<Integer, Column>(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
135 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
136 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
137 public Column getColumn(Fixing.Column meta) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
138 Integer key = meta.getId(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
139 Column column = columns.get(key); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
140 if (column == null) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
141 FixingsColumn data = FixingsColumnFactory |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
142 .getInstance() |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
143 .getColumnData(meta); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
144 if (data != null) { |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
145 column = new Column(meta, data, columns.size()); |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
146 columns.put(key, column); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
147 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
148 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
149 return column; |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
150 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
151 } // class ColumnCache |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
152 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
153 |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 protected String river; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 protected double from; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 protected double to; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 protected double step; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 protected boolean preprocessing; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 protected String function; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 protected int [] events; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 protected int qSectorStart; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 protected int qSectorEnd; |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 public FixCalculation() { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 public FixCalculation(FixAccess access) { |
3451
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
168 String river = access.getRiver(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
169 Double from = access.getFrom(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
170 Double to = access.getTo(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
171 Double step = access.getStep(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
172 String function = access.getFunction(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
173 int [] events = access.getEvents(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
174 Integer qSectorStart = access.getQSectorStart(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
175 Integer qSectorEnd = access.getQSectorEnd(); |
b5eec54bd4a2
FixA: Removed some inner whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3437
diff
changeset
|
176 Boolean preprocessing = access.getPreprocessing(); |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 if (river == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 addProblem("fix.missing.river"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 if (from == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 addProblem("fix.missing.from"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 if (to == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
187 addProblem("fix.missing.to"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 if (step == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 addProblem("fix.missing.step"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 if (function == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
195 addProblem("fix.missing.function"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 if (events == null || events.length < 1) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 addProblem("fix.missing.events"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
200 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
202 if (qSectorStart == null) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
203 addProblem("fix.missing.qstart.sector"); |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
204 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
205 |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
206 if (qSectorEnd == null) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
207 addProblem("fix.missing.qend.sector"); |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
208 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
209 |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
210 if (preprocessing == null) { |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
211 addProblem("fix.missing.preprocessing"); |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
212 } |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
213 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
214 if (!hasProblems()) { |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
215 this.river = river; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 this.from = from; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 this.to = to; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
218 this.step = step; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 this.function = function; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 this.events = events; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 this.qSectorStart = qSectorStart; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
222 this.qSectorEnd = qSectorEnd; |
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 this.preprocessing = preprocessing; |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
225 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
226 |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
227 protected static String toString( |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
228 String [] parameterNames, |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
229 double [] values |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
230 ) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
231 StringBuilder sb = new StringBuilder(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
232 for (int i = 0; i < parameterNames.length; ++i) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
233 if (i > 0) sb.append(", "); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
234 sb.append(parameterNames[i]).append(": ").append(values[i]); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
235 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
236 return sb.toString(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
237 } |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
238 |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
239 protected Filter createFilter() { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
240 return new IdsFilter(events); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
241 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
242 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
243 protected List<Column> getEventColumns( |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
244 FixingsOverview overview, |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
245 ColumnCache cc |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
246 ) { |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
247 FixingsColumnFactory fcf = FixingsColumnFactory.getInstance(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
248 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
249 Filter filter = createFilter(); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
250 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
251 List<Fixing.Column> metas = overview.filter(null, filter); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
252 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
253 List<Column> columns = new ArrayList<Column>(metas.size()); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
254 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
255 for (Fixing.Column meta: metas) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
256 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
257 Column data = cc.getColumn(meta); |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
258 if (data == null) { |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
259 addProblem("fix.cannot.load.data"); |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
260 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
261 else { |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
262 columns.add(data); |
3434
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
263 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
264 } |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
265 |
1a636be7612b
FixA: Moved more common calculation code into base class.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3419
diff
changeset
|
266 return columns; |
3419
da7cf0e3ccaa
FixA: Created a common base class for the fixing related calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
267 } |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
268 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
269 protected FitResult doFitting( |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
270 FixingsOverview overview, |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
271 ColumnCache cc, |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
272 Function func |
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
273 ) { |
2792
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2788
diff
changeset
|
274 boolean debug = log.isDebugEnabled(); |
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2788
diff
changeset
|
275 |
3603
d2ae58f6730d
FixA: Use the column cache to establish a consistent index scheme.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3451
diff
changeset
|
276 final List<Column> eventColumns = getEventColumns(overview, cc); |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
277 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
278 if (eventColumns.size() < 2) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
279 addProblem("fix.too.less.data.columns"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
280 return null; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
281 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
282 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
283 final double [] qs = new double[eventColumns.size()]; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
284 final double [] ws = new double[qs.length]; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
285 final boolean [] interpolated = new boolean[ws.length]; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
286 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
287 Fitting.QWDFactory qwdFactory = new Fitting.QWDFactory() { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
288 @Override |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
289 public QWD create(double q, double w) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
290 // Check all the event columns for close match |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
291 // and take the description and the date from meta. |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
292 for (int i = 0; i < qs.length; ++i) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
293 if (Math.abs(qs[i]-q) < EPSILON |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
294 && Math.abs(ws[i]-w) < EPSILON) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
295 Column column = eventColumns.get(i); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
296 return new QWD( |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
297 qs[i], ws[i], |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
298 column.getDescription(), |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
299 column.getDate(), |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
300 interpolated[i], |
3604
2382b26079ac
FixA: Store unique coulun index into QW models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3603
diff
changeset
|
301 0d, |
2382b26079ac
FixA: Store unique coulun index into QW models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3603
diff
changeset
|
302 column.getIndex()); |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
303 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
304 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
305 log.warn("cannot find column for (" + q + ", " + w + ")"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
306 return new QWD(q, w); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
307 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
308 }; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
309 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
310 Fitting fitting = new Fitting(func, qwdFactory, preprocessing); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
311 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
312 String [] parameterNames = func.getParameterNames(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
313 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
314 Parameters results = |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
315 new Parameters( |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
316 StringUtils.join(STANDARD_COLUMNS, parameterNames)); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
317 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
318 boolean invalid = false; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
319 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
320 double [] kms = DoubleUtil.explode(from, to, step / 1000.0); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
321 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
322 if (debug) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
323 log.debug("number of kms: " + kms.length); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
324 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
325 |
3729
e727e3ebdf85
Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3604
diff
changeset
|
326 KMIndex<QWI []> outliers = new KMIndex<QWI []>(); |
3435
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
327 KMIndex<QWD []> referenced = new KMIndex<QWD []>(kms.length); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
328 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
329 int kmIndex = results.columnIndex("km"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
330 int chiSqrIndex = results.columnIndex("chi_sqr"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
331 int maxQIndex = results.columnIndex("max_q"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
332 int stdDevIndex = results.columnIndex("std-dev"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
333 int [] parameterIndices = results.columnIndices(parameterNames); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
334 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
335 int numFailed = 0; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
336 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
337 for (int i = 0; i < kms.length; ++i) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
338 double km = kms[i]; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
339 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
340 // Fill Qs and Ws from event columns. |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
341 for (int j = 0; j < ws.length; ++j) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
342 interpolated[j] = !eventColumns.get(j).getQW(km, qs, ws, j); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
343 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
344 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
345 fitting.reset(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
346 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
347 if (!fitting.fit(qs, ws)) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
348 ++numFailed; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
349 addProblem(km, "fix.fitting.failed"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
350 continue; |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
351 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
352 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
353 referenced.add(km, fitting.referencedToArray()); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
354 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
355 if (fitting.hasOutliers()) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
356 outliers.add(km, fitting.outliersToArray()); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
357 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
358 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
359 int row = results.newRow(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
360 double [] values = fitting.getParameters(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
361 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
362 results.set(row, kmIndex, km); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
363 results.set(row, chiSqrIndex, fitting.getChiSquare()); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
364 results.set(row, stdDevIndex, fitting.getStandardDeviation()); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
365 results.set(row, maxQIndex, fitting.getMaxQ()); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
366 invalid |= results.set(row, parameterIndices, values); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
367 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
368 if (debug) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
369 log.debug("km: "+km+" " + toString(parameterNames, values)); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
370 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
371 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
372 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
373 if (debug) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
374 log.debug("success: " + (kms.length - numFailed)); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
375 log.debug("failed: " + numFailed); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
376 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
377 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
378 if (invalid) { |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
379 addProblem("fix.invalid.values"); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
380 results.removeNaNs(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
381 } |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
382 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
383 outliers.sort(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
384 referenced.sort(); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
385 |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
386 return new FitResult( |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
387 results, |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
388 referenced, |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
389 outliers); |
262e7d7e58fe
FixA: Made curve fitting over the given calculation range reusable. Removed dead code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3434
diff
changeset
|
390 } |
3437
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
391 |
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
392 public CalculationResult calculate() { |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
393 FixingsOverview overview = |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
394 FixingsOverviewFactory.getOverview(river); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
395 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
396 if (overview == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
397 addProblem("fix.no.overview.available"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
398 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
399 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
400 Function func = FunctionFactory.getInstance() |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
401 .getFunction(function); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
402 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
403 if (func == null) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
404 addProblem("fix.invalid.function.name"); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
405 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
406 |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
407 if (hasProblems()) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
408 return new CalculationResult(this); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
409 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
410 |
3437
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
411 return innerCalculate(overview, func); |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
412 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
413 |
3437
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
414 protected abstract CalculationResult innerCalculate( |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
415 FixingsOverview overview, |
3437
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
416 Function function |
e111902834d3
FixA: Made calculation base class abstract. Sub classes are called with fixings overview an function to fit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3435
diff
changeset
|
417 ); |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
418 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
419 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |