This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Philippe: The most efficient solution: Array data = v.read(); float[] fdata =(float []) data.get1DJavaArray(float.class); this avoids copying if the data is already float. However, you have a 1D array, not 2D. Since you are worried about efficiency, the fastest thing to do is to work with the 1D array (ie dont use a 2D array), and do the stride arithmetic yourself, so use fdata[j*nx+i] whenever you want f[j][i], where nx = data.getShape()[1]. Im assuming you know these are 2D arrays. otherwise you have to allocate the 2D array and copy into it, in which case you might as well do Index ima = data.getIndex(); int [] shape = data.getShape(); for (int j = 0; j<shape[0]; j++) for (int i = 0; i<shape[1]; i++) f[j][i] = data.getFloat( ima.set(j,i)); Regards, John Ticket Details =================== Ticket ID: SCH-111122 Department: Support netCDF Java Priority: Normal Status: Open