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 Carl:Use
GridCoordSys gcsys = grid.getCoordinateSystem()(); Coordinateavis1D axis = gcsys.getVerticalAxis() Generally, the GridCoordSys has lots of good stuff in it. Carl Drews wrote:
John - I have developed a way to extract the grib vertical levels from a Netcdf structure, but it seems rather awkward to me. Do I really have to get the vertical levels by "Name" and then convert the strings to floats? // load the input file into a NetcdfDataset _gridset = ucar.nc2.dataset.grid.GridDataset.open(_gribFilename); ... _mdv = createMDV(_gridset); public Mdv createMDV(ucar.nc2.dataset.grid.GridDataset gridset) { // get the vertical levels java.util.List grids = gridset.getGrids(); GeoGrid firstGeoGrid = (GeoGrid)grids.get(0); ArrayList vlevels = firstGeoGrid.getLevels(); Field newField = createMDVField(oneVar, vlevels); ... } public Field createMDVField(Variable netVar, ArrayList verticalLevels) { ... // create the vertical levels fieldHeader.setNz(verticalLevels.size()); VlevelHdr vlevelHeader = new VlevelHdr(); int[] vtype = vlevelHeader.getVlevelTypes(); float[] vparam = vlevelHeader.getVlevelParams(); for (int zi = 0; zi < fieldHeader.getNz(); zi++) { vtype[zi] = levelType; } for (int zi = 0; zi < fieldHeader.getNz(); zi++) { NamedObject oneLevel = (NamedObject)verticalLevels.get(zi); float oneLevelValue = new Float(oneLevel.getName()); vparam[zi] = oneLevelValue; } ... } Carl
netcdf-java
archives: