sascha@677: package de.intevation.flys.artifacts.model; sascha@677: sascha@677: import java.util.Arrays; sascha@677: sascha@677: import org.apache.log4j.Logger; sascha@677: felix@3265: felix@3265: /** ComputedDischargeCurve. */ sascha@677: public class Calculation2 sascha@677: extends Calculation sascha@677: { sascha@677: private static Logger logger = Logger.getLogger(Calculation2.class); sascha@677: sascha@677: protected double km; sascha@677: sascha@677: public Calculation2() { sascha@677: } sascha@677: sascha@677: public Calculation2(double km) { sascha@677: this.km = km; sascha@677: } sascha@677: sascha@709: public CalculationResult calculate(WstValueTable wst) { sascha@677: sascha@677: logger.debug("Calculation2.calculate"); sascha@677: sascha@677: double [][] wqs = wst.interpolateWQ(km, this); sascha@677: sascha@677: if (wqs == null || wqs[0].length == 0) { sascha@2166: addProblem("cannot.compute.discharge.curve"); sascha@709: return new CalculationResult(new WQKms[0], this); sascha@677: } sascha@677: sascha@677: double [] ws = wqs[0]; sascha@677: double [] qs = wqs[1]; sascha@677: double [] kms = new double[ws.length]; sascha@677: sascha@677: Arrays.fill(kms, km); sascha@677: sascha@677: WQKms wqkms = new WQKms(kms, qs, ws, String.valueOf(km)); sascha@677: sascha@677: if (hasProblems()) { felix@3265: logger.debug("found " + numProblems() + " problems."); sascha@677: wqkms.removeNaNs(); sascha@677: } sascha@677: sascha@709: return new CalculationResult(new WQKms[] { wqkms }, this); sascha@677: } sascha@677: } sascha@677: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :