p3j.experiment.results
Class ResultExport

java.lang.Object
  extended by p3j.experiment.results.ResultExport

public class ResultExport
extends Object

Class responsible for exporting results. There are three modes: Create report: aggregates all data to be displayed in the result report. Export aggregated data: exports various data aggregations, does not copy or generate report-related files. Export data: exports all raw data, to be analyzed with other tools. TODO: Remove hard-coded density-plot years here and in plotting.R!

Author:
Christina Bohk, Roland Ewald

Field Summary
static String R_LIBRARY
          The name of the R library required for report generation.
 
Constructor Summary
ResultExport(ProjectionModel projectionModel, File targetDirectory, IResultFilter resultFilter)
          Instantiates a new result export.
 
Method Summary
protected  double[][] calcQuantiles(double[][] inputMatrix)
          Calculates quantiles per column.
protected  String createEquidistantDensityYearList(int jumpOffYear)
          Creates the density year list.
 void createResultReport()
          Creates result report displaying aggregated results.
 void exportAggregatedResults()
          Exports aggregated data.
 void exportAllResults()
          Exports all results.
protected  double[][] filter(double[][] original)
          Filter out all unnecessary data.
 IResultFilter getResultFilter()
          Gets the result filter.
static StringBuilder toCSV(double[][] matrix, char delim)
          Export to CSV.
protected  void writeResult(File destinationDir, double[][] result, String fileName)
          Write result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

R_LIBRARY

public static final String R_LIBRARY
The name of the R library required for report generation.

See Also:
Constant Field Values
Constructor Detail

ResultExport

public ResultExport(ProjectionModel projectionModel,
                    File targetDirectory,
                    IResultFilter resultFilter)
Instantiates a new result export.

Parameters:
projectionModel - the projection model
targetDirectory - the target directory
resultFilter - the result filter to be used
Method Detail

exportAllResults

public void exportAllResults()
                      throws IOException
Exports all results.

Throws:
IOException - if export fails

exportAggregatedResults

public void exportAggregatedResults()
                             throws IOException
Exports aggregated data.

Parameters:
selectedDir - the selected directory for export
Throws:
IOException - if data storage failed

createResultReport

public void createResultReport()
                        throws IOException,
                               freemarker.template.TemplateException
Creates result report displaying aggregated results.

Throws:
IOException - if aggregation of data fails
freemarker.template.TemplateException - if processing of report template fails

calcQuantiles

protected double[][] calcQuantiles(double[][] inputMatrix)
Calculates quantiles per column.

Parameters:
inputMatrix - the input matrix
Returns:
the double[][]

createEquidistantDensityYearList

protected String createEquidistantDensityYearList(int jumpOffYear)
Creates the density year list. The density years are equidistant among jump-off year and the last year of the projection.

Returns:
the string containing the density year list

filter

protected double[][] filter(double[][] original)
Filter out all unnecessary data.

Parameters:
original - the original
Returns:
the double[][]

writeResult

protected void writeResult(File destinationDir,
                           double[][] result,
                           String fileName)
                    throws IOException
Write result.

Parameters:
destinationDir - the destination dir
result - the result
fileName - the file name
Throws:
IOException - Signals that an I/O exception has occurred.

toCSV

public static StringBuilder toCSV(double[][] matrix,
                                  char delim)
Export to CSV.

Parameters:
matrix - the matrix
delim - the delimiter
Returns:
the string builder

getResultFilter

public IResultFilter getResultFilter()
Gets the result filter.

Returns:
the result filter


Copyright © 2012. All Rights Reserved.