Anton, would something like the following do? HDF5 file and source code attached.
It's not as elegant as the forthcoming method to have attributes directly
at the compound type's members, but is some kind of workaround with the
existing methods.
Werner
h5ls -rvd test.h5
Opened "test.h5" with sec2 driver.
/ Group
Location: 1:96
Links: 1
/data Dataset {5/5}
Location: 1:1504
Links: 1
Storage: 80 logical bytes, 80 allocated bytes, 100.00% utilization
Type: shared-1:1224 struct {
"t" +0 native double
"x" +8 native double
} 16 bytes
Data:
(0) {1, 2}, {3, 4}, {1, 4}, {1, 5}, {5, 0}
/meter Type
Location: 1:800
Links: 2
Type: shared-1:800 native double
/seconds Type
Location: 1:1176
Links: 2
Type: shared-1:1176 native double
/spatiotemporal Type
Attribute: t {1}
Type: shared-1:1176 native double
Data: 0
Attribute: x {1}
Type: shared-1:800 native double
Data: 0
Location: 1:1224
Links: 2
Type: shared-1:1224 struct {
"t" +0 native double
"x" +8 native double
} 16 bytes
On Thu, 18 Mar 2010 11:40:10 -0500, Anton Kulchitsky <[email protected]>
wrote:
Francesc, I think this is a really nice and elegant solution. Honestly, I am still thinking of attributes as of simple strings. Now I see the advantage to use other types. Thank you! I see just another problem with this though. Actually, what I really want is attributes for the types, not the data! When attributes are associated with data, this compound attribute need to be written every time when I write data of this type. However, what I really need for compound type are attributes of the type. Indeed, once fields are described there is no need to repeat this every time I write the data into a file. AntonA Tuesday 16 March 2010 23:56:38 Anton Kulchitsky escrigué:I would like to specify physical units and long names for every field of a compound object. I have an array of particles. Each particle is specified as a C structure with many fields associated with it. I would like to have an attribute for every field. However, when I create a compound object, I am not able to specify an attribute for a field. I am wondering if anyone has similar problem?An elegant solution for this would be to write a compound type attribute, with the first field specifying the field to be described and the others with complementary info. For example, if you have a table with two fields, one possibility is to describe it with a `descr` attribute like: Attribute: descr {2} Type: struct { "fieldname" +0 10-byte null-terminated ASCII string "unit" +10 10-byte null-terminated ASCII string "expl" +20 60-byte null-terminated ASCII string "scale" +80 native double } 88 bytes Data: {"field1", "kg", "long explanatory field 1", 1.2}, {"field2", "km/s", "long explanatory field 2", 24.3} This is simple and quite powerful, IMO._______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
-- ___________________________________________________________________________ Dr. Werner Benger Visualization Research Laboratory for Creative Arts and Technology (LCAT) Center for Computation & Technology at Louisiana State University (CCT/LSU) 211 Johnston Hall, Baton Rouge, Louisiana 70803 Tel.: +1 225 578 4809 Fax.: +1 225 578-5362
h5experiment.c
Description: Binary data
test.h5
Description: Binary data
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
