예제 #1
0
  protected Dataset getCompleteData(IMonitor mon) throws Exception {

    IHierarchicalDataFile file = null;
    try {
      if (mon != null) mon.worked(1);
      file = HierarchicalDataFactory.getReader(path);

      final hdf.object.Dataset set = (hdf.object.Dataset) file.getData(fullPath);
      if (set.getStartDims() == null) set.getMetadata();

      /**
       * The diamond slicing can leave the dataset in memory, and the selection. Therefore if they
       * were slicing in the DExplore view before going here, the full selection is broken, there is
       * a sub slice selected.
       *
       * <p>TODO Get Peter to fix this some time.
       */
      loader.resetDims(set);

      final Object val = set.read();
      return H5Utils.getSet(val, set);

    } finally {
      if (file != null) file.close();
    }
  }
예제 #2
0
  @Override
  public Dataset getDataset(IMonitor mon, SliceND slice) throws IOException {

    if (slice.isAll()) {
      try {
        return getCompleteData(mon);
      } catch (Exception e) {
        throw new IOException("Cannot read " + path + ", " + fullPath, e);
      }
    }

    final SliceObject so = new SliceObject();
    so.setPath(path);
    so.setName(fullPath);
    so.setSlicedShape(slice.getSourceShape());
    so.setSliceStart(slice.getStart());
    so.setSliceStop(slice.getStop());
    so.setSliceStep(slice.getStep());

    if (cache.containsKey(so)) {
      final Reference<Dataset> sr = cache.get(so);
      if (sr.get() != null) {
        return sr.get();
      }
    }
    try {
      Dataset set = loader.slice(so, mon);
      cache.put(so, new SoftReference<Dataset>(set));
      return set;
    } catch (Exception e) {
      throw new IOException("Cannot slice " + path + ", " + fullPath, e);
    }
  }