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

[netCDFJava #SSK-311219]: Slicing in multiple dimensions



Hi Paul:

Hi Paul, youve found a bug in version 2.2 that has been fixed in latest 4.0.
below is a modified version of your testSlice3 which seems to me to be the
correct behavior, which works in 4.0 but not 2.2. Its unlikely we'll fix it in
2.2, but let me know if thats a big problem for you.

  public void testSlice3() throws IOException, InvalidRangeException {
    NetcdfFile file = NetcdfFile.open(NETCDF_FILE);
    Variable var = file.findVariable(DATA_VARIABLE);
    Variable sliced1 = var.slice(0, 3);
    Variable sliced2 = sliced1.slice(0, 3);

    int[] shape = sliced2.getShape();
    assertEquals(2, shape.length);
    assertEquals(DIM_LAT, shape[0]);
    assertEquals(DIM_LON, shape[1]);

    assertEquals("lat lon", sliced2.getDimensionsString());

    Array org = var.read("3,3,:,:");
    Array data = sliced2.read();
    TestCompare.compareData(org, data);
  }

> Sorry, I forgot the attachment....
>
> <<NetCDFTest.java>>
> Regards,
>
> Paul Chown
>
> > _____________________________________________
> > From:       Chown Paul
> > Sent:       Montag, 16. Juni 2008 17:28
> > To: 'address@hidden'
> > Subject:    Slicing in multiple dimensions
> >
> > Hi
> >
> > I am trying to port some code from NetCDF 2.10 to NetCDF 2.2.22 and
> > have a problem when trying to slice a 4D variable down to 2
> > dimensions. I have reproduced this in a JUnit test (attached). The
> > test that fails is testSlice3, and it fails because I get an
> > ArrayIndexOutOfBounds exception.
> >
> > The two slices on their own work correctly, as the other slice tests
> > show, but the combination fails. Similar code in NetCDF 2.10 worked
> > fine. Is this operation still possible in NetCDF 2.2.22?
> >
> > Regards,
> >
> > Paul Chown
> >
> >
> >
> >
> >
> >
> >
>
>


Ticket Details
===================
Ticket ID: SSK-311219
Department: Support netCDF Java
Priority: Normal
Status: Closed