Re: a few late-night questions

"William L. Hibbard" wrote:
> 
> Hi Doug,
> 
> > 1) Any suggestions on why I am getting missing data from my resamplings?
> > The original data seem to be OK but the grid is not particularly
> > regular. (This is some MM5 output.) I defined the original domain as a
> > Gridded3DSet by giving it a list of coordinates that aren't necessarily
> > monotonically increasing.  This field displays fine, but with 60*60*31
> > wind vectors, the scene is a bit crowded (and slow to rotate). My
> > resampling domain is a simple Linear3DSet (20x20x10). The result is
> > mostly OK but there are enough holes (i.e. missing data) that attempts
> > to do IsoContours are not pretty. As expected, NEAREST_NEIGHBOR doesn't
> > leave as many holes as WEIGHTED_AVERAGE, but there are still plenty.
> 
> I ran some tests and believe that the cause of your missing
> points is the nature of resampling and iso-surface computation
> rather than a bug.  When you resample from your Gridded3DSet to
> a Linear3DSet, any sample locations of the Linear3DSet that lie
> outside any "cubes" of the Gridded3DSet will have Field values
> set to missing.  Then, the iso-surface computation will not draw
> in any "cubes" of the Linear3DSet that have a missing Field value
> at any vertex.  A low-resolution Linear3DSet will have large
> "cubes", and some with corners outside the region of the original
> Gridded3DSet will extend far into it and create holes.
> 

I've boiled down my problem to a simple example. The code is below. Does
your explanation above explain my results?

I am resampling along a 1D manifold in 3D space. When my original field
is defined with a Linear3DSet domain, it works. If defined by the "same"
Gridded3DSet domain, I get missing values (using WEIGHTED_AVERAGE).
NEAREST_NEIGHBOR seems to work so I'll use that for now.

Thanks,
Doug

---
import java.rmi.RemoteException;
import java.lang.Math;
import visad.*;

public class Missing
{
  public static void main(String[] args)
       throws Exception
  {
    Missing demo = new Missing();
  }

  public Missing()
       throws Exception
  {
    RealType lon = new RealType("lon",null,null);
    RealType lat = new RealType("lat",null,null);
    RealType alt = new RealType("alt",null,null);
    RealTupleType pos3d = new RealTupleType(lon,lat,alt);
    RealType temp_type = new RealType("temperature", null, null);
    FunctionType temp_ftype = new FunctionType(pos3d,temp_type);
    RealType x = new RealType("x", null, null);
    FunctionType temp2_ftype = new FunctionType(x,temp_type);

    int nx = 60;
    int ny = 60;
    int nz = 31;

    float[][] temp_coords = new float[3][nx*ny*nz];
    float[][] temp_data = new float[1][nx*ny*nz];

    //--- Define Data and Coordinates ---//
    int icnt=0;
    for (int ialt=0; ialt<nz; ialt++) {
      for (int ilat=0; ilat<ny; ilat++) {
        for (int ilon=0; ilon<nx; ilon++) {
          //temp_data[0][icnt] = (float) (Math.sin(ilat*0.5) +
Math.sin(ilon*0.5));
          temp_data[0][icnt]   = 1.0f;
          temp_coords[0][icnt] = 2.0f*ilon/(nx-1) - 114.0f;
          temp_coords[1][icnt] = 2.0f*ilat/(ny-1) +  39.0f;
          temp_coords[2][icnt] = 20000.0f*ialt/(nz-1);
          icnt++;
        }
      }
    }

    //--- Two versions of the "same" set ---//
    Set temp_gset = new Gridded3DSet(pos3d,temp_coords,nx,ny,nz);
    Set temp_lset = new Linear3DSet(pos3d, -114.0, -112.0, nx
                                        ,   39.0,   41.0, ny
                                        ,    0.0, 20000.0, nz);
    System.out.println(temp_gset.toString());
    System.out.println(temp_lset.toString());

    //--- Two versions of the same Field using the above domain sets
---//
    FlatField templ = new FlatField(temp_ftype,temp_lset);
    templ.setSamples(temp_data);
    FlatField tempg = new FlatField(temp_ftype,temp_gset);
    tempg.setSamples(temp_data);

    //--- Define a 1D manifold in 3D space ---//
    int n = 100;
    FlatField temp2 = new FlatField(temp2_ftype, 
                                    new Linear1DSet(x, 0.0, 1.0*(n-1),
n));
    float[][] traj_coords = new float[3][n];
    for (int i=0; i<n; i++) {
      traj_coords[0][i] = -112.5f - 1.0f/n*i;
      traj_coords[1][i] =   40.9f - 1.0f/n*i;
      traj_coords[2][i] = 5000.0f * (float) Math.sin(i*Math.PI/n);
    }
    Gridded3DSet traj_coord_set = new Gridded3DSet(pos3d,traj_coords,n);

    //--- resample from "Linear" data, no missing values ---//
    temp2.setSamples(((FlatField) templ.resample(traj_coord_set,
                        Data.WEIGHTED_AVERAGE,
Data.NO_ERRORS)).getValues());
    System.out.println(temp2.toString());

    //--- resample from "Gridded" data, missing values ---//
    temp2.setSamples(((FlatField) tempg.resample(traj_coord_set,
                        Data.WEIGHTED_AVERAGE,
Data.NO_ERRORS)).getValues());
    System.out.println(temp2.toString());

    //--- resample from "Gridded" data, NEAREST_NEIGHBOR, no missing
values ---//
    temp2.setSamples(((FlatField) tempg.resample(traj_coord_set,
                        Data.NEAREST_NEIGHBOR,
Data.NO_ERRORS)).getValues());
    System.out.println(temp2.toString());

  }
}

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