d_hdf5 ~master
HDF5 bindings and wrappers for the D Programming Language.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
d_hdf5
D bindings and wrappers for the HDF5 scientific data format. These differ from another project in being more C oriented and not exposing the Byzantine HDF5 class structure. I think aldacron's version may be more object-oriented, although I have not looked at it. Link (here)[https://github.com/aldanor/h5d]
Relatively raw stage - there may be some bugs still, although it does work for my own projects.
Ported to D by Laeeth Isharc 2014, 2015. Linux only I am afraid, although it should not be much work to port to Windows.
- Borrowed heavily from C API declarations in https://github.com/SFrijters/hdf5-d
- Three parts:
- Low-level C bindings: hdf5/bindings/api.d and hdf5/bindings/enum.d
- High-level D wrappers: hdf5/wrap.d
- currently these provide simple sugar such as accepting and returning D strings rather than char*. - over time I will work on developing these, but you can see code for dumping and retrieving an array of structs to/from an hdf5 dataset in the file examples/traits.d. Compile-time reflection is used to infer the format of the data set. The mapping from D types to HDF5 dataset types is pretty basic, but usable.
- Ports of the example code from C to D. Only some these have been finished, but they are enough to demonstrate the basic functionality. See examples/*.d for the examples that work. (To build run make or dub in the root directory). Example C code that has not yet been ported is in the old/examples/notyetported/ directory
- To Do
- Better exception handling that calls HDF5 to get error message and returns appropriate subclass of Exception
- Unit tests (use example to build them)
- Refinement of use of CTFE - better checking of types, allow tables of higher dimensions, allow reading tables where the record type is not known beforehand.
- Integration with D dataframe library
- I have started wrapping the high-level library. The bindings are more or less done. The wrappings I have only made a start on and for now the code is commented out.
Sample Use Code (Ported from the C example)
import hdf5.hdf5;
import std.stdio;
import std.exception;
enum filename="dset.h5";
int main(string[] args)
{
int[600][1000] dset_data;
H5open();
// Initialize the dataset.
foreach(i;0..dset_data.length)
foreach(j;0..dset_data[0].length)
dset_data[i][j] = cast(int)i * cast(int)dset_data.length + cast(int)j + 1;
writefln("* opening %s",filename);
// Open an existing file.
auto file_id = H5F.open(filename, H5F_ACC_RDWR, H5P_DEFAULT);
writefln("* opening /dset");
// Open an existing dataset.
auto dataset_id = H5D.open2(file_id, "/dset", H5P_DEFAULT);
// Write the dataset.
writefln("* writing dataset");
H5D.write(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)dset_data.ptr);
writefln("* reading dataset");
H5D.read(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, cast(ubyte*)&dset_data).ptr;
writefln("* closing dataset");
/* Close the dataset. */
H5D.close(dataset_id);
writefln("* closing file");
/* Close the file. */
H5F.close(file_id);
H5close();
return 0;
}
Getting Started
- Make sure you have the hdf5-1.8.15-patch1 version of the HDF5 C library - you should have libhdf5 and libhdf5_hl and check that /etd.dmd.conf knows where to find them. The interface changes for HDF5 even with minor releases, and I do not have the manpower to maintain different versions of the bindings for different releases
- Build the examples
cd examples dub build --force cd ..
- Type rdmd runexamples.d in the base directory to run the examples one by one. Not all examples are finished or working
Pull requests welcomed, and I need to find a co-maintainer as I don't have time to do this consistently.
- Registered by Laeeth Isharc
- ~master released 2 years ago
- Laeeth/d_hdf5
- github.com/Laeeth/d_hdf5
- Boost-1.0
- Authors:
- Dependencies:
- none
- System dependencies:
- requires HDF5 1.8.15.patch-1 versions of libhdf5 and libhdf5_hl
- Versions:
-
0.3.0 2015-Aug-19 0.2.0 2014-Dec-26 0.0.0 2014-Dec-22 ~master 2022-Aug-30 ~hlwork 2015-Apr-06 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
572 downloads total
-
- Score:
- 1.9
- Short URL:
- d_hdf5.dub.pm