A bug with Lat/Lon grids...

John Caron caron at unidata.ucar.edu
Mon Feb 26 10:09:04 MST 2007


Hi Rob: thanks, I found this bug and will patch 2.2.18. Still looking at the gini stride problem.

Rob Weingruber wrote:
> Hi John -
> 
> Looks like I might have found another bug, this time with server-side 
> Netcdf data
> that's natively in a lat/lon grid (seems to work if non-LL grid).
> 
> The method on GridCoordSys:
> 
> public List getRangesFromLatLonRect(LatLonRect rect)
> 
> has this snippet of code near the beginning of the method:
> 
>     if (isLatLon()) {
>       minx = getMinOrMaxLon( llpt.getLongitude(), ulpt.getLongitude(), 
> true);
>       miny = Math.min( llpt.getLatitude(), lrpt.getLatitude());
>       maxx = getMinOrMaxLon( urpt.getLongitude(), lrpt.getLongitude(), 
> false);
>       maxy = Math.min( ulpt.getLatitude(), urpt.getLatitude());
> 
>     } else {...}
> 
> If I try to geoGrid.subset(....) with a lat/lon bbox that is *bigger* 
> than the data
> (say I zooom waaaay out, strides = 1), the above code will return, say, 
> a minx and maxx that would
> extend outside of the data.  That's good (i think).  But then a few 
> lines later, the following
> code will have problems:
> 
>     if ((xaxis instanceof CoordinateAxis1D) && (yaxis instanceof 
> CoordinateAxis1D)) {
>       CoordinateAxis1D xaxis1 = (CoordinateAxis1D) xaxis;
>       CoordinateAxis1D yaxis1 = (CoordinateAxis1D) yaxis;
> 
>       int minxIndex = xaxis1.findCoordElementBounded(minx);
>       int minyIndex = yaxis1.findCoordElementBounded(miny);
> 
>       int maxxIndex = xaxis1.findCoordElementBounded(maxx);
>       int maxyIndex = yaxis1.findCoordElementBounded(maxy);
> 
>       ArrayList list = new ArrayList();
>       try {
>         list.add(new Range(Math.min(minyIndex, maxyIndex), 
> Math.max(minyIndex, maxyIndex)));
>         list.add(new Range(Math.min(minxIndex, maxxIndex), 
> Math.max(minxIndex, maxxIndex)));
>       } catch (InvalidRangeException e) {
>         e.printStackTrace();
>       }
> 
> 
> If the minx/maxx etc fall outside of the data, then for example,
> xaxis1.findCoordElementBounded(minx) might return -1, in which
> case the new Range(....) will throw an exception.
> 
> Havent tried non-1 strides yet...
> 
> Here's the url (with tunnel ;-( that I am using:
> 
> http://www.rap.ucar.edu/projects/rdwx_mdss/thredds.php/dodsC/data/decIR
> 
> geoGridName = "micron11"
> 
> And an example data file is attached.
> 
> ;-)  Thanks for listening, and whatever you can do ;-))
> 
> Enjoying the conference??
> 
> ;-)



More information about the Netcdf-java mailing list