From 2eeea818c561b24a9e5d8b6925ed25099106fb1b Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Tue, 7 Nov 2023 10:47:05 +0100 Subject: [PATCH] apply isort and flake8 on jfstrixel --- src/cal_tools/jungfrau/jfstrixel.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/cal_tools/jungfrau/jfstrixel.py b/src/cal_tools/jungfrau/jfstrixel.py index 3eff2ca75..f4c26622c 100644 --- a/src/cal_tools/jungfrau/jfstrixel.py +++ b/src/cal_tools/jungfrau/jfstrixel.py @@ -5,7 +5,17 @@ from pathlib import Path REGULAR_SHAPE = (512, 1024) DIR_PATH = package_directory = Path(__file__).resolve().parent + 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": @@ -39,20 +49,19 @@ def store_double_pixel_indices(): 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) + 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) - 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 @@ -69,7 +78,8 @@ def to_strixel(data, out=None, kind="A0123"): strx = get_strixel_parameters(kind) if out is None: - out = np.zeros((*data.shape[:-2], *strx["frame_shape"]), dtype=data.dtype) + 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"]] -- GitLab