Weird problem with interpolation

Hi all,

I'm trying to do what I thought was a fairly straightforward field.evaluate(blah) call, and ended up with some NullPointerExceptions. It's a tool under development, so I *might* be giving bad samples or something like that, but I'll post various bits of code and stack trace, and you can make up your own minds. I looked at the VisAD source to try to see what was going on. The datestamp on my visad.jar is July 14th, and the source I'm working from is out of the visad_src.jar with the same timestamp. I included a lot of code / traces, so hopefully what you need is here. Let me know if I've made a dumb error....

My code is :


double[][] timeSet = animationControl.getSet().getDoubles(false); Real timeSample = new Real(RealType.Time, timeSet[0][animationControl.getCurrent()]); FieldImpl distanceField = (FieldImpl)field.evaluate(timeSample);
RealTuple domainSample = new RealTuple(LEVEL_DISTANCE_TYPE, new double[] { dDistance, dHeight });
               Data intensityData = distanceField.evaluate(domainSample);
               RealTuple intensityTuple = (RealTuple) intensityData;
               double[] intensityValues = intensityTuple.getValues();

with the error occurring on the line that reads
               Data intensityData = distanceField.evaluate(domainSample);

The mathType of the FieldImpl is :
((LevelXS, VerticalDistanceXS) -> XSGASPMIX)

The RealType I'm trying to evaluate has the samples :
(224.13154940119756, 205.24017467248817)

Both those numbers are valid numbers to ask for, for either level _or_ distance, so it's not a silly specified-the-samples-wrong problem.

The stack trace is :
at visad.Gridded2DDoubleSet.valueToInterp(
       at visad.FieldImpl.resample(
       at visad.FunctionImpl.evaluate(
       at visad.FunctionImpl.evaluate(
at at$900( at$MouseMovedListener.mouseMoved( at java.awt.AWTEventMulticaster.mouseMoved(
       at java.awt.Component.processMouseMotionEvent(
       at java.awt.Component.processEvent(
       at java.awt.Component.dispatchEventImpl(
       at java.awt.Component.dispatchEvent(
       at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForHierarchy( at java.awt.EventDispatchThread.pumpEventsForHierarchy( at java.awt.EventDispatchThread.pumpEvents( at java.awt.EventDispatchThread.pumpEvents(

Gridded2DDoubleSet.valueToInterp reads :

 /** for each of an array of values in R^DomainDimension, compute an array
     of 1-D indices and an array of weights, to be used for interpolation;
     indices[i] and weights[i] are null if i-th value is outside grid
     (i.e., if no interpolation is possible) */
 public void valueToInterp(float[][] value, int[][] indices,
   float[][] weights) throws VisADException
   int len = weights.length;
   double[][] w = new double[len][];
   for (int i=0; i<len; i++) w[i] = new double[weights[i].length];
   doubleToInterp(Set.floatToDouble(value), indices, w);
   for (int i=0; i<len; i++) {
     System.arraycopy(w[i], 0, weights[i], 0, w.length);

With the problematic line being :
   for (int i=0; i<len; i++) w[i] = new double[weights[i].length];

Looking at at visad.FieldImpl.resample(, which is the calling line shows :

     int[][] indices = new int[length][];
     float[][] coefs = new float[length][];
((GriddedSet) DomainSet).valueToInterp(vals, indices, coefs); <-- this is the calling line

So the weights[][] array in interp is this coefs array. The line " for (int i=0; i<len; i++) w[i] = new double[weights[i].length];" doesn't seem like it will ever work, because it's always a new double[length][], i.e. null for all i.


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