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.
> John, > > Thanks for the info. I suspected that groups weren't implemented based > on the resulting file. I've implemented my data model using all global > variables and attributes, which will work, but it's very messy. I have > 40+ channels of data which each have their own attributes, so I end up > with a huge list of variables and attributes. > > I'm trying to avoid using the C library interface since I'm trying to > minimize platform dependencies. > > I'm very happy to be able to read hdf files directly in Java and output > the simple netcdf format for my data model. I'm curious about the > future development and enhancement of the Java library. I hope that it > will continue be be developed since I would like to base several data > readers on it. The netCDF-Java library is an integral part of Unidata's development plans, so it will continue to be developed and enhanced into the forseeable future. > I have already written a MODIS reader (ported from a C > program) using the Java API, and I'm thining about porting a McIdas, and > ASTER (hdf) reader also. I would be very interested in incorporating your code into the base, if possible. > > FYI, Here is the project I'm working on. You can add it to your list of > packages using the Java netCDF library. > > http://miningsolutions.itsc.uah.edu/glider/ very cool, i will add. > > Thanks, > Todd > > Unidata netCDF Java Support wrote: > > Hi Todd: > > > > Netcdf-Java can only write to netcdf-3 format, which does not support > > groups. I realize the API is confusing, since NetcdfFileWriteable > > subclasses NetcdfFile which has an addGroup() method. I will refactor > > eventually to clarify that. > > > > Meanwhile, the only way to use Groups is in netcdf-4, which requires the C > > library. We may eventually have a JNI interface to it, but not yet. > > > > John > > > > > >> Hi, > >> > >> I'm trying to create a netCDF file using the netCDF Java 4.1 and I'm > >> having some trouble. I'm trying to use groups, but I haven't found a > >> good example with the current API. So my first question is are groups > >> even supported in the output API? I'm able to create an output file, > >> but the groups seem to be ignored. Instead, the variables in shown in > >> the NetCDFTools app as group/varname, but no groups are defined. In my > >> program, the NetcdfFile.findGroup method also fails to find the groups > >> when I try to read in the created file. > >> > >> Here's a snippet of the code that creates the group and it's attributes > >> and variables > >> > >> // previous open in another method > >> NetcdfFileWriteable fptr = > >> NetcdfFileWriteable.createNew(GliderFilename, false); > >> > >> Group g=new Group(fptr, null, mGroupName); > >> fptr.addGroup(null, g); > >> > >> // dimensions are defined global > >> fptr.addVariable(g,"Image", DataType.SHORT, "NumberOfLines > >> NumberOfPixels"); > >> > >> fptr.addAttribute(g, new Attribute("Key", new Integer(mKey))); > >> fptr.addAttribute(g, new Attribute("Type", new Integer(mType))); > >> fptr.addAttribute(g, new Attribute("Units", new Integer(mUnits))); > >> fptr.addAttribute(g, new Attribute("NumPix", new Integer(mNumPix))); > >> fptr.addAttribute(g, new Attribute("NumLines", new > >> Integer(mNumLines))); > >> fptr.addAttribute(g, new Attribute("ChannelWaveLength", new > >> Float(mChannelWaveLength))); > >> fptr.addAttribute(g, new Attribute("SpatialResolutionX", new > >> Float(mSpatialResolutionX))); > >> fptr.addAttribute(g, new Attribute("SpatialResolutionY", new > >> Float(mSpatialResolutionY))); > >> fptr.addAttribute(g, new Attribute("DataByteSize", new > >> Integer(mDataByteSize))); > >> fptr.addAttribute(g, new Attribute("MaxValue", new > >> Float(mMaxValue))); > >> fptr.addAttribute(g, new Attribute("MinValue", new > >> Float(mMinValue))); > >> fptr.addAttribute(g, new Attribute("ChannelLabel", new > >> String(mChannelLabel))); > >> fptr.addAttribute(g, new Attribute("ChannelComment", new > >> String(mChannelComment))); > >> > >> // set up channel LUT for scaling one and two byte unsigned values > >> if (mChannelLUT!=null) { > >> Array lut = Array.factory( mChannelLUT); > >> fptr.addAttribute(g, new Attribute("ChannelLUT", lut)); > >> > >> } > >> > >> fptr.addVariable(g,"HistogramMaxValue", DataType.FLOAT,null); > >> fptr.addVariable(g,"HistogramMinValue", DataType.FLOAT,null); > >> fptr.addVariable(g,"HistogramBins", DataType.INT, > >> "NumHistogramBins"); > >> > >> It seems like all of these things get interpreted as global and the > >> group is ignored. Am I missing something? > >> > >> Thanks, > >> > >> Todd > >> > >> > >> > >> > > > > > > Ticket Details > > =================== > > Ticket ID: CQJ-124352 > > Department: Support netCDF Java > > Priority: Normal > > Status: Closed > > > > > > > > > -- > __________________________________________ > > Todd Berendes > Research Scientist > Information Technology and Systems Center > University of Alabama in Huntsville > (256) 824-4251 > address@hidden > __________________________________________ > > Ticket Details =================== Ticket ID: CQJ-124352 Department: Support netCDF Java Priority: Normal Status: Open