[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDFJava #CQJ-124352]: Writing netCDF file using netCDF Java 4.1
- Subject: [netCDFJava #CQJ-124352]: Writing netCDF file using netCDF Java 4.1
- Date: Thu, 15 Oct 2009 15:17:05 -0600
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