public static Contour getSubContour(Contour contour, double start, double end)
      throws AuToBIException {
    if (start > end) {
      throw new AuToBIException("start (" + start + ") greater than end (" + end + ")");
    }
    if (contour == null)
      throw new AuToBIException("Null Contour.");
    if (contour.size() == 0) return null;
    int start_idx = contour.indexFromTimeCeil(start);
    int end_idx = contour.indexFromTimeFloor(end);

    Contour subcontour = new Contour(contour.timeFromIndex(start_idx), contour.getStep(), end_idx - start_idx + 1);
    for (int i = start_idx; i <= end_idx; ++i) {
      if (contour.isEmpty(i)) {
        subcontour.setEmpty(i - start_idx);
      } else {
        subcontour.set(i - start_idx, contour.get(i));
      }
    }
    return subcontour;
  }