File: carray1.py

package info (click to toggle)
pytables 3.10.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,228 kB
  • sloc: ansic: 82,212; python: 65,296; cpp: 753; sh: 394; makefile: 100
file content (20 lines) | stat: -rw-r--r-- 472 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np

import tables as tb

file_name = "carray1.h5"
shape = (200, 300)
atom = tb.UInt8Atom()
filters = tb.Filters(complevel=5, complib="zlib")

h5f = tb.open_file(file_name, "w")
ca = h5f.create_carray(h5f.root, "carray", atom, shape, filters=filters)
# Fill a hyperslab in ``ca``.
ca[10:60, 20:70] = np.ones((50, 50))
h5f.close()

# Re-open and read another hyperslab
h5f = tb.open_file(file_name)
print(h5f)
print(h5f.root.carray[8:12, 18:22])
h5f.close()