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

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



If all you want to do is to read the data, you should use 

  Array data = Variable.read()

if you want to then reduce the singleton dimensions, use

  Array.reduce();

> Hi,
> 
> first of all, thanks for the fast reply.
> 
> Basically I have a lot of data on disk (complete meteorological model
> run data) and need an efficient way to carry out multi-slices without
> loading the whole data set into memory. The Array.read(sectionSpec)
> doesn't seem to handle the slices in 2.2 as I still have 4 dimensions
> after the call. This wouldn't be so bad if the sliced dimensions are
> always the first ones, but this isn't necessarily the case.
> 
> If this isn't possible in 2.2 then that seems like a major bug. The
> website indicates that version 4.0 is still alpha, which is probably not
> something that I want to deploy in the most critical part of our
> application.
> 
> Regards,
> 
> Paul
> 
> > -----Original Message-----
> > From: Unidata netCDF Java Support
> > [mailto:address@hidden]
> > Sent: Dienstag, 17. Juni 2008 01:42
> > To: Chown Paul
> > Cc: address@hidden
> > Subject: [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
> >
> >
> 
> 


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