comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQCurveFacet.java @ 3552:1df6984628c3

S/Q: Extented the result data model of the S/Q calculation to store the curve coefficients for each iteration step of the outlier elimination. flys-artifacts/trunk@5146 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 27 Jul 2012 12:36:09 +0000
parents 8af1111af180
children
comparison
equal deleted inserted replaced
3551:e7f1556192b3 3552:1df6984628c3
51 51
52 @Override 52 @Override
53 public Object getData(Artifact artifact, CallContext context) { 53 public Object getData(Artifact artifact, CallContext context) {
54 log.debug("SQCurveFacet.getData"); 54 log.debug("SQCurveFacet.getData");
55 55
56 if (artifact instanceof FLYSArtifact) { 56 if (!(artifact instanceof FLYSArtifact)) {
57 FLYSArtifact flys = (FLYSArtifact) artifact; 57 return null;
58
59 CalculationResult res = (CalculationResult) flys.compute(
60 context, ComputeType.ADVANCE, false);
61
62 SQResult[] results = (SQResult[]) res.getData();
63 SQFractionResult result = results[index].getFraction(fractionIdx);
64
65 Function func = FunctionFactory.getInstance().getFunction(FUNCTION);
66 String[] paramNames = func.getParameterNames();
67
68 Parameters params = result.getParameters();
69
70 if (params == null) {
71 log.debug("no parameters found");
72 return null;
73 }
74
75 double[] coeffs = params.get(0, paramNames);
76
77 if (log.isDebugEnabled()) {
78 for (int i = 0, N = paramNames.length; i < N; i++) {
79 log.debug("retrieved parameter " + paramNames[i] +
80 " = " + coeffs[i]);
81 }
82 }
83
84 de.intevation.flys.artifacts.math.Function mf =
85 func.instantiate(coeffs);
86
87 return new SQFunction(mf, result.getMinQ(), result.getMaxQ());
88 } 58 }
89 59
90 return null; 60 FLYSArtifact flys = (FLYSArtifact) artifact;
61
62 CalculationResult res = (CalculationResult) flys.compute(
63 context, ComputeType.ADVANCE, false);
64
65 SQResult[] results = (SQResult[]) res.getData();
66 SQFractionResult result = results[index].getFraction(fractionIdx);
67
68 Parameters params = result.getParameters();
69
70 if (params == null) {
71 log.debug("no parameters found");
72 return null;
73 }
74
75 Function func = FunctionFactory.getInstance().getFunction(FUNCTION);
76 String[] paramNames = func.getParameterNames();
77
78 double [] coeffs = params.get(0, paramNames);
79
80 if (log.isDebugEnabled()) {
81 for (int i = 0, N = paramNames.length; i < N; i++) {
82 log.debug("retrieved parameter " + paramNames[i] +
83 " = " + coeffs[i]);
84 }
85 }
86
87 de.intevation.flys.artifacts.math.Function mf =
88 func.instantiate(coeffs);
89
90 double [] extent = result.getQExtent();
91 return new SQFunction(mf, extent[0], extent[1]);
91 } 92 }
92 93
93 94
94 @Override 95 @Override
95 public SQCurveFacet deepCopy() { 96 public SQCurveFacet deepCopy() {

http://dive4elements.wald.intevation.org