public static void main(String arg[]) { String url = "http://localhost:8080/thredds/dodsC/testContent/testData.nc.ascii?reftime[0:1:0]"; // "http://ingrid.ldeo.columbia.edu/expert/SOURCES/.LEVITUS94/dods"; try (DODSNetcdfFile df = new DODSNetcdfFile(url, null)) { System.out.println("dods file = " + url + "\n" + df); } catch (Exception ioe) { System.out.println("error = " + url); ioe.printStackTrace(); } }
private void downloadDapFile(File targetDir, String dapURI, boolean isLargeFile) throws IOException { String[] uriComponents = dapURI.split("\\?"); String constraintExpression = ""; String fileName = dapURI.substring(uriComponents[0].lastIndexOf("/") + 1); if (uriComponents.length > 1) { constraintExpression = uriComponents[1]; } updateProgressBar(fileName, 0); DODSNetcdfFile netcdfFile = new DODSNetcdfFile(dapURI); writeNetcdfFile(targetDir, fileName, constraintExpression, netcdfFile, isLargeFile); }
static DODSNetcdfFile openAbs(String filename) throws IOException { System.out.println("TestDODSRead = "+filename); DODSNetcdfFile dodsfile = new DODSNetcdfFile(filename); if (showFileDebug) System.out.println(dodsfile.getDetailInfo()); if (showFile) System.out.println(dodsfile.toString()); return dodsfile; }
boolean process1(Testcase testcase) throws Exception { DODSNetcdfFile ncfile = new DODSNetcdfFile(testcase.url); if(ncfile == null) throw new Exception("Cannot read: " + testcase.url); StringWriter ow = new StringWriter(); PrintWriter pw = new PrintWriter(ow); ncfile.writeCDL(pw, false); pw.close(); ow.close(); String captured = ow.toString(); boolean pass = true; visual(testcase.title, captured); if(System.getProperty("baseline") != null) { baseline(testcase, captured); } else pass = diff(testcase, captured); return pass; }
boolean process1(Testcase testcase) throws Exception DODSNetcdfFile ncfile = new DODSNetcdfFile(testcase.url); if(ncfile == null) throw new Exception("Cannot read: " + testcase.url);
boolean localpass = true; try { DODSNetcdfFile ncfile = new DODSNetcdfFile(result.url); if (ncfile == null) throw new Exception("Cannot read: " + result.url);
static void testArray(String urlName) throws IOException, opendap.dap.DAP2Exception { System.out.println("checkArray ="+urlName); DConnect2 dodsConnection = new DConnect2(urlName, true); // get the DataDDS DataDDS dataDDS = dodsConnection.getData("?", null); dataDDS.print(System.out); System.out.println(); DodsV root = DodsV.parseDataDDS( dataDDS); ConvertD2N converter = new ConvertD2N(); DODSNetcdfFile dodsfile = new DODSNetcdfFile(urlName); List vars = dodsfile.getVariables(); for (int i = 0; i < vars.size(); i++) { Variable v = (Variable) vars.get(i); String name = DODSNetcdfFile.getDODSConstraintName(v); DodsV dodsV = root.findByDodsShortName( name); if (dodsV == null) { System.out.println("Cant find "+name); continue; } Array data = converter.convertTopVariable(v, null, dodsV); showArray( v.getFullName(), data, System.out, ""); } /* for (int i = 0; i < root.children.size(); i++) { DodsV dodsV = (DodsV) root.children.get(i); Variable v = dodsfile.findVariable( dodsV.getNetcdfShortName()); Array data = converter.convertTopVariable(v, null, dodsV); showArray( data, System.out, ""); } */ System.out.println("============"); }
static void testConvertDDS( String urlName, DataDDS dataDDS, PrintStream out) throws IOException, DAP2Exception { DODSNetcdfFile dodsfile = new DODSNetcdfFile(urlName); System.out.println(dodsfile.toString()); if (useNC) { List vars = dodsfile.getVariables(); for (int i = 0; i < vars.size(); i++) { Variable v = (Variable) vars.get(i); Array data = v.read(); if (showData) logger.debug(NCdumpW.toString(data, v.getFullName() + data.shapeToString(), null)); } } ConvertD2N converter = new ConvertD2N(); DodsV root = DodsV.parseDataDDS( dataDDS); for (int i = 0; i < root.children.size(); i++) { DodsV dodsV = root.children.get(i); Variable v = dodsfile.findVariable( dodsV.getFullName()); Array data = converter.convertTopVariable(v, null, dodsV); showArray( v.getFullName(), data, out, ""); if (useNC) { Array data2 = v.read(); UtilsMa2Test.testEquals(data, data2); } if (showData) logger.debug(NCdumpW.toString(data, v.getFullName()+data.shapeToString(), null)); } }
@Ignore @Test public void testActualWriting() throws Exception { final DAPDownloader dapDownloader = new DAPDownloader(null, null, new NullDownloadContext(), new NullLabelledProgressBarPM()); final DODSNetcdfFile sourceNetcdfFile = new DODSNetcdfFile( "http://test.opendap.org:80/opendap/data/nc/coads_climatology.nc"); dapDownloader.writeNetcdfFile(TESTDATA_DIR, "deleteme.nc", "", sourceNetcdfFile, false); final File testFile = getTestFile("deleteme.nc"); assertTrue(testFile.exists()); assertTrue(NetcdfFile.canOpen(testFile.getAbsolutePath())); final NetcdfFile netcdfFile = NetcdfFileOpener.open(testFile.getAbsolutePath()); assertNotNull(netcdfFile.findVariable("SST")); }
@Ignore @Test public void testActualWriting_WithConstraint() throws Exception { final DAPDownloader dapDownloader = new DAPDownloader(null, null, new NullDownloadContext(), new NullLabelledProgressBarPM()); final DODSNetcdfFile sourceNetcdfFile = new DODSNetcdfFile( "http://test.opendap.org:80/opendap/data/nc/coads_climatology.nc"); dapDownloader.writeNetcdfFile(TESTDATA_DIR, "deleteme.nc", "COADSX[0:1:4]", sourceNetcdfFile, false); final File testFile = getTestFile("deleteme.nc"); assertTrue(testFile.exists()); assertTrue(NetcdfFile.canOpen(testFile.getAbsolutePath())); final NetcdfFile netcdfFile = NetcdfFileOpener.open(testFile.getAbsolutePath()); assertNull(netcdfFile.findVariable("SST")); assertNotNull(netcdfFile.findVariable("COADSX")); }
try dfs = new DODSNetcdfFile( dfsURL);