File indexing completed on 2024-04-06 12:01:30
0001
0002 import h5py
0003 import numpy as np
0004
0005 with h5py.File('test.h5', 'w') as h5file:
0006 h5file.attrs["at"] = "fileAt".encode("ascii")
0007 AGroup = h5file.create_group("Agroup")
0008 AGroup.attrs["b_at"] = "groupAt".encode("ascii")
0009 dset = AGroup.create_dataset("byte_array", data=np.array([1],dtype='b'))
0010 dset.attrs["d_at"] = "dsetAt".encode("ascii")
0011 dset2 = AGroup.create_dataset("byte_array2", data=np.array([2,2],dtype='b'))
0012 dset3 = AGroup.create_dataset("byte_array3", data=np.array([3,3,3],dtype='b'))
0013 dset4 = AGroup.create_dataset("byte_array4", data=np.array([4,4,4,4],dtype='b'))
0014 BGroup = AGroup.create_group("Bgroup")
0015
0016 RefGroup = h5file.create_group("RefGroup")
0017 groupRefDS = RefGroup.create_dataset("groupRefs", data=[AGroup.ref, BGroup.ref], dtype=h5py.ref_dtype)
0018 dsetRefDS = RefGroup.create_dataset("dsetRefs", data=[dset.ref], dtype=h5py.ref_dtype)
0019 dset2DRefDS = RefGroup.create_dataset("dset2DRefs", data=[[dset.ref,dset2.ref],[dset3.ref,dset4.ref]], dtype=h5py.ref_dtype)
0020
0021
0022
0023 syncValueType = np.dtype([("high", np.uint32),("low", np.uint32)])
0024 firstValues = ((1,0),(2,1),(0xFFFFFFFF,0xFFFFFFFF))
0025 first_np = np.empty(shape=(len(firstValues),), dtype=syncValueType)
0026 first_np['high'] = [ x[0] for x in firstValues]
0027 first_np['low'] = [ x[1] for x in firstValues]
0028 SyncGroup = h5file.create_group("SyncGroup")
0029 sDS = SyncGroup.create_dataset("sync", data=first_np)