mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-17 17:57:13 +02:00
added first tests for reading files
This commit is contained in:
BIN
data/jungfrau/jungfrau_single_0.npy
Normal file
BIN
data/jungfrau/jungfrau_single_0.npy
Normal file
Binary file not shown.
@ -24,7 +24,7 @@ header_dt = np.dtype(
|
||||
# Read three frames from a jungfrau file with a single interface
|
||||
rows = 512
|
||||
cols = 1024
|
||||
frames = 3
|
||||
frames = 10
|
||||
|
||||
data = np.zeros((frames,rows,cols), dtype = np.uint16)
|
||||
header = np.zeros(frames, dtype = header_dt)
|
||||
@ -32,15 +32,15 @@ for file_id in range(4):
|
||||
file_name = 'jungfrau_single_d0_f{}_0.raw'.format(file_id)
|
||||
print("Reading file:", file_name)
|
||||
with open(file_name) as f:
|
||||
for i in range(frames if file_id != 3 else 1):
|
||||
header[i] = np.fromfile(f, dtype=header_dt, count = 1)
|
||||
data[i] = np.fromfile(f, dtype=np.uint16,count = rows*cols).reshape(rows,cols)
|
||||
for i in range(3 if file_id != 3 else 1):
|
||||
header[i+file_id*3] = np.fromfile(f, dtype=header_dt, count = 1)
|
||||
data[i+file_id*3] = np.fromfile(f, dtype=np.uint16,count = rows*cols).reshape(rows,cols)
|
||||
|
||||
|
||||
for i in range(frames if file_id != 3 else 1 ):
|
||||
print("frame:",i)
|
||||
print(data[i][0,0],data[i][0,1],data[i][1,0],data[i][rows-1,cols-1])
|
||||
print("")
|
||||
# for i in range(frames if file_id != 3 else 1 ):
|
||||
# print("frame:",i)
|
||||
# print(data[i][0,0],data[i][0,1],data[i][1,0],data[i][rows-1,cols-1])
|
||||
# print("")
|
||||
|
||||
|
||||
#fig, ax = plt.subplots()
|
||||
|
29
data/scripts/read_first_frame_number.py
Normal file
29
data/scripts/read_first_frame_number.py
Normal file
@ -0,0 +1,29 @@
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
header_dt = np.dtype(
|
||||
[
|
||||
("Frame Number", "u8"),
|
||||
("SubFrame Number/ExpLength", "u4"),
|
||||
("Packet Number", "u4"),
|
||||
("Bunch ID", "u8"),
|
||||
("Timestamp", "u8"),
|
||||
("Module Id", "u2"),
|
||||
("Row", "u2"),
|
||||
("Column", "u2"),
|
||||
("Reserved", "u2"),
|
||||
("Debug", "u4"),
|
||||
("Round Robin Number", "u2"),
|
||||
("Detector Type", "u1"),
|
||||
("Header Version", "u1"),
|
||||
("Packets caught mask", "8u8")
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
|
||||
with open("data/eiger/eiger_500k_16bit_d0_f0_0.raw", "rb") as f:
|
||||
for i in range(3):
|
||||
frame_number = np.fromfile(f, dtype=header_dt, count=1)["Frame Number"][0]
|
||||
print(frame_number)
|
||||
f.seek(262144,1)
|
Reference in New Issue
Block a user