annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BedQualityCalculator.java @ 9450:7e1fb8d0cb0d

Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
author mschaefer
date Wed, 22 Aug 2018 19:12:51 +0200
parents
children fd6621f47a72
rev   line source
9450
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
2 * Software engineering by
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
5 *
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
9 */
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
10
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
11 package org.dive4elements.river.artifacts.bundu.bezugswst;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
12
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
13 import java.util.Date;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
14
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
15 import org.dive4elements.artifacts.CallContext;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
16 import org.dive4elements.river.artifacts.access.BedQualityAccess;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
17 import org.dive4elements.river.artifacts.bundu.BUNDUArtifact;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
18 import org.dive4elements.river.artifacts.model.Calculation;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
19 import org.dive4elements.river.artifacts.model.Calculation.Problem;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
20 import org.dive4elements.river.artifacts.model.CalculationResult;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
21 import org.dive4elements.river.artifacts.model.minfo.BedQualityCalculation;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
22 import org.dive4elements.river.artifacts.model.minfo.BedQualityResult;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
23 import org.dive4elements.river.artifacts.model.minfo.BedQualityResultValue;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
24 import org.dive4elements.river.model.River;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
25
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
26 /**
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
27 * Calculator for bed quality parameters in a km range and time period, wrapping the minfo BedQualityCalculation
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
28 *
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
29 * @author Matthias Schäfer
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
30 *
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
31 */
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
32 public class BedQualityCalculator {
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
33
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
34 private final CallContext context;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
35
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
36 private final BUNDUArtifact bundu;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
37
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
38
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
39 public BedQualityCalculator(final CallContext context, final BUNDUArtifact bundu) {
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
40 this.context = context;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
41 this.bundu = bundu;
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
42 }
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
43
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
44 /**
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
45 * Calculates the river bed sublayer densities for an array of kms and a time period of measurements
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
46 */
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
47 public double[][] execute(final Calculation problems, final River river, final double[] kms, final Date startDay, final Date endDay) {
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
48 final BedQualityCalculation bqCalc = new BedQualityCalculation();
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
49 final BedQualityAccess access = createBqAccess(kms[0], kms[kms.length - 1], startDay, endDay);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
50 final CalculationResult bqCalcResult = bqCalc.calculate(access);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
51 if (bqCalcResult.getReport().getProblems() != null) {
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
52 for (final Problem problem : bqCalcResult.getReport().getProblems())
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
53 problems.addProblem(problem);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
54 }
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
55 final BedQualityResult[] results = (BedQualityResult[]) bqCalcResult.getData();
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
56 final BedQualityResult result = results[0];
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
57 final BedQualityResultValue bqResValue = result.getValue("density", "sublayer");
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
58 return bqResValue.getDataInterpolated(kms);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
59 }
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
60
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
61 /**
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
62 * Creates an access object for the bed quality calculation
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
63 */
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
64 private BedQualityAccess createBqAccess(final double fromKm, final double toKm, final Date startDay, final Date endDay) {
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
65 final BunduMinfoArtifactWrapper minfo = new BunduMinfoArtifactWrapper(this.bundu, startDay, endDay);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
66 return new BedQualityAccess(minfo, this.context);
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
67 }
7e1fb8d0cb0d Bundu bzws calculation nearly completed, some corrections with csv output, started with linking the minfo density calculation
mschaefer
parents:
diff changeset
68 }

http://dive4elements.wald.intevation.org