<div dir="ltr">1) I completely agree with the idea of adding system metadata that indicates the library version(s) that wrote the file.<div><br></div><div>2) the way shared dimensions are implemented by netcdf4 is a unique signature that would likely identify (100 - epsilon) % of real data files in the wild. One could add such detection to the netcdf4 and/or hdf5 libraries, and/or write a utility program to detect.</div><div><br></div><div>there are 2 variants:<br></div><div><br></div><div>2.1) one could write a netcdf4 file without shared dimensions, though im pretty sure no one does. but you could argue then that its fine to just treat it as an hdf5 file and read through hdf5 library</div><div><br></div><div>2.2) one could write a netcdf4 file with hdf5 library, if you knew what you are doing. i have heard of this happening. but then you could argue that its really a netcdf4 file and you should use netcdf library to read.</div><div><br></div><div>i have written various blogs on the unidata site about why netcdf4 != hdf5, and what the unique signature for shared dimensions looks like, in case you want details.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 21, 2016 at 4:18 PM, Pedro Vicente <span dir="ltr"><<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you have hdf5 files that should be readable, then I will undertake to<br>
look at them and see what the problem is.<br>
</blockquote>
<br>
<br>
ok, thank you<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
WRT to old files: We could produce a utility that would redef the file and insert the<br>
_NCProperties attribute. This would allow someone to wholesale<br>
mark old files.<br>
</blockquote>
<br>
<br>
Excellent idea , Dennis<span class=""><br>
<br>
----------------------<br>
Pedro Vicente<br>
<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a><br>
<a href="https://twitter.com/_pedro__vicente" rel="noreferrer" target="_blank">https://twitter.com/_pedro__vicente</a><br>
<a href="http://www.space-research.org/" rel="noreferrer" target="_blank">http://www.space-research.org/</a><br>
<br>
<br>
----- Original Message ----- From: <<a href="mailto:dmh@ucar.edu" target="_blank">dmh@ucar.edu</a>><br></span>
To: "Pedro Vicente" <<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>>; <<a href="mailto:cf-metadata@cgd.ucar.edu" target="_blank">cf-metadata@cgd.ucar.edu</a>>; "Discussion forum for the NeXus data format" <<a href="mailto:nexus@nexusformat.org" target="_blank">nexus@nexusformat.org</a>>; <<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a>><br>
Sent: Thursday, April 21, 2016 5:02 PM<span class=""><br>
Subject: Re: [netcdfgroup] [Hdf-forum] Detecting netCDF versus HDF5 -- PROPOSED SOLUTIONS --REQUEST FOR COMMENTS<br>
<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you have hdf5 files that should be readable, then I will undertake to<br>
look at them and see what the problem is.<br>
WRT to old files: We could produce a utility that would redef the file and insert the<br>
_NCProperties attribute. This would allow someone to wholesale<br>
mark old files.<br>
=Dennis Heimbigner<br>
Unidata<div><div class="h5"><br>
<br>
On 4/21/2016 2:17 PM, Pedro Vicente wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dennis<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am in the process of adding a global attribute in the root group<br>
</blockquote></blockquote></blockquote>
that captures both the netcdf library version and the hdf5 library version<br>
whenever a netcdf file is created. The current form is<br>
_NCProperties="version=...|netcdflibversion=...|hdflibversion=..."<br>
</blockquote>
<br>
<br>
ok, good to know, thank you<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> 1. I am open to suggestions about changing the format or adding<br>
info > to it.<br>
</blockquote></blockquote></blockquote>
<br>
<br>
I personally don't care, anything that uniquely identifies a netCDF file (HDF5 based) as such will work<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2. Of course this attribute will not exist in files written using older<br>
</blockquote></blockquote>
versions of the netcdf library, but at least the process will have begun.<br>
</blockquote>
<br>
yes<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
3. This technically does not address the original issue because there exist<br>
hdf5 files not written by netcdf that are still compatible with and can be<br>
read by netcdf. Not sure this case is important or not.<br>
</blockquote>
<br>
there will always be HDF5 files not written by netcdf that netCDF will read as we are now.<br>
<br>
this is not really the issue, but you just made a further issue :-)<br>
<br>
the issue is that I would like an application that reads a netCDF (HDF5 based) file to decide to use the netCDF or HDF5 API.<br>
your attribute writing will do , for future files.<br>
for older nertCDF files there may be a way to detect the current attributes and data structures to see if we can make it "identify itself"<br>
as netCDF. A bit of debugging will confirm that, since Dimension Scales are used, that would be an (imperfect maybe) way to do it<br>
<br>
regarding the "further issue " above<br>
<br>
you could go one step further and for any HDF5 files not written by netcdf , you could make netCDF reject the file reading,<br>
because it's not "netCDF compliant".<br>
Since having netCDF read pure HDF5 files is not a problem (at least for me), I don't know if you would want to do this, just an idea.<br>
In my mind taking complexity and ambiguities of problems is always a good thing<br>
<br>
<br>
ah, I forgot one thing, related to this<br>
<br>
<br>
In the past I have found several pure HDF5 files that netCDF failed in reading.<br>
Since netCDF is HDF5 binary compatible, one would expect that all HDF5 files will be read by netCDF.<br>
Except if you specifically wrote something in the code that makes it to fail if some condition is not met,<br>
This was a while ago, I'll try to find those cases and I'll send a bug report to the bug report email<br>
<br>
----------------------<br>
Pedro Vicente<br>
<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a><br>
<a href="https://twitter.com/_pedro__vicente" rel="noreferrer" target="_blank">https://twitter.com/_pedro__vicente</a><br>
<a href="http://www.space-research.org/" rel="noreferrer" target="_blank">http://www.space-research.org/</a><br>
<br>
----- Original Message ----- From: <<a href="mailto:dmh@ucar.edu" target="_blank">dmh@ucar.edu</a>><br>
To: "Pedro Vicente" <<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>>; "HDF Users Discussion List" <<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a>>; <<a href="mailto:cf-metadata@cgd.ucar.edu" target="_blank">cf-metadata@cgd.ucar.edu</a>>; "Discussion forum for the NeXus data format" <<a href="mailto:nexus@nexusformat.org" target="_blank">nexus@nexusformat.org</a>>; <<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a>><br>
Cc: "John Shalf" <<a href="mailto:jshalf@lbl.gov" target="_blank">jshalf@lbl.gov</a>>; <<a href="mailto:Richard.E.Ullman@nasa.gov" target="_blank">Richard.E.Ullman@nasa.gov</a>>; "Marinelli, Daniel J. (GSFC-5810)" <<a href="mailto:daniel.j.marinelli@nasa.gov" target="_blank">daniel.j.marinelli@nasa.gov</a>>; "Miller, Mark C." <<a href="mailto:miller86@llnl.gov" target="_blank">miller86@llnl.gov</a>><br>
Sent: Thursday, April 21, 2016 2:30 PM<br>
Subject: Re: [netcdfgroup] [Hdf-forum] Detecting netCDF versus HDF5 -- PROPOSED SOLUTIONS --REQUEST FOR COMMENTS<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am in the process of adding a global attribute in the root group<br>
that captures both the netcdf library version and the hdf5 library version<br>
whenever a netcdf file is created. The current form is<br>
_NCProperties="version=...|netcdflibversion=...|hdflibversion=..."<br>
Where version is the version of the _NCProperties attribute and the others<br>
are e.g. 1.8.18 or 4.4.1-rc1.<br>
Issues:<br>
1. I am open to suggestions about changing the format or adding info to it.<br>
2. Of course this attribute will not exist in files written using older versions<br>
of the netcdf library, but at least the process will have begun.<br>
3. This technically does not address the original issue because there exist<br>
hdf5 files not written by netcdf that are still compatible with and can be<br>
read by netcdf. Not sure this case is important or not.<br>
=Dennis Heimbigner<br>
Unidata<br>
<br>
<br>
On 4/21/2016 9:33 AM, Pedro Vicente wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
DETECTING HDF5 VERSUS NETCDF GENERATED FILES<br>
REQUEST FOR COMMENTS<br>
AUTHOR: Pedro Vicente<br>
<br>
AUDIENCE:<br>
1) HDF, netcdf developers,<br>
Ed Hartnett<br>
Kent Yang<br>
2) HDF, netcdf users, that replied to this thread<br>
Miller, Mark C.<br>
John Shalf<br>
3 ) netcdf tools developers<br>
Mary Haley , NCL<br>
4) HDF, netcdf managers and sponsors<br>
David Pearah , CEO HDF Group<br>
Ward Fisher, UCAR<br>
Marinelli, Daniel J. , Richard Ullmman, Christopher Lynnes, NASA<br>
5)<br>
[CF-metadata] list<br>
After this thread started 2 months ago, there was an annoucement on the [CF-metadata] mail list<br>
about<br>
"a meeting to discuss current and future netCDF-CF efforts and directions.<br>
The meeting will be held on 24-26 May 2016 in Boulder, CO, USA at the UCAR Center Green facility."<br>
This would be a good topic to put on the agenda, maybe?<br>
THE PROBLEM:<br>
Currently it is impossible to detect if an HDF5 file was generated by the HDF5 API or by the netCDF API.<br>
See previous email about the reasons why.<br>
WHY THIS MATTERS:<br>
Software applications that need to handle both netCDF and HDF5 files cannot decide which API to use.<br>
This includes popular visualization tools like IDL, Matlab, NCL, HDF Explorer.<br>
SOLUTIONS PROPOSED: 2<br>
SOLUTION 1: Add a flag to HDF5 source<br>
The hdf5 format specification, listed here<br>
<a href="https://www.hdfgroup.org/HDF5/doc/H5.format.html" rel="noreferrer" target="_blank">https://www.hdfgroup.org/HDF5/doc/H5.format.html</a><br>
describes a sequence of bytes in the file layout that have special meaning for the HDF5 API. It is common practice, when designing a data format,<br>
so leave some fields "reserved for future use".<br>
This solution makes use of one of these empty "reserved for future use" spaces to save a byte (for example) that describes an enumerator<br>
of "HDF5 compatible formats".<br>
An "HDF5 compatible format" is a data format that uses the HDF5 API at a lower level (usually hidden from the user of the upper API),<br>
and providing its own API.<br>
This category can still be divide in 2 formats:<br>
1) A "pure HDF5 compatible format". Example, NeXus<br>
<a href="http://www.nexusformat.org/" rel="noreferrer" target="_blank">http://www.nexusformat.org/</a><br>
NeXus just writes some metadata (attributes) on top of the HDF5 API, that has some special meaning for the NeXus community<br>
2) A "non pure HDF5 compatible format". Example, netCDF<br>
Here, the format adds some extra feature besides HDF5. In the case of netCDF, these are shared dimensions between variables.<br>
This sub-division between 1) and 2) is irrelevant for the problem and solution in question<br>
The solution consists of writing a different enumerator value on the "reserved for future use" space. For example<br>
Value decimal 0 (current value): This file was generated by the HDF5 API (meaning the HDF5 only API)<br>
Value decimal 1: This file was generated by the netCDF API (using HDF5)<br>
Value decimal 2: This file was generated by <put here another HDF5 based format><br>
and so on<br>
The advantage of this solution is that this process involves 2 parties: the HDF Group and the other format's organization.<br>
This allows the HDF Group to "keep track" of new HDF5 based formats. It allows to make the other format "HDF5 certified" .<br>
SOLUTION 2: Add some metadata to the other API on top of HDF5<br>
This is what Nexus uses.<br>
A Nexus file on creation writes several attributes on the root group, like "NeXus_version" and other numeric data.<br>
This is done using the public HDF5 API calls.<br>
The solution for netCDF consists of the same approach, just write some specific attributes, and a special netCDF API to write/read them.<br>
This solutions just requires the work of one party (the netCDF group)<br>
END OF RFC<br>
In reply to people that commented in the thread<br>
@John Shalf<br>
>>Perhaps NetCDF (and other higher-level APIs that are built on top of<br>
HDF5) should include an attribute attached<br>
>>to the root group that identifies the name and version of the API<br>
that created the file? (adopt this as a convention)<br>
yes, that's one way to do it, Solution 2 above<br>
@Mark Miller<br>
>>>Hmmm. Is there any big reason NOT to try to read a netCDF produced<br>
HDF5 file with the native HDF5 library if someone so chooses?<br>
It's possible to read a netCDF file using HDF5, yes.<br>
There are 2 things that you will miss doing this:<br>
1) the ability to inquire about shared netCDF dimensions.<br>
2) the ability to read remotely with openDAP.<br>
Reading with HDF5 also exposes metadata that is supposed to be private to netCDF. See below<br>
>>>> And, attempting to read an HDF5 file produced by Silo using just<br>
the HDF5 library (e.g. w/o Silo) is a major pain.<br>
This I don't understand. Why not read the Silo file with the Silo API?<br>
That's the all purpose of this issue, each higher level API on top of HDF5 should be able to detect "itself".<br>
I am not familiar with Silo, but if Silo cannot do this, then you have the same design flaw that netCDF has.<br>
<br>
>>> In a cursory look over the libsrc4 sources in netCDF distro, I see<br>
a few things that might give a hint a file was created with netCDF. . .<br>
>>>> First, in NC_CLASSIC_MODEL, an attribute gets attached to the<br>
root group named "_nc3_strict". So, the existence of an attribute on the root group by that name would suggest the HDF5 file was generated by netCDF.<br>
I think this is done only by the "old" netCDF3 format.<br>
>>>>> Also, I tested a simple case of nc_open, nc_def_dim, etc.<br>
nc_close to see what it produced.<br>
>>>> It appears to produce datasets for each 'dimension' defined with<br>
two attributes named "CLASS" and "NAME".<br>
This is because netCDF uses the HDF5 Dimension Scales API internally to keep track of shared dimensions. These are internal attributes<br>
of Dimension Scales. This approach would not work because an HDF5 only file with Dimension Scales would have the same attributes.<br>
<br>
>>>> I like John's suggestion here.<br>
>>>>>But, any code you add to any applications now will work *only*<br>
for files that were produced post-adoption of this convention.<br>
yes. there are 2 actions to take here.<br>
1) fix the issue for the future<br>
2) try to retroactively have some workaround that makes possible now to differentiate a HDF5/netCDF files made before the adopted convention<br>
see below<br>
<br>
>>>> In VisIt, we support >140 format readers. Over 20 of those are<br>
different variants of HDF5 files (H5part, Xdmf, Pixie, Silo, Samrai, netCDF, Flash, Enzo, Chombo, etc., etc.)<br>
>>>>When opening a file, how does VisIt figure out which plugin to<br>
use? In particular, how do we avoid one poorly written reader plugin (which may be the wrong one for a given file) from preventing the correct one from being found. Its kinda a hard problem.<br>
<br>
Yes, that's the problem we are trying to solve. I have to say, that is quick a list of HDF5 based formats there.<br>
>>>> Some of our discussion is captured here. . .<br>
<a href="http://www.visitusers.org/index.php?title=Database_Format_Detection" rel="noreferrer" target="_blank">http://www.visitusers.org/index.php?title=Database_Format_Detection</a><br>
I"ll check it out, thank you for the suggestions<br>
@Ed Hartnett<br>
>>>I must admit that when putting netCDF-4 together I never considered<br>
that someone might want to tell the difference between a "native" HDF5 file and a netCDF-4/HDF5 file.<br>
>>>>>Well, you can't think of everything.<br>
This is a major design flaw.<br>
If you are in the business of designing data file formats, one of the things you have to do is how to make it possible to identify it from the other formats.<br>
<br>
>>> I agree that it is not possible to canonically tell the<br>
difference. The netCDF-4 API does use some special attributes to track named dimensions,<br>
>>>>and to tell whether classic mode should be enforced. But it can<br>
easily produce files without any named dimensions, etc.<br>
>>>So I don't think there is any easy way to tell.<br>
I remember you wrote that code together with Kent Yang from the HDF Group.<br>
At the time I was with the HDF Group but unfortunately I did follow closely what you were doing.<br>
I don't remember any design document being circulated that explains the internals of the "how to" make the netCDF (classic) model of shared dimensions<br>
use the hierarchical group model of HDF5.<br>
I know this was done using the HDF5 Dimension Scales (that I wrote), but is there any design document that explains it?<br>
Maybe just some internal email exchange between you and Kent Yang?<br>
Kent, how are you?<br>
Do you remember having any design document that explains this?<br>
Maybe something like a unique private attribute that is written somewhere in the netCDF file?<br>
<br>
@Mary Haley, NCL<br>
NCL is a widely used tool that handles both netCDF and HDF5<br>
Mary, how are you?<br>
How does NCL deal with the case of reading both pure HDF5 files and netCDF files that use HDF5?<br>
Would you be interested in joining a community based effort to deal with this, in case this is an issue for you?<br>
<br>
@David Pearah , CEO HDF Group<br>
I volunteer to participate in the effort of this RFC together with the HDF Group (and netCDF Group).<br>
Maybe we could make a "task force" between HDF Group, netCDF Group and any volunteer (such as tools developers that happen to be in these mail lists)?<br>
The "task force" would have 2 tasks:<br>
1) make a HDF5 based convention for the future and<br>
2) try to retroactively salvage the current design issue of netCDF<br>
My phone is <a href="tel:217-898-9356" value="+12178989356" target="_blank">217-898-9356</a>, you are welcome to call in anytime.<br>
----------------------<br>
Pedro Vicente<br>
<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a> <mailto:<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>><br>
<a href="https://twitter.com/_pedro__vicente" rel="noreferrer" target="_blank">https://twitter.com/_pedro__vicente</a><br>
<a href="http://www.space-research.org/" rel="noreferrer" target="_blank">http://www.space-research.org/</a><br>
<br>
----- Original Message -----<br>
*From:* Miller, Mark C. <mailto:<a href="mailto:miller86@llnl.gov" target="_blank">miller86@llnl.gov</a>><br>
*To:* HDF Users Discussion List <mailto:<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a>><br>
*Cc:* <a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a><br>
<mailto:<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a>> ; Ward Fisher<br>
<mailto:<a href="mailto:wfisher@ucar.edu" target="_blank">wfisher@ucar.edu</a>><br>
*Sent:* Wednesday, March 02, 2016 7:07 PM<br>
*Subject:* Re: [Hdf-forum] Detecting netCDF versus HDF5<br>
<br>
I like John's suggestion here.<br>
<br>
But, any code you add to any applications now will work *only* for<br>
files that were produced post-adoption of this convention.<br>
<br>
There are probably a bazillion files out there at this point that<br>
don't follow that convention and you probably still want your<br>
applications to be able to read them.<br>
<br>
In VisIt, we support >140 format readers. Over 20 of those are<br>
different variants of HDF5 files (H5part, Xdmf, Pixie, Silo,<br>
Samrai, netCDF, Flash, Enzo, Chombo, etc., etc.) When opening a<br>
file, how does VisIt figure out which plugin to use? In<br>
particular, how do we avoid one poorly written reader plugin<br>
(which may be the wrong one for a given file) from preventing the<br>
correct one from being found. Its kinda a hard problem.<br>
<br>
Some of our discussion is captured here. . .<br>
<br>
<a href="http://www.visitusers.org/index.php?title=Database_Format_Detection" rel="noreferrer" target="_blank">http://www.visitusers.org/index.php?title=Database_Format_Detection</a><br>
<br>
Mark<br>
<br>
<br>
From: Hdf-forum <<a href="mailto:hdf-forum-bounces@lists.hdfgroup.org" target="_blank">hdf-forum-bounces@lists.hdfgroup.org</a><br>
<mailto:<a href="mailto:hdf-forum-bounces@lists.hdfgroup.org" target="_blank">hdf-forum-bounces@lists.hdfgroup.org</a>>> on behalf of John<br>
Shalf <<a href="mailto:jshalf@lbl.gov" target="_blank">jshalf@lbl.gov</a> <mailto:<a href="mailto:jshalf@lbl.gov" target="_blank">jshalf@lbl.gov</a>>><br>
Reply-To: HDF Users Discussion List <<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a><br>
<mailto:<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a>>><br>
Date: Wednesday, March 2, 2016 1:02 PM<br>
To: HDF Users Discussion List <<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a><br>
<mailto:<a href="mailto:hdf-forum@lists.hdfgroup.org" target="_blank">hdf-forum@lists.hdfgroup.org</a>>><br>
Cc: "<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a><br>
<mailto:<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a>>"<br>
<<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a><br>
<mailto:<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a>>>, Ward Fisher<br>
<<a href="mailto:wfisher@ucar.edu" target="_blank">wfisher@ucar.edu</a> <mailto:<a href="mailto:wfisher@ucar.edu" target="_blank">wfisher@ucar.edu</a>>><br>
Subject: Re: [Hdf-forum] Detecting netCDF versus HDF5<br>
<br>
Perhaps NetCDF (and other higher-level APIs that are built on<br>
top of HDF5) should include an attribute attached to the root<br>
group that identifies the name and version of the API that<br>
created the file? (adopt this as a convention)<br>
<br>
-john<br>
<br>
On Mar 2, 2016, at 12:55 PM, Pedro Vicente<br>
<<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a><br>
<mailto:<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>>> wrote:<br>
Hi Ward<br>
As you know, Data Explorer is going to be a general<br>
purpose data reader for many formats, including HDF5 and<br>
netCDF.<br>
Here<br>
<a href="http://www.space-research.org/" rel="noreferrer" target="_blank">http://www.space-research.org/</a><br>
Regarding the handling of both HDF5 and netCDF, it seems<br>
there is a potential issue, which is, how to tell if any<br>
HDF5 file was saved by the HDF5 API or by the netCDF API?<br>
It seems to me that this is not possible. Is this correct?<br>
netCDF uses an internal function NC_check_file_type to<br>
examine the first few bytes of a file, and for example for<br>
any HDF5 file the test is<br>
/* Look at the magic number */<br>
/* Ignore the first byte for HDF */<br>
if(magic[1] == 'H' && magic[2] == 'D' && magic[3] == 'F') {<br>
*filetype = FT_HDF;<br>
*version = 5;<br>
The problem is that this test works for any HDF5 file and<br>
for any netCDF file, which makes it impossible to tell<br>
which is which.<br>
Which makes it impossible for any general purpose data<br>
reader to decide to use the netCDF API or the HDF5 API.<br>
I have a possible solution for this , but before going any<br>
further, I would just like to confirm that<br>
1) Is indeed not possible<br>
2) See if you have a solid workaround for this,<br>
excluding the dumb ones, for example deciding on a<br>
extension .nc or .h5, or traversing the HDF5 file to see<br>
if it's non netCDF conforming one. Yes, to further<br>
complicate things, it is possible that the above test says<br>
OK for a HDF5 file, but then the read by the netCDF API<br>
fails because the file is a HDF5 non netCDF conformant<br>
Thanks<br>
----------------------<br>
Pedro Vicente<br>
<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a><br>
<mailto:<a href="mailto:pedro.vicente@space-research.org" target="_blank">pedro.vicente@space-research.org</a>><br>
<a href="http://www.space-research.org/" rel="noreferrer" target="_blank">http://www.space-research.org/</a><br>
_______________________________________________<br>
Hdf-forum is for HDF software users discussion.<br>
<a href="mailto:Hdf-forum@lists.hdfgroup.org" target="_blank">Hdf-forum@lists.hdfgroup.org</a><br>
<mailto:<a href="mailto:Hdf-forum@lists.hdfgroup.org" target="_blank">Hdf-forum@lists.hdfgroup.org</a>><br>
<br>
<a href="http://secure-web.cisco.com/1r-EJFFfg6rWlpQsvXstBNTjaHQaKT_NkYRN0Jj_f-Z3EK0-hs6IbYc8XUBRyPsH3mU3CS0iiY7_qnchCA0QxNzQt270d_2HikCwpAWFmuHdacin62eaODutktDSOULIJmVbVYqFVSKWPzoX7kdP0yN9wIzSFxZfTwfhU8ebsN409xRg1PsW_8cvNiWzxDNm9wv9yBf9yK6nkEm-bOx2S0kBLbg9WfIChWzZrkpE3AHU9I-c2ZRH_IN-UF4g_g0_Dh4qE1VETs7tZTfKd1ox1MtBmeyKf7EKUCd3ezR9EbI5tK4hCU5qW4v5WWOxOrD17e8yCVmob27xz84Lr3bCK5wIQdH5VzFRTtyaAhudpt9E/http%3A%2F%2Flists.hdfgroup.org%2Fmailman%2Flistinfo%2Fhdf-forum_lists.hdfgroup.org" rel="noreferrer" target="_blank">http://secure-web.cisco.com/1r-EJFFfg6rWlpQsvXstBNTjaHQaKT_NkYRN0Jj_f-Z3EK0-hs6IbYc8XUBRyPsH3mU3CS0iiY7_qnchCA0QxNzQt270d_2HikCwpAWFmuHdacin62eaODutktDSOULIJmVbVYqFVSKWPzoX7kdP0yN9wIzSFxZfTwfhU8ebsN409xRg1PsW_8cvNiWzxDNm9wv9yBf9yK6nkEm-bOx2S0kBLbg9WfIChWzZrkpE3AHU9I-c2ZRH_IN-UF4g_g0_Dh4qE1VETs7tZTfKd1ox1MtBmeyKf7EKUCd3ezR9EbI5tK4hCU5qW4v5WWOxOrD17e8yCVmob27xz84Lr3bCK5wIQdH5VzFRTtyaAhudpt9E/http%3A%2F%2Flists.hdfgroup.org%2Fmailman%2Flistinfo%2Fhdf-forum_lists.hdfgroup.org</a><br>
Twitter: <a href="https://twitter.com/hdf5" rel="noreferrer" target="_blank">https://twitter.com/hdf5</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Hdf-forum is for HDF software users discussion.<br>
<a href="mailto:Hdf-forum@lists.hdfgroup.org" target="_blank">Hdf-forum@lists.hdfgroup.org</a> <mailto:<a href="mailto:Hdf-forum@lists.hdfgroup.org" target="_blank">Hdf-forum@lists.hdfgroup.org</a>><br>
<br>
<a href="http://secure-web.cisco.com/1r-EJFFfg6rWlpQsvXstBNTjaHQaKT_NkYRN0Jj_f-Z3EK0-hs6IbYc8XUBRyPsH3mU3CS0iiY7_qnchCA0QxNzQt270d_2HikCwpAWFmuHdacin62eaODutktDSOULIJmVbVYqFVSKWPzoX7kdP0yN9wIzSFxZfTwfhU8ebsN409xRg1PsW_8cvNiWzxDNm9wv9yBf9yK6nkEm-bOx2S0kBLbg9WfIChWzZrkpE3AHU9I-c2ZRH_IN-UF4g_g0_Dh4qE1VETs7tZTfKd1ox1MtBmeyKf7EKUCd3ezR9EbI5tK4hCU5qW4v5WWOxOrD17e8yCVmob27xz84Lr3bCK5wIQdH5VzFRTtyaAhudpt9E/http%3A%2F%2Flists.hdfgroup.org%2Fmailman%2Flistinfo%2Fhdf-forum_lists.hdfgroup.org" rel="noreferrer" target="_blank">http://secure-web.cisco.com/1r-EJFFfg6rWlpQsvXstBNTjaHQaKT_NkYRN0Jj_f-Z3EK0-hs6IbYc8XUBRyPsH3mU3CS0iiY7_qnchCA0QxNzQt270d_2HikCwpAWFmuHdacin62eaODutktDSOULIJmVbVYqFVSKWPzoX7kdP0yN9wIzSFxZfTwfhU8ebsN409xRg1PsW_8cvNiWzxDNm9wv9yBf9yK6nkEm-bOx2S0kBLbg9WfIChWzZrkpE3AHU9I-c2ZRH_IN-UF4g_g0_Dh4qE1VETs7tZTfKd1ox1MtBmeyKf7EKUCd3ezR9EbI5tK4hCU5qW4v5WWOxOrD17e8yCVmob27xz84Lr3bCK5wIQdH5VzFRTtyaAhudpt9E/http%3A%2F%2Flists.hdfgroup.org%2Fmailman%2Flistinfo%2Fhdf-forum_lists.hdfgroup.org</a><br>
Twitter: <a href="https://twitter.com/hdf5" rel="noreferrer" target="_blank">https://twitter.com/hdf5</a><br>
<br>
<br>
------------------------------------------------------------------------<br>
<br>
_______________________________________________<br>
Hdf-forum is for HDF software users discussion.<br>
<a href="mailto:Hdf-forum@lists.hdfgroup.org" target="_blank">Hdf-forum@lists.hdfgroup.org</a><br>
<br>
<a href="http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org" rel="noreferrer" target="_blank">http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org</a><br>
Twitter: <a href="https://twitter.com/hdf5" rel="noreferrer" target="_blank">https://twitter.com/hdf5</a><br>
<br>
<br>
<br>
_______________________________________________<br>
netcdfgroup mailing list<br>
<a href="mailto:netcdfgroup@unidata.ucar.edu" target="_blank">netcdfgroup@unidata.ucar.edu</a><br>
For list information or to unsubscribe, visit: <a href="http://www.unidata.ucar.edu/mailing_lists/" rel="noreferrer" target="_blank">http://www.unidata.ucar.edu/mailing_lists/</a><br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</div></div></blockquote><div class="HOEnZb"><div class="h5">
<br>
_______________________________________________<br>
CF-metadata mailing list<br>
<a href="mailto:CF-metadata@cgd.ucar.edu" target="_blank">CF-metadata@cgd.ucar.edu</a><br>
<a href="http://mailman.cgd.ucar.edu/mailman/listinfo/cf-metadata" rel="noreferrer" target="_blank">http://mailman.cgd.ucar.edu/mailman/listinfo/cf-metadata</a><br>
</div></div></blockquote></div><br></div>