Hi Alexander:
You are subsetting [-180,+180] across a [0,360] dataset. This is a known
bug. Sorry, but I dont have a fix for it yet.
John
On 1/21/2011 2:00 PM, Alexander Berkes wrote:
Hello,
I found some strange behaviour when subsetting a GridDataset:
Grib2 file used:
http://nomad3.ncep.noaa.gov/pub/gfs/rotating-0.5/gfs.t00z.pgrb2f00
netcdf-java library version: tested with both 4.2 and 4.2.18 (with the
same results)
-----------------------------code snippet
begin-----------------------------------------
GridDatatype gdt = gds.findGridDatatype(name);
int rtIndex = gdt.getRunTimeDimensionIndex();
int eIndex = gdt.getEnsembleDimensionIndex();
int zDimIndex = gdt.getZDimensionIndex();
int timeIndex = gdt.getTimeDimensionIndex();
Array data = gdt.readDataSlice(rtIndex, eIndex, timeIndex, zDimIndex,
-1, -1);
float[] values = (float[]) data.get1DJavaArray(float.class);
System.out.println("Length: "+values.length);
-----------------------------code snippet
end-------------------------------------------
This gives me the correct length of values: 259920
(tested with some linux-commandline-tools, so this is correct)
But when I try to make a subset like this:
-----------------------------code snippet
begin-----------------------------------------
LatLonRect bounds = new LatLonRect(new LatLonPointImpl(-90, -180), new
LatLonPointImpl(90, 180)); //(whole world)
GridDatatype gdt = gds.findGridDatatype(name);
GridDatatype gdt = gdt.makeSubset(null, null, bounds, -1, -1, -1);
int rtIndex = gdt.getRunTimeDimensionIndex();
int eIndex = gdt.getEnsembleDimensionIndex();
int zDimIndex = gdt.getZDimensionIndex();
int timeIndex = gdt.getTimeDimensionIndex();
Array data = gdt.readDataSlice(rtIndex, eIndex, timeIndex, zDimIndex,
-1, -1);
float[] values = (float[]) data.get1DJavaArray(float.class);
System.out.println("Length: "+values.length);
-----------------------------code snippet
end-------------------------------------------
This gives me the wrong length of values: 130321
As my bounds reflect the whole world, the above method
should give me the same length of values as the first mentioned or
am I missing something?
This has also effect on the point-lengths I get from the x and y axis:
-----------------------------code snippet
begin-----------------------------------------
GridCoordSystem coordSys = gdt.getCoordinateSystem();
CoordinateAxis xAxis = coordSys.getXHorizAxis();
CoordinateAxis yAxis = coordSys.getYHorizAxis();
long xSize = xAxis.getSize();
long ySize = yAxis.getSize();
System.out.println("Total size: "+xSize*ySize);
-----------------------------code snippet
end-------------------------------------------
Without subsetting I get the correct point count = 259920
With subsetting I get the same incorrect point count = 130321
This seems to be a strange issue, because it only fails with the
noaa grib files (both grib1 and grib2 version) f.e.:
grib2: http://nomad3.ncep.noaa.gov/pub/gfs/rotating-0.5/gfs.t00z.pgrb2f00
grib1: http://nomad3.ncep.noaa.gov/pub/gfs/rotating/gfs.t00z.pgrbf00
I tested other grib1 files (zygrib files, grib.us files f.e. and others)
where this doesn't fail...
Furthermore it is maybe interesting to mention, that when I display on a GUI
the subsetting method seems to only deliver points>= the 0 meridian in
England
Any help would be appreciated!
Best regards,
Alex
_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/