NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: a few late-night questions

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.
 
A better approach might be to resample to a lower resolution
version of the original Gridded3DSet.  Assume the original
Gridded3DSet and FlatField are constructed by:
 
  float[][] samples = ...
  float[][] values = ...
  Gridded3DSet set = new Gridded3DSet(type, samples, nx, ny, nz);
  FlatField field = new FlatField(ftype, set);
  field.setSamples(values);
 
Then down-sample by an integer factor of nn, as follows:
 
  int mx = (nx + nn - 1) / nn;
  int my = (ny + nn - 1) / nn;
  int mz = (nz + nn - 1) / nn;
 
  float[][] new_samples = new float[3][mx * my * mz];
  float[][] new_values = new float[1][mx * my * mz];
  int m = 0;
  for (int k=0; k<mz; k++) {
    for (int j=0; j<my; j++) {
      for (int i=0; i<mx; i++) {
        int new = i + mx * (j + my * k);
        int old = i*nn + nx * (j*nn + ny * k*nn);
        new_samples[0][new] = samples[0][old];
        new_samples[1][new] = samples[1][old];
        new_samples[2][new] = samples[2][old];
        new_values[0][new] = values[0][old];
      }
    }
  }
  Gridded3DSet new_set
    new Gridded3DSet(type, new_samples, mx, my, mz);
  FlatField new_field = new FlatField(ftype, new_set);
  new_field.setSamples(new_values);
 
There won't be any missing values (unless there were in the
original field values).  I haven;t run this code, so it may
have bugs.  But its the basic idea.
 
By the way, in working on this problem I did find and fix a
bug in the iso-surface computation, that only occurred with
missing data.
 
Cheers,
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
 

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