Re: [netcdf-java] Reading "linearly" through a multi-dimensional array

hi bob,

the problem with this is that I need an array first; that implies (if I
understand correctly), that I have the entire file read into one array
first (which is not feasible in my case); what I'm doing now, is for a
given linear range (e.g. 1000th to 2000th element in the "flat data") I
calculate small number of appropriate sections which will then when
iterated one after another reproduce that exact linear range.

best, .h.h.


On 26/01/17 17:14, Bob Simons - NOAA Federal wrote:
> Perhaps you could use one of the built-in iterators, such as
> Array.getRangeIterator
> <http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/javadoc/ucar/ma2/Array.html#getRangeIterator-java.util.List->(java.util.List<Range
> <http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/javadoc/ucar/ma2/Range.html>>
>  ranges)
> 
> On Thu, Jan 26, 2017 at 7:58 AM, Hanns Holger Rutz <rutz@xxxxxx
> <mailto:rutz@xxxxxx>> wrote:
> 
>     hi there,
> 
>     for the record, i managed to implement an algorithm that solves
>     this (
>     
> https://stackoverflow.com/questions/41850946/linearly-reading-a-multi-dimensional-array-obeying-dimensional-sub-sectioning#41870662
>     
> <https://stackoverflow.com/questions/41850946/linearly-reading-a-multi-dimensional-array-obeying-dimensional-sub-sectioning#41870662>
>     shows how to generate the sub-ranges within the overall section to
>     be read )
> 
>     best, .h.h.
> 
> 
>     On 25/01/17 12:20, Hanns Holger Rutz wrote:
>     > 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.
>     >
>     > _______________________________________________
>     > NOTE: All exchanges posted to Unidata maintained email lists are
>     > recorded in the Unidata inquiry tracking system and made publicly
>     > available through the web.  Users who post to any of the lists we
>     > maintain are reminded to remove any personal information that they
>     > do not want to be made public.
>     >
>     >
>     > netcdf-java mailing list
>     > netcdf-java@xxxxxxxxxxxxxxxx <mailto:netcdf-java@xxxxxxxxxxxxxxxx>
>     > For list information or to unsubscribe, visit:
>     http://www.unidata.ucar.edu/mailing_lists/
>     <http://www.unidata.ucar.edu/mailing_lists/>
>     >
> 
> 
> 
>     _______________________________________________
>     NOTE: All exchanges posted to Unidata maintained email lists are
>     recorded in the Unidata inquiry tracking system and made publicly
>     available through the web.  Users who post to any of the lists we
>     maintain are reminded to remove any personal information that they
>     do not want to be made public.
> 
> 
>     netcdf-java mailing list
>     netcdf-java@xxxxxxxxxxxxxxxx <mailto:netcdf-java@xxxxxxxxxxxxxxxx>
>     For list information or to unsubscribe, visit:
>     http://www.unidata.ucar.edu/mailing_lists/
>     <http://www.unidata.ucar.edu/mailing_lists/>
> 
> 
> 
> 
> -- 
> Sincerely,
> 
> Bob Simons
> IT Specialist
> Environmental Research Division
> NOAA Southwest Fisheries Science Center
> 99 Pacific St., Suite 255A      (New!)
> Monterey, CA 93940               (New!) 
> Phone: (831)333-9878            (New!)
> Fax:   (831)648-8440
> Email: bob.simons@xxxxxxxx <mailto:bob.simons@xxxxxxxx>
> 
> The contents of this message are mine personally and
> do not necessarily reflect any position of the
> Government or the National Oceanic and Atmospheric Administration.
> <>< <>< <>< <>< <>< <>< <>< <>< <><
> 
> 
> 
> _______________________________________________
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web.  Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
> 
> 
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit: 
> http://www.unidata.ucar.edu/mailing_lists/ 
> 


Attachment: signature.asc
Description: OpenPGP digital signature

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