Package xal.app.scanner
Class Hdf5Writer
- java.lang.Object
-
- xal.app.scanner.Hdf5Writer
-
- All Implemented Interfaces:
AutoCloseable
public class Hdf5Writer extends Object implements AutoCloseable
This is an early template of what we need in terms of static HDF5 writer. Should be refactored and put in a core i/o class- Author:
- yngvelevinsen
-
-
Constructor Summary
Constructors Constructor Description Hdf5Writer()Create a new writer object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Make sure HDF5 file is closed before instance is destroyed (unsure if this is necessary tbh)voidcloseSourceFile()Closes the HDF file access.hdf.object.h5.H5GroupgetOrCreateGroup(hdf.object.h5.H5File h5File, String path)If the name already exist in group, return it cast as a H5Group, otherwise create it and return the object.ArrayList<String>h5GetAllGroups(String groupPath)Returns all groups one level below the group path givenstatic booleanh5LibsWorks()Test HDF5 writing, return true if it works wellvoidsetSource(String filePath)Set the path to the HDF file and open itvoidwriteArrayAsHDF5DataSet(String path, String tStamp, double[] data)voidwriteDoubleAsHDF5DataSet(String path, String tStamp, double data)voidwriteHDF5Attribute(String path, String attributeName, String attributeContent)Write a string attribute to a H5Object in the file
-
-
-
Method Detail
-
close
public void close()
Make sure HDF5 file is closed before instance is destroyed (unsure if this is necessary tbh)- Specified by:
closein interfaceAutoCloseable
-
closeSourceFile
public void closeSourceFile()
Closes the HDF file access. Should also flush any remaining output.
-
setSource
public void setSource(String filePath) throws Exception
Set the path to the HDF file and open it- Parameters:
filePath- Path to HDF file- Throws:
Exception- If there was a problem opening the file
-
writeArrayAsHDF5DataSet
public void writeArrayAsHDF5DataSet(String path, String tStamp, double[] data) throws Exception
- Throws:
Exception
-
writeDoubleAsHDF5DataSet
public void writeDoubleAsHDF5DataSet(String path, String tStamp, double data) throws Exception
- Throws:
Exception
-
writeHDF5Attribute
public void writeHDF5Attribute(String path, String attributeName, String attributeContent) throws Exception
Write a string attribute to a H5Object in the file- Parameters:
path- Path to H5Object that should have the attributeattributeName- Name of attributeattributeContent- Content of attribute- Throws:
Exception- If there is a problem creating the attribute
-
getOrCreateGroup
public hdf.object.h5.H5Group getOrCreateGroup(hdf.object.h5.H5File h5File, String path) throws ExceptionIf the name already exist in group, return it cast as a H5Group, otherwise create it and return the object.- Parameters:
h5File- The name of the child group objectpath- The name of the parent group- Returns:
- The child group
- Throws:
Exception- If there was a problem creating a group
-
h5GetAllGroups
public ArrayList<String> h5GetAllGroups(String groupPath) throws Exception
Returns all groups one level below the group path given- Parameters:
groupPath- Path to group (e.g "/" to get top level)- Returns:
- list of all groups one level below
- Throws:
Exception- If there was a problem creating a group
-
h5LibsWorks
public static boolean h5LibsWorks()
Test HDF5 writing, return true if it works well- Returns:
- True if you are able to write HDF5 files
-
-