Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Ewm9433 defect fix spectral edges" #552

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/snapred/backend/dao/state/PixelGroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 9 additions & 13 deletions src/snapred/backend/recipe/RebinFocussedGroupDataRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ constants:

CropFactors:
lowWavelengthCrop: 0.05
lowdSpacingCrop: 0.0
highdSpacingCrop: 0.0
lowdSpacingCrop: 0.1
highdSpacingCrop: 0.15

RawVanadiumCorrection:
numberOfSlices: 1
Expand Down
19 changes: 0 additions & 19 deletions tests/unit/backend/recipe/test_RebinFocussedGroupDataRecipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Loading