Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.

[netcdf-java] indexing problems with sliced array

Hello!

I'm doing a double slice on a three-dimensional variable to get a 1-D slice and 
then trying to read out the values. Unfortunately, indexing seems to give me 
values from the full original array rather than the slice I'm working with.

Array twoD = array.slice(0, 1);
Array oneD = twoD.slice(0,1);
System.out.println(oneD.getDouble(0));
System.out.println(oneD);
System.out.println(array.getDouble(0));

This is what I see:

178.0
-9999 -9999 -9999 81 66 93 103 -9999 -9999 -9999 -9999 -9999
178.0

I would expect the first print statement to print -9999 since that is the first 
element of the slice I'm working on. So this kind of looks like a bug to me. 
How do I get the first element of my slice rather than of the entire parent 
array?

Thanks.
Christine

--------------------------------
Dr. Christine Smit
christine.e.smit@xxxxxxxx<mailto:christine.e.smit@xxxxxxxx>
+1-301-614-5752
NASA Goddard, Building 32, N126-12
Code 610.2

  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: