add python bindings for numpy

This commit is contained in:
Bechir Braham
2024-03-11 16:05:54 +01:00
parent 25d282717c
commit c4c88c50d1
5 changed files with 49 additions and 2 deletions

View File

@ -1,13 +1,32 @@
import os
from pathlib import Path
from aare import File, Frame
import numpy as np
if __name__ == "__main__":
#get env variable
root_dir = Path(os.environ.get("PROJECT_ROOT_DIR"))
# read JSON master file
data_path = str(root_dir / "data"/"jungfrau_single_master_0.json")
file = File(data_path)
frame = file.get_frame(0)
print(frame.rows, frame.cols)
print(frame.get(0,0))
print(frame.get(0,0))
# read Numpy file
data_path = str(root_dir / "data"/"test_numpy_file.npy")
file = File(data_path)
frame = file.get_frame(0)
print(frame.rows, frame.cols)
print(frame.get(0,0))
arr = np.array(frame.get_array())
print(arr)
print(arr.shape)
print(np.array_equal(arr, np.load(data_path)[0]))