Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java @ 9257:ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Fri, 13 Jul 2018 18:38:05 +0200 |
parents | c2a0028bfa9f |
children | e5367900dd6d |
rev | line source |
---|---|
9252 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; | |
10 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
11 //import java.util.ArrayList; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
12 //import java.util.List; |
9252 | 13 |
14 import org.apache.log4j.Logger; | |
15 import org.dive4elements.artifactdatabase.state.DefaultFacet; | |
16 import org.dive4elements.artifactdatabase.state.Facet; | |
17 import org.dive4elements.artifacts.Artifact; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.river.artifacts.D4EArtifact; | |
20 import org.dive4elements.river.artifacts.model.CalculationResult; | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
21 //import org.dive4elements.river.artifacts.model.WQDay; |
9252 | 22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
23 | |
24 | |
25 /** | |
26 * Data of a duration curve. | |
27 */ | |
28 public class FloodDurationCurveFacet extends DefaultFacet { | |
29 | |
30 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); | |
31 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
32 // /** Blackboard data provider key for durationcurve (wqday) data. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
33 // public static String BB_DURATIONCURVE = "durationcurve"; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
34 // |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
35 // /** Blackboard data provider key for km of durationcurve. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
36 // public static String BB_DURATIONCURVE_KM = "durationcurve.km"; |
9252 | 37 |
38 public FloodDurationCurveFacet() { | |
39 } | |
40 | |
41 public FloodDurationCurveFacet(final String name, final String description) { | |
42 super(0, name, description); | |
43 } | |
44 | |
45 | |
46 /** | |
47 * Expose state computation from SINFOArtifact. | |
48 */ | |
49 @Override | |
50 public Object getData(final Artifact artifact, final CallContext context) { | |
51 | |
52 log.debug("Get data for flood duration curve data"); | |
53 | |
54 final D4EArtifact flys = (D4EArtifact) artifact; | |
55 | |
56 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | |
57 | |
58 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | |
59 | |
60 return data.getDurationCurve(); | |
61 // return getTestData(); | |
62 } | |
63 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
64 // private WQDay getTestData() { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
65 // final int[] days = new int[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
66 // final double[] ws = new double[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
67 // final double[] qs = new double[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
68 // for (int i = 0; i <= 365; i++) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
69 // days[i] = i; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
70 // final double x = (i - 182.5) / 182.5; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
71 // ws[i] = 102.0 - (Math.pow(x, 5) + x); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
72 // qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
73 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
74 // return new WQDay(days, ws, qs); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
75 // } |
9252 | 76 |
77 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
78 // @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
79 // public List getStaticDataProviderKeys(final Artifact art) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
80 // final List list = new ArrayList(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
81 // list.add(BB_DURATIONCURVE); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
82 // list.add(BB_DURATIONCURVE_KM); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
83 // return list; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
84 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
85 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
86 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
87 // /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
88 // * Can provide whatever getData returns and additionally the location. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
89 // * @param key will respond on BB_DURATIONCURVE +KM |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
90 // * @param param ignored |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
91 // * @param context ignored |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
92 // * @return whatever getData delivers or location. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
93 // */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
94 // @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
95 // public Object provideBlackboardData(final Artifact artifact, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
96 // final Object key, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
97 // final Object param, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
98 // final CallContext context |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
99 // ) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
100 // if (key.equals(BB_DURATIONCURVE)) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
101 // return getData(artifact, context); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
102 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
103 // else if (key.equals(BB_DURATIONCURVE_KM)) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
104 // return ((D4EArtifact)artifact).getDataAsString("ld_locations"); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
105 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
106 // else { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
107 // return null; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
108 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
109 // } |
9252 | 110 |
111 | |
112 /** Create a deep copy. */ | |
113 @Override | |
114 public Facet deepCopy() { | |
115 final FloodDurationCurveFacet copy = new FloodDurationCurveFacet(); | |
116 copy.set(this); | |
117 return copy; | |
118 } | |
119 } | |
120 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |