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 Christopher, Christopher Mueller wrote:
I am subsetting an opendap nc file to a local nc file and I’m running into a bit of a problem. After subsetting, the variable of interest has 4 dimensions (x, y, level, record) however there is only 1 level. I would like to remove the level dimension as it is unnecessary and causes some problems later in the application. Is there a way to do this? I’ve tried removing the dimension from the “root group” of the NetcdfWritable file with no luck. I’ve also tried iterating through the dimensions (var.getDimensions().remove(i)) and removing the one with length = 1, also no luck.Has anyone done this before? Is it possible, or do I need to extract the data, reduce the resulting array, and then recreate the variable by hand?
I haven't tried this but you can create a new Variable without the level dimension by calling Variable.slice() on the existing Variable and specifying the level dimension. Then, before you call create() on your NetcdfFileWritable, you can remove the old Variable and add the new one.
Hope that helps, Ethan -- Ethan R. Davis Telephone: (303) 497-8155 Software Engineer Fax: (303) 497-8690 UCAR Unidata Program Center E-mail: edavis@xxxxxxxx P.O. Box 3000 Boulder, CO 80307-3000 http://www.unidata.ucar.edu/ ---------------------------------------------------------------------------
netcdf-java
archives: