Re: [visad] Linear*DSet progression arguments... bug or feature?

  • To: Stefan Below <stefanbelow@xxxxxx>
  • Subject: Re: [visad] Linear*DSet progression arguments... bug or feature?
  • From: Curtis Rueden <ctrueden@xxxxxxxx>
  • Date: Tue, 13 Mar 2012 10:27:07 -0500
Hi Stefan,

As Don mentions, the problem is that System.currentTimeMillis() returns
values that are too large to be completely represented as 32-bit floats,
which is what Linear*Set uses internally. Here is some code that
illustrates the basic issue:

        long x = System.currentTimeMillis();
        long y = x + 1;
        float f = (float) x;
        float g = (float) y;
        long xp = (long) f;
        long yp = (long) g;
        System.out.println(x + " != " + xp);
        System.out.println(y + " != " + yp);

You can use the Gridded*DDoubleSet to explicitly define your entire
sampling grid (but make it linear to match Linear*DSet). The performance
penalty should not be too much, and the precision will allow for use of
64-bit timestamps as domain sample coordinates.

Alternately, have you tried using VisAD's Units package? Use smaller values
for your Linear*DSet range, but assign a Unit to them at construction to
define the unit that those smaller values represent. I have not used this
feature much myself, but it may work.

HTH,
Curtis


On Tue, Mar 13, 2012 at 9:46 AM, Stefan Below <stefanbelow@xxxxxx> wrote:

> Another picture with vector plots and the sam issue:
>
> When i use the correct date, i get this:
>
> http://tinypic.com/r/uadxg/5
>
> with dummy dates (start value set to 0, end value to number of steps):
> http://tinypic.com/view.php?**pic=2s7civq&s=5<http://tinypic.com/view.php?pic=2s7civq&s=5>
>
> The vector plot with correct date values are somehow interpolated or
> gridded. There are n Vector on the same point....
>
> Stefan
>
>
>
>
>
>
>
>
>
>
>  Hi,
>> what i wanna do is plotting time series.
>>
>> When i set the Linear*set or griddedset to fake dates (eg. from 0 to
>> numbers of steps)
>> time_set = new Linear1DSet(time, 0,5, 5);
>>
>> the plot is ok. 
>> (http://tinypic.com/r/121ykxl/**5<http://tinypic.com/r/121ykxl/5>
>> )
>>
>> But when i change the Linearset to real time values like
>>
>> double currentTime = new DateTime().getValue();
>> time_set = new Linear1DSet(time, currentTime,currentTime+5, 5);
>>
>>
>> i get this plot:  http://tinypic.com/r/161hw0n/5
>> (Axis labels are correct, but plot shows only one singe vertical line)
>>
>>
>> xAxis is mapped to RealType.Time
>>
>> Thanks for your help,
>> Stefan
>>
>> Am 13.03.2012 14:49, schrieb Don Murray:
>>
>>> Hi Stefan-
>>>
>>> I'm not sure what you mean by "the plot looks very strange".
>>> Linear*DSets are backed by float values, so when you use very large
>>> numbers, you will run into precision problems.  If you need that type of
>>> precision, then you could use the Gridded*DDoubleSet.  Unfortunately, there
>>> are no Linear*DDoubleSet classes.
>>>
>>> Don
>>>
>>> On 3/12/12 9:26 AM, Stefan Below wrote:
>>>
>>>> Hello,
>>>>
>>>> i am just start learning this powerful visualisation library and now
>>>> some questions come up.
>>>>
>>>> When i use Linear*DSet with arithmetic progression, i get different
>>>> visualisation results when first/last arguments are quite high.
>>>>
>>>> For example, if i use this
>>>> domain_set = new Linear2DSet(domain_tuple, 0.0, NROWS, NROWS,
>>>> 0, NCOLS, NCOLS);
>>>>
>>>> the plot looks fine.
>>>>
>>>> But when i use
>>>> long xEnd=System.currentTimeMillis(**);
>>>> long xStart = xEnd-NCOLS;
>>>> domain_set = new Linear2DSet(domain_tuple, 0.0, NROWS, NROWS,
>>>> 0, NCOLS, NCOLS);
>>>>
>>>> (Look at the attachment for a full working example , line 112ff)
>>>>
>>>> The plot looks very strange.
>>>> I expect that the plot is the same except the labels of the xAxis.
>>>>
>>>> Maybe someone can give me a hint?
>>>>
>>>> Or do i have to set the Axis values in an other way?
>>>>
>>>> Thanks,
>>>> Stefan Below
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ______________________________**_________________
>>>> visad mailing list
>>>> visad@xxxxxxxxxxxxxxxx
>>>> For list information, to unsubscribe, visit:
>>>> http://www.unidata.ucar.edu/**mailing_lists/<http://www.unidata.ucar.edu/mailing_lists/>
>>>>
>>>
>>>
>> ______________________________**_________________
>> visad mailing list
>> visad@xxxxxxxxxxxxxxxx
>> For list information, to unsubscribe, visit: http://www.unidata.ucar.edu/
>> **mailing_lists/ <http://www.unidata.ucar.edu/mailing_lists/>
>>
>
> ______________________________**_________________
> visad mailing list
> visad@xxxxxxxxxxxxxxxx
> For list information, to unsubscribe, visit: http://www.unidata.ucar.edu/*
> *mailing_lists/ <http://www.unidata.ucar.edu/mailing_lists/>
>