From 2efbf3a64ab41a66f46cea65239c511a0a2239e1 Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Wed, 13 Mar 2024 17:20:01 +0100 Subject: [PATCH] fixed regression tests, file was archived --- src/cristallina/analysis.py | 9 ++++----- src/cristallina/plot.py | 5 ++++- tests/test_regression.py | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cristallina/analysis.py b/src/cristallina/analysis.py index e270a86..3219940 100644 --- a/src/cristallina/analysis.py +++ b/src/cristallina/analysis.py @@ -233,15 +233,13 @@ def perform_image_stack_sum( im_ROI = im[roi.rows, roi.cols] summed = np.zeros(im_ROI[0].shape) - - #for image_slice, slice2 in zip(Images.in_batches(batch_size), other.in_batches(batch_size)): for image_slice in Images.in_batches(batch_size): index_slice, im = image_slice if roi is None: - im_ROI = im[:] + im_ROI = im else: im_ROI = im[:, roi.rows, roi.cols] @@ -281,7 +279,8 @@ def perform_image_roi_crop( Preview only applies calculation to first batch and returns. - Returns: an 1D array (along the pulses recorded without missing) of 2D images + Returns: An 1D array (along the pulses recorded without missing) of 2D images + Beware though: this can create a rather large array that exceeds available memory. TODO: should we create a complete channel here instead of returning `raw` data? @@ -305,7 +304,7 @@ def perform_image_roi_crop( index_slice, im = image_slice if roi is None: - im_ROI = im[:] + im_ROI = im else: im_ROI = im[:, roi.rows, roi.cols] diff --git a/src/cristallina/plot.py b/src/cristallina/plot.py index ba72218..be31c1c 100644 --- a/src/cristallina/plot.py +++ b/src/cristallina/plot.py @@ -164,6 +164,8 @@ def plot_detector_image(image_data, title=None, comment=None, ax=None, rois=None - rois: draw a rectangular patch for the given roi(s) - norms: [min, max] values for colormap - log_colorscale: True for a logarithmic colormap + - title: Title of the plot + - show_legend: True if the legend box should be drawn """ im = image_data @@ -196,12 +198,13 @@ def plot_detector_image(image_data, title=None, comment=None, ax=None, rois=None [roi.left, roi.bottom], roi.width, roi.height, - linewidth=3, + linewidth=2, edgecolor=f"C{i}", facecolor="none", label=roi.name, ) ax.add_patch(rect) + if comment is not None: description = f"{comment}\nmean: {mean:.2e},\nstd: {std:.2e}" else: diff --git a/tests/test_regression.py b/tests/test_regression.py index 99c9787..8ebf42a 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -9,8 +9,8 @@ import tracemalloc @pytest.mark.regression def test_JU_memory(): - base_path = "/sf/cristallina/data/p19739/raw/" - run_number = 49 + base_path = "/sf/cristallina/data/p19150/raw" + run_number = 146 averages = [] tracemalloc.start()