Kevin-
Kevin Manross wrote:
Thanks, Don. This worked to extract the data that I was wanting.
Based on the netCDF file, when I display the data, the coords are
defined by the dimensions of the netCDF file (1079/1298).
Taking the data that I have extracted can I "force" a ScalarMap with
the extracted values? I.e. after calculating the actual Lat/Lon,
create a ScalarMap with those calculated ranges and then (hopefully) the
middle-click will display the actual Lat/Lon as well. It sounds like my
best bet may be just to rewrite the netCDF file to include the actual
lat/lon.
There are a couple of ways you could do this. One would be to
create a new domainSet (LinearLatLonSet) for the FlatField and
then create a new FlatField with the values of the first:
FlatField ff = (FlatField) plain.open("myfile");
Linear2DSet oldSet = (Linear2DSet) ff.getDomainSet();
int numX = oldSet.getLengths()[0];
int numY = oldSet.getLengths()[1];
LinearLatLonSet llSet = new LinearLatLonSet(
RealTupleType.SpatialEarth2DTuple,
startingLon, startingLon+(numX*LonGridSpacing), numX,
startingLat, startingLat+(numX*LatGridSpacing), numY);
FlatField newFF
new FlatField(
new FunctionType(RealTupleType.SpatialEarth2DTuple,
DataUtility.getFlatRangeType(ff)),
llSet);
newFF.setSamples(ff.getSamples(), false);
and then use newFF (I didn't check this code to see if it compiles
or is accurate). The false on the setSamples says not to copy
the arrays so it should be memory efficient.
The other way would be to create a new FunctionType where the
domain would be a RealTupleType with a CoordinateSystem that
converted from (index_X, index_Y) -> (Longitude, Latitude)
and then call changeMathType() on the original FlatField.
This would be more complicated but would give you practice
at using CoordinateSystems. You could probably use an
EmpericalCoordinateSystem using the domain set created
by Plain as the world and the LatLonSet as created above as
the reference.
That's the nice thing about VisAD - there are many ways to
skin the same cat.
-------
Finally, regarding the Units question, I tried your suggestion but
received a compile error regarding static methods (still getting
familiar with Java).
RHIpanel.java:97: non-static method setOverrideUnit(visad.Unit) cannot
be referenced from a static context
ScalarMap.setOverrideUnit(km);
You know, I thought about you trying this explicitly when I was
writing it, but meant for you to do what you did below.
I have also tried
xMap.setOverrideUnit(km);
yMap.setOverrideUnit(km);
but still get the previous behavior (xxx.xxxx 1000.0 m)
Hmm, I guess the cursor readout doesn't look at the override unit,
but only displays in the default unit of the ScalarMap.
So, unless Bill thinks we should change this, I don't know
of another way.
Don
*************************************************************
Don Murray UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx P.O. Box 3000
(303) 497-8628 Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************