Skip to content
Snippets Groups Projects
Commit e316f589 authored by David Hammer's avatar David Hammer
Browse files

Update LUT, update test

parent 0b32e7fd
Branches rotate-strixel_rows_a1256
No related tags found
1 merge request!88Update strixel "rows A1256" implementation to accomodate rotation
No preview for this file type
......@@ -7,10 +7,10 @@ pixel_data = np.arange(512 * 1024).reshape(512, 1024).astype(np.float32)
def test_cols_A0123():
def convert_cols_A0123(data, out=None):
def convert_cols_A0123(data):
# https://redmine.xfel.eu/issues/126444
if out is None:
out = np.zeros((86, (1024 * 3 + 18)), dtype=np.float32)
out = np.empty((86, (1024 * 3 + 18)), dtype=np.float32)
out.fill(np.nan)
# 256 not divisible by 3, so we round up
# 18 since we have 6 more pixels in H per gap
# first we fill the normal pixels, the gap ones will be overwritten later
......@@ -51,38 +51,38 @@ def test_cols_A0123():
lut=lut_package["lut"],
mask=lut_package["mask"],
out=strixel_lut,
missing=0,
missing=np.nan,
)
assert np.array_equal(strixel_naive, strixel_lut)
assert np.array_equal(strixel_naive, strixel_lut, equal_nan=True)
def test_rows_A1256():
def convert_rows_A1256(data, out=None):
def convert_rows_A1256(data):
# https://redmine.xfel.eu/issues/161148
if out is None:
out = np.zeros([*data.shape[:-2], 1488, 165], dtype=np.float32)
out = np.empty([*data.shape[:-2], 1488, 164], dtype=np.float32)
out.fill(np.nan)
# Select only 4 center ASICS
data = np.rot90(data, k=2, axes=(-2, -1))
data = data[..., 256:768]
# Offset due to guard ring pixels
offset_y = 9
offset_x = 11
offset_x_l = 11
offset_x_r = 12
for xin in range(
offset_x, 512 - 9
): # on the right side, there are 9 guard ring pixels
# Bottom ASICs
for xin in range(offset_x_l, 512 - offset_x_r):
for yin in range(offset_y, 255):
yout = (xin - offset_x) % 3 + (yin - offset_y) * 3
xout = (xin - offset_x) // 3 + (xin) // 257
yout = (xin - offset_x_l) % 3 + (yin - offset_y) * 3
xout = (xin - offset_x_l) // 3 + xin // 257
out[..., yout, xout] = data[..., yin, xin]
# Top ASICs (mirrored on the horizontal axis)
# mirrored on the horizontal axis
for yin in range(257, 512 - offset_y):
yout = 2 - (xin - offset_x) % 3 + (yin - offset_y) * 3 + 6
xout = (xin - offset_x) // 3 + (xin) // 257
yout = 2 - (xin - offset_x_l) % 3 + (yin - offset_y) * 3 + 6
xout = (xin - offset_x_l) // 3 + xin // 257
out[..., yout, xout] = data[..., yin, xin]
out[:] = np.rot90(out, k=2, axes=(-2, -1))
return out
......@@ -91,12 +91,12 @@ def test_rows_A1256():
base_kernel_runner.kernel_dir / "strixel_rows_A1256-lut_mask.npz"
)
assert tuple(lut_package["frame_shape"]) == strixel_naive.shape
strixel_lut = np.zeros_like(strixel_naive)
strixel_lut = np.empty_like(strixel_naive)
utils.apply_partial_lut(
data=pixel_data,
lut=lut_package["lut"],
mask=lut_package["mask"],
out=strixel_lut,
missing=0,
missing=np.nan,
)
assert np.array_equal(strixel_naive, strixel_lut)
assert np.array_equal(strixel_naive, strixel_lut, equal_nan=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment