Re: [netcdf-java] sample code for reading multidim vlen variable

  • To: Bob Simons - NOAA Federal <bob.simons@xxxxxxxx>
  • Subject: Re: [netcdf-java] sample code for reading multidim vlen variable
  • From: Christian Ward-Garrison <cwardgar@xxxxxxxx>
  • Date: Mon, 20 Jun 2016 16:57:56 -0600
Hi Bob,

> How do I read the data?

Either via index or via iterator. Here are some example print functions:
https://gist.github.com/cwardgar/44e52ea157e1acc73ec54b37388376e5

The iterator approach is more robust, I'd say, but not exactly convenient.

> Is there a way to find out the various sizes of the second dimension other
> than looking at the sizes of each of the responses for varA[0][*],
varA[1][*], ...?

Nope, you must get the nested ArrayInt objects and ask them their size.

> If a variable uses a vlen dimension, will it always be the rightmost
dimension?

My gut says "yes" because I can't imagine how I'd define a variable with
the vlen dimension on the left, at least in CDL. However, this question is
probably better for the netcdf-c list.

-Christian

On Mon, Jun 20, 2016 at 10:22 AM, Bob Simons - NOAA Federal <
bob.simons@xxxxxxxx> wrote:

> Thanks for the information. Here's a revised request:
>
> I have a file with a variable varA[dimA][*], where the rightmost dimension
> is a vlen dimension.
> 1) How do I read the data? Can/must I make a series of requests: for
> varA[0][*], then varA[1][*], ...? Is there an alternative?
> 2) Is there a way to find out the various sizes of the second dimension
> other than looking at the sizes of each of the responses for varA[0][*],
> varA[1][*], ...?
> 3) If a variable uses a vlen dimension, will it always be the rightmost
> dimension?
>
> Thank you.
>
>
> On Sat, Jun 18, 2016 at 2:48 PM, Christian Ward-Garrison <
> cwardgar@xxxxxxxx> wrote:
>
>> Hi Bob,
>>
>> I did some research, and the short answer is that multiple VLEN
>> dimensions are not supported. Check out the GitHub issue [1] for my full
>> findings. Sorry about that.
>>
>> Cheers,
>> Christian
>>
>> [1] https://github.com/Unidata/thredds/issues/567
>>
>> On Fri, Jun 17, 2016 at 11:33 AM, Bob Simons - NOAA Federal <
>> bob.simons@xxxxxxxx> wrote:
>>
>>> Is there sample code somewhere for reading a multidimensional variable
>>> where some of the dimensions are vlen, e.g., myVar[dimA][*][*] ?
>>>
>>> I found
>>>
>>> http://www.unidata.ucar.edu/software/thredds/v4.5/netcdf-java/reference/StructureData.html#vlen
>>> but the temp variable just has the one dimension.
>>>
>>> Just calling myVar.read() doesn't work(java.io.IOException) -- I suspect
>>> because it would be useless without knowing all the subdimension sizes.
>>>
>>> Is there a way to get a flattened version of the data and dimensions?
>>> e.g., have myVar[dimA][*][*] flattened into
>>> a  b  c myVar
>>> 0  0  0  1.2
>>> 0  0  1  1.4
>>> 0  1  0  1.6
>>> 1  0  0  1.1
>>> 1  0  1  1.3
>>> 1  0  2  1.4
>>> 1  1  0  1.7
>>> 1  1  1  1.1
>>> 1  2  0  1.2
>>>
>>> Or, can you give me general advice on how to get the data out of a
>>> variable like this?
>>> Do I need to iterate through the dimA values, and do separate read()s
>>> for each value of a, then separate reads for each value of that dimension?
>>>
>>> Thank you.
>>>
>>> --
>>> 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
>>>
>>> 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/
>>>
>>
>>
>
>
> --
> 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
>
> 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.
> <>< <>< <>< <>< <>< <>< <>< <>< <><
>
>
  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: