Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java @ 6999:3e93f29281bc
Fix for flys/issue1479: The indices of the dates of the analysis periods where re-mapped wrong.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 12 Sep 2013 16:35:07 +0200 |
parents | 8efef772a488 |
children | 6650485c2c9b |
comparison
equal
deleted
inserted
replaced
6998:e96d3f6c7c42 | 6999:3e93f29281bc |
---|---|
124 | 124 |
125 protected KMIndex<AnalysisPeriod []> calculateAnalysisPeriods( | 125 protected KMIndex<AnalysisPeriod []> calculateAnalysisPeriods( |
126 Function function, | 126 Function function, |
127 Parameters parameters, | 127 Parameters parameters, |
128 FixingsOverview overview, | 128 FixingsOverview overview, |
129 ColumnCache cc | 129 ColumnCache cc |
130 ) { | 130 ) { |
131 Range range = new Range(from, to); | 131 Range range = new Range(from, to); |
132 | 132 |
133 int kmIndex = parameters.columnIndex("km"); | 133 int kmIndex = parameters.columnIndex("km"); |
134 int maxQIndex = parameters.columnIndex("max_q"); | 134 int maxQIndex = parameters.columnIndex("max_q"); |
148 IdsFilter idsFilter = new IdsFilter(events); | 148 IdsFilter idsFilter = new IdsFilter(events); |
149 | 149 |
150 TIntIntHashMap [] col2indices = | 150 TIntIntHashMap [] col2indices = |
151 new TIntIntHashMap[analysisPeriods.length]; | 151 new TIntIntHashMap[analysisPeriods.length]; |
152 | 152 |
153 DateRangeFilter [] drfs = new DateRangeFilter[analysisPeriods.length]; | |
154 | |
155 boolean debug = log.isDebugEnabled(); | |
156 | |
153 for (int i = 0; i < analysisPeriods.length; ++i) { | 157 for (int i = 0; i < analysisPeriods.length; ++i) { |
154 col2indices[i] = new TIntIntHashMap(); | 158 col2indices[i] = new TIntIntHashMap(); |
159 drfs[i] = new DateRangeFilter( | |
160 analysisPeriods[i].getFrom(), | |
161 analysisPeriods[i].getTo()); | |
162 | |
163 if (debug) { | |
164 log.debug("Analysis period " + (i+1) + " date range: " + | |
165 analysisPeriods[i].getFrom() + " - " + | |
166 analysisPeriods[i].getTo()); | |
167 } | |
155 } | 168 } |
156 | 169 |
157 for (int row = 0, R = parameters.size(); row < R; ++row) { | 170 for (int row = 0, R = parameters.size(); row < R; ++row) { |
158 double km = parameters.get(row, kmIndex); | 171 double km = parameters.get(row, kmIndex); |
159 parameters.get(row, parameterIndices, parameterValues); | 172 parameters.get(row, parameterIndices, parameterValues); |
160 | 173 |
161 // This is the paraterized function for a given km. | 174 // This is the parameterized function for a given km. |
162 org.dive4elements.river.artifacts.math.Function instance = | 175 org.dive4elements.river.artifacts.math.Function instance = |
163 function.instantiate(parameterValues); | 176 function.instantiate(parameterValues); |
164 | 177 |
165 KmFilter kmFilter = new KmFilter(km); | 178 KmFilter kmFilter = new KmFilter(km); |
166 | 179 |
169 | 182 |
170 for (int ap = 0; ap < analysisPeriods.length; ++ap) { | 183 for (int ap = 0; ap < analysisPeriods.length; ++ap) { |
171 DateRange analysisPeriod = analysisPeriods[ap]; | 184 DateRange analysisPeriod = analysisPeriods[ap]; |
172 TIntIntHashMap col2index = col2indices[ap]; | 185 TIntIntHashMap col2index = col2indices[ap]; |
173 | 186 |
174 DateRangeFilter drf = new DateRangeFilter( | 187 DateRangeFilter drf = drfs[ap]; |
175 analysisPeriod.getFrom(), | |
176 analysisPeriod.getTo()); | |
177 | 188 |
178 QWD [] qSectorAverages = new QWD[4]; | 189 QWD [] qSectorAverages = new QWD[4]; |
179 double [] qSectorStdDevs = new double[4]; | 190 double [] qSectorStdDevs = new double[4]; |
180 | 191 |
181 ArrayList<QWD> allQWDs = new ArrayList<QWD>(); | 192 ArrayList<QWD> allQWDs = new ArrayList<QWD>(); |
289 double oldMaxQ = parameters.get(row, maxQIndex); | 300 double oldMaxQ = parameters.get(row, maxQIndex); |
290 if (oldMaxQ < maxQ) { | 301 if (oldMaxQ < maxQ) { |
291 parameters.set(row, maxQIndex, maxQ); | 302 parameters.set(row, maxQIndex, maxQ); |
292 } | 303 } |
293 | 304 |
294 results.add(km, periodResults.toArray( | 305 AnalysisPeriod [] rap = new AnalysisPeriod[periodResults.size()]; |
295 new AnalysisPeriod[periodResults.size()])); | 306 periodResults.toArray(rap); |
307 results.add(km, rap); | |
296 } | 308 } |
297 | 309 |
298 return results; | 310 return results; |
299 } | 311 } |
300 | 312 |