Re: NetCDF attributes

Hi Cristy,
 
First, these are great questions that really get to the heart of VisAD.
 
> I can display my netCDF file using code from DisplayTest, case 10.
> However, I cannot figure out how to query the attributes of the file.
> In my test netCDF file I use variables (x, y) -> documents.  Where x goes
> from 1-30 and y goes from 1-40.  I will not always know this apriori.  If
> I read this file as
>
>   java DisplayTest 10 equinox.nc
>
> it displays as expected.  My question is how can I query the range of
> the x and y variables.  When I try
>
>   double[] range1lat = map1lat.getRange();
>
> where map1lat is
>
>   new ScalarMap((RealType) dtype.getComponent(0),Display.XAxis));
>
> NaN is returned.  I tried various other combinations of methods and
> could not produce the simple result of 1,30 and 1,40 for (x,y).  Any
> suggestions?
 
The range of values in a ScalarMap (returned by getRange) is set either
by (1) an explicit call to setRange, or (2) autoscaling the first time
data objects are displayed.  Autoscaling will compute the ranges of
values of RealTypes, which is what you want.  But autoscaling does not
happen until the Display thread has had time to display the data.  So
an immediate call to getRange is likely to return NaN (i.e., missing).
 
Case 27 of visad/examples/DisplayTest.java calls getRange to get the
same information you are after, and it first waits 2 seconds (this is
a bit of a kludge, we should create some sort of event / listener
mechanism for when autoscaled ranges are available).
 
Another, and probably better, way to get the range of values of
x and y from your netCDF file would be like this:
 
  Field netCDF = . . .
  SampledSet set = (SampledSet) netCDF.getDomainSet();
  // getDomainSet throws VisADException, RemoteException
  float[] low = set.getLow();
  float[] hi = set.getHi();
  // now low = {min_x, min_y} and hi = {max_low, max_hi}
 
 
> Another question.  I have a JTable.  I would like the cursor on the
> surface to reflect the proper entry in the JTable.  Which method
> returns the (x,y) position of the cursor on the 3-D surface?  From
> this I can compute the appropriate entry in the JTable.
 
There are two ways to approach this.  First, you can get the cursor
location as follows:
 
  DisplayImplJ3D display = . . .
  Vector cursor_vector = display.getDisplayRenderer().getCursorStringVector();
  Enumeration strings = cursor_vector.elements();
  while(strings.hasMoreElements()) {
    String string = (String) strings.nextElement();
    // parse string; these are just the strings of the
    // form "nl = 1.6514" that appear in the display window
    // when you press the middle mouse button
  }
 
The second way to do this, and more in the VisAD spirit, is to
create your own cursor as a RealTuple data object displayed using
DirectManipulationRendererJ3D.  This is done by case 27 of
visad/examples/DisplayTest.java (note case 27 again, a very useful
case).  The benefit of doing it this way is that this RealTuple
data object can be connected to a computational Cell (via a call
to addReference) and the Cell's doAction method will be invoked
whenever the RealTuple "cursor" is moved.  The drawback is the
"cursor" will appear as a dot rather than a cross hair (you can
at least make the dot large by:
 
  GraphicsModeControl mode = display.getGraphicsModeControl();
  mode.setPointSize(5.0f);
 
Note that DisplayRealType "Shape" is currently not implemented.
When it is, it will allow you to define any shape you want for
a customized cursor.
 
Please let me know if you have any other questions or problems.
 
Bill
 
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
whibbard@xxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html

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