[Nexus] Reading generic h5 files.

tieman tieman at aps.anl.gov
Wed Feb 21 15:22:22 GMT 2007


Freddie,

Sigh, yes, the proposed code change gets me past the first stumbling 
block...now the problem is in NX5opengroup where there are a number of 
dependencies on the NX_class group attribute.  I can probably hack my 
way around these as well...why is this different for H5 though?  HDF4 
also had group attributes, but I could set the attribute to what I want 
and, more importantly, when I read a file there didn't seem to be a 
required attribute ("NX_class" or otherwise) to properly read the file.  
I often read HDF4 files written from sources other than NAPI and, as 
long as they are SDS and not raster, I can read them just fine. 

Is there a reason why H5 support is not "generic" enough to read files 
created outside NAPI?  Does this extend to HDF4 support now?  Was I just 
getting lucky with reading genereic HDF4 files in the past?

As far as Matlab goes, if I could read generic H5 files, I would have no 
need for bindings...Matlab supports H5 native.  Of course the files 
would not be "Nexus" compliant without the bindings or mimic thereof 
within Matlab.  But even if I wanted Nexus compliance, I'm probably 
better off binding to my "Nexus wrapper" libraries that are somewhat 
higher level than NAPI and much more familiar to me :)  In either case, 
I have to deal with HDF4 and HDF5 files created outside of Nexus often 
enough that this is a limiting issue...

Brian

Akeroyd, FA (Freddie) wrote:
> Brian,
>
> "NX_class" is an attribute and is attached to each group to indicate its
> NeXus class (NXentry, NXinstrument etc.). If you remove the lines that
> try to read this attribute and instead just have something like
>
> strcpy(nxclass, "NXunknown")
>
> Does that help?
>
> matlab bindings for NeXus would be another way around this problem ... 
> I have that on my list of things to do in the next month.  
>
> Regards,
>
> Freddie
>
> -----Original Message-----
> From: nexus-bounces at nexusformat.org
> [mailto:nexus-bounces at nexusformat.org] On Behalf Of tieman
> Sent: 20 February 2007 21:18
> To: nexus at nexusformat.org
> Subject: [Nexus] Reading generic h5 files.
>
> Hi all,
>
> Can Nexus (3.0.0) read "generic" h5 files that were not written with the
>
> Nexus API.  Experimentation tells me the answer is "no" but I am holding
>
> out hope that I am doing something wrong...
>
> I need to exchange data between a process I've written that uses Nexus 
> to read/write HDF5 files and Matlab.  Matlab can read the files I 
> generate just fine, however, I can not read the files Matlab generates.
>
> We took an h5 file I wrote with nexus and read it into Matlab without a 
> problem.  We then rewrote the file from within Matlab, but my Nexus 
> program can not read it.
>
> I think I've managed to trace part of the problem to NX5GetNextEntry and
>
> the following lines:
>
>            attr1 = H5Aopen_name(grp, "NX_class");
>            type=H5T_C_S1;
>            atype=H5Tcopy(type);
>            H5Tset_size(atype,128); 
>            iRet = H5Aread(attr1, atype, data);
>            strcpy(nxclass,data);
>
> I don't understand h5 very well yet but it looks to me like this section
>
> of code is looking for a "group type" of "NX_class" which Matlab is 
> unlikely to have written and so the later call to H5Aread fails.  I see 
> NX5MakeGroup seems to attach the "NX_class" type when the file is
> created.
>
> Is there a way around this?  I have a strong need to inter-operate with 
> Matlab and potentially additional sources of h5 data but I already have 
> a large codebase built around NAPI that I'd love to leverage as well.  
> Any thoughts?
>
> Thanks!
>
> Brian Tieman
> Advanced Photon Source
> Argonne National Laboratory
>
>
> _______________________________________________
> NeXus mailing list
> NeXus at nexusformat.org
> http://lists.nexusformat.org/mailman/listinfo/nexus
>
> _______________________________________________
> NeXus mailing list
> NeXus at nexusformat.org
> http://lists.nexusformat.org/mailman/listinfo/nexus
>   



More information about the NeXus mailing list