Hi Cameron,
> I am trying to traverse through the structure of a field and extract the data
> for verification purposes.
>
> Here is a snippet of code.
>
> DataImpl mofStructure = plain.open(args[0]); //open and load netcdf file
> FieldImpl mofField = (FieldImpl)mofStructure; //convert to fieldimpl
> Data mofData = mofField.getSample(0); //get first sample
>
> The data object received from 'getSample()' is of type Real.
> It should be tuple however I cannot cast it to Tuple and therefore cannot
> access the data (through getData() from tuple).
> How do I access the data?
If mofData is Real, you can get its value by:
double value = ((Real) mofData)).getValue();
In general, if the MathType of a Field is something like:
((x, y) -> z)
then the samples of the Field will be Real. If the MathType
of the Field is something like:
((x, y) -> (z, w))
then the samples of the Field will be Tuple (actually RealTuple
which is a subclass of Tuple).
So it could be that the netCDF adapter is not reading your
file the way you think it should be. I am not sure how it
will deal with Text values.
Perhaps Steve can tell us.
Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html