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 John: You dont want to have to read the data in order to write the next time step. Have a look at this example and let me know if that clarifies things: http://www.unidata.ucar.edu/software/netcdf-java/tutorial/NetcdfWriteable.html#RecordAtaTime John Cartwright wrote:
Hello All,I have a question very similar to Chris' regarding appending data to a previously created file. I have a simple 3D file w/ longitude,latitude, and time as the dimensions. Time is the unlimited dimension. I'm having a little trouble getting my array indices correct in the program that appends the data. Do the x,y elements of the origins array need to be incremented as well? The code below does not seem to increment the timestep. Can someone help me out w/ what I'm doing wrong?Thanks! -- john //add some data (1 days worth) Variable time = ncfile.findVariable("time"); ArrayInt.D1 timeData = (ArrayInt.D1)time.read(); timeData.set(timeDim.getLength()-1, daysSinceEpoch); ncfile.write("time", timeData); Variable atmp = ncfile.findVariable("atmp"); int[] origin = new int[3]; origin[0] = ncfile.findDimension("time").getLength() -1; ArrayInt.D3 atmpData = (ArrayInt.D3)atmp.read(); int time_idx = timeDim.getLength()-1; //generate a grid of dummy data to append at the new timestep int counter = 0; for (int lat_idx = 0; lat_idx < latDim.getLength(); lat_idx++) { for (int lon_idx = 0; lon_idx < lonDim.getLength(); lon_idx++) { atmpData.set(time_idx, lat_idx, lon_idx, counter); counter++; } } ncfile.write("atmp", origin, atmpData); _______________________________________________ netcdf-java mailing list netcdf-java@xxxxxxxxxxxxxxxxFor list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/
netcdf-java
archives: