annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationCalculation.java @ 8605:b0e5a2ce0b09

(issue1750) Fix id handling with oracle On oracle the id is returned as BigDecimal. This could probably be done better with hibernate but checking the Object also works.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 20 Mar 2015 18:42:00 +0100
parents a56fe3bc6700
children 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: 5396
diff changeset
9 package org.dive4elements.river.artifacts.model.sq;
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
11 import org.dive4elements.artifacts.common.utils.StringUtils;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
12 import org.dive4elements.river.artifacts.access.SQRelationAccess;
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
13
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
14 import org.dive4elements.river.artifacts.math.fitting.Function;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
15 import org.dive4elements.river.artifacts.math.fitting.FunctionFactory;
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
17 import org.dive4elements.river.artifacts.model.Calculation;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
18 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
19 import org.dive4elements.river.artifacts.model.DateRange;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
20 import org.dive4elements.river.artifacts.model.Parameters;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
21
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5396
diff changeset
22 import org.dive4elements.river.backend.SedDBSessionHolder;
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
23
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
24 import java.util.ArrayList;
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
25 import java.util.Arrays;
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
26 import java.util.List;
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
27
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
28 import org.apache.log4j.Logger;
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public class SQRelationCalculation extends Calculation {
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
32 private static final Logger log =
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 Logger.getLogger(SQRelationCalculation.class);
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
35 public static final boolean NON_LINEAR_FITTING =
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
36 Boolean.getBoolean("minfo.sq.calcution.non.linear.fitting");
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
37
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
38 public static final String SQ_POW_FUNCTION_NAME = "sq-pow";
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
39 public static final String SQ_LIN_FUNCTION_NAME = "linear";
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
40
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
41 public static final String [] EXTRA_PARAMETERS = {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
42 "chi_sqr",
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
43 "std_dev",
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
44 "max_q",
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
45 "c_ferguson",
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
46 "c_duan",
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
47 "r2"
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
48 };
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
49
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
50 protected String river;
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
51 protected double location;
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
52 protected DateRange period;
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
53 protected double outliers;
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
54 private String method;
3305
b24920235944 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3304
diff changeset
55
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
56 public SQRelationCalculation() {
3079
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
57 }
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
58
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
59 public SQRelationCalculation(SQRelationAccess access) {
3079
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
60
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7248
diff changeset
61 String river = access.getRiverName();
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
62 Double location = access.getLocation();
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
63 DateRange period = access.getPeriod();
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
64 Double outliers = access.getOutliers();
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
65 String method = access.getOutlierMethod();
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
66
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
67 if (river == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
68 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
69 addProblem("sq.missing.river");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
70 }
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
71
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
72 if (location == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
73 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
74 addProblem("sq.missing.location");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
75 }
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
76
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
77 if (period == null) {
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
78 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
79 addProblem("sq.missing.periods");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
80 }
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
81
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
82 if (outliers == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
83 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
84 addProblem("sq.missing.outliers");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
85 }
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
86
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
87 if (method == null) {
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
88 //TODO: i18n
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
89 addProblem("sq.missing.method");
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
90 }
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
91
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
92 if (!hasProblems()) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
93 this.river = river;
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
94 this.location = location;
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
95 this.period = period;
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
96 this.outliers = outliers;
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
97 this.method = method;
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
98 }
3079
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
99 }
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
100
3105
9592b7d76633 Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3101
diff changeset
101
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
102 public CalculationResult calculate() {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
103 log.debug("SQRelationCalculation.calculate");
3079
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
104
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
105 if (hasProblems()) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
106 return new CalculationResult(this);
3118
6fb211753674 The fake calculation for SQ relation now creates only values bigger than 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3105
diff changeset
107 }
3079
8ad8a227d983 Added model classes for SQ calculation; generate fake results and improved the SQRelationGenerator which now draws the outliers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3072
diff changeset
108
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
109 SedDBSessionHolder.acquire();
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
110 try {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
111 return internalCalculate();
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
112 }
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
113 finally {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
114 SedDBSessionHolder.release();
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
115 }
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
116 }
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
117
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
118 public interface TransformCoeffs {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
119 double [] transform(double [] coeffs);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
120 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
121
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
122 public static final TransformCoeffs IDENTITY_TRANS =
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
123 new TransformCoeffs() {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
124 @Override
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
125 public double [] transform(double [] coeffs) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
126 return coeffs;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
127 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
128 };
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
129
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
130 public static final TransformCoeffs LINEAR_TRANS =
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
131 new TransformCoeffs() {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
132 @Override
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
133 public double [] transform(double [] coeffs) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
134 log.debug("before transform: " + Arrays.toString(coeffs));
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
135 if (coeffs.length == 2) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
136 coeffs = new double [] { Math.exp(coeffs[1]), coeffs[0] };
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
137 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
138 log.debug("after transform: " + Arrays.toString(coeffs));
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
139 return coeffs;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
140 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
141 };
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
142
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
143 protected CalculationResult internalCalculate() {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
144
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
145 Function powFunction = FunctionFactory
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
146 .getInstance()
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
147 .getFunction(SQ_POW_FUNCTION_NAME);
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
148
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
149 if (powFunction == null) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
150 log.error("No '" + SQ_POW_FUNCTION_NAME + "' function found.");
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
151 // TODO: i18n
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
152 addProblem("sq.missing.sq.function");
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
153 return new CalculationResult(new SQResult[0], this);
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
154 }
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
155
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
156 Function function;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
157 SQ.View sqView;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
158 SQ.Factory sqFactory;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
159 ParameterCreator pc;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
160
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
161 if (NON_LINEAR_FITTING) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
162 log.debug("Use non linear fitting.");
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
163 sqView = SQ.SQ_VIEW;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
164 sqFactory = SQ.SQ_FACTORY;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
165 function = powFunction;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
166 pc = new ParameterCreator(
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
167 powFunction.getParameterNames(),
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
168 powFunction.getParameterNames(),
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
169 powFunction,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
170 sqView);
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
171 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
172 else {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
173 log.debug("Use linear fitting.");
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
174 sqView = LogSQ.LOG_SQ_VIEW;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
175 sqFactory = LogSQ.LOG_SQ_FACTORY;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
176 function = FunctionFactory
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
177 .getInstance()
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
178 .getFunction(SQ_LIN_FUNCTION_NAME);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
179 if (function == null) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
180 log.error("No '" + SQ_LIN_FUNCTION_NAME + "' function found.");
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
181 // TODO: i18n
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
182 addProblem("sq.missing.sq.function");
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
183 return new CalculationResult(new SQResult[0], this);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
184 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
185 pc = new LinearParameterCreator(
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
186 powFunction.getParameterNames(),
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
187 function.getParameterNames(),
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
188 function,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
189 sqView);
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
190 }
6780
b8f94e865875 S/Q relation: Part I of 'faking' fitting linear data. S/Qs can now be subclassed and processed through views. TODO: Add knob to setup a linear data path.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
191
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
192 Measurements measurements =
6780
b8f94e865875 S/Q relation: Part I of 'faking' fitting linear data. S/Qs can now be subclassed and processed through views. TODO: Add knob to setup a linear data path.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
193 MeasurementFactory.getMeasurements(
b8f94e865875 S/Q relation: Part I of 'faking' fitting linear data. S/Qs can now be subclassed and processed through views. TODO: Add knob to setup a linear data path.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
194 river, location, period, sqFactory);
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
195
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
196 SQFractionResult [] fractionResults =
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
197 new SQFractionResult[SQResult.NUMBER_FRACTIONS];
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
198
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
199
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
200 for (int i = 0; i < fractionResults.length; ++i) {
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
201 List<SQ> sqs = measurements.getSQs(i);
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
202
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
203 SQFractionResult fractionResult;
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
204
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
205 List<SQFractionResult.Iteration> iterations =
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
206 doFitting(function, sqs, sqView, pc);
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
207
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
208 if (iterations == null) {
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
209 // TODO: i18n
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
210 addProblem("sq.fitting.failed." + i);
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
211 fractionResult = new SQFractionResult();
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
212 }
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
213 else {
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
214 fractionResult = new SQFractionResult(
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
215 sqs.toArray(new SQ[sqs.size()]),
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
216 iterations);
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
217 }
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
218
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
219 fractionResults[i] = fractionResult;
3297
79c8e0d9fdea SQ relation: Use only first time period.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3290
diff changeset
220 }
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
221
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
222 return new CalculationResult(
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
223 new SQResult[] { new SQResult(location, fractionResults) },
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
224 this);
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
226
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
227 protected List<SQFractionResult.Iteration> doFitting(
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
228 final Function function,
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
229 List<SQ> sqs,
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
230 SQ.View sqView,
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
231 final ParameterCreator pc
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
232 ) {
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
233 final List<SQFractionResult.Iteration> iterations =
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
234 new ArrayList<SQFractionResult.Iteration>();
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
235
6780
b8f94e865875 S/Q relation: Part I of 'faking' fitting linear data. S/Qs can now be subclassed and processed through views. TODO: Add knob to setup a linear data path.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
236 boolean success = new Fitting(function, outliers, sqView).fit(
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
237 sqs,
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
238 method,
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
239 new Fitting.Callback() {
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
240 @Override
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
241 public void afterIteration(
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
242 double [] coeffs,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
243 SQ [] measurements,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
244 SQ [] outliers,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
245 double standardDeviation,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
246 double chiSqr
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
247 ) {
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
248 Parameters parameters = pc.createParameters(
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
249 coeffs,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
250 standardDeviation,
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
251 chiSqr,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
252 measurements);
3552
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
253 iterations.add(new SQFractionResult.Iteration(
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
254 parameters,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
255 measurements,
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
256 outliers));
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
257 }
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
258 });
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
259
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
260 return success ? iterations : null;
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
261 }
1df6984628c3 S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3426
diff changeset
262
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
263 public static class ParameterCreator {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
264
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
265 protected String [] origNames;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
266 protected String [] proxyNames;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
267
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
268 protected Function function;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
269 protected SQ.View view;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
270
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
271 public ParameterCreator(
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
272 String [] origNames,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
273 String [] proxyNames,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
274 Function function,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
275 SQ.View view
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
276 ) {
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
277 this.origNames = origNames;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
278 this.proxyNames = proxyNames;
6822
330ea2915168 S/Q relation: Fixed broken parameter creator constructor.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6797
diff changeset
279 this.function = function;
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
280 this.view = view;
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
281 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
282
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
283 protected double [] transformCoeffs(double [] coeffs) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
284 return coeffs;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
285 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
286
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
287 private static double maxQ(SQ [] sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
288 double max = -Double.MAX_VALUE;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
289 for (SQ sq: sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
290 double q = sq.getQ(); // Don't use view here!
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
291 if (q > max) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
292 max = q;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
293 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
294 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
295 return Math.max(0d, max);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
296 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
297
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
298 private double cFerguson(
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
299 org.dive4elements.river.artifacts.math.Function instance,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
300 SQ [] sqs
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
301 ) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
302 double sqrSum = 0d;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
303
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
304 for (SQ sq: sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
305 double s = view.getS(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
306 double q = view.getQ(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
307 double diffS = s - instance.value(q);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
308 sqrSum += diffS*diffS;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
309 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
310
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
311 return Math.exp(0.5d * sqrSum/(sqs.length-2));
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
312 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
313
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
314 private double cDuan(
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
315 org.dive4elements.river.artifacts.math.Function instance,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
316 SQ [] sqs
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
317 ) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
318 double sum = 0d;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
319
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
320 for (SQ sq: sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
321 double s = view.getS(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
322 double q = view.getQ(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
323 double diffS = s - instance.value(q);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
324 sum += Math.exp(diffS);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
325 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
326 return sum / sqs.length;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
327 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
328
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
329 private double r2(
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
330 org.dive4elements.river.artifacts.math.Function instance,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
331 SQ [] sqs
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
332 ) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
333 double xm = 0;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
334 double ym = 0;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
335 for (SQ sq: sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
336 double s = view.getS(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
337 double q = view.getQ(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
338 double fs = instance.value(q);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
339 xm += s;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
340 ym += fs;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
341 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
342 xm /= sqs.length;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
343 ym /= sqs.length;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
344
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
345 double mixXY = 0d;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
346 double sumX = 0d;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
347 double sumY = 0d;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
348
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
349 for (SQ sq: sqs) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
350 double s = view.getS(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
351 double q = view.getQ(sq);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
352 double fs = instance.value(q);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
353
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
354 double xDiff = xm - s;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
355 double yDiff = ym - fs;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
356
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
357 mixXY += xDiff*yDiff;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
358
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
359 sumX += xDiff*xDiff;
6827
2972a219743d Fix typo in SQRelation calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 6822
diff changeset
360 sumY += yDiff*yDiff;
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
361 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
362
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
363 double r = mixXY/Math.sqrt(sumX*sumY);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
364 return r*r;
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
365 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
366
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
367
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
368 public Parameters createParameters(
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
369 double [] coeffs,
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
370 double standardDeviation,
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
371 double chiSqr,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
372 SQ [] measurements
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
373 ) {
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
374 String [] columns = StringUtils.join(EXTRA_PARAMETERS, origNames);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
375
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
376 Parameters parameters = new Parameters(columns);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
377 int row = parameters.newRow();
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
378 parameters.set(row, origNames, transformCoeffs(coeffs));
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
379 parameters.set(row, "chi_sqr", chiSqr);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
380 parameters.set(row, "std_dev", standardDeviation);
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
381 parameters.set(row, "max_q", maxQ(measurements));
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
382
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
383 // We need to instantiate the function to calculate
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
384 // the remaining values.
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
385 org.dive4elements.river.artifacts.math.Function f =
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
386 function.instantiate(coeffs);
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
387
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
388 parameters.set(row, "c_ferguson", cFerguson(f, measurements));
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
389 parameters.set(row, "c_duan", cDuan(f, measurements));
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
390 parameters.set(row, "r2", r2(f, measurements));
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
391
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
392 return parameters;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
393 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
394 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
395
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
396 /** We need to transform the coeffs back to the original function. */
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
397 public static class LinearParameterCreator extends ParameterCreator {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
398
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
399 public LinearParameterCreator(
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
400 String [] origNames,
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
401 String [] proxyNames,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
402 Function function,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
403 SQ.View view
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
404 ) {
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
405 super(origNames, proxyNames, function, view);
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
406 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
407
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
408 @Override
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
409 protected double [] transformCoeffs(double [] coeffs) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
410
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
411 int bP = StringUtils.indexOf("m", proxyNames);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
412 int mP = StringUtils.indexOf("b", proxyNames);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
413
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
414 int aO = StringUtils.indexOf("a", origNames);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
415 int bO = StringUtils.indexOf("b", origNames);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
416
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
417 if (bP == -1 || mP == -1 || aO == -1 || bO == -1) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
418 log.error("index not found: "
7248
1dff8e71c4d6 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6827
diff changeset
419 + bP + " " + mP + " "
6787
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
420 + aO + " " + bO);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
421 return coeffs;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
422 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
423
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
424 double [] ncoeffs = (double [])coeffs.clone();
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
425 ncoeffs[aO] = Math.exp(coeffs[mP]);
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
426 ncoeffs[bO] = coeffs[bP];
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
427
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
428 if (log.isDebugEnabled()) {
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
429 log.debug("before transform: " + Arrays.toString(coeffs));
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
430 log.debug("after transform: " + Arrays.toString(ncoeffs));
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
431 }
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
432
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
433 return ncoeffs;
51eb6491c537 S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property S/Q: Excel compat completed: Now the data is linearized before fitting. This can be prevented by setting the system property "minfo.sq.calcution.non.linear.fitting" to true.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6780
diff changeset
434 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
435 }
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
436 }
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
437 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org