Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8238:be3c11bef6e8
(issue1448) Finally use the sq time interval as filter in the calculation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 08 Sep 2014 19:01:26 +0200 |
parents | ebdf34cae14d |
children | b207eeb66edd |
comparison
equal
deleted
inserted
replaced
8237:25c3a62863d2 | 8238:be3c11bef6e8 |
---|---|
22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station; | 22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station; |
23 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And; | 23 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And; |
24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch; | 24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch; |
25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial; | 25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial; |
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not; | 26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not; |
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval; | |
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects; | 28 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects; |
28 import org.dive4elements.river.utils.DoubleUtil; | 29 import org.dive4elements.river.utils.DoubleUtil; |
29 | 30 |
30 public class SedimentLoadDataCalculation | 31 public class SedimentLoadDataCalculation |
31 extends Calculation | 32 extends Calculation |
149 private String unit; | 150 private String unit; |
150 private int [][] epochs; | 151 private int [][] epochs; |
151 private int [] years; | 152 private int [] years; |
152 private double from; | 153 private double from; |
153 private double to; | 154 private double to; |
155 /* The sq time interval to use. 0 means this is ignored. */ | |
156 private int sqTiId; | |
154 | 157 |
155 | 158 |
156 public SedimentLoadDataCalculation() { | 159 public SedimentLoadDataCalculation() { |
157 } | 160 } |
158 | 161 |
166 int [] years = null; | 169 int [] years = null; |
167 int [][] epochs = null; | 170 int [][] epochs = null; |
168 | 171 |
169 double from = access.getLowerKM(); | 172 double from = access.getLowerKM(); |
170 double to = access.getUpperKM(); | 173 double to = access.getUpperKM(); |
174 | |
175 int sqTiId = access.getSQTiId(); | |
171 | 176 |
172 if (yearEpoch.equals("year")) { | 177 if (yearEpoch.equals("year")) { |
173 years = access.getPeriod(); | 178 years = access.getPeriod(); |
174 } | 179 } |
175 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { | 180 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { |
194 this.unit = unit; | 199 this.unit = unit; |
195 this.years = years; | 200 this.years = years; |
196 this.epochs = epochs; | 201 this.epochs = epochs; |
197 this.from = from; | 202 this.from = from; |
198 this.to = to; | 203 this.to = to; |
204 this.sqTiId = sqTiId; | |
199 return internalCalculate(); | 205 return internalCalculate(); |
200 } | 206 } |
201 | 207 |
202 return error(null); | 208 return error(null); |
203 } | 209 } |
225 | 231 |
226 SedimentLoadDataResult sldr = new SedimentLoadDataResult(); | 232 SedimentLoadDataResult sldr = new SedimentLoadDataResult(); |
227 | 233 |
228 Not notEpochs = new Not(IsEpoch.INSTANCE); | 234 Not notEpochs = new Not(IsEpoch.INSTANCE); |
229 | 235 |
236 SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId); | |
237 | |
230 Sum sum = new Sum(); | 238 Sum sum = new Sum(); |
231 | 239 |
232 SedimentDensity sd = getSedimentDensity(); | 240 SedimentDensity sd = getSedimentDensity(); |
233 | 241 |
234 int min = Math.min(years[0], years[1]); | 242 int min = Math.min(years[0], years[1]); |
235 int max = Math.max(years[0], years[1]); | 243 int max = Math.max(years[0], years[1]); |
236 | 244 |
237 for (int year = min; year <= max; ++year) { | 245 for (int year = min; year <= max; ++year) { |
238 Value.Filter filter = new And(notEpochs) | 246 Value.Filter filter = new And(notEpochs) |
239 .add(new TimeRangeIntersects(year)); | 247 .add(new TimeRangeIntersects(year)).add(sqTiFilter); |
240 String period = Integer.toString(year); | 248 String period = Integer.toString(year); |
241 | 249 |
242 for (LoadSum ls: LOAD_SUMS) { | 250 for (LoadSum ls: LOAD_SUMS) { |
243 | 251 |
244 double [][] result = sum( | 252 double [][] result = sum( |
276 SedimentDensity sd = getSedimentDensity(); | 284 SedimentDensity sd = getSedimentDensity(); |
277 | 285 |
278 // They are not epochs, they are single years! | 286 // They are not epochs, they are single years! |
279 Not notEpochs = new Not(IsEpoch.INSTANCE); | 287 Not notEpochs = new Not(IsEpoch.INSTANCE); |
280 | 288 |
289 SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId); | |
290 | |
281 for (int [] epoch: epochs) { | 291 for (int [] epoch: epochs) { |
282 int min = Math.min(epoch[0], epoch[1]); | 292 int min = Math.min(epoch[0], epoch[1]); |
283 int max = Math.max(epoch[0], epoch[1]); | 293 int max = Math.max(epoch[0], epoch[1]); |
284 | 294 |
285 String period = Integer.toString(epoch[0]) + " - " + | 295 String period = Integer.toString(epoch[0]) + " - " + |
289 | 299 |
290 List<double [][]> results = new ArrayList<double [][]>(); | 300 List<double [][]> results = new ArrayList<double [][]>(); |
291 | 301 |
292 for (int year = min; year <= max; ++year) { | 302 for (int year = min; year <= max; ++year) { |
293 Value.Filter filter = new And(notEpochs) | 303 Value.Filter filter = new And(notEpochs) |
294 .add(new TimeRangeIntersects(year)); | 304 .add(new TimeRangeIntersects(year)).add(sqTiFilter); |
295 | 305 |
296 double [][] result = sum( | 306 double [][] result = sum( |
297 sld, ls.getGrainFractions(), ls.getStationType(), | 307 sld, ls.getGrainFractions(), ls.getStationType(), |
298 filter, sum); | 308 filter, sum); |
299 | 309 |