Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an HDF5 sample file by marqov #34

Merged
merged 1 commit into from
Dec 5, 2022
Merged

Conversation

CaptainSifff
Copy link
Contributor

This is an HDF5 file by MARQOV, available here: http://marqov.de
The file is described at
https://gitpages.physik.uni-wuerzburg.de/marqov/webmarqov/doc/io.html

@pdurbin
Copy link
Member

pdurbin commented Dec 5, 2022

@CaptainSifff thanks!

I ran it through the NetCDF Java library I mentioned but unfortunately it can't handle this type of HDF5 files (it does seem to handle certain HDF5 files).

Here's the error I get...

D'oh! ioexception: java.io.IOException: java.lang.IllegalArgumentException: Dimension length =0 must be > 0

... when I print out the exception using the code change below.

Interestingly, this is the same error I see when I try to pass an HDF4 file to the library.

Anyway, I'm happy to merge this so we have the data handy. However, Dataverse will need more work to do anything with this file. Thanks again!

diff --git a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
index 257bc166ea..63aa8c9369 100644
--- a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
+++ b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
@@ -677,7 +677,7 @@ public class FileUtil implements java.io.Serializable  {
     }
 
     public static String checkNetcdfOrHdf5(File file) {
-        try ( NetcdfFile netcdfFile = NetcdfFiles.open(file.getAbsolutePath())) {
+        try ( NetcdfFile netcdfFile = NetcdfFiles.open(file.getAbsolutePath())) { // try another hdf5 file
             if (netcdfFile == null) {
                 // Can't open as a NetCDF or HDF5 file.
                 return null;
@@ -697,6 +697,7 @@ public class FileUtil implements java.io.Serializable  {
                     break;
             }
         } catch (IOException ex) {
+            System.out.println("D'oh! ioexception: " + ex);
             /**
              * When an HDF4 file is passed, it won't be detected. Instead, we've
              * seen exceptions like this:
@@ -708,6 +709,7 @@ public class FileUtil implements java.io.Serializable  {
              * java.lang.IllegalArgumentException: Dimension length =0 must be >
              * 0
              */
+            // Similar message for some HDF5 files?
             return null;
         }
         return null;
diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java
index 1d481f18cf..e88ce0ed88 100644
--- a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java
+++ b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java
@@ -396,6 +396,15 @@ public class FileUtilTest {
         assertEquals("application/x-hdf5", contentType);
     }
 
+    @Test
+    public void testHdf5File2() throws IOException {
+        String path = "/tmp/";
+        String pathAndFile = path + "beta0.300000_0.h5";
+        File file = new File(pathAndFile);
+        String contentType = FileUtil.determineFileType(file, pathAndFile);
+        assertEquals("application/x-h5", contentType);
+    }
+
     @Test
     public void testHdf4File() throws IOException {
         // We got test.hdf from https://people.sc.fsu.edu/~jburkardt/data/hdf/hdf.html

For more context, for others:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants