annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixResult.java @ 6891:8efef772a488

FixA: Remapped indices of analysis periods, too. Needs testing!
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 21 Aug 2013 15:41:58 +0200
parents 2d96d8240e3e
children a3f318347707 0a5239a1e46e
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3729
diff changeset
9 package org.dive4elements.river.artifacts.model.fixings;
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
11 import org.apache.log4j.Logger;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3729
diff changeset
12 import org.dive4elements.river.artifacts.model.Parameters;
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3729
diff changeset
14 import org.dive4elements.river.utils.KMIndex;
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import java.io.Serializable;
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
17 import java.util.Collection;
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
18 import java.util.Date;
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
19 import java.util.TreeMap;
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
20 import java.util.TreeSet;
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 public class FixResult
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 implements Serializable
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 {
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
25 private static Logger log =
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
26 Logger.getLogger(FixResult.class);
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
27
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 protected Parameters parameters;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 protected KMIndex<QWD []> referenced;
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3450
diff changeset
30 protected KMIndex<QWI []> outliers;
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 public FixResult() {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 public FixResult(
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 Parameters parameters,
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 KMIndex<QWD []> referenced,
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3450
diff changeset
38 KMIndex<QWI []> outliers
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 ) {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 this.parameters = parameters;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 this.referenced = referenced;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 this.outliers = outliers;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 public KMIndex<QWD []> getReferenced() {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 return referenced;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 public void setReferenced(KMIndex<QWD []> referenced) {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 this.referenced = referenced;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
53 public void makeReferenceEventsDatesUnique() {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
54 DateUniqueMaker dum = new DateUniqueMaker();
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
55 for (KMIndex.Entry<QWD []> entry: referenced) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
56 for (QWD ref: entry.getValue()) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
57 dum.makeUnique(ref);
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
58 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
59 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
60 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
61
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
62 public Collection<Integer> getReferenceEventsIndices() {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
63 TreeMap<Date, Integer> dates = new TreeMap<Date, Integer>();
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
64 for (KMIndex.Entry<QWD []> entry: referenced) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
65 for (QWD value: entry.getValue()) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
66 dates.put(value.date, value.index);
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
67 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
68 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
69 return dates.values();
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
70 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
71
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
72 public void remapReferenceIndicesToRank() {
6891
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6877
diff changeset
73 RankRemapper remapper = new RankRemapper();
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6877
diff changeset
74 for (Integer idx: getReferenceEventsIndices()) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6877
diff changeset
75 remapper.toMap(idx);
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
76 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
77 for (KMIndex.Entry<QWD []> entry: referenced) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
78 for (QWD value: entry.getValue()) {
6891
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6877
diff changeset
79 remapper.remap(value);
6877
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
80 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
81 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
82 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
83
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
84 public Collection<Date> getReferenceEventsDates() {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
85 TreeSet<Date> dates = new TreeSet<Date>();
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
86 for (KMIndex.Entry<QWD []> entry: referenced) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
87 for (QWD qwd: entry.getValue()) {
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
88 dates.add(qwd.date);
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
89 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
90 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
91 return dates;
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
92 }
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
93
2d96d8240e3e FixA: Make dates of analysis periods unique, too. TODO: Remap the indices like the reference interval.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
94
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3450
diff changeset
95 public KMIndex<QWI []> getOutliers() {
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 return outliers;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98
3729
e727e3ebdf85 Factored out a pure QW model to be more reusable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3450
diff changeset
99 public void setOutliers(KMIndex<QWI []> outliers) {
3450
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 this.outliers = outliers;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 public Parameters getParameters() {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 return parameters;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 public void setParameters(Parameters parameters) {
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 this.parameters = parameters;
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
22790758b132 FixA/Vollmer: return the result now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org