[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- Date: Mon, 22 Jul 2002 10:35:41 -0600
Bob,
> This is a clarification to your e-mail regarding
> the confusion over the generation of lines such as:
>
> float latitude(latitude);
> int woce_date(woce_date);
> char pcode(pcode_no, strlen10);
> float temperature(time,pressure, latitude,longitude);
>
> In my question I should have said that the above lines were
> from a generation of CDL from an existing binary netCDF file by "ncdump",
> and, that I am attempting to do this in a Java program. I have
> done this by the command "System.out.println( nc )", but I would like
> to know how this can be done by individul Java commands.
OK, thanks, now I understand the question.
Assume you have a ucar.netcdf.Variable ncvar that you got from the
getVariableIterator() method of NetcdfFile, for example.
To get its type, use
ncvar.getComponentType()
which returns a Class whose toString() method can be used for the type
string.
To get its dimensions, use a dimension iterator:
ucar.netcdf.DimensionIterator iter=ncvar.getDimensionIterator();
To get the name for each dimension, use its getName() method:
iter.next().getName()
This is all done in a private method in the source for
ucar.nc2.Variable:
private void getFullNameN(StringBuffer buf) {
buf.append(ncvar.getComponentType());
buf.append(" ");
buf.append(ncvar.getName());
buf.append("(");
ucar.netcdf.DimensionIterator iter=ncvar.getDimensionIterator();
while( iter.hasNext()) {
buf.append( iter.next().getName() );
if(!iter.hasNext())
break;
buf.append(",");
}
buf.append(")");
}
--Russ