From e14d121f7d36913b8116ab0d069f44826e3338d6 Mon Sep 17 00:00:00 2001 From: mguthriem Date: Wed, 5 Feb 2025 11:33:27 -0500 Subject: [PATCH 1/5] updated application.yml --- src/snapred/resources/application.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/snapred/resources/application.yml b/src/snapred/resources/application.yml index 9f63239a0..67e70d83e 100644 --- a/src/snapred/resources/application.yml +++ b/src/snapred/resources/application.yml @@ -12,7 +12,7 @@ instrument: name: SNAP home: ${IPTS.root}/SNAP calibration: - home: ${instrument.home}/shared/Calibration + home: ${instrument.home}/shared/Calibration_testing sample: home: ${instrument.calibration.home}/CalibrantSamples extensions: @@ -215,11 +215,11 @@ constants: tofMax: 14500 rebinParams: [2000, -0.001, 14500] CropFactors: - lowWavelengthCrop: 0.05 - lowdSpacingCrop: 0.1 - highdSpacingCrop: 0.15 + lowWavelengthCrop: -0.04 + lowdSpacingCrop: 0.05 + highdSpacingCrop: 0.05 CrystallographicInfo: - crystalDMin: 0.4 + crystalDMin: 0.7 crystalDMax: 100.0 DetectorPeakPredictor: fwhm: 1.17741002252 # used to convert gaussian to fwhm (2 * log_e(2)) @@ -227,7 +227,7 @@ constants: toggleCompressionTolerance: false # false = no tolerance compression, true = tolerance compression # tolerance: -0.004 # tolerance override for calculated compression GroupDiffractionCalibration: - MaxChiSq: 100 + MaxChiSq: 10000 RawVanadiumCorrection: numberOfSlices: 10 numberOfAnnuli: 10 From f26a76a85d220ff4c89295d60bfbb646c2c73dfe Mon Sep 17 00:00:00 2001 From: mguthriem Date: Wed, 5 Feb 2025 12:05:55 -0500 Subject: [PATCH 2/5] added instrumentState to normalisationIngredients and used in rawvanadiumcorrection --- .../backend/dao/ingredients/NormalizationIngredients.py | 2 ++ .../recipe/algorithm/RawVanadiumCorrectionAlgorithm.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/snapred/backend/dao/ingredients/NormalizationIngredients.py b/src/snapred/backend/dao/ingredients/NormalizationIngredients.py index 563776e4b..279b148a5 100644 --- a/src/snapred/backend/dao/ingredients/NormalizationIngredients.py +++ b/src/snapred/backend/dao/ingredients/NormalizationIngredients.py @@ -5,6 +5,7 @@ from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.dao.state.CalibrantSample import CalibrantSample from snapred.backend.dao.state.PixelGroup import PixelGroup +from snapred.backend.dao.state.InstrumentState import InstrumentState class NormalizationIngredients(BaseModel): @@ -13,3 +14,4 @@ class NormalizationIngredients(BaseModel): pixelGroup: PixelGroup calibrantSample: CalibrantSample detectorPeaks: List[GroupPeakList] + instrumentState: InstrumentState diff --git a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py index 4f06996d7..7fc8b19b6 100644 --- a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py +++ b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py @@ -52,6 +52,8 @@ def chopIngredients(self, ingredients: Ingredients) -> None: self.geometry = ingredients.calibrantSample.geometry self.material = ingredients.calibrantSample.material self.sampleShape = self.geometry.shape + self.lambdaMin = ingredients.instrumentState.particleBounds.wavelength.minimum + self.lambdaMax = ingredients.instrumentState.particleBounds.wavelength.maximum def unbagGroceries(self) -> None: self.inputVanadiumWS = self.getPropertyValue("InputWorkspace") @@ -83,6 +85,8 @@ def chopNeutronData(self, inputWS: str, outputWS: str) -> None: BinningMode="Logarithmic", ) + print(f"/n I AM ABOUT TO CHOP TO THESE: {self.lambdaMin} {self.lambdaMax}\n") + self.mantidSnapper.MakeDirtyDish( "make a copy of data after chop", InputWorkspace=outputWS, From 9c0d6afa7f851dec1edc714988af4a78de23b021 Mon Sep 17 00:00:00 2001 From: mguthriem Date: Wed, 5 Feb 2025 14:32:15 -0500 Subject: [PATCH 3/5] added lambda filter to normalisation workflow --- .../RawVanadiumCorrectionAlgorithm.py | 23 ++++++++++++++++++- src/snapred/backend/service/SousChef.py | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py index 7fc8b19b6..f2e8d9210 100644 --- a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py +++ b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py @@ -85,7 +85,28 @@ def chopNeutronData(self, inputWS: str, outputWS: str) -> None: BinningMode="Logarithmic", ) - print(f"/n I AM ABOUT TO CHOP TO THESE: {self.lambdaMin} {self.lambdaMax}\n") + #Malcolm added these lines ################## + self.mantidSnapper.ConvertUnits( + "Convert workspace to wavelength units", + InputWorkspace=outputWS, + Outputworkspace=outputWS, + Target="Wavelength", + ) + + self.mantidSnapper.CropWorkspace( + "crop all events outside of range", + InputWorkspace=outputWS, + Outputworkspace=outputWS, + XMin = self.lambdaMin, + XMax = self.lambdaMax) + + self.mantidSnapper.ConvertUnits( + "Ensure workspace is in TOF units", + InputWorkspace=outputWS, + Outputworkspace=outputWS, + Target="TOF", + ) + ################################ self.mantidSnapper.MakeDirtyDish( "make a copy of data after chop", diff --git a/src/snapred/backend/service/SousChef.py b/src/snapred/backend/service/SousChef.py index a0f5714e1..4dc15c6b2 100644 --- a/src/snapred/backend/service/SousChef.py +++ b/src/snapred/backend/service/SousChef.py @@ -302,6 +302,7 @@ def prepNormalizationIngredients(self, ingredients: FarmFreshIngredients) -> Nor pixelGroup=self.prepPixelGroup(ingredients), calibrantSample=self.prepCalibrantSample(ingredients.calibrantSamplePath), detectorPeaks=self.prepDetectorPeaks(ingredients, purgePeaks=False), + instrumentState = self.prepInstrumentState(ingredients), ) def prepDiffractionCalibrationIngredients( From 330e443301fbd3ddc1e8cd74814677889997c70a Mon Sep 17 00:00:00 2001 From: mguthriem Date: Thu, 6 Feb 2025 17:44:20 -0500 Subject: [PATCH 4/5] optimal d-crop values --- src/snapred/resources/application.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snapred/resources/application.yml b/src/snapred/resources/application.yml index 67e70d83e..4e7670c0e 100644 --- a/src/snapred/resources/application.yml +++ b/src/snapred/resources/application.yml @@ -216,8 +216,8 @@ constants: rebinParams: [2000, -0.001, 14500] CropFactors: lowWavelengthCrop: -0.04 - lowdSpacingCrop: 0.05 - highdSpacingCrop: 0.05 + lowdSpacingCrop: 0.015 + highdSpacingCrop: 0.022 CrystallographicInfo: crystalDMin: 0.7 crystalDMax: 100.0 From d914c9b527fb4e0cd3e80da4423ca18e56fb0277 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 16:28:36 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../backend/dao/ingredients/NormalizationIngredients.py | 2 +- .../recipe/algorithm/RawVanadiumCorrectionAlgorithm.py | 7 ++++--- src/snapred/backend/service/SousChef.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/snapred/backend/dao/ingredients/NormalizationIngredients.py b/src/snapred/backend/dao/ingredients/NormalizationIngredients.py index 279b148a5..ba2bbcf65 100644 --- a/src/snapred/backend/dao/ingredients/NormalizationIngredients.py +++ b/src/snapred/backend/dao/ingredients/NormalizationIngredients.py @@ -4,8 +4,8 @@ from snapred.backend.dao.GroupPeakList import GroupPeakList from snapred.backend.dao.state.CalibrantSample import CalibrantSample -from snapred.backend.dao.state.PixelGroup import PixelGroup from snapred.backend.dao.state.InstrumentState import InstrumentState +from snapred.backend.dao.state.PixelGroup import PixelGroup class NormalizationIngredients(BaseModel): diff --git a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py index f2e8d9210..ea4008cac 100644 --- a/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py +++ b/src/snapred/backend/recipe/algorithm/RawVanadiumCorrectionAlgorithm.py @@ -85,7 +85,7 @@ def chopNeutronData(self, inputWS: str, outputWS: str) -> None: BinningMode="Logarithmic", ) - #Malcolm added these lines ################## + # Malcolm added these lines ################## self.mantidSnapper.ConvertUnits( "Convert workspace to wavelength units", InputWorkspace=outputWS, @@ -97,8 +97,9 @@ def chopNeutronData(self, inputWS: str, outputWS: str) -> None: "crop all events outside of range", InputWorkspace=outputWS, Outputworkspace=outputWS, - XMin = self.lambdaMin, - XMax = self.lambdaMax) + XMin=self.lambdaMin, + XMax=self.lambdaMax, + ) self.mantidSnapper.ConvertUnits( "Ensure workspace is in TOF units", diff --git a/src/snapred/backend/service/SousChef.py b/src/snapred/backend/service/SousChef.py index 4dc15c6b2..2d232d336 100644 --- a/src/snapred/backend/service/SousChef.py +++ b/src/snapred/backend/service/SousChef.py @@ -302,7 +302,7 @@ def prepNormalizationIngredients(self, ingredients: FarmFreshIngredients) -> Nor pixelGroup=self.prepPixelGroup(ingredients), calibrantSample=self.prepCalibrantSample(ingredients.calibrantSamplePath), detectorPeaks=self.prepDetectorPeaks(ingredients, purgePeaks=False), - instrumentState = self.prepInstrumentState(ingredients), + instrumentState=self.prepInstrumentState(ingredients), ) def prepDiffractionCalibrationIngredients(