NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdf-java] Remove z levels

Hi all,
I'm new to netCDF and I've a simple (I think) problem.
I've a netCDF file containing currents forecast (u and v variables) for 3 days and 33 deep ocean levels. Now I would to remove all deep levels but the first one (0.0 - surface level).
How I can do it?
I tryed this but does't works:

        String fileIn = "C:/Users/Test/Desktop/latest.nc";
        NetcdfFileWriteable  aa = NetcdfFileWriteable.openExisting(fileIn);
        List<Variable> vars2 = aa.getVariables();
        for (Variable va : vars2) {
            System.out.println("Variable name :" + va.getFullName());
            List<Dimension> dims = va.getDimensions();
            for (Dimension di : dims) {
System.out.println("dim name: " + di.getName() + " len:" + di.getLength());

                if (di.getName().equals("Depth")) di.setLength(1);
            }
        }
        aa.finish();
        aa.finish();
        aa.close();

This is my output:
Variable name :u
dim name: MT   len:3
dim name: Depth   len:33
dim name: Y   len:30
dim name: X   len:38
Variable name :MT
dim name: MT   len:3
Variable name :Depth
dim name: Depth   len:1
Variable name :Latitude
dim name: Y   len:30
dim name: X   len:38
Variable name :Longitude
dim name: Y   len:30
dim name: X   len:38
Variable name :v
dim name: MT   len:3
dim name: Depth   len:1
dim name: Y   len:30
dim name: X   len:38


What could be wrong?

Best regards
Giovanni



  • 2013 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: