I need the Attribute of a Dataset HDF5 to be a string

1

Good afternoon, I'm trying to create some attributes for my datasets, I was able to create the attributes but at the time of setting their values I'm not getting it, I've already tried it in several different ways, and currently the string that appears appears to be bugged or in another format ... The code I am using is the below:

I was able to create the attributes "Eng. Unit" and "Attrib2", but I can not set their values as "Temperatua" and "Test", respectively

        foreach (BasicVariable bv in pf.basicVariableList.bvList)
        {               
            H5DataSetId dataSetId = H5D.create(bvGroupId, bv.bvTag, typeId, spaceId);
            bv.atribList.Add(new Atribbs("Eng. Unit", "Temperatura"));
            bv.atribList.Add(new Atribbs("Atrib2", "Teste"));
            foreach(Atribbs a in bv.atribList )
            {


                H5DataTypeId auxDT = H5T.copy(H5T.H5Type.C_S1);
                H5T.setSize(auxDT, H5T.getSize(H5T.H5Type.C_S1));
                const int auxData = 2;
                long[] auxDim = new long[1];
                auxDim[0] = 1;
                H5DataSpaceId auxDS = H5S.create_simple(1, auxDim);


                var attr_id = H5A.create(dataSetId, a.attName, auxDT, auxDS);
                byte[] bytes = Encoding.UTF8.GetBytes(a.valueStr);
                var atrData = new string[] { Encoding.Default.GetString(bytes)};
                H5A.write<string>(attr_id, auxDT, new H5Array<string>(atrData));

                H5A.close(attr_id);
            }
            H5D.close(dataSetId);
        }
        H5F.close(fileId);

On the HDF View screen they appear like this

    
asked by anonymous 04.06.2018 / 21:29

0 answers