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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [netcdf-java] GridCoordSys introduces rounding error when converting from km to m and integer axis-type



Heiko Klein wrote:
Hi John,

you can download a file from http://pastebin.met.no/pastebin/cgi-bin/file?id=84f2552e57e811173f846941bfab295a733bb219/mipom_nordic4_inM_small4.nc


We've been using the file through thredds/WCS and it didn't give a bounding-box in GetCapabilities. Changing the axes datatype to double solved the problem.


I guess, the problem lies in:
private CoordinateAxis convertUnits(CoordinateAxis axis) {
    ....
    Array data;
    try {
      data = axis.read();
    ....
    IndexIterator ii = data.getIndexIterator();
    while (ii.hasNext())
      ii.setDoubleCurrent(factor * ii.getDoubleNext());
    ....
with data having the same datatype as axis.

yes, thats the problem, thanks for figuring it out. Ill have to figure out a workaround, i guess i should promote to double. it sounds like you have a fix for now?


The class ucar.nc2.dt.grid.GridCoordSys converts internally all projection-axes to km. But it seems like it does not convert the datatype to a float or double datatype and introduces therefore large rounding errors.

I have given my axes as m (in integer):
-3716017, -3712004, -3707991

The isRegular function of Coordinate1D sees (with a debugger attched) the values:
-3716, -3712, -3707
and as such fails with my approx. 4km grid-distance.




Best regards,

Heiko




 
 
  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