All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generated.docs.javadoc.org.eclipse.dawnsci.hdf5.HDF5Utils.html Maven / Gradle / Ivy






HDF5Utils (h5jan API)












org.eclipse.dawnsci.hdf5

Class HDF5Utils

  • java.lang.Object
    • org.eclipse.dawnsci.hdf5.HDF5Utils


  • public class HDF5Utils
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  HDF5Utils.DatasetType 
    • Constructor Summary

      Constructors 
      Constructor and Description
      HDF5Utils() 
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      static java.lang.String absolutePathToData(java.lang.String parentPath, java.lang.String name) 
      static long calcLongSize(long[] shape) 
      static void closeDataset(long[] ids) 
      static void createDataset(HDF5File f, int compression, java.lang.String dataPath, int dtype, int[] iShape, int[] iMaxShape, int[] iChunks, java.lang.Object fillValue)
      Create a dataset in given file
      static Dataset createDataset(java.lang.Object data, int[] shape, int dtype, boolean extend)
      Create a dataset from the given data object
      static void createDataset(java.lang.String fileName, java.lang.String parentPath, java.lang.String name, int[] initialShape, int[] maxShape, int[] chunking, int dtype, java.lang.Object fill, boolean asUnsigned)
      Create a dataset in HDF5 file.
      static void createExternalLink(HDF5File f, java.lang.String destination, java.lang.String externalFileName, java.lang.String source)
      Create a link to a source node in an external file
      static void createExternalLink(java.lang.String fileName, java.lang.String destination, java.lang.String externalFileName, java.lang.String source)
      Create a link to a source node in an external file
      static LazyWriteableDataset createLazyDataset(java.lang.String fileName, java.lang.String parentPath, java.lang.String name, int[] initialShape, int[] maxShape, int[] chunking, int dtype, java.lang.Object fill, boolean asUnsigned)
      Create a lazy dataset in HDF5 file
      static HDF5Utils.DatasetType findClassesInComposite(long tid)
      Find classes in composite data type
      static void flushDataset(long[] ids) 
      static Dataset getAttrDataset(long locId, java.lang.String path, long i) 
      static int[][] getDatasetShape(java.lang.String fileName, java.lang.String node)
      Get dataset shape information from given file
      static HDF5Utils.DatasetType getDatasetType(long typeId, long nativeTypeId) 
      static int getDType(int dclass, int dsize)
      Translate between data type and dataset type
      static long getHDF5type(java.lang.Class<?> clazz)
      Get HDF5 data type constants for boxed primitives
      static long getHDF5type(int dtype)
      Get HDF5 data type constants for dataset types
      static java.lang.String getLocalHostName()
      Gracefully gets the local host name (if there is a mis-configuration or any other issue, "localhost" is returned)
      static long H5Fopen(java.lang.String filePath, int flags, long fapl)
      Deprecated. 
      static boolean hasDataset(java.lang.String fileName, java.lang.String node)
      Check whether a dataset exists in a file
      static boolean isHDF5(java.lang.String fileName)
      Check if file is a HDF5 file
      static Dataset loadDataset(HDF5File fid, java.lang.String node)
      Load entire dataset from given file
      static Dataset loadDataset(java.lang.String fileName, java.lang.String node)
      Load entire dataset from given file
      static Dataset loadDataset(java.lang.String fileName, java.lang.String node, int[] start, int[] count, int[] step, int dtype, int isize, boolean extend)
      Load dataset from given file
      static Dataset loadDatasetWithClose(java.lang.String fileName, java.lang.String node, int[] start, int[] count, int[] step, int dtype, int isize, boolean extend)
      Load dataset from given file
      static long[] openDataset(HDF5File f, java.lang.String dataPath) 
      static Dataset[] readAttributes(long oid) 
      static Dataset[] readAttributes(long oid, java.lang.String path) 
      static Dataset[] readAttributes(java.lang.String fileName, java.lang.String path)
      Read attributes from group or dataset in given file
      static Dataset readDataset(HDF5File f, java.lang.String dataPath, int[] start, int[] count, int[] step, int dtype, int isize, boolean extend)
      Read dataset from given file ID
      static int[][] readDatasetShape(HDF5File f, java.lang.String dataPath)
      Read shape information from a dataset
      static void setDatasetSlice(java.lang.String fileName, java.lang.String parentPath, java.lang.String name, SliceND slice, IDataset value)
      Set slice of dataset in HDF5 file.
      static void setExistingDatasetSlice(java.lang.String fileName, java.lang.String parentPath, java.lang.String name, SliceND slice, IDataset value)
      Set slice of dataset in HDF5 file.
      static int[] toIntArray(long[] in)
      Convert long array to integer array
      static long[] toLongArray(int[] in)
      Convert integer array to long array
      static void writeAttributes(HDF5File f, java.lang.String path, IDataset... attributes)
      Write attributes to a group or dataset in given file
      static void writeAttributes(java.lang.String fileName, java.lang.String path, boolean isGroup, IDataset... attributes)
      Write attributes to a group or dataset in given file.
      static void writeDataset(HDF5File f, java.lang.String dataPath, IDataset data)
      Write a dataset in given file
      static void writeDataset(java.lang.String fileName, java.lang.String parentPath, IDataset data)
      Write a dataset in HDF5 file.
      static void writeDatasetSlice(HDF5File f, java.lang.String dataPath, SliceND slice, IDataset value)
      Write to a slice in a dataset
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HDF5Utils

        public HDF5Utils()
    • Method Detail

      • getLocalHostName

        public static java.lang.String getLocalHostName()
        Gracefully gets the local host name (if there is a mis-configuration or any other issue, "localhost" is returned)
        Returns:
        local host name
      • isHDF5

        public static boolean isHDF5(java.lang.String fileName)
        Check if file is a HDF5 file
        Parameters:
        fileName -
        Returns:
        true if it can be read as an HDF5 file
      • createDataset

        public static Dataset createDataset(java.lang.Object data,
                                            int[] shape,
                                            int dtype,
                                            boolean extend)
        Create a dataset from the given data object
        Parameters:
        data -
        shape -
        dtype -
        extend - true dataset for unsigned types
        Returns:
        dataset
      • getDType

        public static int getDType(int dclass,
                                   int dsize)
        Translate between data type and dataset type
        Parameters:
        dclass - data type class
        dsize - data type element size in bytes
        Returns:
        dataset type
      • getHDF5type

        public static long getHDF5type(java.lang.Class<?> clazz)
        Get HDF5 data type constants for boxed primitives
        Parameters:
        clazz -
        Returns:
      • getHDF5type

        public static long getHDF5type(int dtype)
        Get HDF5 data type constants for dataset types
        Parameters:
        dtype -
        Returns:
      • loadDatasetWithClose

        public static Dataset loadDatasetWithClose(java.lang.String fileName,
                                                   java.lang.String node,
                                                   int[] start,
                                                   int[] count,
                                                   int[] step,
                                                   int dtype,
                                                   int isize,
                                                   boolean extend)
                                            throws ScanFileHolderException
        Load dataset from given file
        Parameters:
        fileName -
        node -
        start -
        count -
        step -
        dtype -
        isize -
        extend -
        Returns:
        dataset
        Throws:
        java.lang.Exception
        ScanFileHolderException
      • loadDataset

        public static Dataset loadDataset(java.lang.String fileName,
                                          java.lang.String node)
                                   throws ScanFileHolderException
        Load entire dataset from given file
        Parameters:
        fileName -
        node -
        Returns:
        dataset
        Throws:
        java.lang.Exception
        ScanFileHolderException
      • hasDataset

        public static boolean hasDataset(java.lang.String fileName,
                                         java.lang.String node)
                                  throws ScanFileHolderException
        Check whether a dataset exists in a file
        Parameters:
        fileName -
        node -
        Returns:
        dataset
        Throws:
        java.lang.Exception
        ScanFileHolderException
      • loadDataset

        public static Dataset loadDataset(java.lang.String fileName,
                                          java.lang.String node,
                                          int[] start,
                                          int[] count,
                                          int[] step,
                                          int dtype,
                                          int isize,
                                          boolean extend)
                                   throws ScanFileHolderException
        Load dataset from given file
        Parameters:
        fileName -
        node -
        start -
        count -
        step -
        dtype -
        isize -
        extend -
        Returns:
        dataset
        Throws:
        java.lang.Exception
        ScanFileHolderException
      • getDatasetShape

        public static int[][] getDatasetShape(java.lang.String fileName,
                                              java.lang.String node)
                                       throws ScanFileHolderException
        Get dataset shape information from given file
        Parameters:
        fileName -
        dataPath -
        Returns:
        null for when there's no data; two empty arrays for a zero-rank dataset; shape, max shape otherwise
        Throws:
        ScanFileHolderException
      • readDatasetShape

        public static int[][] readDatasetShape(HDF5File f,
                                               java.lang.String dataPath)
                                        throws NexusException
        Read shape information from a dataset
        Parameters:
        f -
        dataPath -
        Returns:
        null for when there's no data; two empty arrays for a zero-rank dataset; shape, max shape otherwise
        Throws:
        NexusException
      • readDataset

        public static Dataset readDataset(HDF5File f,
                                          java.lang.String dataPath,
                                          int[] start,
                                          int[] count,
                                          int[] step,
                                          int dtype,
                                          int isize,
                                          boolean extend)
                                   throws NexusException
        Read dataset from given file ID
        Parameters:
        f -
        dataPath -
        start -
        count -
        step -
        dtype - (can be -1 for dataset type from file)
        isize - (can be -1 for item size from file)
        extend -
        Returns:
        dataset
        Throws:
        NexusException
      • absolutePathToData

        public static java.lang.String absolutePathToData(java.lang.String parentPath,
                                                          java.lang.String name)
        Returns:
        the absolute path to data
      • createDataset

        public static void createDataset(java.lang.String fileName,
                                         java.lang.String parentPath,
                                         java.lang.String name,
                                         int[] initialShape,
                                         int[] maxShape,
                                         int[] chunking,
                                         int dtype,
                                         java.lang.Object fill,
                                         boolean asUnsigned)
                                  throws ScanFileHolderException
        Create a dataset in HDF5 file. Create the file if necessary
        Parameters:
        fileName -
        parentPath - path to group containing dataset
        name - name of dataset
        initialShape -
        maxShape -
        chunking -
        dtype - dataset type
        fill -
        asUnsigned -
        Throws:
        ScanFileHolderException
      • createLazyDataset

        public static LazyWriteableDataset createLazyDataset(java.lang.String fileName,
                                                             java.lang.String parentPath,
                                                             java.lang.String name,
                                                             int[] initialShape,
                                                             int[] maxShape,
                                                             int[] chunking,
                                                             int dtype,
                                                             java.lang.Object fill,
                                                             boolean asUnsigned)
        Create a lazy dataset in HDF5 file
        Parameters:
        fileName -
        parentPath -
        name -
        initialShape -
        maxShape -
        chunking -
        dtype -
        fill -
        asUnsigned -
        Returns:
      • createDataset

        public static void createDataset(HDF5File f,
                                         int compression,
                                         java.lang.String dataPath,
                                         int dtype,
                                         int[] iShape,
                                         int[] iMaxShape,
                                         int[] iChunks,
                                         java.lang.Object fillValue)
                                  throws NexusException
        Create a dataset in given file
        Parameters:
        f -
        compression -
        dataPath -
        dtype -
        iShape -
        iMaxShape -
        iChunks -
        fillValue -
        Throws:
        NexusException
      • writeDataset

        public static void writeDataset(java.lang.String fileName,
                                        java.lang.String parentPath,
                                        IDataset data)
                                 throws ScanFileHolderException
        Write a dataset in HDF5 file. Create the file if necessary
        Parameters:
        fileName -
        parentPath - path to group containing dataset
        data -
        Throws:
        ScanFileHolderException
        java.lang.IllegalArgumentException - when data has null or empty name
      • writeDataset

        public static void writeDataset(HDF5File f,
                                        java.lang.String dataPath,
                                        IDataset data)
                                 throws NexusException
        Write a dataset in given file
        Parameters:
        f -
        dataPath -
        data -
        Throws:
        NexusException
      • writeAttributes

        public static void writeAttributes(java.lang.String fileName,
                                           java.lang.String path,
                                           boolean isGroup,
                                           IDataset... attributes)
                                    throws ScanFileHolderException
        Write attributes to a group or dataset in given file. When writing to group, this checks if group exists in file and creates group if not
        Parameters:
        fileName -
        path -
        isGroup -
        attributes -
        Throws:
        ScanFileHolderException
      • writeAttributes

        public static void writeAttributes(HDF5File f,
                                           java.lang.String path,
                                           IDataset... attributes)
                                    throws NexusException
        Write attributes to a group or dataset in given file
        Parameters:
        f -
        path -
        attributes -
        Throws:
        NexusException
        java.lang.IllegalArgumentException - when any attribute has null or empty name
      • setDatasetSlice

        public static void setDatasetSlice(java.lang.String fileName,
                                           java.lang.String parentPath,
                                           java.lang.String name,
                                           SliceND slice,
                                           IDataset value)
                                    throws ScanFileHolderException
        Set slice of dataset in HDF5 file. Create file if necessary
        Parameters:
        fileName -
        parentPath -
        name -
        slice -
        value -
        Throws:
        ScanFileHolderException
      • setExistingDatasetSlice

        public static void setExistingDatasetSlice(java.lang.String fileName,
                                                   java.lang.String parentPath,
                                                   java.lang.String name,
                                                   SliceND slice,
                                                   IDataset value)
                                            throws ScanFileHolderException
        Set slice of dataset in HDF5 file. Create file if necessary
        Parameters:
        fileName -
        parentPath -
        name -
        slice -
        value -
        Throws:
        ScanFileHolderException
      • writeDatasetSlice

        public static void writeDatasetSlice(HDF5File f,
                                             java.lang.String dataPath,
                                             SliceND slice,
                                             IDataset value)
                                      throws NexusException
        Write to a slice in a dataset
        Parameters:
        f -
        dataPath -
        slice -
        value -
        Throws:
        NexusException
      • H5Fopen

        public static long H5Fopen(java.lang.String filePath,
                                   int flags,
                                   long fapl)
                            throws HDF5LibraryException,
                                   java.lang.NullPointerException
        Deprecated. Use H5.H5Fopen(String,int,long) directly
        Wrapper to fix super block status flag issue
        Parameters:
        filePath -
        flags -
        fapl -
        Returns:
        file ID
        Throws:
        HDF5LibraryException
        java.lang.NullPointerException
      • createExternalLink

        public static void createExternalLink(java.lang.String fileName,
                                              java.lang.String destination,
                                              java.lang.String externalFileName,
                                              java.lang.String source)
                                       throws ScanFileHolderException
        Create a link to a source node in an external file
        Parameters:
        fileName - file name where link will be created
        destination - path of created link
        externalFileName - external file
        source - path of source node
        Throws:
        ScanFileHolderException
      • createExternalLink

        public static void createExternalLink(HDF5File f,
                                              java.lang.String destination,
                                              java.lang.String externalFileName,
                                              java.lang.String source)
                                       throws NexusException
        Create a link to a source node in an external file
        Parameters:
        f -
        destination - path of created link (if ends with then use name from source)
        externalFileName - external file
        source - path of source node
        Throws:
        ScanFileHolderException
        NexusException
      • getAttrDataset

        public static Dataset getAttrDataset(long locId,
                                             java.lang.String path,
                                             long i)
                                      throws NexusException
        Throws:
        NexusException
      • calcLongSize

        public static long calcLongSize(long[] shape)
      • toLongArray

        public static final long[] toLongArray(int[] in)
        Convert integer array to long array
        Parameters:
        in -
        Returns:
        long array
      • toIntArray

        public static int[] toIntArray(long[] in)
        Convert long array to integer array
        Parameters:
        in -
        Returns:
        integer array




© 2015 - 2024 Weber Informatics LLC | Privacy Policy