Skip to main content
NIST Public Domain

LazyHDF5: Python Macros for h5py… because I’m lazy

LazyHDF5 is a small package for interacting with HDF5 files. The h5py library can do-it-all, but it’s not necessarily easy to use and often requires many lines of code to do routine tasks. This package facilitates easier use.

Also, an HDF5 file viewer written in PyQt5 (optional, not required for installation) that displaces groups, datasets, and attributes.

  • Inspection

    • Get groups, datasets, file hierarchy, dataset attributes

  • Editing

    • Write/alter/re-write attributes

    • Repack datasets (coming soon)

    • Copy datasets and files

  • Basic file viewer

Dependencies

Note: These are the developmental system specs. Older versions of certain packages may work.

  • python >= 3.4

    • Tested with 3.4.6, 3.5.4, 3.6.3

  • numpy (1.9.3)

    • Tested with 1.12.1, 1.13.1, 1.13.3

  • h5py (>=2.6.0)

Optional Dependencies

The HDF file view is written in PyQt5; thus, it’s necessary if you want to that functionality. All of the other tools in this library are command-line.

  • PyQt5 (5.8)

Note: PyQt5 only tested on Windows (via AppVeyor)

Known Issues

Installation

Using pip (hard install)

# Only Python 3.* installed
pip install LazyHDF5

# If you have both Python 2.* and 3.* you may need
pip3 install LazyHDF5

Using pip (soft install [can update with git])

# Make new directory for LazyHDF5 and enter it
# Clone from github
git clone https://github.com/CCampJr/LazyHDF5

# Only Python 3.* installed
pip install -e .

# If you have both Python 2.* and 3.* you may need instead
pip3 install -e .

# To update in the future
git pull

Using setuptools

You will need to download the repository or clone the repository with git:

# Make new directory for LazyHDF5 and enter it
# Clone from github
git clone https://github.com/CCampJr/LazyHDF5

Perform the install:

python setup.py install

Usage Examples

  1. Getting a list of groups from an un-opened HDF5 file

Note: when a filename is provided, the file is opened, queried, and then closed.

from lazy5.inspect import get_groups

filename = 'SomeFile.h5'
grp_list = get_groups(filename)

print('Groups:')
for grp in grp_list:
    print(grp)
  1. Getting list of datasets from an open HDF5 file

Note: when a file-id is provided, the file is queried and then left open.

import h5py
from lazy5.inspect import get_datasets

filename = 'SomeFile.h5'
fid = h5py.File(filename, 'r')

dset_list = get_datasets(fid)

print('Datasets:')
for dset in dset_list:
    print(dset)

fid.close()
  1. Getting the file hierarchy

from lazy5.inspect import get_hierarchy

filename = 'SomeFile.h5'

hierarchy = get_hierarchy(filename)

print('Hierarchy:')
for k in hierarchy:
    print('{} : {}'.format(k, hierarchy[k]))
  1. Ordered dictionary of dataset attributes

from lazy5.inspect import get_attrs_dset

filename = 'SomeFile.h5'
dsetname = '/Group/SomeDataset'

attr_dict = get_attrs_dset(filename, dsetname)

print('Dataset Attributes:')
for k in attr_dict:
    print('{} : {}'.format(k, attr_dict[k]))
  1. PyQt5 HDF5 file viewer

# From the command line
python ./lazy5/ui/QtHdfLoad.py
  1. PyQt5 HDF5 file viewer (programmatically)

import sys
from PyQt5.QtWidgets import QApplication
from lazy5.ui.QtHdfLoad import HdfLoad

app = QApplication(sys.argv)

result = HdfLoad.getFileDataSets(pth='.')
print('Result: {}'.format(result))

sys.exit()

NONLICENSE

This software was developed by employees of the National Institute of Standards and Technology (NIST), an agency of the Federal Government. Pursuant to title 17 United States Code Section 105, works of NIST employees are not subject to copyright protection in the United States and are considered to be in the public domain. Permission to freely use, copy, modify, and distribute this software and its documentation without fee is hereby granted, provided that this notice and disclaimer of warranty appears in all copies.

THE SOFTWARE IS PROVIDED ‘AS IS’ WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.

Contact

Charles H Camp Jr: charles.camp@nist.gov

Contributors

Charles H Camp Jr

Release files for LazyHDF5 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LazyHDF5 0.3.0
File Size Uploaded
LazyHDF5-0.3.0.tar.gz 22.3 kB Details

Release files / LazyHDF5-0.3.0.tar.gz

Download URL LazyHDF5-0.3.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5fe6072ae3cad7d551c0ef34f59ae504b18ed561d5fff3d6405e1a60daf3849f
BLAKE2b-256 checksum
How to use checksums
fca5ed653eadef343116b962ff835a5f48a46b8b00fcc03bb14e6ceede36e0a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page