Created
February 9, 2022 09:18
-
-
Save graeme-winter/6afd4b8c513d5e48cc72b9db5294599a to your computer and use it in GitHub Desktop.
Verify that the frames of an HDF5 file are all identical, and return the hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
import hdf5plugin | |
import sys | |
def verify(filename): | |
with h5py.File(filename, "r") as f: | |
data = f["data"] | |
nn = data.shape[0] | |
h = None | |
for j in range(nn): | |
a = data[j, :, :] | |
a.flags.writeable = False | |
if h is None: | |
h = hash(a.data.tobytes()) | |
else: | |
assert h == hash(a.data.tobytes()) | |
print(filename, h) | |
for filename in sys.argv[1:]: | |
verify(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment