![]() |
VOOZH | about |
dotnet add package PureHDF.SourceGenerator --version 1.0.1
NuGet\Install-Package PureHDF.SourceGenerator -Version 1.0.1
<PackageReference Include="PureHDF.SourceGenerator" Version="1.0.1" />
<PackageVersion Include="PureHDF.SourceGenerator" Version="1.0.1" />Directory.Packages.props
<PackageReference Include="PureHDF.SourceGenerator" />Project file
paket add PureHDF.SourceGenerator --version 1.0.1
#r "nuget: PureHDF.SourceGenerator, 1.0.1"
#:package PureHDF.SourceGenerator@1.0.1
#addin nuget:?package=PureHDF.SourceGenerator&version=1.0.1Install as a Cake Addin
#tool nuget:?package=PureHDF.SourceGenerator&version=1.0.1Install as a Cake Tool
A pure C# library without native dependencies that makes reading and writing of HDF5 files (groups, datasets, attributes, ...) very easy.
The minimum supported target framework is .NET Standard 2.0 which includes
This library runs on all platforms (ARM, x86, x64) and operating systems (Linux, Windows, MacOS, Raspbian, etc) that are supported by the .NET ecosystem without special configuration.
The implemention follows the HDF5 File Format Specification (HDF5 1.10).
Please read the docs for samples and API documentation.
To keep the code base clean, version 2 of PureHDF supports active .NET versions only, which are .NET 6 and .NET 8 as of now (June 2024).
Version 1 of PureHDF supports all .NET versions starting with .NET 4.7.2 and continues to receive bug fixes. Features will be backported upon request if feasible.
dotnet add package PureHDF
// root group
var file = H5File.OpenRead("path/to/file.h5");
// sub group
var group = file.Group("path/to/group");
// attribute
var attribute = group.Attribute("my-attribute");
var attributeData = attribute.Read<int>();
// dataset
var dataset = group.Dataset("my-dataset");
var datasetData = dataset.Read<double>();
See the docs to learn more about data types, multidimensional arrays, chunks, compression, slicing and more.
The first step is to create a new H5File instance:
var file = new H5File();
A H5File derives from the H5Group type because it represents the root group. H5Group implements the IDictionary interface, where the keys represent the links in an HDF5 file and the value determines the type of the link: either it is another H5Group or a H5Dataset.
You can create an empty group like this:
var group = new H5Group();
If the group should have some datasets, just add them using the dictionary collection initializer - just like with a normal dictionary:
var group = new H5Group()
{
["numerical-dataset"] = new double[] { 2.0, 3.1, 4.2 },
["string-dataset"] = new string[] { "One", "Two", "Three" }
}
Datasets and attributes can both be created either by instantiating their specific class (H5Dataset, H5Attribute) or by just providing some kind of data. This data can be nearly anything: arrays, scalars, numerical values, strings, anonymous types, enums, complex objects, structs, bool values, etc. However, whenever you want to provide more details like the dimensionality of the attribute or dataset, the chunk layout or the filters to be applied to a dataset, you need to instantiate the appropriate class.
But first, let's see how to add attributes. Attributes cannot be added directly using the dictionary collection initializer because that is only for datasets. However, every H5Group has an Attribute property which accepts our attributes:
var group = new H5Group()
{
Attributes = new()
{
["numerical-attribute"] = new double[] { 2.0, 3.1, 4.2 },
["string-attribute"] = new string[] { "One", "Two", "Three" }
}
}
The full example with the root group, a subgroup, two datasets and two attributes looks like this:
var file = new H5File()
{
["my-group"] = new H5Group()
{
["numerical-dataset"] = new double[] { 2.0, 3.1, 4.2 },
["string-dataset"] = new string[] { "One", "Two", "Three" },
Attributes = new()
{
["numerical-attribute"] = new double[] { 2.0, 3.1, 4.2 },
["string-attribute"] = new string[] { "One", "Two", "Three" }
}
}
};
The last step is to write the defined file to the drive:
file.Write("path/to/file.h5");
See the docs to learn more about data types, multidimensional arrays, chunks, compression, slicing and more.
The tests of PureHDF are executed against .NET 6 and .NET 7 so these two runtimes are required. Please note that due to an currently unknown reason the writing tests cannot be run in parallel to other tests because some unrelated temp files are in use although they should not be and thus cannot be accessed by the unit tests.
If you are using Visual Studio Code as your IDE, you can simply execute one of the predefined test tasks by selecting Run Tasks from the global menu (Ctrl+Shift+P). The following test tasks are predefined:
tests: commontests: writingtests: filterstests: HSDSThe HSDS tests require a python installation to be present on the system with the venv package available.
Overwhelmed by the number of different HDF 5 libraries? Here is a comparison table:
Note: The following table considers only projects listed on Nuget.org
| Name | Arch | Platform | Kind | Mode | Version | License | Maintainer | Comment |
|---|---|---|---|---|---|---|---|---|
| v1.10 | ||||||||
| PureHDF | all | all | managed | rw | 1.10.* | MIT | Apollo3zehn | |
| HDF5-CSharp | x86,x64 | Win,Lin,Mac | HL | rw | 1.10.6 | MIT | LiorBanai | |
| SciSharp.Keras.HDF5 | x86,x64 | Win,Lin,Mac | HL | rw | 1.10.5 | MIT | SciSharp | fork of HDF-CSharp |
| ILNumerics.IO.HDF5 | x64 | Win,Lin | HL | rw | ? | proprietary | IL_Numerics_GmbH | probably 1.10 |
| LiteHDF | x86,x64 | Win,Lin,Mac | HL | ro | 1.10.5 | MIT | silkfire | |
| hdflib | x86,x64 | Windows | HL | wo | 1.10.6 | MIT | bdebree | |
| Mbc.Hdf5Utils | x86,x64 | Win,Lin,Mac | HL | rw | 1.10.6 | Apache-2.0 | bqstony | |
| HDF.PInvoke | x86,x64 | Windows | bindings | rw | 1.8,1.10.6 | HDF5 | hdf,gheber | |
| HDF.PInvoke.1.10 | x86,x64 | Win,Lin,Mac | bindings | rw | 1.10.6 | HDF5 | hdf,Apollo3zehn | |
| HDF.PInvoke.NETStandard | x86,x64 | Win,Lin,Mac | bindings | rw | 1.10.5 | HDF5 | surban | |
| v1.8 | ||||||||
| HDF5DotNet.x64 | x64 | Windows | HL | rw | 1.8 | HDF5 | thieum | |
| HDF5DotNet.x86 | x86 | Windows | HL | rw | 1.8 | HDF5 | thieum | |
| sharpHDF | x64 | Windows | HL | rw | 1.8 | MIT | bengecko | |
| HDF.PInvoke | x86,x64 | Windows | bindings | rw | 1.8,1.10.6 | HDF5 | hdf,gheber | |
| hdf5-v120-complete | x86,x64 | Windows | native | rw | 1.8 | HDF5 | daniel.gracia | |
| hdf5-v120 | x86,x64 | Windows | native | rw | 1.8 | HDF5 | keen |
Abbreviations:
| Term | .NET API | Native dependencies |
|---|---|---|
managed |
high-level | none |
HL |
high-level | C-library |
bindings |
low-level | C-library |
native |
none | C-library |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.2 | 153 | 3/17/2026 |
| 2.1.1 | 303 | 8/16/2024 |
| 2.1.0 | 234 | 6/28/2024 |
| 2.0.1 | 200 | 6/26/2024 |
| 2.0.0 | 192 | 6/24/2024 |
| 1.0.1 | 232 | 7/24/2024 |
| 1.0.0 | 199 | 6/24/2024 |
| 1.0.0-beta.27 | 145 | 6/21/2024 |
| 1.0.0-beta.26 | 172 | 6/18/2024 |
| 1.0.0-beta.25 | 160 | 6/14/2024 |
| 1.0.0-beta.24 | 164 | 6/13/2024 |
| 1.0.0-beta.23 | 172 | 5/30/2024 |
| 1.0.0-beta.22 | 152 | 5/29/2024 |
| 1.0.0-beta.21 | 186 | 5/28/2024 |
| 1.0.0-beta.20 | 139 | 5/28/2024 |
| 1.0.0-beta.19 | 146 | 5/27/2024 |
| 1.0.0-beta.18 | 162 | 5/20/2024 |
| 1.0.0-beta.17 | 144 | 5/16/2024 |
| 1.0.0-beta.16 | 132 | 5/3/2024 |
| 1.0.0-beta.15 | 135 | 5/1/2024 |