annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 2758:b05faaa9099b

Create points for ref.curve in facet, handle these in generator. flys-artifacts/trunk@4493 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 24 May 2012 04:41:57 +0000
parents c1f2e792704a
children f87fcedbfa82
rev   line source
2695
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import gnu.trove.TDoubleArrayList;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.io.Serializable;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 public class Parameters
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 implements Serializable
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 protected String [] columnNames;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 protected TDoubleArrayList [] columns;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 public Parameters() {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 public Parameters(String [] columnNames) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 if (columnNames == null || columnNames.length < 1) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 throw new IllegalArgumentException("columnNames too short.");
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 this.columnNames = columnNames;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 columns = new TDoubleArrayList[columnNames.length];
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 for (int i = 0; i < columns.length; ++i) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 columns[i] = new TDoubleArrayList();
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public int columnIndex(String name) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 for (int i = 0; i < columnNames.length; ++i) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 if (name.equals(name)) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 return i;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 return -1;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
2729
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
36 public int newRow() {
2695
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 int N = columns[0].size();
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 for (int i = 0; i < columns.length; ++i) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 columns[i].add(Double.NaN);
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
2729
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
44 return N;
2695
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 public double get(int i, int index) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 return columns[index].getQuick(i);
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 public double get(int i, String columnName) {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 int index = columnIndex(columnName);
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 return index >= 0
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 ? columns[index].getQuick(i)
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 : Double.NaN;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57
2729
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
58 public void set(int i, String columnName, double value) {
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
59 int idx = columnIndex(columnName);
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
60 if (idx >= 0) {
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
61 columns[i].setQuick(idx, value);
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
62 }
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
63 }
a441be7f1589 Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2695
diff changeset
64
2695
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 public int size() {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 return columns[0].size();
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 public int getNumberColumns() {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 return columnNames.length;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 public String [] getColumnNames() {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 return columnNames;
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 public void removeNaNs() {
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 W.removeNaNs(columns);
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 }
2744
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
80
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
81 public int [] columnIndices(String [] columns) {
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
82 int [] indices = new int[columns.length];
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
83 for (int i = 0; i < columns.length; ++i) {
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
84 indices[i] = columnIndex(columns[i]);
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
85 }
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
86 return indices;
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
87 }
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
88
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
89 public void get(int row, int [] columnIndices, double [] values) {
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
90 for (int i = 0; i < columnIndices.length; ++i) {
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
91 int index = columnIndices[i];
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
92 values[i] = index >= 0 && index < columns.length
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
93 ? columns[index].getQuick(row)
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
94 : Double.NaN;
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
95 }
c1f2e792704a FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2729
diff changeset
96 }
2695
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 }
ae0742f92cd5 Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org