diff --git a/src/snapred/backend/dao/state/PixelGroup.py b/src/snapred/backend/dao/state/PixelGroup.py index e6c23dfc6..33b2764bd 100644 --- a/src/snapred/backend/dao/state/PixelGroup.py +++ b/src/snapred/backend/dao/state/PixelGroup.py @@ -82,7 +82,7 @@ def dMax(self, default=0.0) -> List[float]: # different Mantid algorithms use either "0.0" or "NaN" to indicate an unspecified value, # so these values may need to be filtered. return [ - self.pixelGroupingParameters[gid].dResolution.maximum - Config["constants.CropFactors.highdSpacingCrop"] + self.pixelGroupingParameters[gid].dResolution.maximum if not self.pixelGroupingParameters[gid].isMasked else default for gid in self.groupIDs @@ -93,7 +93,7 @@ def dMin(self, default=0.0) -> List[float]: # different Mantid algorithms use either "0.0" or "NaN" to indicate an unspecified value, # so these values may need to be filtered. return [ - self.pixelGroupingParameters[gid].dResolution.minimum + Config["constants.CropFactors.lowdSpacingCrop"] + self.pixelGroupingParameters[gid].dResolution.minimum if not self.pixelGroupingParameters[gid].isMasked else default for gid in self.groupIDs diff --git a/src/snapred/backend/recipe/RebinFocussedGroupDataRecipe.py b/src/snapred/backend/recipe/RebinFocussedGroupDataRecipe.py index 4551cee37..f2588e94a 100644 --- a/src/snapred/backend/recipe/RebinFocussedGroupDataRecipe.py +++ b/src/snapred/backend/recipe/RebinFocussedGroupDataRecipe.py @@ -28,28 +28,24 @@ def chopIngredients(self, ingredients: Ingredients): Chops off the needed elements of the ingredients. We are mostly concerned about the drange for a ResampleX operation. """ + self.pixelGroup = ingredients.pixelGroup + # The adjustment below is a temp fix, will be permanently fixed in EWM 6262 lowdSpacingCrop = Config["constants.CropFactors.lowdSpacingCrop"] - highdSpacingCrop = Config["constants.CropFactors.highdSpacingCrop"] - if lowdSpacingCrop < 0: raise ValueError("Low d-spacing crop factor must be positive") + + highdSpacingCrop = Config["constants.CropFactors.highdSpacingCrop"] if highdSpacingCrop < 0: raise ValueError("High d-spacing crop factor must be positive") - if (lowdSpacingCrop > 100) or (highdSpacingCrop > 100): - raise ValueError("d-spacing crop factors are too large") - - self.pixelGroup = ingredients.pixelGroup - dMin = self.pixelGroup.dMin() - dMax = self.pixelGroup.dMax() - dBin = self.pixelGroup.dBin() - - if not all(_dMax > _dMin for _dMin, _dMax in zip(dMin, dMax)): - raise ValueError("Invalid d-spacing range detected: some dMax <= dMin.") + dMin = [x + lowdSpacingCrop for x in self.pixelGroup.dMin()] + dMax = [x - highdSpacingCrop for x in self.pixelGroup.dMax()] + if not dMax > dMin: + raise ValueError("d-spacing crop factors are too large -- resultant dMax must be > resultant dMin") self.dMin = dMin self.dMax = dMax - self.dBin = dBin + self.dBin = self.pixelGroup.dBin() self.preserveEvents = ingredients.preserveEvents diff --git a/tests/resources/application.yml b/tests/resources/application.yml index 008486d71..f66a97288 100644 --- a/tests/resources/application.yml +++ b/tests/resources/application.yml @@ -292,8 +292,8 @@ constants: CropFactors: lowWavelengthCrop: 0.05 - lowdSpacingCrop: 0.0 - highdSpacingCrop: 0.0 + lowdSpacingCrop: 0.1 + highdSpacingCrop: 0.15 RawVanadiumCorrection: numberOfSlices: 1 diff --git a/tests/unit/backend/recipe/test_RebinFocussedGroupDataRecipe.py b/tests/unit/backend/recipe/test_RebinFocussedGroupDataRecipe.py index 01eafaa8a..d1673ea40 100644 --- a/tests/unit/backend/recipe/test_RebinFocussedGroupDataRecipe.py +++ b/tests/unit/backend/recipe/test_RebinFocussedGroupDataRecipe.py @@ -12,7 +12,6 @@ from util.dao import DAOFactory from util.SculleryBoy import SculleryBoy -from snapred.backend.dao.Limit import Limit from snapred.backend.recipe.RebinFocussedGroupDataRecipe import RebinFocussedGroupDataRecipe as Recipe ThisRecipe: str = "snapred.backend.recipe.RebinFocussedGroupDataRecipe" @@ -73,21 +72,3 @@ def test_badChopIngredients(self): pytest.raises(ValueError, match="High d-spacing crop factor must be positive"), ): recipe.chopIngredients(ingredients) - - def test_bad_dspacing_range(self): - pixel_group = self.sculleryBoy.prepPixelGroup() - - first_group_id = list(pixel_group.pixelGroupingParameters.keys())[0] - group_params = pixel_group.pixelGroupingParameters[first_group_id] - - group_params.dResolution = Limit[float](minimum=0.1, maximum=2.0) - - ingredients = Recipe.Ingredients(pixelGroup=pixel_group, preserveEvents=True) - recipe = Recipe() - - with ( - Config_override("constants.CropFactors.lowdSpacingCrop", 3.0), - Config_override("constants.CropFactors.highdSpacingCrop", 0.0), - pytest.raises(ValueError, match="Invalid d-spacing range detected: some dMax <= dMin."), - ): - recipe.chopIngredients(ingredients)