public NetcdfFile acquireFile(CancelTask cancelTask) throws IOException { if (debugOpenFile) System.out.println(" try to acquire " + cacheLocation); long start = System.currentTimeMillis(); NetcdfFile ncfile = NetcdfDataset.acquireFile(reader, null, cacheLocation, -1, cancelTask, spiObject); // must merge NcML before enhancing if (mergeNcml != null) ncfile = NcMLReader.mergeNcML(ncfile, mergeNcml); // create new dataset if (enhance == null || enhance.isEmpty()) { if (debugOpenFile) System.out.println(" acquire (no enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ncfile; } // must enhance NetcdfDataset ds; if (ncfile instanceof NetcdfDataset) { ds = (NetcdfDataset) ncfile; ds.enhance(enhance); // enhance "in place", ie modify the NetcdfDataset } else { ds = new NetcdfDataset(ncfile, enhance); // enhance when wrapping } if (debugOpenFile) System.out.println(" acquire (enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ds; }
public NetcdfFile acquireFile(CancelTask cancelTask) throws IOException { if (debugOpenFile) System.out.println(" try to acquire " + cacheLocation); long start = System.currentTimeMillis(); NetcdfFile ncfile = NetcdfDataset.acquireFile(reader, null, cacheLocation, -1, cancelTask, spiObject); // must merge NcML before enhancing if (mergeNcml != null) ncfile = NcMLReader.mergeNcML(ncfile, mergeNcml); // create new dataset if (enhance == null || enhance.isEmpty()) { if (debugOpenFile) System.out.println(" acquire (no enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ncfile; } // must enhance NetcdfDataset ds; if (ncfile instanceof NetcdfDataset) { ds = (NetcdfDataset) ncfile; ds.enhance(enhance); // enhance "in place", ie modify the NetcdfDataset } else { ds = new NetcdfDataset(ncfile, enhance); // enhance when wrapping } if (debugOpenFile) System.out.println(" acquire (enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ds; }
public NetcdfFile acquireFile(CancelTask cancelTask) throws IOException { if (debugOpenFile) System.out.println(" try to acquire " + cacheLocation); long start = System.currentTimeMillis(); if (durl == null) durl = DatasetUrl.findDatasetUrl(cacheLocation); // cache the ServiceType so we dont have to keep figuring it out NetcdfFile ncfile = NetcdfDataset.acquireFile(reader, null, durl, -1, cancelTask, spiObject); // must merge NcML before enhancing if (mergeNcml != null) ncfile = NcMLReader.mergeNcML(ncfile, mergeNcml); // create new dataset if (enhance == null || enhance.isEmpty()) { if (debugOpenFile) System.out.println(" acquire (no enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ncfile; } // must enhance NetcdfDataset ds; if (ncfile instanceof NetcdfDataset) { ds = (NetcdfDataset) ncfile; ds.enhance(enhance); // enhance "in place", ie modify the NetcdfDataset } else { ds = new NetcdfDataset(ncfile, enhance); // enhance when wrapping } if (debugOpenFile) System.out.println(" acquire (enhance) " + cacheLocation + " took " + (System.currentTimeMillis() - start)); return ds; }
/** * Open a file, keep track of open files * @param location open this location * @param openFiles keep track of open files * @return file or null if not found */ private NetcdfDataset open(String location, HashMap<String, NetcdfDataset> openFiles) { // } throws IOException { NetcdfDataset ncd = null; if (openFiles != null) { ncd = openFiles.get(location); if (ncd != null) return ncd; } try { if (config.innerNcml == null) { ncd = NetcdfDataset.acquireDataset(location, null); // default enhance } else { NetcdfFile nc = NetcdfDataset.acquireFile(location, null); ncd = NcMLReader.mergeNcML(nc, config.innerNcml); // create new dataset ncd.enhance(); // now that the ncml is added, enhance "in place", ie modify the NetcdfDataset } } catch (IOException ioe) { logger.error("Cant open file ", ioe); // file was deleted ?? return null; } if (openFiles != null && ncd != null) { openFiles.put(location, ncd); } return ncd; }
/** * Open a file, keep track of open files * @param location open this location * @param openFiles keep track of open files * @return file or null if not found */ private NetcdfDataset open(String location, Map<String, NetcdfDataset> openFiles) throws IOException { NetcdfDataset ncd; if (openFiles != null) { ncd = openFiles.get(location); if (ncd != null) return ncd; } if (config.innerNcml == null) { ncd = NetcdfDataset.acquireDataset(location, null); // default enhance } else { NetcdfFile nc = NetcdfDataset.acquireFile(location, null); ncd = NcMLReader.mergeNcML(nc, config.innerNcml); // create new dataset ncd.enhance(); // now that the ncml is added, enhance "in place", ie modify the NetcdfDataset } if (openFiles != null && ncd != null) { openFiles.put(location, ncd); } return ncd; }
/** * Open a file, keep track of open files * @param location open this location * @param openFiles keep track of open files * @return file or null if not found */ private NetcdfDataset open(String location, Map<String, NetcdfDataset> openFiles) throws IOException { NetcdfDataset ncd; if (openFiles != null) { ncd = openFiles.get(location); if (ncd != null) return ncd; } if (config.innerNcml == null) { ncd = NetcdfDataset.acquireDataset(new DatasetUrl(null, location), true, null); // default enhance } else { NetcdfFile nc = NetcdfDataset.acquireFile(new DatasetUrl(null, location), null); ncd = NcMLReader.mergeNcML(nc, config.innerNcml); // create new dataset ncd.enhance(); // now that the ncml is added, enhance "in place", ie modify the NetcdfDataset } if (openFiles != null && ncd != null) { openFiles.put(location, ncd); } return ncd; }
NetcdfDataset ncd = NcMLReader.mergeNcML(nc, ncml); // create new dataset
NetcdfDataset ncd = NcMLReader.mergeNcML(nc, ncml); // create new dataset
NetcdfDataset ncd = NcMLReader.mergeNcML(nc, ncml); // create new dataset