Hi Quincey,
I did tried using H5Tget_native_type(), however the results were just the
same.
DataType data_type = dataset.getDataType();
//Returns value from enum H5T_class_t
int val = data_type.getClass(); //returns 0 for integer(could be short,
char, unsigned int) 1 for float(could be double, ...), 3 for string
hid_t native_type_datatype=H5Tget_native_type(datatype.getId(),
H5T_DIR_DEFAULT);
My assumption was that native_type_datatype would be set with a native
datatype value as
//H5T_NATIVE_CHAR, H5T_NATIVE_SCHAR, H5T_NATIVE_UCHAR, H5T_NATIVE_SHORT,
H5T_NATIVE_USHORT,.....),
But, it was returning always H5T_INTEGER even if it was char, uchar,
short, or int, the same value returned by data_type.getClass();
Thanks
Anish
Quincey Koziol <koziol@hdfgroup.org>
02/01/2008 01:00 PM
To
Anish Anto <anto.anish@yahoo.com>
cc
hdf-forum@hdfgroup.org
Subject
Re: HDF5 C++ API's -Finding datatype of a DataSet ?
Hi Anish,
Hello Francesc,
I did not find a easy solution to find the low level datatype from a
abstract datatype class.
One solution was to implement a way - just coming to a conclusion of
lowlevel datatype based on .getSize() , as you had also suggested.
Another option, i tried out was to
//create static datatype objects by
DataType dt1(PredType::NATIVE_CHAR);
DataType dt2(PredType::NATIVE_FLOAT);
DataType dt3(PredType::NATIVE_DOUBLE);
//Get datatype class object from Dataset - returns abstract datatype
- int/string/float -
//does not return you char, double or long.
DataType dt_org = dataset.getDataType();
//compare these 2 datatypes based on ==() oerator of Datatype class.
if(dt_org==dt1)
{
//ok, its a native char - though dt_org.getClass() returns
H5T_INTEGER.
}
elseif(dt_org==dt2)
{
//ok, its a native float}
}
elseif(dt_org==dt3)
{
//ok, its a native double - though dt_org.getClass() returns
H5T_FLOAT}
}
Since, i know that x,y,z are the datatypes i would be using - i
would create static objects and use them to compare. Not a good way,
though.
Any other recommended elegant way of getting the low level datatype
of a Datatype class object ?
Would the H5Tget_native_type() API routine help you?
Quincey
Thanks Again
A Wednesday 30 January 2008, escriguéreu:
> Hello frances,
>
> Thanks for your input.
> So basically that would mean, whatever format native_char, double,
> int or string, whatever format we use while writing data (write(d0,
> PredType::NATIVE_INT, However they are all broadly stored in as
> H5T_INTEGER, H5T_FLOAT or H5T_STRING type and there is no exact way
> HDF provides for identifying the the low level datatype - whether it
> belongs to a int, double, float, string or char is ,except that
> analysing the element size - u can come to a conclusion - what
> datatype it might belong to, However, this is really a platform
> specific data - size of datatype. Only issue is what when a source
> needs to be supported on multiple platforms - (u will probably end
up
> lot of #ifdefs for each platform).
Yes, I agree that this is dependent on platform. My solution has been
using fixed-size datatypes in-memory, so that you don't have to worry
about platform dependency. This comes for free when using NumPy, a
package to deal with multidimensional data for Python. For C++ you
should find an alternate solution. In any case, in all the platforms
that I'm aware of, a float takes 4 bytes and a double takes 8 bytes.
And when I said 'most platforms' I wanted to exclude more exotic
architectures (Cray or other kind of super-computers); but if you are
not using them, then I think you are safe assuming the 4/8 sizes for
float/double.
> Earlier , i had a question on writing/reading string datasets. Would
> it be ok, if you can provide me some suggestions on this.
I'm sorry, but I'm more used to the C interface to HDF5, so I'm not
sure
about what's happening in this case. Somebody more knowledable will
have to help you here.
Regards,
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to
hdf-forum-subscribe@hdfgroup.org
···
On Feb 1, 2008, at 2:29 PM, Anish Anto wrote:
Francesc Altet <faltet@carabos.com> wrote:
.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
Try it now.
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to
hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.