Re: Time values as floats

Hi Russell,

First, IrregularSet.valueToIndex() returns visad.UnimplementedException
because this class is intended as an implementation of the general n-D
IrregularSet, which would be very complex and hence has never been done
(but note IrregularSet also serves as the superclass of Irregular1DSet,
etc).

For times you need doubles, so I am afraid you need to sort them and
use a Gridded1DDoubleSet. At least VisAD gives you some help with the
sort. Given an array 'double[] times' and an array 'Data[] range' of
dependent values, you can do:

  int n = times.length;
  double[] newTimes = new double[n];
  System.arraycopy(time, 0, newTimes, 0, n);
  int[] newToOld = QuickSort.sort(newTimes);
  Data[] newRange = new Data[n];
  for (int i=0; i<n; i++) {
    newRange[i] = range[newToOld[i]];
  }

and now newTimes and newRange are sorted versions of the times and
range arrays.

The sort could be avoided if VisAD included an implementation of
Irregular1DDoubleSet (extending Irregular1DSet) and an
IrregularDoubleSet interface for it to implement, similar to
Gridded1DDoubleSet and GriddedDoubleSet. But these are not yet
implemented.

Cheers,
Bill

> I am attempting to construct a FlatField with a FunctionType that is
> (Time -> (Latitude, Longitude, <other stuff> )).  I have been using an
> IrregularSet as the domain.  I chose IrregularSet because the data will
> not necessarily be in any fixed time sequence.
> 
> My problem is that the Time values get rounded to intervals of 32
> seconds.  This is because the IrregularSet is initialised with
> float[][], and java floats (which are IEEE floats) have only 24 bits of
> precision.  The measure of seconds from 1970-01-01 to now (2001-06-22)
> takes 29 bits.  I would like to retain one second precision.
> 
> One way around this that I have investigated is to start with an empty
> IrregularSet and then fill in the FlatField values with setSample(),
> which is actually FieldImpl.setSample(RealTuple domain,Data range). This
> would allow the Time values to remain as doubles and not go through the
> float array step. But this results in an UnimplementedException, which
> originates from IrregularSet.valueToIndex().  (On the other hand,
> IrregularSet appears to store floats internally, so this may not make
> any difference.)
> 
> Have I missed something here? Is there some better way to implement the
> domain in this case?
> 
> Is IrregularSet.valueToIndex() meant to remain unimplemented, given that
> its "samples do not form any ordered pattern" (from the javadoc)?

--
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


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