Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9256:6c24c857ccf9 | 9257:ef7b65576d4b |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; | 9 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
10 | 10 |
11 import java.util.ArrayList; | 11 //import java.util.ArrayList; |
12 import java.util.List; | 12 //import java.util.List; |
13 | 13 |
14 import org.apache.log4j.Logger; | 14 import org.apache.log4j.Logger; |
15 import org.dive4elements.artifactdatabase.state.DefaultFacet; | 15 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
16 import org.dive4elements.artifactdatabase.state.Facet; | 16 import org.dive4elements.artifactdatabase.state.Facet; |
17 import org.dive4elements.artifacts.Artifact; | 17 import org.dive4elements.artifacts.Artifact; |
18 import org.dive4elements.artifacts.CallContext; | 18 import org.dive4elements.artifacts.CallContext; |
19 import org.dive4elements.river.artifacts.D4EArtifact; | 19 import org.dive4elements.river.artifacts.D4EArtifact; |
20 import org.dive4elements.river.artifacts.model.CalculationResult; | 20 import org.dive4elements.river.artifacts.model.CalculationResult; |
21 import org.dive4elements.river.artifacts.model.WQDay; | 21 //import org.dive4elements.river.artifacts.model.WQDay; |
22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
23 | 23 |
24 | 24 |
25 /** | 25 /** |
26 * Data of a duration curve. | 26 * Data of a duration curve. |
27 */ | 27 */ |
28 public class FloodDurationCurveFacet extends DefaultFacet { | 28 public class FloodDurationCurveFacet extends DefaultFacet { |
29 | 29 |
30 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); | 30 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); |
31 | 31 |
32 /** Blackboard data provider key for durationcurve (wqday) data. */ | 32 // /** Blackboard data provider key for durationcurve (wqday) data. */ |
33 public static String BB_DURATIONCURVE = "durationcurve"; | 33 // public static String BB_DURATIONCURVE = "durationcurve"; |
34 | 34 // |
35 /** Blackboard data provider key for km of durationcurve. */ | 35 // /** Blackboard data provider key for km of durationcurve. */ |
36 public static String BB_DURATIONCURVE_KM = "durationcurve.km"; | 36 // public static String BB_DURATIONCURVE_KM = "durationcurve.km"; |
37 | 37 |
38 public FloodDurationCurveFacet() { | 38 public FloodDurationCurveFacet() { |
39 } | 39 } |
40 | 40 |
41 public FloodDurationCurveFacet(final String name, final String description) { | 41 public FloodDurationCurveFacet(final String name, final String description) { |
59 | 59 |
60 return data.getDurationCurve(); | 60 return data.getDurationCurve(); |
61 // return getTestData(); | 61 // return getTestData(); |
62 } | 62 } |
63 | 63 |
64 private WQDay getTestData() { | 64 // private WQDay getTestData() { |
65 final int[] days = new int[366]; | 65 // final int[] days = new int[366]; |
66 final double[] ws = new double[366]; | 66 // final double[] ws = new double[366]; |
67 final double[] qs = new double[366]; | 67 // final double[] qs = new double[366]; |
68 for (int i = 0; i <= 365; i++) { | 68 // for (int i = 0; i <= 365; i++) { |
69 days[i] = i; | 69 // days[i] = i; |
70 final double x = (i - 182.5) / 182.5; | 70 // final double x = (i - 182.5) / 182.5; |
71 ws[i] = 102.0 - (Math.pow(x, 5) + x); | 71 // ws[i] = 102.0 - (Math.pow(x, 5) + x); |
72 qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); | 72 // qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); |
73 } | 73 // } |
74 return new WQDay(days, ws, qs); | 74 // return new WQDay(days, ws, qs); |
75 } | 75 // } |
76 | 76 |
77 | 77 |
78 @Override | 78 // @Override |
79 public List getStaticDataProviderKeys(final Artifact art) { | 79 // public List getStaticDataProviderKeys(final Artifact art) { |
80 final List list = new ArrayList(); | 80 // final List list = new ArrayList(); |
81 list.add(BB_DURATIONCURVE); | 81 // list.add(BB_DURATIONCURVE); |
82 list.add(BB_DURATIONCURVE_KM); | 82 // list.add(BB_DURATIONCURVE_KM); |
83 return list; | 83 // return list; |
84 } | 84 // } |
85 | 85 |
86 | 86 |
87 /** | 87 // /** |
88 * Can provide whatever getData returns and additionally the location. | 88 // * Can provide whatever getData returns and additionally the location. |
89 * @param key will respond on BB_DURATIONCURVE +KM | 89 // * @param key will respond on BB_DURATIONCURVE +KM |
90 * @param param ignored | 90 // * @param param ignored |
91 * @param context ignored | 91 // * @param context ignored |
92 * @return whatever getData delivers or location. | 92 // * @return whatever getData delivers or location. |
93 */ | 93 // */ |
94 @Override | 94 // @Override |
95 public Object provideBlackboardData(final Artifact artifact, | 95 // public Object provideBlackboardData(final Artifact artifact, |
96 final Object key, | 96 // final Object key, |
97 final Object param, | 97 // final Object param, |
98 final CallContext context | 98 // final CallContext context |
99 ) { | 99 // ) { |
100 if (key.equals(BB_DURATIONCURVE)) { | 100 // if (key.equals(BB_DURATIONCURVE)) { |
101 return getData(artifact, context); | 101 // return getData(artifact, context); |
102 } | 102 // } |
103 else if (key.equals(BB_DURATIONCURVE_KM)) { | 103 // else if (key.equals(BB_DURATIONCURVE_KM)) { |
104 return ((D4EArtifact)artifact).getDataAsString("ld_locations"); | 104 // return ((D4EArtifact)artifact).getDataAsString("ld_locations"); |
105 } | 105 // } |
106 else { | 106 // else { |
107 return null; | 107 // return null; |
108 } | 108 // } |
109 } | 109 // } |
110 | 110 |
111 | 111 |
112 /** Create a deep copy. */ | 112 /** Create a deep copy. */ |
113 @Override | 113 @Override |
114 public Facet deepCopy() { | 114 public Facet deepCopy() { |