Skip to content

Commit

Permalink
Remove this, ended up in the wrong branch
Browse files Browse the repository at this point in the history
  • Loading branch information
darshdinger committed Nov 25, 2024
1 parent c5831af commit 084284b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/snapred/backend/recipe/ReductionRecipe.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 084284b

Please sign in to comment.