From 084284bb826cbb60fc92d091f8cca1c1294b20e6 Mon Sep 17 00:00:00 2001 From: Darsh Date: Mon, 25 Nov 2024 09:25:41 -0500 Subject: [PATCH] Remove this, ended up in the wrong branch --- src/snapred/backend/recipe/ReductionRecipe.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/snapred/backend/recipe/ReductionRecipe.py b/src/snapred/backend/recipe/ReductionRecipe.py index 7abeafee7..cc6253e22 100644 --- a/src/snapred/backend/recipe/ReductionRecipe.py +++ b/src/snapred/backend/recipe/ReductionRecipe.py @@ -1,7 +1,6 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Type from snapred.backend.dao.ingredients import ReductionIngredients as Ingredients -from snapred.backend.dao.state.PixelGroup import PixelGroup from snapred.backend.log.logger import snapredLogger from snapred.backend.recipe.ApplyNormalizationRecipe import ApplyNormalizationRecipe from snapred.backend.recipe.GenerateFocussedVanadiumRecipe import GenerateFocussedVanadiumRecipe @@ -182,9 +181,20 @@ def _prepGroupingWorkspaces(self, groupingIndex: int): self.groceries["normalizationWorkspace"] = normalizationClone return sampleClone, normalizationClone - def _isGroupFullyMasked(self, pixelGroup: PixelGroup) -> bool: - # Checks if the entire PixelGroup is masked. - return all(pixelGroup.isMasked) + def _isGroupFullyMasked(self, groupingWorkspace: str) -> bool: + maskWorkspace = self.mantidSnapper.mtd[self.maskWs] + groupWorkspace = self.mantidSnapper.mtd[groupingWorkspace] + + totalMaskedPixels = 0 + totalGroupPixels = 0 + + for i in range(groupWorkspace.getNumberHistograms()): + group_spectra = groupWorkspace.readY(i) + for spectrumIndex in group_spectra: + if maskWorkspace.readY(int(spectrumIndex))[0] == 1: + totalMaskedPixels += 1 + totalGroupPixels += 1 + return totalMaskedPixels == totalGroupPixels def queueAlgos(self): pass @@ -214,10 +224,9 @@ def execute(self): self._cloneIntermediateWorkspace(self.normalizationWs, "normalization_preprocessed") for groupingIndex, groupingWs in enumerate(self.groupingWorkspaces): - pixelGroup = self.ingredients.pixelGroups[groupingIndex] self.groceries["groupingWorkspace"] = groupingWs - if self.maskWs and self._isGroupFullyMasked(pixelGroup): + if self.maskWs and self._isGroupFullyMasked(groupingWs): # Notify the user of a fully masked group, but continue with the workflow self.logger().warning( f"\nAll pixels masked within {groupingWs} schema.\n"