private String debugMissingVar(NetcdfFile proto, NetcdfFile result) { Formatter f = new Formatter(); f.format("%nresult dataset %s%n", result.getLocation()); for (Variable v: result.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); f.format("%n"); f.format("proto dataset %s%n", proto.getLocation()); for (Variable v: proto.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); return f.toString(); }
private String debugMissingVar(NetcdfFile proto, NetcdfFile result) { Formatter f = new Formatter(); f.format("%nresult dataset %s%n", result.getLocation()); for (Variable v: result.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); f.format("%n"); f.format("proto dataset %s%n", proto.getLocation()); for (Variable v: proto.getVariables()) f.format(" %s%n", v.getNameAndDimensions()); return f.toString(); }
protected void toStringStart(Formatter f, Indent indent, boolean strict) { String name = getLocation(); if (strict) { if (name.endsWith(".nc")) name = name.substring(0, name.length() - 3); if (name.endsWith(".cdl")) name = name.substring(0, name.length() - 4); name = NetcdfFile.makeValidCDLName(name); } f.format("%snetcdf %s {%n", indent, name); indent.incr(); rootGroup.writeCDL(f, indent, strict); indent.decr(); }
protected void toStringStart(Formatter f, Indent indent, boolean strict) { String name = getLocation(); if (strict) { if (name.endsWith(".nc")) name = name.substring(0, name.length() - 3); if (name.endsWith(".cdl")) name = name.substring(0, name.length() - 4); name = NetcdfFile.makeValidCDLName(name); } f.format("%snetcdf %s {%n", indent, name); indent.incr(); rootGroup.writeCDL(f, indent, strict); indent.decr(); }
/** * Copy constructor, used by NetcdfDataset. * Shares the iosp. * * @param ncfile copy from here */ protected NetcdfFile(NetcdfFile ncfile) { this.location = ncfile.getLocation(); this.id = ncfile.getId(); this.title = ncfile.getTitle(); this.spi = ncfile.spi; }
/** * Copy constructor, used by NetcdfDataset. * Shares the iosp. * * @param ncfile copy from here */ protected NetcdfFile(NetcdfFile ncfile) { this.location = ncfile.getLocation(); this.id = ncfile.getId(); this.title = ncfile.getTitle(); this.spi = ncfile.spi; }
/** * Copy constructor, used by NetcdfDataset. * Shares the iosp. * * @param ncfile copy from here */ protected NetcdfFile(NetcdfFile ncfile) { this.location = ncfile.getLocation(); this.id = ncfile.getId(); this.title = ncfile.getTitle(); this.spi = ncfile.spi; }
/** * Debugging * * @param out write here * @param ncd info about this */ public static void debugDump(PrintStream out, NetcdfDataset ncd) { String referencedLocation = ncd.orgFile == null ? "(null)" : ncd.orgFile.getLocation(); out.println("\nNetcdfDataset dump = " + ncd.getLocation() + " url= " + referencedLocation + "\n"); ncd.dumpClasses(ncd.getRootGroup(), out); }
/** * Debugging * * @param out write here * @param ncd info about this */ public static void debugDump(PrintWriter out, NetcdfDataset ncd) { String referencedLocation = ncd.orgFile == null ? "(null)" : ncd.orgFile.getLocation(); out.println("\nNetcdfDataset dump = " + ncd.getLocation() + " url= " + referencedLocation + "\n"); ncd.dumpClasses(ncd.getRootGroup(), out); }
/** * Debugging * * @param out write here * @param ncd info about this */ public static void debugDump(PrintWriter out, NetcdfDataset ncd) { String referencedLocation = ncd.orgFile == null ? "(null)" : ncd.orgFile.getLocation(); out.println("\nNetcdfDataset dump = " + ncd.getLocation() + " url= " + referencedLocation + "\n"); ncd.dumpClasses(ncd.getRootGroup(), out); }
private boolean compare(NetcdfFile nc1, NetcdfFile nc2, boolean showCompare, boolean showEach, boolean compareData) throws IOException { Formatter f = new Formatter(); CompareNetcdf2 tc = new CompareNetcdf2(f, showCompare, showEach, compareData); boolean ok = tc.compare(nc1, nc2, new CompareNetcdf2.Netcdf4ObjectFilter(), showCompare, showEach, compareData); System.out.printf(" %s compare %s to %s ok = %s%n", ok ? "" : "***", nc1.getLocation(), nc2.getLocation(), ok); if(!ok) System.out.printf(" %s%n", f); return ok; }
/** read all data, make sure variable metadata matches the array */ static public void testReadData( NetcdfFile ncfile, boolean showStatus) { try { for (Variable v : ncfile.getVariables()) { testVarMatchesData(v, showStatus); } } catch (IOException ioe) { ioe.printStackTrace(); assert (false); } if (showStatus) logger.debug( "**** testReadData done on {}", ncfile.getLocation()); }
@Test public void testUamiv() throws IOException { try (NetcdfFile ncfile = NetcdfFile.open(TestDir.cdmUnitTestDir + "formats/uamiv/uamiv.grid", null)) { logger.debug("open {}", ncfile.getLocation()); ucar.nc2.Variable v = ncfile.findVariable("UP"); assert v != null; assert v.getDataType() == DataType.FLOAT; Array data = v.read(); assert Arrays.equals(data.getShape(), new int[]{12, 5, 7, 6}); } }
private void testEquals(String ncmlLocation) throws IOException { System.out.println("testEquals"); NetcdfDataset ncd = NcMLReader.readNcML(ncmlLocation, null); String locref = ncd.getReferencedFile().getLocation(); NetcdfDataset ncdref = NetcdfDataset.openDataset(locref, false, null); ucar.unidata.util.test.CompareNetcdf.compareFiles(ncd, ncdref, false, false, false); ncd.close(); ncdref.close(); }
private void testEnhanceEquals(String ncmlLocation) throws IOException { System.out.println("testEnhanceEquals"); NetcdfDataset ncml = NcMLReader.readNcML(ncmlLocation, null); NetcdfDataset ncmlEnhanced = new NetcdfDataset(ncml, true); String locref = ncml.getReferencedFile().getLocation(); NetcdfDataset ncdrefEnhanced = NetcdfDataset.openDataset(locref, true, null); ucar.unidata.util.test.CompareNetcdf.compareFiles(ncmlEnhanced, ncdrefEnhanced, false, false, false); ncml.close(); ncdrefEnhanced.close(); }
public NcStreamWriterChannel(NetcdfFile ncfile, String location) throws IOException { this.ncfile = ncfile; NcStreamProto.Group.Builder rootBuilder = NcStream.encodeGroup(ncfile.getRootGroup(), sizeToCache); NcStreamProto.Header.Builder headerBuilder = NcStreamProto.Header.newBuilder(); headerBuilder.setLocation(location == null ? ncfile.getLocation() : location); if (ncfile.getTitle() != null) headerBuilder.setTitle(ncfile.getTitle()); if (ncfile.getId() != null) headerBuilder.setId(ncfile.getId()); headerBuilder.setRoot(rootBuilder); header = headerBuilder.build(); }
public NcStreamWriterChannel(NetcdfFile ncfile, String location) throws IOException { this.ncfile = ncfile; NcStreamProto.Group.Builder rootBuilder = NcStream.encodeGroup(ncfile.getRootGroup(), sizeToCache); NcStreamProto.Header.Builder headerBuilder = NcStreamProto.Header.newBuilder(); headerBuilder.setLocation(location == null ? ncfile.getLocation() : location); if (ncfile.getTitle() != null) headerBuilder.setTitle(ncfile.getTitle()); if (ncfile.getId() != null) headerBuilder.setId(ncfile.getId()); headerBuilder.setRoot(rootBuilder); header = headerBuilder.build(); }
public NcStreamWriterChannel(NetcdfFile ncfile, String location) throws IOException { this.ncfile = ncfile; NcStreamProto.Group.Builder rootBuilder = NcStream.encodeGroup(ncfile.getRootGroup(), sizeToCache); NcStreamProto.Header.Builder headerBuilder = NcStreamProto.Header.newBuilder(); headerBuilder.setLocation(location == null ? ncfile.getLocation() : location); if (ncfile.getTitle() != null) headerBuilder.setTitle(ncfile.getTitle()); if (ncfile.getId() != null) headerBuilder.setId(ncfile.getId()); headerBuilder.setRoot(rootBuilder); header = headerBuilder.build(); }
public NcStreamWriter(NetcdfFile ncfile, String location) throws IOException { this.ncfile = ncfile; NcStreamProto.Group.Builder rootBuilder = NcStream.encodeGroup(ncfile.getRootGroup(), sizeToCache); NcStreamProto.Header.Builder headerBuilder = NcStreamProto.Header.newBuilder(); headerBuilder.setLocation(location == null ? ncfile.getLocation() : location); if (ncfile.getTitle() != null) headerBuilder.setTitle(ncfile.getTitle()); if (ncfile.getId() != null) headerBuilder.setId(ncfile.getId()); headerBuilder.setRoot(rootBuilder); headerBuilder.setVersion(currentVersion); header = headerBuilder.build(); }
public NcStreamWriter(NetcdfFile ncfile, String location) throws IOException { this.ncfile = ncfile; NcStreamProto.Group.Builder rootBuilder = NcStream.encodeGroup(ncfile.getRootGroup(), sizeToCache); NcStreamProto.Header.Builder headerBuilder = NcStreamProto.Header.newBuilder(); headerBuilder.setLocation(location == null ? ncfile.getLocation() : location); if (ncfile.getTitle() != null) headerBuilder.setTitle(ncfile.getTitle()); if (ncfile.getId() != null) headerBuilder.setId(ncfile.getId()); headerBuilder.setRoot(rootBuilder); headerBuilder.setVersion(currentVersion); header = headerBuilder.build(); }