/** * Get number of coordinates in this Dataset. * If not already set, open the file and get it from the aggregation dimension. * * @param cancelTask allow cancellation * @return number of coordinates in this Dataset. * @throws java.io.IOException if io error */ public int getNcoords(CancelTask cancelTask) throws IOException { if (ncoord <= 0) { try (NetcdfFile ncd=acquireFile(cancelTask)) { if ((cancelTask != null) && cancelTask.isCancel()) return 0; Dimension d = ncd.findDimension(dimName); // long name of dimension if (d != null) ncoord = d.getLength(); else throw new IllegalArgumentException("Dimension not found= " + dimName); } } return ncoord; }
@Override protected Array read(Variable mainv, CancelTask cancelTask, List<Range> section) throws IOException, InvalidRangeException { NetcdfFile ncd = null; try { ncd = acquireFile(cancelTask); if ((cancelTask != null) && cancelTask.isCancel()) return null; Variable v = findVariable(ncd, mainv); if (v == null) { logger.error("AggOuterDimension cant find " + mainv.getFullName() + " in " + ncd.getLocation() + "; return all zeroes!!!"); return Array.factory(mainv.getDataType(), new Section(section).getShape()); // all zeros LOOK need missing value } if (debugRead) { Section want = new Section(section); System.out.printf("AggOuter.read(%s) %s from %s in %s%n", want, mainv.getNameAndDimensions(), v.getNameAndDimensions(), getLocation()); } // its possible that we are asking for more of the time coordinate than actually exists (fmrc ragged time) // so we need to read only what is there Range fullRange = v.getRanges().get(0); Range want = section.get(0); if (fullRange.last() < want.last()) { Range limitRange = new Range(want.first(), fullRange.last(), want.stride()); section = new ArrayList<>(section); // make a copy section.set(0, limitRange); } return v.read(section); } finally { close(ncd); } }
@Override protected Array read(Variable mainv, CancelTask cancelTask, List<Range> section) throws IOException, InvalidRangeException { NetcdfFile ncd = null; try { ncd = acquireFile(cancelTask); if ((cancelTask != null) && cancelTask.isCancel()) return null; Variable v = findVariable(ncd, mainv); if (v == null) { logger.error("AggOuterDimension cant find " + mainv.getFullName() + " in " + ncd.getLocation() + "; return all zeroes!!!"); return Array.factory(mainv.getDataType(), new Section(section).getShape()); // all zeros LOOK need missing value } if (debugRead) { Section want = new Section(section); System.out.printf("AggOuter.read(%s) %s from %s in %s%n", want, mainv.getNameAndDimensions(), v.getNameAndDimensions(), getLocation()); } // its possible that we are asking for more of the time coordinate than actually exists (fmrc ragged time) // so we need to read only what is there Range fullRange = v.getRanges().get(0); Range want = section.get(0); if (fullRange.last() < want.last()) { Range limitRange = new Range(want.first(), fullRange.last(), want.stride()); section = new ArrayList<Range>(section); // make a copy section.set(0, limitRange); } return v.read(section); } finally { close(ncd); } }
@Override protected Array read(Variable mainv, CancelTask cancelTask, List<Range> section) throws IOException, InvalidRangeException { NetcdfFile ncd = null; try { ncd = acquireFile(cancelTask); if ((cancelTask != null) && cancelTask.isCancel()) return null; Variable v = findVariable(ncd, mainv); if (v == null) { logger.error("AggOuterDimension cant find " + mainv.getFullName() + " in " + ncd.getLocation() + "; return all zeroes!!!"); return Array.factory(mainv.getDataType(), new Section(section).getShape()); // all zeros LOOK need missing value } if (debugRead) { Section want = new Section(section); System.out.printf("AggOuter.read(%s) %s from %s in %s%n", want, mainv.getNameAndDimensions(), v.getNameAndDimensions(), getLocation()); } // its possible that we are asking for more of the time coordinate than actually exists (fmrc ragged time) // so we need to read only what is there Range fullRange = v.getRanges().get(0); Range want = section.get(0); if (fullRange.last() < want.last()) { Range limitRange = new Range(want.first(), fullRange.last(), want.stride()); section = new ArrayList<Range>(section); // make a copy section.set(0, limitRange); } return v.read(section); } finally { close(ncd); } }
/** * Get number of coordinates in this Dataset. * If not already set, open the file and get it from the aggregation dimension. * * @param cancelTask allow cancellation * @return number of coordinates in this Dataset. * @throws java.io.IOException if io error */ public int getNcoords(CancelTask cancelTask) throws IOException { if (ncoord <= 0) { NetcdfFile ncd = null; try { ncd = acquireFile(cancelTask); if ((cancelTask != null) && cancelTask.isCancel()) return 0; Dimension d = ncd.findDimension(dimName); // long name of dimension if (d != null) ncoord = d.getLength(); else throw new IllegalArgumentException("Dimension not found= " + dimName); } finally { close(ncd); } } return ncoord; }
/** * Get number of coordinates in this Dataset. * If not already set, open the file and get it from the aggregation dimension. * * @param cancelTask allow cancellation * @return number of coordinates in this Dataset. * @throws java.io.IOException if io error */ public int getNcoords(CancelTask cancelTask) throws IOException { if (ncoord <= 0) { NetcdfFile ncd = null; try { ncd = acquireFile(cancelTask); if ((cancelTask != null) && cancelTask.isCancel()) return 0; Dimension d = ncd.findDimension(dimName); // long name of dimension if (d != null) ncoord = d.getLength(); else throw new IllegalArgumentException("Dimension not found= " + dimName); } finally { close(ncd); } } return ncoord; }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }
protected Array read(DatasetOuterDimension dset) throws IOException { Array data = getData(dset.getId()); if (data != null) return data; if (type == Type.joinNew) return null; // ?? NetcdfFile ncfile = null; try { ncfile = dset.acquireFile(null); return read(dset, ncfile); } finally { if (ncfile != null) ncfile.close(); } }