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.
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
visad
archives: