static public boolean compareFiles(NetcdfFile org, NetcdfFile copy, Formatter f, boolean _compareData, boolean _showCompare, boolean _showEach) { CompareNetcdf2 tc = new CompareNetcdf2(f, _showCompare, _showEach, _compareData); return tc.compare(org, copy); }
static public boolean compareFiles(NetcdfFile org, NetcdfFile copy, Formatter f, boolean _compareData, boolean _showCompare, boolean _showEach) { CompareNetcdf2 tc = new CompareNetcdf2(f, _showCompare, _showEach, _compareData); return tc.compare(org, copy); }
static public boolean compareFiles(NetcdfFile org, NetcdfFile copy, Formatter f, boolean _compareData, boolean _showCompare, boolean _showEach) { CompareNetcdf2 tc = new CompareNetcdf2(f, _showCompare, _showEach, _compareData); return tc.compare(org, copy); }
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; }
static int compareDatasets(String local, String remote, boolean readData) throws IOException { System.out.printf("--Compare %s to %s%n", local, remote); try (NetcdfFile ncfile = NetcdfDataset.openFile(local, null); NetcdfFile ncremote = new CdmRemote(remote)) { Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(ncfile, ncremote, new NcstreamObjFilter(), false, false, readData); if (!ok) { System.out.printf(" %s%n", f); } Assert.assertTrue(local + " != " + remote, ok); } return 1; }
static int compareDatasets(String local, String remote, boolean readData) throws IOException { try (NetcdfFile ncfile = NetcdfDataset.openFile(local, null); NetcdfFile ncremote = new CdmRemote(remote)) { Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(ncfile, ncremote, new NcstreamObjFilter(), false, false, readData); if (!ok) { System.out.printf("--Compare %s to %s%n", local, remote); System.out.printf(" %s%n", f); } Assert.assertTrue(local + " != " + remote, ok); } return 1; }
public void compare(Structure obs) throws IOException, InvalidRangeException { int start = 0; for (Message m : msgs) { Array data1; if (!m.isTablesComplete()) continue; if (!m.dds.isCompressed()) { MessageUncompressedDataReader reader = new MessageUncompressedDataReader(); data1 = reader.readEntireMessage(construct.recordStructure, protoMessage, m, raf, null); } else { MessageCompressedDataReader reader = new MessageCompressedDataReader(); data1 = reader.readEntireMessage(construct.recordStructure, protoMessage, m, raf, null); } int n = m.getNumberDatasets(); m.calcTotalBits(null); Array data2 = obs.read(new Section().appendRange(start, start + n - 1)); CompareNetcdf2 cn = new CompareNetcdf2( new Formatter(System.out), true, true, true); cn.compareData("all", data1, data2, true); start += n; } }
private boolean doCompare(String location, boolean showCompare, boolean showEach, boolean compareData) throws IOException { NetcdfFile ncfile = NetcdfFile.open(location); NetcdfFile jni = openJni(location); jni.setLocation(location+" (jni)"); //System.out.printf("Compare %s to %s%n", ncfile.getIosp().getClass().getName(), jni.getIosp().getClass().getName()); Formatter f= new Formatter(); CompareNetcdf2 tc = new CompareNetcdf2(f, showCompare, showEach, compareData); boolean ok = tc.compare(ncfile, jni, new CompareNetcdf2.Netcdf4ObjectFilter(), showCompare, showEach, compareData); System.out.printf(" %s compare %s ok = %s%n", ok ? "" : "***", location, ok); if (!ok ||(showCompare && showCompareResults)) System.out.printf("%s%n=====================================%n", f); ncfile.close(); jni.close(); return ok; }
public int doAct(String filename) throws IOException { filename = StringUtil2.replace(filename, '\\', "/"); filename = StringUtil2.remove(filename, dirName); String dodsUrl = urlPrefix + filename; String localPath = dirName + filename; logger.debug("--Compare {} to {}", localPath, dodsUrl); NetcdfDataset org_ncfile = NetcdfDataset.openDataset(localPath); NetcdfDataset dods_file = NetcdfDataset.openDataset(dodsUrl); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(org_ncfile, dods_file, new TestDODScompareWithFiles.DodsObjFilter(), false, false, false); if (!ok) { logger.debug("--Compare {}", filename); logger.debug(" {}", f); } Assert.assertTrue( localPath+ " != "+dodsUrl, ok); return 1; } }, false);
private void compareDatasets(String dodsUrl, String localPath) throws IOException { System.out.printf("--Compare %s to %s%n", localPath, dodsUrl); NetcdfDataset ncfile = null, ncremote = null; try { ncfile = NetcdfDataset.openDataset(localPath); ncremote = NetcdfDataset.openDataset(dodsUrl); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, false, false, false); boolean ok = mind.compare(ncfile, ncremote, new DodsObjFilter(), showCompare, showEach, compareData); if (!ok) { System.out.printf("--Compare %s%n", filename); System.out.printf(" %s%n", f); fail++; } else { success++; } Assert.assertTrue( localPath+ " != "+dodsUrl, ok); } finally { if (ncfile != null) ncfile.close(); if (ncremote != null) ncremote.close(); } }
@Test public void testChardata() { // was failing on char data being sign extended try { String filename = "/netcdf3/files/c0_64.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void compareDatasets() throws IOException { NetcdfFile ncfile = null, jni = null; try { ncfile = NetcdfFile.open(filename); jni = openJni(filename); jni.setLocation(filename + " (jni)"); System.err.println("Test input: "+ncfile.getLocation()); System.err.println("Baseline: "+jni.getLocation()); System.err.flush(); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, false); boolean ok = mind.compare(ncfile, jni, new CompareNetcdf2.Netcdf4ObjectFilter(), true, true, false); if (!ok) { fail++; System.out.printf("--Compare %s%n", filename); System.out.printf(" %s%n", f); } else { System.out.printf("--Compare %s is OK%n", filename); success++; } Assert.assertTrue(filename, ok); } finally { if (ncfile != null) ncfile.close(); if (jni != null) jni.close(); } }
@Test public void testByteOrder() { try { String filename = "/netcdf3/longOffset.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath + filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, true, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testVlen() { try { String filename = "/netcdf4/vlen/tst_vl.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testVlenInStructure() { try { String filename = "/netcdf4/vlen/IntTimSciSamp.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testVariableNameWithDot() { try { String filename = "/hdf5/grid_1_3d_xyz_aug.h5"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), false, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } } }
@Test public void testTopVlenInt() { try { String filename = "/netcdf4/vlen/vlenInt.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
@Test public void testStringArray() { try { String filename = "/netcdf4/files/tst_string_data.nc"; String remoteFile = TestOnLocalServer.withHttpPath(urlPath+filename); CdmRemote ncfileRemote = new CdmRemote(remoteFile); String localFile = contentRoot+filename; NetcdfFile ncfileLocal = NetcdfFile.open(localFile); Formatter f = new Formatter(); CompareNetcdf2 mind = new CompareNetcdf2(f, true, true, true); boolean ok = mind.compare(ncfileLocal, ncfileRemote, new TestCdmRemoteCompareHeadersP.NcstreamObjFilter(), true, false, true); System.out.printf("--Compare %s to %s%n", localFile, remoteFile); System.out.printf(" %s%n", f); Assert.assertTrue(ok); ncfileLocal.close(); ncfileRemote.close(); } catch (Exception e) { e.printStackTrace(); assert false; } }
CompareNetcdf2 nc = new CompareNetcdf2(compareOutputFormatter, false, false, true);
@Test public void testMissingDataReplaced() throws Exception { // this one has misssing longitude data, but not getting set to NaN String filename = TestDir.cdmUnitTestDir + "/ft/point/netcdf/Surface_Synoptic_20090921_0000.nc"; NetcdfFile ncfile = null; NetcdfDataset ds = null; try { ncfile = NetcdfFile.open(filename); ds = NetcdfDataset.openDataset(filename); String varName = "Lon"; Variable wrap = ds.findVariable(varName); Array data_wrap = wrap.read(); CompareNetcdf2 compare = new CompareNetcdf2(); assert wrap instanceof CoordinateAxis1D; CoordinateAxis1D axis = (CoordinateAxis1D) wrap; assert compare.compareData(varName, data_wrap, axis.getCoordValues()); } finally { if (ncfile != null) ncfile.close(); if (ds != null) ds.close(); } }