Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java @ 6828:708416bb560c
(issue1347) Add new variables to SQ Relation output.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 14 Aug 2013 15:23:36 +0200 |
parents | 8c976bb0362f |
children | eb4b123daaf7 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Wed Aug 14 15:20:01 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Wed Aug 14 15:23:36 2013 +0200 @@ -16,6 +16,7 @@ import java.util.Date; import java.util.Locale; import java.text.DateFormat; +import java.text.NumberFormat; import org.w3c.dom.Document; @@ -99,8 +100,11 @@ public static final String CSV_C_FERGUSON = "export.sqrelation.csv.header.c.ferguson"; - public static final String CSV_VARIANCE = - "export.sqrelation.csv.header.variance"; + public static final String CSV_QMAX = + "export.sqrelation.csv.header.qmax"; + + public static final String CSV_SD = + "export.sqrelation.csv.header.sd"; public static final String PDF_TITLE= "export.sqrelation.pdf.title"; @@ -136,9 +140,13 @@ msg(CSV_PARAMETER, CSV_PARAMETER), msg(CSV_COEFF_A , CSV_COEFF_A), msg(CSV_COEFF_B , CSV_COEFF_B), + msg(CSV_SD, CSV_SD), + msg(CSV_QMAX, CSV_QMAX), + msg(CSV_COEFF_R, CSV_COEFF_R), msg(CSV_N_TOTAL , CSV_N_TOTAL), msg(CSV_N_OUTLIERS, CSV_N_OUTLIERS), - msg(CSV_VARIANCE , CSV_VARIANCE) + msg(CSV_C_DUAN, CSV_C_DUAN), + msg(CSV_C_FERGUSON, CSV_C_FERGUSON) }); } @@ -160,6 +168,12 @@ ).format(result.getKm()); List<String[]> retval = new ArrayList<String[]>(); + NumberFormat sqAFormatter = Formatter.getSQRelationA(context); + NumberFormat sqBFormatter = Formatter.getSQRelationB(context); + NumberFormat fThreeFormatter = Formatter.getFormatter(context, 3, 3); + NumberFormat fTwoFormatter = Formatter.getFormatter(context, 2, 2); + NumberFormat fZeroFormatter = Formatter.getFormatter(context, 0, 0); + for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) { SQFractionResult fraction = result.getFraction(i); @@ -171,10 +185,17 @@ continue; } - String a, b, sd, o, t; - a = Formatter.getSQRelationA(context).format(parameters.getValue(0, "a")); - b = Formatter.getSQRelationB(context).format(parameters.getValue(0, "b")); - sd = Formatter.getVariance(context).format(Math.sqrt(parameters.getValue(0, "std_dev"))); + String a, b, sd, o, t, max_q, c_ferguson, c_duan, r2; + a = sqAFormatter.format(parameters.getValue(0, "a")); + b = sqBFormatter.format(parameters.getValue(0, "b")); + + /* The std_dev parameter contains the standard error actually */ + sd = fThreeFormatter.format(parameters.getValue(0, "std_dev")); + max_q = fZeroFormatter.format(parameters.getValue(0, "max_q")); + c_ferguson = fTwoFormatter.format(parameters.getValue(0, "c_ferguson")); + c_duan = fTwoFormatter.format(parameters.getValue(0, "c_duan")); + r2 = fTwoFormatter.format(parameters.getValue(0, "r2")); + o = String.valueOf(fraction.totalNumOutliers()); t = String.valueOf(fraction.numMeasurements() + o); @@ -184,9 +205,13 @@ name, a, b, - t, - o, - sd + sd, // 4 + max_q, // 5 + r2, // 6 + t, // 7 + o, // 8 + c_duan, // 9 + c_ferguson // 10 }); } return retval;