@Test public void testRedefine() throws IOException, InvalidRangeException { String org = TestDir.cdmLocalTestDataDir + "testWriteRecord.nc"; String path = tempFolder.newFile().getAbsolutePath(); File orgFile = new File(org); File newFile = new File(path); if (newFile.exists()) newFile.delete(); IO.copyFile(orgFile, newFile); try (NetcdfFileWriter ncfile = NetcdfFileWriter.openExisting(path)) { System.out.println(ncfile); ncfile.setRedefineMode(true); Variable tvar = ncfile.findVariable("T"); ncfile.setExtraHeaderBytes(1024); ncfile.addVariable("header_data", DataType.FLOAT, tvar.getDimensions()); System.out.println(ncfile); } } }
writer.setExtraHeaderBytes(64 * 1024);
@Test public void testRewriteHeader3() throws IOException, InvalidRangeException { String filename = tempFolder.newFile().getAbsolutePath(); try (NetcdfFileWriter file = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, filename)) { file.addGlobalAttribute("att8", "1234567890"); file.setExtraHeaderBytes(10); file.create(); file.setRedefineMode(true); file.addGlobalAttribute("att8", "123456789012345"); boolean rewriteAll = file.setRedefineMode(false); assert !rewriteAll; Attribute att = file.findGlobalAttribute("att8"); assert att != null; assert att.getStringValue().equals("123456789012345") : att.getStringValue(); } }
String filename = tempFolder.newFile().getAbsolutePath(); NetcdfFileWriter ncFile = NetcdfFileWriter.createNew (filename, false); ncFile.setExtraHeaderBytes (64*1000); Dimension dim = ncFile.addDimension ("time", 100);