I would like to build a 2D dataset by adding 1 extra line in every consecutive save. That is:
First save:
0.2 0.1 0.3 0.5
Second save:
0.2 0.1 0.3 0.5
0.8 0.5 0.6 0.4
and so on. Whenever the user triggers the save action, a new line (trace) is added. However the H5Dcreate_simple.vi seems to interpret every input as a 1D array, and will concatenate the vectors like:
0.2
0.1
0.3
0.5
0.8
0.5
0.6
0.4
If anyone knows a way to do this or a workaround I would be very grateful.
Thank you,
Pablo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried your append-dataset-2D.vi example with the 2D strings instead of I32s and it generates a 1D dataset with only first record (0 1 2 3 4) in it. I converted 2D I32 data to 2D strings and wired to the type in terminal of the H5Dcreate_simple function and data terminal of the H5Dwrite.xnode function. As far as I understand, each record must be of a fixed size and strings are variable by default so I wired a "<32>" string constant to the type name terminal of the H5Dwrite.xnode. What I am missing? Is it possible to append 1D string arrays to a 2D string dataset?
Thanks,
Gerry.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Gerry,
Thanks for your question, it raises an interesting point. The "type" of the dataset must be defined at creation time, and cannot be changed after that (not without deleting/recreating the dataset). When using H5Dcreate_simple to initialise the empty dataset, the type is locked in. So whatever you feed into the subsequent H5Dwrite.xnode will be ignored (unless you're writing a compound type, which is a separate issue) because the type was already defined.
This points out a bug in H5Dcreate_simple, because it's currently not possible to create a fixed-length string dataset with this function. I will add this to the bug database and fix it when I have the chance.
There are two immediate solutions: one is to use variable length strings, which is perfectly valid (I'm not sure why you say the records must have a fixed size? Unless that is the spec you must conform to) and should work out of the box. The second is to use H5Dcreate instead of H5Dcreate_simple to create a dataset with the correct fixed-length string type. This is a bit more involved but the example "zipped-dataset.vi" shows how it can be done. If you want to pursue this I could make an example.
But either approach should let you append strings as desired.
Cheers,
Martijn
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Gerry,
Can you export your VI to LV2010? I can't open this as it's a LV2013 version. I've attached an example that works for me to append to a 2D dataset of strings. It might not look like it because of how HDFView handles arrays of strings, but does indeed produce a 2D dataset.
Hi all,
I would like to build a 2D dataset by adding 1 extra line in every consecutive save. That is:
First save:
0.2 0.1 0.3 0.5
Second save:
0.2 0.1 0.3 0.5
0.8 0.5 0.6 0.4
and so on. Whenever the user triggers the save action, a new line (trace) is added. However the H5Dcreate_simple.vi seems to interpret every input as a 1D array, and will concatenate the vectors like:
0.2
0.1
0.3
0.5
0.8
0.5
0.6
0.4
If anyone knows a way to do this or a workaround I would be very grateful.
Thank you,
Pablo
Hi Pablo,
The key is how you create and fill the dataset as it must correctly index a 2D array. I've attached an example showing how to achieve this.
Cheers.
Hi Martijn,
I have a follow up question.
I tried your append-dataset-2D.vi example with the 2D strings instead of I32s and it generates a 1D dataset with only first record (0 1 2 3 4) in it. I converted 2D I32 data to 2D strings and wired to the type in terminal of the H5Dcreate_simple function and data terminal of the H5Dwrite.xnode function. As far as I understand, each record must be of a fixed size and strings are variable by default so I wired a "<32>" string constant to the type name terminal of the H5Dwrite.xnode. What I am missing? Is it possible to append 1D string arrays to a 2D string dataset?
Thanks,
Gerry.
Hi Gerry,
Thanks for your question, it raises an interesting point. The "type" of the dataset must be defined at creation time, and cannot be changed after that (not without deleting/recreating the dataset). When using H5Dcreate_simple to initialise the empty dataset, the type is locked in. So whatever you feed into the subsequent H5Dwrite.xnode will be ignored (unless you're writing a compound type, which is a separate issue) because the type was already defined.
This points out a bug in H5Dcreate_simple, because it's currently not possible to create a fixed-length string dataset with this function. I will add this to the bug database and fix it when I have the chance.
There are two immediate solutions: one is to use variable length strings, which is perfectly valid (I'm not sure why you say the records must have a fixed size? Unless that is the spec you must conform to) and should work out of the box. The second is to use H5Dcreate instead of H5Dcreate_simple to create a dataset with the correct fixed-length string type. This is a bit more involved but the example "zipped-dataset.vi" shows how it can be done. If you want to pursue this I could make an example.
But either approach should let you append strings as desired.
Cheers,
Martijn
Hi Martijn,
Thanks for the prompt reply.
I removed the <32> fixed length string constant as per your advice. It still does not append the new data. See modified example in the attachment.
Thanks,
GG.
Hi Gerry,
Can you export your VI to LV2010? I can't open this as it's a LV2013 version. I've attached an example that works for me to append to a 2D dataset of strings. It might not look like it because of how HDFView handles arrays of strings, but does indeed produce a 2D dataset.
Cheers,
Martijn
You are right, Martijn. HDFView deceived me.
Last edit: Gerry G. 2015-08-05