Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java @ 3643:171db4d5d3cb
FixA: AT export: prevent some numerical problems with steep functions around zero.
flys-artifacts/trunk@5363 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 05 Sep 2012 08:38:12 +0000 |
parents | e3c7a3228bc2 |
children | 26774405c884 |
rev | line source |
---|---|
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.fixings; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.Artifact; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.artifacts.CallContext; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.flys.artifacts.FLYSArtifact; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3210
diff
changeset
|
8 import de.intevation.flys.artifacts.access.FixAnalysisAccess; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
9 |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
10 import de.intevation.flys.artifacts.model.CalculationResult; |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
11 import de.intevation.flys.artifacts.model.DataFacet; |
3210
ae14f412ba10
SQ: finished the access stuff.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3203
diff
changeset
|
12 import de.intevation.flys.artifacts.model.DateRange; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.model.FacetTypes; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
17 import de.intevation.flys.utils.KMIndex; |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
18 |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3088
diff
changeset
|
19 import org.apache.log4j.Logger; |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 * Facet to show W values for Q values at km for a date. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 * |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 public class FixAnalysisPeriodsFacet |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 extends DataFacet |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 implements FacetTypes { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 /** House logger. */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 private static Logger logger = Logger.getLogger(FixAnalysisPeriodsFacet.class); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 /** Trivial Constructor. */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 public FixAnalysisPeriodsFacet() { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 * @param name |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 */ |
3043
22da13d1b180
Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3039
diff
changeset
|
41 public FixAnalysisPeriodsFacet(int index, String name, String description) { |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 super(index, |
3043
22da13d1b180
Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3039
diff
changeset
|
43 name, |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 description, |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 ComputeType.ADVANCE, |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 null, |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 null); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 * Returns the data this facet requires. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 * |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 * @param artifact the owner artifact. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 * @param context the CallContext (ignored). |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 * |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 * @return the data. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 @Override |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 public Object getData(Artifact artifact, CallContext context) { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 logger.debug("FixAnalysisPeriodsFacet.getData"); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 if (artifact instanceof FLYSArtifact) { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 FLYSArtifact flys = (FLYSArtifact)artifact; |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3210
diff
changeset
|
65 FixAnalysisAccess access = new FixAnalysisAccess(flys); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 CalculationResult res = |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 (CalculationResult) flys.compute(context, |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 ComputeType.ADVANCE, |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 false); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 |
3415
e3c7a3228bc2
FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3408
diff
changeset
|
72 FixAnalysisResult result = (FixAnalysisResult) res.getData(); |
3088
960307cf2adc
Moved current km to context and added an abstract generator for fix analysis
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3080
diff
changeset
|
73 double currentKm = |
960307cf2adc
Moved current km to context and added an abstract generator for fix analysis
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3080
diff
changeset
|
74 ((Double)context.getContextValue("currentKm")).doubleValue(); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3062
diff
changeset
|
77 KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry = |
3080
dc2765e31e1f
Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3076
diff
changeset
|
78 kmPeriods.binarySearch(currentKm); |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
79 |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
80 if (kmPeriodsEntry == null) { |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
81 return null; |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
82 } |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
83 |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
84 AnalysisPeriod[] periods = kmPeriodsEntry.getValue(); |
3039
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 if (periods == null) { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 return null; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 DateRange[] dates = new DateRange[periods.length]; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 for (int i = 0; i < periods.length; i++) { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 dates[i] = periods[i].getDateRange(); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 return dates; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 else { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 logger.debug("Not an instance of FixationArtifact."); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 return null; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 /** |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 * Create a deep copy of this Facet. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 * @return a deep copy. |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 */ |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 @Override |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 public FixAnalysisPeriodsFacet deepCopy() { |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 FixAnalysisPeriodsFacet copy = new FixAnalysisPeriodsFacet(); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 copy.set(this); |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 return copy; |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 } |
7db919b1bc1e
Added new facet for analysis periods and updated facet names in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |