void writeNetCDF(String filename) { try { FileWriter2 writer = new FileWriter2(ds, filename, NetcdfFileWriter.Version.netcdf3); NetcdfFile result = writer.write(); result.close(); JOptionPane.showMessageDialog(this, "File successfully written"); } catch (Exception ioe) { JOptionPane.showMessageDialog(this, "ERROR: " + ioe.getMessage()); ioe.printStackTrace(); } }
public void testReadStandardVar() throws Exception { ncfileRead = NetcdfFile.open(filename); dsRead = NetcdfDataset.openDataset(filename); readDouble(); readByte2Short(); readByte(); readShortMissing(); readShort2FloatMissing(); readDoubleMissing(); ncfileRead.close(); dsRead.close(); }
private void compareDataset(CompareDialog.Data data) { if (data.name == null) return; NetcdfFile compareFile = null; try { compareFile = NetcdfDataset.openFile(data.name, null); Formatter f = new Formatter(); CompareNetcdf2 cn = new CompareNetcdf2(f, data.showCompare, data.showDetails, data.readData); if (data.howMuch == CompareDialog.HowMuch.All) cn.compare(ds, compareFile); else { NestedTable nested = nestedTableList.get(0); Variable org = getCurrentVariable(nested.table); if (org == null) return; Variable ov = compareFile.findVariable(org.getFullNameEscaped()); if (ov != null) cn.compareVariable(org, ov); } infoTA.setText(f.toString()); infoTA.gotoTop(); infoWindow.setTitle("Compare"); infoWindow.show(); } catch (Throwable ioe) { ByteArrayOutputStream bos = new ByteArrayOutputStream(10000); ioe.printStackTrace(new PrintStream(bos)); infoTA.setText(bos.toString()); infoTA.gotoTop(); infoWindow.show(); } finally { if (compareFile != null) try { compareFile.close(); } catch (Exception eek) { } } }