Beispiel #1
0
  /**
   * Method is used to aggregate runs of a given range.
   *
   * @param seriesData SeriesData object that is about to be aggregated
   * @param from Index of the first run
   * @param to Index of the last run
   * @return AggregatedSeries object containing the aggregated runs
   * @throws AggregationException
   * @throws IOException
   */
  public static AggregatedSeries aggregate(SeriesData seriesData, int from, int to)
      throws AggregationException, IOException {
    ArrayList<RunData> rdList = new ArrayList<RunData>();

    Aggregation.test(seriesData);
    // check all RunData-Objects for compatibility
    for (int i = 0; i < rdList.size() - 1; i++) {
      if (!RunData.isSameType(seriesData.getRun(i), seriesData.getRun(i + 1)))
        throw new AggregationException("RunDatas not of the same type!");
    }

    for (int i = from; i < to + 1; i++) {
      try {
        rdList.add(seriesData.getRun(i));
      } catch (IndexOutOfBoundsException e) {
        throw new AggregationException(
            "Trying to aggregate over run "
                + i
                + " from series "
                + seriesData.getName()
                + " which is not available.");
      }
    }
    return Aggregation.aggregateRuns(seriesData, rdList);
  }
Beispiel #2
0
  /**
   * Calculates the maximum of Value objects of a list of Values objects.
   *
   * @param list list of Values object to compute the maximum for
   * @param name name of the new Values object
   * @return maximum Values object of the given list
   * @throws AggregationException
   */
  public static Values maximum(Values[] list, String name) throws AggregationException {
    Aggregation.test(list);

    double[][] values = new double[list[0].getValues().length][2];
    for (int i = 0; i < values.length; i++) {
      values[i][0] = list[0].getValues()[i][0];
      double[] temp = new double[list.length];
      for (int j = 0; j < list.length; j++) {
        temp[j] = list[j].getValues()[i][1];
      }
      values[i][1] = ArrayUtils.max(temp);
    }
    return new Values(values, name);
  }