Java Code Examples for ucar.nc2.NetcdfFile#setRootGroup()

The following examples show how to use ucar.nc2.NetcdfFile#setRootGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NcStreamReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private NetcdfFile proto2nc(NcStreamProto.Header proto, NetcdfFile ncfile) {
  if (ncfile == null)
    ncfile = new NetcdfFileSubclass(); // not used i think
  ncfile.setLocation(proto.getLocation());
  if (!proto.getId().isEmpty())
    ncfile.setId(proto.getId());
  if (!proto.getTitle().isEmpty())
    ncfile.setTitle(proto.getTitle());

  NcStreamProto.Group root = proto.getRoot();
  Group.Builder rootBuilder = Group.builder().setNcfile(ncfile).setName("");
  NcStream.readGroup(root, rootBuilder);
  ncfile.setRootGroup(rootBuilder.build());
  ncfile.finish();
  return ncfile;
}
 
Example 2
Source File: H5iospNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  super.open(raf, ncfile, cancelTask);
  Group.Builder rootGroup = Group.builder().setName("").setNcfile(ncfile);
  header = new H5headerNew(raf, rootGroup, this);
  header.read(null);
  ncfile.setRootGroup(rootGroup.build());

  // check if its an HDF5-EOS file
  if (useHdfEos) {
    rootGroup.findGroupLocal(HdfEos.HDF5_GROUP).ifPresent(eosGroup -> {
      try {
        isEos = HdfEos.amendFromODL(raf.getLocation(), header, eosGroup);
      } catch (IOException e) {
        log.warn(" HdfEos.amendFromODL failed");
      }
    });
  }

  ncfile.finish();
}
 
Example 3
Source File: N3iospNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Deprecated
@Override
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  super.open(raf, ncfile, cancelTask);

  String location = raf.getLocation();
  if (!location.startsWith("http:")) {
    File file = new File(location);
    if (file.exists())
      lastModified = file.lastModified();
  }

  raf.order(RandomAccessFile.BIG_ENDIAN);
  header = createHeader();

  Group.Builder rootGroup = Group.builder().setName("").setNcfile(ncfile);
  header.read(raf, rootGroup, null);
  ncfile.setRootGroup(rootGroup.build());
  ncfile.finish();
}
 
Example 4
Source File: H4iosp.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void open(RandomAccessFile raf, NetcdfFile ncfile, CancelTask cancelTask) throws IOException {
  super.open(raf, ncfile, cancelTask);
  Group.Builder rootGroup = Group.builder().setName("").setNcfile(ncfile);
  getHeader().read(raf, rootGroup, null);
  ncfile.setRootGroup(rootGroup.build());
  ncfile.finish();
}