From ec916d18042612c4294fa647bbfe8044a2d5d08b Mon Sep 17 00:00:00 2001 From: "Dr. Phil Maffettone" <43007690+maffettone@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:17:36 -0700 Subject: [PATCH] Apply suggestions from code review. Fix logic and clean docs Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> --- csxtools/fastccd/dask.py | 10 +++++----- csxtools/image/dask.py | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/csxtools/fastccd/dask.py b/csxtools/fastccd/dask.py index c4e9281..0aef0fc 100644 --- a/csxtools/fastccd/dask.py +++ b/csxtools/fastccd/dask.py @@ -12,17 +12,17 @@ def correct_images(images: DaskArray, dark: ArrayLike, flat: ArrayLike, gain: Tuple[float, float, float]): - """_summary_ + """Apply intensity corrections to a stack of images. Parameters ---------- images : DaskArray - Input array of images to correct of shape (N, y, x) where N is the + Input array of images to correct; has shape (N, y, x) where N is the number of images and x and y are the image size. dark : ArrayLike Input array of dark images. This should be of shape (3, y, x). - dark[0] is the gain 8 (most sensitive setting) dark image with - dark[2] being the gain 1 (least sensitive) dark image. + dark[0] is the GAIN_8 (most sensitive setting) dark image with + dark[2] being the GAIN_1 (least sensitive) dark image. flat : ArrayLike Input array for the flatfield correction. This should be of shape (y, x) @@ -31,7 +31,7 @@ def correct_images(images: DaskArray, dark: ArrayLike, flat: ArrayLike, gain: Tu gain settings // Note GAIN_1 is the least sensitive setting which means we need to multiply the - // measured values by 8. Conversly GAIN_8 is the most sensitive and therefore only + // measured values by 8. Conversly GAIN_8 is the most sensitive and therefore // does not need a multiplier """ diff --git a/csxtools/image/dask.py b/csxtools/image/dask.py index 9fd0514..7a91ba8 100644 --- a/csxtools/image/dask.py +++ b/csxtools/image/dask.py @@ -23,9 +23,13 @@ def rotate90(images: DaskArray, sense: bool) -> DaskArray: """ # Rotate images. The axes (1, 2) specify the plane of rotation (y-x plane for each image). # k controls the direction and repetitions of the rotation. - if sense: + if sense != 0: + # Counter-clockwise k = 1 - elif sense: + elif sense == 0: + # Clockwise k = -1 + else: + raise ValueError(f"{sense = } is not a valid integer") rotated_images = da.rot90(images, k=k, axes=(-2, -1)) return rotated_images