NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[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: