Reading HDF5 files

Hi all,

I would like to load hdf5 files (I tried to attach it but possibly I can't as it is 50 mb). It is a satellite dataset. It has data for different satellite channels (downloaded from EUMETSAT). I can load it successfully, but when I select one of groups of this file eg. Channel 1 (I can see within the datasets field, the image file that I want, but I can't open it. If I try to Load it, I get this message: While executing HDF5LoadImage, the following error occured: The image dataset's SUBCLASS attribute is incorrect - expected IMAGE GRAYSCALE, IMAGE TRUECOLOR, IMAGE BITMAP or IMAGE INDEXED.

Do you have any piece of advice?

I finally uploaded the file here. Please unzip before use.

http://www.filedropper.com/msg2-sevi-msg15-0100-na-20151111112915758000…
The problem is that the image dataset's IMAGE_SUBCLASS attribute is incorrect.

HDF5 defines an image format here: http://www.hdfgroup.org/HDF5/doc/ADGuide/ImageSpec.html

This says that an image, if it follows the format, must have an IMAGE_SUBCLASS attribute and its value must be one of the following:
IMAGE_GRAYSCALE, IMAGE_TRUECOLOR, IMAGE_BITMAP, IMAGE_INDEXED

I call such images "formal images" to distinguish them from a 2D dataset that does not follow the specification.

In your file, the IMAGE_DATA dataset is trying to be a formal image but the IMAGE_SUBCLASS attribute is IMAGE_U16BIT. This is not a valid value. It appears to be made up by whoever wrote the file because Google finds no hits for IMAGE_U16BIT.

You are getting the error because the HDF5 Browser looks for image datasets that follow the specification and tries to load them following the specification.

You can load such images without treating them as formal images (images that follow the specification) using HDF5LoadData instead of HDF5LoadImage.

You can load the entire file into Igor using HDF5LoadGroup without the /IMAG flag. When you omit this flag, or specify /IMAG=0, HDF5LoadGroup does not look for formal images and uses HDF5LoadData instead of HDF5LoadImage.

You can load the entire file into Igor with this function:
Function LoadHDF5File()
    Variable fileID
    HDF5OpenFile /I/R fileID as ""
    if (V_Flag != 0)
        return -1       // User cancelled
    endif

    HDF5LoadGroup /O /R /T=TempHDF5Data root:, fileID , "." // Load entire file into root:TempHDF5Data
   
    HDF5CloseFile fileID
   
    return 0            // Success
End


Another solution which I think would work, though I'm not sure, is to fix the IMAGE_SUBCLASS attributes by changing them to IMAGE_GRAYSCALE. I think that is the correct value for these images but I'm not sure.

To fix the file, you would first clone it so as to leave the original unchanged. You would then have to write an Igor function that would open the clone and look for all IMAGE_SUBCLASS attributes with value IMAGE_U16BIT and change them to IMAGE_GRAYSCALE. You would then close the file.

This should create a file that you can browse in the HDF5 Browser. This is a complicated function and you would have to be good at Igor programming and have a good understanding of HDF5.


Thanks a lot for your very informative response,

The code worked perfectly,

Stavros
Hello again,

how could I see the attributes of the file that I uploaded (or general of an hdf5 file)?

Actually, I need to see if there are any longitude and latitude data or at least if there is a minimum/maximum data of longitude and latitude.

Thank you,

Stavros
It depends on what you mean by "see the attributes of the file".

You can see them in the HDF5 Browser.

If you want to inspect them programmatically, you have to load them into Igor using HDF5LoadData with the /A flag.

Quote:
Actually, I need to see if there are any longitude and latitude data or at least if there is a minimum/maximum data of longitude and latitude.


You can use the /Z flag with HDF5LoadData. Then check the V_flag variable. If it is non-zero, the operation failed and, most likely, the attribute you are looking for does not exist.

Alternatively you can use HDF5ListAttributes to find what attributes are attached to a particular dataset before attempting to load a given attribute.