annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationCalculation.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
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
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 7261
diff changeset
28 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 7261
diff changeset
29 import org.apache.logging.log4j.LogManager;
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public class SQRelationCalculation extends Calculation {
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
33 private static final Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 7261
diff changeset
34 LogManager.getLogger(SQRelationCalculation.class);
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
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
36 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
37 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
38
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_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
40 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
41
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
42 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
43 "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
44 "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
45 "max_q",
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
46 "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
47 "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
48 "r2"
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
49 };
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
50
3426
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 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
52 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
53 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
54 protected double outliers;
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
55 private String method;
3305
b24920235944 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3304
diff changeset
56
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
57 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
58 }
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
59
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
60 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
61
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7248
diff changeset
62 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
63 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
64 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
65 Double outliers = access.getOutliers();
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
66 String method = access.getOutlierMethod();
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
67
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
68 if (river == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
69 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
70 addProblem("sq.missing.river");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
71 }
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
72
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
73 if (location == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
74 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
75 addProblem("sq.missing.location");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
76 }
3101
b31397addf2f Create Facets for each SQResult and SQFractionResult.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3079
diff changeset
77
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
78 if (period == null) {
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
79 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
80 addProblem("sq.missing.periods");
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
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
83 if (outliers == null) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
84 // TODO: i18n
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
85 addProblem("sq.missing.outliers");
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
86 }
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
87
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
88 if (method == null) {
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
89 //TODO: i18n
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
90 addProblem("sq.missing.method");
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
91 }
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
92
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
93 if (!hasProblems()) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
94 this.river = river;
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
95 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
96 this.period = period;
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
97 this.outliers = outliers;
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
98 this.method = method;
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
99 }
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
100 }
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
101
3105
9592b7d76633 Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3101
diff changeset
102
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
103 public CalculationResult calculate() {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
104 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
105
3222
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
106 if (hasProblems()) {
116b342893e3 SQ: Connect calculation with artifact parameter access.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3118
diff changeset
107 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
108 }
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
109
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
110 SedDBSessionHolder.acquire();
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
111 try {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
112 return internalCalculate();
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
113 }
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
114 finally {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
115 SedDBSessionHolder.release();
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 }
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
118
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
119 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
120 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
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
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 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
124 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
125 @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
126 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
127 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
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
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 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
132 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
133 @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
134 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
135 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
136 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
137 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
138 }
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 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
140 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
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 };
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
143
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
144 protected CalculationResult internalCalculate() {
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
145
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
146 Function powFunction = FunctionFactory
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
147 .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
148 .getFunction(SQ_POW_FUNCTION_NAME);
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
149
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
150 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
151 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
152 // TODO: i18n
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
153 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
154 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
155 }
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
156
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
157 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
158 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
159 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
160 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
161
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 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 powFunction,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
171 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
172 }
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 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
174 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
175 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
176 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
177 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
178 .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
179 .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
180 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
181 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
182 // 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
183 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
184 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
185 }
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 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
187 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
188 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
189 function,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
190 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
191 }
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
192
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
193 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
194 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
195 river, location, period, sqFactory);
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
196
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
197 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
198 new SQFractionResult[SQResult.NUMBER_FRACTIONS];
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
199
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
200
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
201 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
202 List<SQ> sqs = measurements.getSQs(i);
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
203
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
204 SQFractionResult fractionResult;
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
205
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
206 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
207 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
208
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
209 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
210 // 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
211 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
212 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
213 }
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
214 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
215 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
216 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
217 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
218 }
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
219
3426
e7a67407dea1 Limited the input of time periods in SQ relation calculation to 1.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3392
diff changeset
220 fractionResults[i] = fractionResult;
3297
79c8e0d9fdea SQ relation: Use only first time period.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3290
diff changeset
221 }
3289
ec9aab93f292 SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3222
diff changeset
222
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
223 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
224 new SQResult[] { new SQResult(location, fractionResults) },
3310
8af1111af180 SQ relation: More fixes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3305
diff changeset
225 this);
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
227
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
228 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
229 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
230 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
231 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
232 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
233 ) {
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 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
235 new ArrayList<SQFractionResult.Iteration>();
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
236
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
237 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
238 sqs,
5396
aaf810d4ec82 Use new state 'outlier mehtod selection' in SQ-relation.
Raimund Renkert <rrenkert@intevation.de>
parents: 4039
diff changeset
239 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
240 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
241 @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
242 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
243 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
244 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
245 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
246 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
247 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
248 ) {
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
249 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
250 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
251 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
252 chiSqr,
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
253 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
254 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
255 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
256 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
257 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
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
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 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
262 }
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
263
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
264 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
265
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 [] 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
267 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
268
6796
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 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
270 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
271
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
272 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
273 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
274 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
275 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
276 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
277 ) {
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
278 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
279 this.proxyNames = proxyNames;
6822
330ea2915168 S/Q relation: Fixed broken parameter creator constructor.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6797
diff changeset
280 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
281 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
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
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 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
285 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
286 }
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
287
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
288 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
289 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
290 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
291 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
292 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
293 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
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 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
296 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
297 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
298
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
299 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
300 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
301 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
302 ) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
303 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
304
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
305 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
306 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
307 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
308 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
309 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
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
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
312 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
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
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
315 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
316 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
317 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
318 ) {
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
319 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
320
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
321 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
322 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
323 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
324 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
325 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
326 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
327 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
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
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
330 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
331 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
332 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
333 ) {
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 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 }
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
343 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
344 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
345
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 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
347 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
348 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
349
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
350 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
351 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
352 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
353 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
354
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 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
356 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
357
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
358 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
359
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
360 sumX += xDiff*xDiff;
6827
2972a219743d Fix typo in SQRelation calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 6822
diff changeset
361 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
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
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
364 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
365 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
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
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
368
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
369 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
370 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
371 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
372 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
373 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
374 ) {
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
375 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
376
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
377 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
378 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
379 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
380 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
381 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
382 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
383
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
384 // 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
385 // 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
386 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
387 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
388
6797
e237a83fd87d S/Q relation: Spell Ferguson with F.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6796
diff changeset
389 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
390 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
391 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
392
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
393 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
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
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 /** 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
398 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
399
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 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
401 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
402 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
403 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
404 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
405 ) {
6796
978ab716a15e flys/issue1347: Added missing calcutions. TODO: Bring them into the generated outs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6787
diff changeset
406 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
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
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 @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
410 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
411
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 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
413 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
414
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 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
416 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
417
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 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
419 log.error("index not found: "
7248
1dff8e71c4d6 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6827
diff changeset
420 + 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
421 + 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
422 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
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
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 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
426 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
427 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
428
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 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
430 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
431 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
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
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 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
435 }
3304
02d5731b43a2 SQ relation: Build a valid SQResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3297
diff changeset
436 }
3072
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
437 }
0d3dd8230064 Added component stubs for SQ relation calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
438 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org