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] Reading "linearly" through a multi-dimensional array

hi there,

I have a scenario where I need to read the entire contents of a
multi-dimensional section'ed variable piecewise linearly.

for example, say the variable has shape [a][b][c] and I have section'ed
it as [s1][s2][s3]. say data type is double. now i need to read the
stream of elements, the total size of which is s1.size * s2.size *
s3.size in chunks, for example of chunk size x.

the API for variable doesn't allow me to specify "flat" linear indices,
so I need to calculate intermediate sub-sections, I guess. this looks
very complicated because the chunk size x might not be a simple multiple
of s3.size, s2.size*s3.size, etc.

So I can only think of two approaches: read "too" much data and then
throw away some. Read multiple times; perhaps this problem can be
formulated in maximally three read calls?

Has anyone solved this somehow? Or is there a trick in the API that I
haven't seen, to get a linear read command that preserves the offsets
and strides of sections?

thanks, .h.h.



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