Copyrighrt (c) 2014-2020 UPVI, LLC
Welcome, Guest
Username: Password: Remember me
LVHDF5 Toolkit Forum
  • Page:
  • 1


Variable Length (VLEN) datatype in Live HDF5 ? 6 years 7 months ago #14

  • jdsommer
  • jdsommer's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 23
  • Thank you received: 1
Here's a text response. I'll try to find time to do some code in the next day or two if you don't solve the problem before I do. The main problem is that I expect VLENs to be inside of clusters, and never tested the case of a a naked VLEN or, oddly, even envisioned it. A dataset of naked VLENs doesn't make a lot of sense in the general case in LabVIEW because you cannot have an array of arrays. You simply end up with a higher-dimension array, but this is not quite the same thing. So, while you could have a 2-D dataset array of clusters of 1-D array VLENs (which will work with Live HDF5), you can't have a 2-D dataset array of 1-D VLENs without the cluster. This datatype simply can't be represented in LabVIEW.

I think what you're trying to do could be made to work, but it will take (as you guessed) manually wiring the dtype input as well as the memory dataspace input, AND, you'll still have to make the VLEN inside a cluster to get it to work.

Why? Glad you asked.

Live HDF5 has to handle arrays differently than scalars because of the way that LabVIEW stores arrays (look up a discussion on LabVIEW array handles some time). Since, when using datasets, one almost always is passing an array of the datatype (the "dataset array"), the function normally assumes that any array passed to it is an array of dtypes. If dtype is not specified, then it will create a dtype based on the type element type of the array. Likewise, it will create a dataspace (if it is unspecified) based on the dimensions of the array. Finally, any array that is wired to the read and write functions is assumed to be a "dataset array", and Live HDF5 goes into to it to find the first data element. (This is actually also true of the attribute functions, since attributes also have dataspaces.)

I think the following will work. Manually create a file and memory datatype for the array. Be sure to use LVH5Screate_element_type (not LVH5Screate_dataset_type, which creates a type based on the element of the array wired if an array is wired to it). You'll need to use the Memory/File input and call the function twice, one for each datatype. Create any dataspace you like. Wire all these up to the H5Dwrite/read functions. Create your VLEN data arrays and wrap each one in a one-element cluster. Build all the clusters into an array matching the dataspace you previously created. (Skip this step if you created a scalar dataspace.) Wire this array of clusters up to your write and read functions.

The observant will note that the datatype created and wired at the memory and file types doesn't actually match the datatype written/read, since the H5 type is a dataset array of VLENs, while the labview type is a dataset array of a one-member cluster of (VLEN) arrays. However, this should still work because a one-member cluster is a transparent element as far as the data in memory is concerned.

If this seems convoluted, it's because it is. An array of clusters of arrays are the only general way to represent a dataset of VLENs in LabVIEW.

Hope this helps,

Please Log in or Create an account to join the conversation.

Variable Length (VLEN) datatype in Live HDF5 ? 6 years 7 months ago #13

  • gerald
  • gerald's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
I've been trying to to use VLEN datatype in Live HDF5 but have not been able to create an example that works so far...
I could figure out how to use the Array datatype quite easily, but cannot get a simplistic example that would use VLEN data to run.
I attach an example that illustrates the approach : create a VLEN datatype that will simply contain DBL, create a simple dataset that will contain a single element (basically a 1D array that is filled with N samples of a sine wave)
The file is created (in the temp directory), it contains a group and a dataset, but no useful data.
The problem obviously comes from the H5DWrite...but I have not been able to get it to work so far. (should the type ref be connected ? Is is an issue with memory and file space references, ...?)
I'm sure it must be a stupid mistake on my side...

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.140 seconds