Re: Test-Case GriddedTo2DSet

Desiree,

I think you might be having problems with the resolution of floating-point
values in Java.  Differences in the coordinate values are very close to the
resolution of the Java "float" primitive type.

>Date: Fri, 6 Jul 2001 17:20:31 +0200 (MET DST)
>From: Desiree Hilbring <hilbring@xxxxxxxxxxxxxxxxxxxx>
>To: Ugo Taddei <p6taug@xxxxxxxxxxxxxxxxx>
>Subject: Test-Case GriddedTo2DSet

The above message contained the following:

> import visad.*;
> import visad.java2d.DisplayImplJ2D;
> import java.rmi.RemoteException;
> import java.awt.*;
> import javax.swing.*;
> import java.awt.event.*;
> import visad.java3d.DisplayImplJ3D;
> 
> 
> public class DGM1{
> 
>     // Declare variables
>     // The domain quantities longitude and latitude
>     // and the dependent quantities altitude, temperature
>         
>     private RealType eastValues,northValues;
>     private RealType heightValues;
>     
>     // Two Tuples: one to pack longitude and latitude together, as the domain
>     // and the other for the range (altitude, temperature)    
>     private RealTupleType domain_tuple;
>     
>     // The function (domain_tuple -> range_tuple )
>     private FunctionType func_en_h;
> 
>     // Our Data values for the domain are represented by the Set
>     private Set domain_set;
>   
>     // The Data class FlatField
>     private FlatField vals_ff;  
>   
>     // The DataReference from data to display
>     private DataReferenceImpl data_ref;
> 
>     // The 2D display, and its the maps
>     private DisplayImpl display;
>     private ScalarMap eastMap, northMap, heightMap;
>   
>     public DGM1(String []args)
>       throws RemoteException, VisADException {
> 
>       float[] eastNaN = 
> {3479991.5f,3479991.5f,3479991.5f,3479991.5f,3479991.5f,
>                          
> 3479992.5f,3479992.5f,3479992.5f,3479992.5f,3479992.5f,

The difference between these values is perilously close to the
resolution of the IEEE 754-1985 format for single-precision Java
floating-point values (approximately 1 part in 3.5e6).  You might think 
about adjusting them or using double[] arrays.

>                          
> 3479993.5f,3479993.5f,3479993.5f,3479993.5f,3479993.5f,
>                          
> 3479994.5f,3479994.5f,3479994.5f,3479994.5f,3479994.5f,
>                          
> 3479995.5f,3479995.5f,3479995.5f,3479995.5f,3479995.5f,
>                          
> 3479996.5f,3479996.5f,3479996.5f,3479996.5f,3479996.5f,
>                          
> 3479997.5f,3479997.5f,3479997.5f,3479997.5f,3479997.5f,
>                          
> 3479998.5f,3479998.5f,3479998.5f,3479998.5f,3479998.5f,
>                          
> 3479999.5f,3479999.5f,3479999.5f,3479999.5f,3479999.5f};
>       float[] northNaN = 
> {5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,

The comment about resolution is relevant for this variable as well.

>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f,
>                           
> 5417829.5f,5417830.5f,5417831.5f,5417832.5f,5417833.5f};
>       float[] heightNaN = {245.65f,200.0f,200.0f,200.0f,200.0f,
>                            245.65f,200.0f,200.0f,200.0f,200.0f,
>                            245.68f,245.66f,200.0f,200.0f,200.0f,
>                            245.64f,245.64f,200.0f,200.0f,200.0f,
>                            245.63f,245.65f,245.63f,200.0f,200.0f,
>                            245.62f,245.65f,245.63f,200.0f,200.0f,
>                            245.60f,245.62f,245.63f,245.59f,200.0f,
>                            245.60f,245.62f,245.63f,245.59f,200.0f,
>                            245.58f,245.57f,245.62f,245.64f,245.54f};
> 
> 
> 
>       int nCols = 9;
>       int nRows = 5;
>       double[][] coords = new double[2][nCols*nRows]; 
>       for (int i=0;i<(nCols*nRows);i++) {
>           coords[0][i]=eastNaN[i];
>           coords[1][i]=northNaN[i];
>       }
...

Because the float values are being transferred to a double array,
there's no reason that I can see not to specify the float values as
double to begin with.

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>


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