jfstrixel
from_strixel(data, out=None, kind='A0123')
¶
Transform from strixel to regular geometry.
Only the last two axes are considered for transformation, input data may have any number of additional axes in front.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
array_like
|
Data in strixel geometry. |
required |
out |
array_like
|
Buffer for transformed output, a new one is allocated if omitted. Must match all non-frame axes of input data and able to hold regular frame. |
None
|
Returns:
Type | Description |
---|---|
array_like
|
Data in regular geometry. |
Source code in /usr/src/app/checkouts/readthedocs.org/user_builds/european-xfel-offline-calibration/envs/latest/lib/python3.8/site-packages/cal_tools/jungfrau/jfstrixel.py
def from_strixel(data, out=None, kind="A0123"):
"""Transform from strixel to regular geometry.
Only the last two axes are considered for transformation, input data
may have any number of additional axes in front.
Args:
data (array_like): Data in strixel geometry.
out (array_like, optional): Buffer for transformed output, a new
one is allocated if omitted. Must match all non-frame axes
of input data and able to hold regular frame.
Returns:
(array_like): Data in regular geometry.
"""
if kind is None:
return data
strx = get_strixel_parameters(kind)
if out is None:
out = np.zeros((*data.shape[:-2], *REGULAR_SHAPE), dtype=data.dtype)
out.reshape(*out.shape[:-2], -1)[..., strx["lut"]] = data.reshape(
*data.shape[:-2], -1)[..., strx["mask"]]
return out
get_strixel_parameters(kind)
cached
¶
Returns a dictionary of strixel parameters stored in .npz file based on the given kind.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kind |
str
|
Specifies the type of strixel parameters to retrieve. There is two possible values: "A0123" or "A1256" |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary contating the strixel parameters. |
Source code in /usr/src/app/checkouts/readthedocs.org/user_builds/european-xfel-offline-calibration/envs/latest/lib/python3.8/site-packages/cal_tools/jungfrau/jfstrixel.py
@lru_cache
def get_strixel_parameters(kind):
"""Returns a dictionary of strixel parameters stored in .npz file
based on the given kind.
Args:
kind (str): Specifies the type of strixel parameters to retrieve.
There is two possible values: "A0123" or "A1256"
Returns:
(dict): Dictionary contating the strixel parameters.
"""
strx_parameters = {}
if kind == "A0123":
file_path = DIR_PATH / "strixel_cols_A0123-lut_mask.npz"
elif kind == "A1256":
file_path = DIR_PATH / "strixel_rows_A1256-lut_mask.npz"
with np.load(file_path) as data:
for k in data.files:
strx_parameters[k] = data[k]
return strx_parameters
store_double_pixel_indices()
¶
Build index arrays for double-size pixels.
In raw data for A0123 strixel detector, the entire columns 255, 256, 511, 512, 767 and 768 are double-size pixels. After strixelation, these end up in columns 765-776, 1539-1550 and 2313-2324 on rows 0-85 or 0-83, with a set of four columns with 86 rows followed by a set of 84 and 86 again.
This function builds the index arrays for double pixels after strixelation and stores it in the available A0123 .npz file.
Source code in /usr/src/app/checkouts/readthedocs.org/user_builds/european-xfel-offline-calibration/envs/latest/lib/python3.8/site-packages/cal_tools/jungfrau/jfstrixel.py
def store_double_pixel_indices():
"""Build index arrays for double-size pixels.
In raw data for A0123 strixel detector,
the entire columns 255, 256, 511, 512, 767 and 768
are double-size pixels. After strixelation, these end up in columns
765-776, 1539-1550 and 2313-2324 on rows 0-85 or 0-83, with a set
of four columns with 86 rows followed by a set of 84 and 86 again.
This function builds the index arrays for double pixels after
strixelation and stores it in the available A0123 .npz file.
"""
ydouble = []
xdouble = []
file_path = DIR_PATH / "strixel_cols_A0123-lut_mask.npz"
with np.load(file_path) as data:
for double_col in [765, 1539, 2313]:
for col in range(double_col, double_col+12):
for row in range(84 if ((col-double_col) // 4) == 1 else 86):
ydouble.append(row)
xdouble.append(col)
np.savez(file_path, **data, ydouble=ydouble, xdouble=xdouble)
to_strixel(data, out=None, kind='A0123')
¶
Transform from regular to strixel geometry.
Only the last two axes are considered for transformation, input data may have any number of additional axes in front.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
array_like
|
Data in regular geometry. |
required |
out |
array_like
|
Buffer for transformed output, a new one is allocated if omitted. Must match all non-frame axes of input data and able to hold strixel frame. |
None
|
Returns:
Type | Description |
---|---|
(array_like) Data in strixel geometry. |
Source code in /usr/src/app/checkouts/readthedocs.org/user_builds/european-xfel-offline-calibration/envs/latest/lib/python3.8/site-packages/cal_tools/jungfrau/jfstrixel.py
def to_strixel(data, out=None, kind="A0123"):
"""Transform from regular to strixel geometry.
Only the last two axes are considered for transformation, input data
may have any number of additional axes in front.
Args:
data (array_like): Data in regular geometry.
out (array_like, optional): Buffer for transformed output, a new
one is allocated if omitted. Must match all non-frame axes
of input data and able to hold strixel frame.
Returns:
(array_like) Data in strixel geometry.
"""
if kind is None:
return data
strx = get_strixel_parameters(kind)
if out is None:
out = np.zeros(
(*data.shape[:-2], *strx["frame_shape"]), dtype=data.dtype)
out.reshape(*out.shape[:-2], -1)[..., ~strx["mask"]] = data.reshape(
*data.shape[:-2], -1)[..., strx["lut"]]
return out