Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

RE: the AD in VisAD

Hi Andrew,

On Tue, 25 Mar 2003, Wilson, Andrew, J wrote:
> OK, so for the purposes of my education, lets start with a
> very trivial example. What would be the best, most generic,
> most re-usable way for me to extend the existing
> functionality to enable average and variance to be computed?

I am CC'ing to visad-list, since this is the sort of technical
question that should go to the list.

I wouldn't extend FieldImpl or FlatField, but would write a
static method in some class to do this, much like the methods
in visad.math.Histogram and visad.math.FFT. Given a Field
argument to the method, you could call its getValues() or
getFloats(), then add up the double or float values and
compute the means for each column (i.e., each RealType in
the Field range). Similarly for the variances. You'd probably
want to test values for missing (represented by NaNs, which
fail a 'values[i][j] == values[i][j]' test), and exclude them
from your means and variances. Such a method wouldn't be much
code. You could return the means and variances as simple
double or float arrays, or as a RealTuple.

Note that different samplings of the same function would give
different means and variances, so you might want to precede
the computation by a resample() call to a uniform gridded
sampling.

Good luck,
Bill


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690