Re: netCDF and other things


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)"myfile");
   Linear2DSet oldSet = (Linear2DSet) ff.getDomainSet();
   int numX = oldSet.getLengths()[0];
   int numY = oldSet.getLengths()[1];
   LinearLatLonSet llSet = new LinearLatLonSet(
       startingLon, startingLon+(numX*LonGridSpacing), numX,
       startingLat, startingLat+(numX*LatGridSpacing), numY);
   FlatField newFF
     new FlatField(
         new FunctionType(RealTupleType.SpatialEarth2DTuple,
   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). non-static method setOverrideUnit(visad.Unit) cannot be referenced from a static context

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


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 Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307

  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: