Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/SQRelation.java @ 3552:1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
store the curve coefficients for each iteration step
of the outlier elimination.
flys-artifacts/trunk@5146 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 27 Jul 2012 12:36:09 +0000 |
parents | 0f7abd95c6e2 |
children | f9f266504f1d |
comparison
equal
deleted
inserted
replaced
3551:e7f1556192b3 | 3552:1df6984628c3 |
---|---|
14 import de.intevation.flys.artifacts.model.FacetTypes; | 14 import de.intevation.flys.artifacts.model.FacetTypes; |
15 | 15 |
16 import de.intevation.flys.artifacts.model.sq.SQCurveFacet; | 16 import de.intevation.flys.artifacts.model.sq.SQCurveFacet; |
17 import de.intevation.flys.artifacts.model.sq.SQFractionResult; | 17 import de.intevation.flys.artifacts.model.sq.SQFractionResult; |
18 import de.intevation.flys.artifacts.model.sq.SQMeasurementFacet; | 18 import de.intevation.flys.artifacts.model.sq.SQMeasurementFacet; |
19 import de.intevation.flys.artifacts.model.sq.SQOutlierCurveFacet; | |
19 import de.intevation.flys.artifacts.model.sq.SQOutlierFacet; | 20 import de.intevation.flys.artifacts.model.sq.SQOutlierFacet; |
21 import de.intevation.flys.artifacts.model.sq.SQOutlierMeasurementFacet; | |
22 import de.intevation.flys.artifacts.model.sq.SQOverviewFacet; | |
20 import de.intevation.flys.artifacts.model.sq.SQRelationCalculation; | 23 import de.intevation.flys.artifacts.model.sq.SQRelationCalculation; |
21 import de.intevation.flys.artifacts.model.sq.SQResult; | 24 import de.intevation.flys.artifacts.model.sq.SQResult; |
22 import de.intevation.flys.artifacts.model.sq.SQOverviewFacet; | |
23 | 25 |
24 import de.intevation.flys.artifacts.resources.Resources; | 26 import de.intevation.flys.artifacts.resources.Resources; |
25 | 27 |
26 import java.util.List; | 28 import java.util.List; |
27 | 29 |
42 "facet.sq_relation.measurements"; | 44 "facet.sq_relation.measurements"; |
43 | 45 |
44 public static final String I18N_FACET_OUTLIERS = | 46 public static final String I18N_FACET_OUTLIERS = |
45 "facet.sq_relation.outliers"; | 47 "facet.sq_relation.outliers"; |
46 | 48 |
49 public static final String I18N_FACET_OUTLIER_CURVE = | |
50 "facet.sq_relation.outlier.curve"; | |
51 | |
52 public static final String I18N_FACET_OUTLIER_MEASUREMENT = | |
53 "facet.sq_relation.outlier.measurement"; | |
47 | 54 |
48 public SQRelation() { | 55 public SQRelation() { |
49 } | 56 } |
50 | 57 |
51 | 58 |
92 CallContext context, | 99 CallContext context, |
93 List<Facet> container, | 100 List<Facet> container, |
94 SQResult[] sqr, | 101 SQResult[] sqr, |
95 String hash | 102 String hash |
96 ) { | 103 ) { |
104 boolean debug = log.isDebugEnabled(); | |
105 | |
97 CallMeta meta = context.getMeta(); | 106 CallMeta meta = context.getMeta(); |
98 String stateId = getID(); | 107 String stateId = getID(); |
99 for (int i = 0; i < 6; i++) { | 108 for (int i = 0; i < 6; i++) { |
100 container.add(new SQOverviewFacet( | 109 container.add(new SQOverviewFacet( |
101 i, | 110 i, |
110 getID() | 119 getID() |
111 )); | 120 )); |
112 } | 121 } |
113 for (int res = 0, n = sqr.length; res < n; res++) { | 122 for (int res = 0, n = sqr.length; res < n; res++) { |
114 | 123 |
115 for (int i = 0; i < 6; i++) { | 124 for (int i = 0; i < SQResult.NUMBER_FRACTIONS; i++) { |
116 SQFractionResult result = sqr[res].getFraction(i); | 125 SQFractionResult result = sqr[res].getFraction(i); |
117 | 126 |
118 if (result == null) { | 127 if (result == null) { |
119 log.warn("Fraction at index " + i + " is empty!"); | 128 log.warn("Fraction at index " + i + " is empty!"); |
120 continue; | 129 continue; |
121 } | 130 } |
131 | |
132 container.add(new SQCurveFacet( | |
133 res, | |
134 i, | |
135 getFractionFacetname(0, i), | |
136 Resources.getMsg( | |
137 meta, | |
138 I18N_FACET_CURVE, | |
139 I18N_FACET_CURVE | |
140 ), | |
141 hash, | |
142 stateId | |
143 )); | |
144 | |
145 for (int j = 0, C = result.numIterations()-1; j < C; j++) { | |
146 | |
147 Object [] round = new Object [] { j + 1 }; | |
148 | |
149 int index = res; | |
150 index = index << 16; | |
151 index = index + j; | |
152 | |
153 if (debug) { | |
154 log.debug("new outliers facet (index=" +index+ ")"); | |
155 log.debug(" result index = " + res); | |
156 log.debug(" fraction idx = " + i); | |
157 log.debug(" iteration = " + j); | |
158 } | |
159 | |
160 container.add(new SQOutlierFacet( | |
161 index, | |
162 i, | |
163 getFractionFacetname(2, i), | |
164 Resources.getMsg( | |
165 meta, | |
166 I18N_FACET_OUTLIERS, | |
167 I18N_FACET_OUTLIERS, | |
168 round | |
169 ), | |
170 hash, | |
171 stateId | |
172 )); | |
173 | |
174 container.add(new SQOutlierCurveFacet( | |
175 index, | |
176 i, | |
177 getFractionFacetname(3, i), | |
178 Resources.getMsg( | |
179 meta, | |
180 I18N_FACET_OUTLIER_CURVE, | |
181 I18N_FACET_OUTLIER_CURVE, | |
182 round | |
183 ), | |
184 hash, | |
185 stateId | |
186 )); | |
187 | |
188 container.add(new SQOutlierMeasurementFacet( | |
189 index, | |
190 i, | |
191 getFractionFacetname(4, i), | |
192 Resources.getMsg( | |
193 meta, | |
194 I18N_FACET_OUTLIER_MEASUREMENT, | |
195 I18N_FACET_OUTLIER_MEASUREMENT, | |
196 round | |
197 ), | |
198 hash, | |
199 stateId | |
200 )); | |
201 } // for all outliers | |
122 | 202 |
123 container.add(new SQMeasurementFacet( | 203 container.add(new SQMeasurementFacet( |
124 res, | 204 res, |
125 i, | 205 i, |
126 getFractionFacetname(1, i), | 206 getFractionFacetname(1, i), |
130 I18N_FACET_MEASUREMENTS | 210 I18N_FACET_MEASUREMENTS |
131 ), | 211 ), |
132 hash, | 212 hash, |
133 stateId | 213 stateId |
134 )); | 214 )); |
135 | 215 } // for all fractions |
136 container.add(new SQCurveFacet( | 216 } // for all results |
137 res, | 217 } |
138 i, | 218 |
139 getFractionFacetname(0, i), | 219 public static final String [][] FACET_NAMES = { |
140 Resources.getMsg( | 220 { SQ_A_CURVE, SQ_B_CURVE, SQ_C_CURVE, |
141 meta, | 221 SQ_D_CURVE, SQ_E_CURVE, SQ_F_CURVE |
142 I18N_FACET_CURVE, | 222 }, |
143 I18N_FACET_CURVE | 223 { SQ_A_MEASUREMENT, SQ_B_MEASUREMENT, SQ_C_MEASUREMENT, |
144 ), | 224 SQ_D_MEASUREMENT, SQ_E_MEASUREMENT, SQ_F_MEASUREMENT |
145 hash, | 225 }, |
146 stateId | 226 { SQ_A_OUTLIER, SQ_B_OUTLIER, SQ_C_OUTLIER, |
147 )); | 227 SQ_D_OUTLIER, SQ_E_OUTLIER, SQ_F_OUTLIER |
148 | 228 }, |
149 for (int j = 0, C = result.getOutliersCount(); j < C; j++) { | 229 { SQ_A_OUTLIER_CURVE, SQ_B_OUTLIER_CURVE, SQ_C_OUTLIER_CURVE, |
150 int index = res; | 230 SQ_D_OUTLIER_CURVE, SQ_E_OUTLIER_CURVE, SQ_F_OUTLIER_CURVE |
151 index = index << 16; | 231 }, |
152 index = index + j; | 232 { SQ_A_OUTLIER_MEASUREMENT, SQ_B_OUTLIER_MEASUREMENT, |
153 | 233 SQ_C_OUTLIER_MEASUREMENT, SQ_D_OUTLIER_MEASUREMENT, |
154 if (log.isDebugEnabled()) { | 234 SQ_E_OUTLIER_MEASUREMENT, SQ_F_OUTLIER_MEASUREMENT |
155 log.debug("new outliers facet (index=" +index+ ")"); | 235 } |
156 log.debug(" result index = " + res); | 236 }; |
157 log.debug(" fraction idx = " + i); | 237 |
158 log.debug(" iteration = " + j); | 238 |
159 } | 239 protected static String getFractionFacetname(int type, int idx) { |
160 | 240 if (log.isDebugEnabled()) { |
161 container.add(new SQOutlierFacet( | 241 log.debug("getFractionFacetname(): " + type + " | " + idx); |
162 index, | 242 } |
163 i, | 243 type %= FACET_NAMES.length; |
164 getFractionFacetname(2, i), | 244 return FACET_NAMES[type][idx % FACET_NAMES[type].length]; |
165 Resources.getMsg( | |
166 meta, | |
167 I18N_FACET_OUTLIERS, | |
168 I18N_FACET_OUTLIERS, | |
169 new Object[] { j } | |
170 ), | |
171 hash, | |
172 stateId | |
173 )); | |
174 } | |
175 } | |
176 } | |
177 } | |
178 | |
179 | |
180 protected String getFractionFacetname(int type, int fractionIdx) { | |
181 log.debug("getFractionFacetname(): " + type + " | " + fractionIdx); | |
182 | |
183 switch (type) { | |
184 case 0: | |
185 switch (fractionIdx) { | |
186 case 0: return SQ_A_CURVE; | |
187 case 1: return SQ_B_CURVE; | |
188 case 2: return SQ_C_CURVE; | |
189 case 3: return SQ_D_CURVE; | |
190 case 4: return SQ_E_CURVE; | |
191 case 5: return SQ_F_CURVE; | |
192 } | |
193 case 1: | |
194 switch (fractionIdx) { | |
195 case 0: return SQ_A_MEASUREMENT; | |
196 case 1: return SQ_B_MEASUREMENT; | |
197 case 2: return SQ_C_MEASUREMENT; | |
198 case 3: return SQ_D_MEASUREMENT; | |
199 case 4: return SQ_E_MEASUREMENT; | |
200 case 5: return SQ_F_MEASUREMENT; | |
201 } | |
202 case 2: | |
203 switch (fractionIdx) { | |
204 case 0: return SQ_A_OUTLIER; | |
205 case 1: return SQ_B_OUTLIER; | |
206 case 2: return SQ_C_OUTLIER; | |
207 case 3: return SQ_D_OUTLIER; | |
208 case 4: return SQ_E_OUTLIER; | |
209 case 5: return SQ_F_OUTLIER; | |
210 } | |
211 } | |
212 | |
213 return null; | |
214 } | 245 } |
215 } | 246 } |
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 247 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |