Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
Hi Andreas: The write utilities aren't that convenient to use. Youll have to add the new Variables yourself, then read data from the original file and write to the new file. 1. What version of the library are you using? 2. Generally when you get an Exception, its best to post the complete stack trace if you have it. 3. I find using the GitHub issues on the appropriate repo is better than the mailing list. YMMV. John On Wed, Jun 22, 2022 at 10:31 AM andreas.lieta via netcdf-java < netcdf-java@xxxxxxxxxxxxxxxx> wrote: > I have two Netcdf-4 files. Both are for the same region and same time > interval. The first contains two variables U and V. The second variables S > and T. I need to generate third Netcdf-4 file with four variables U, V, S, > T. I had an idea to make copy of the first file and add additional > variables to the copy. What i did: > > > 1. NetcdfFile fileUV = NetcdfFiles.open(fnameUV); // file with U and > V > 2. NetcdfFile fileST = NetcdfFiles.open(fnameST); // file with S > and T > 3. Nc4Chunking chunker = Nc4ChunkingStrategy.factory(type, > deflateLevel, shuffle); > 4. NetcdfFormatWriter.Builder builder = > NetcdfFormatWriter.createNewNetcdf4(NetcdfFileFormat.NETCDF4, > outName, chunker); > 5. NetcdfCopier copier = NetcdfCopier.create(fileUV, builder); > // copier UV-file -> outfile > 6. NetcdfFile ncfileOut = copier.write(null); // do copy > 7. NetcdfFormatWriter writer = builder.build(); > 8. ImmutableList<Variable> vST = fileST.getVariables(); // variables > S and T > 9. for(var v : vST) writer.write(v, null); // add vriables to > outfile > > > String 7 generates the exception *java.lang.IllegalStateException: Group > was already built.* > > May be it is impossible to use the same builder for copying and adding > variables? Could anyone help me to solve my task correctly? Thanks in > advance > > Andreas Lieta > > _______________________________________________ > NOTE: All exchanges posted to Unidata maintained email lists are > recorded in the Unidata inquiry tracking system and made publicly > available through the web. Users who post to any of the lists we > maintain are reminded to remove any personal information that they > do not want to be made public. > > > netcdf-java mailing list > netcdf-java@xxxxxxxxxxxxxxxx > For list information or to unsubscribe, visit: > https://www.unidata.ucar.edu/mailing_lists/ >
netcdf-java
archives: