Skip to content
Merged
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
1 change: 1 addition & 0 deletions Testing/Data/SystemTest/ZOOM00038238.nxs.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f46b506522760c88b9a7baec5ffbcb03
1 change: 1 addition & 0 deletions Testing/Data/SystemTest/ZOOM00038335.nxs.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8dc37e0a56316abf322b851c04f64361
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +

import systemtesting

from mantid.api import AnalysisDataService
from mantid.simpleapi import *


class DepolarizedAnalyzerTransmissionTest(systemtesting.MantidSystemTest):
def runTest(self):
Load("ZOOM00038238.nxs", OutputWorkspace="mt_run")
Load("ZOOM00038335.nxs", OutputWorkspace="dep_run")

mt_group = self._prepare_workspace("mt_run")
dep_group = self._prepare_workspace("dep_run")
mt = self._average_workspaces_in_group(list(mt_group))
dep = self._average_workspaces_in_group(list(dep_group))

DepolarizedAnalyserTransmission(dep, mt, OutputWorkspace="params" "", OutputFitCurves="curves")

def _prepare_workspace(self, input_ws_name):
converted = ConvertUnits(input_ws_name, "Wavelength", AlignBins=True, StoreInADS=False)
monitor_3 = CropWorkspace(converted, StartWorkspaceIndex=2, EndWorkspaceIndex=2, StoreInADS=False)
monitor_4 = CropWorkspace(converted, StartWorkspaceIndex=3, EndWorkspaceIndex=3, StoreInADS=False)
return monitor_4 / monitor_3

def _average_workspaces_in_group(self, ws_list):
return sum(ws_list) / 4

def validate(self):
self.tolerance = 1e-5
result_curves = "curves"
reference_curves = "DepolCurvesReference.nxs"
result_params = "params"
reference_params = "DepolParamsReference.nxs"

def validate_group(result, reference):
Load(Filename=reference, OutputWorkspace=reference)
compare_alg = AlgorithmManager.create("CompareWorkspaces")
compare_alg.setPropertyValue("Workspace1", result)
compare_alg.setPropertyValue("Workspace2", reference)
compare_alg.setPropertyValue("Tolerance", str(self.tolerance))
compare_alg.setChild(True)

compare_alg.execute()
if compare_alg.getPropertyValue("Result") != "1":
print("Workspaces do not match.")
print(self.__class__.__name__)
SaveNexus(InputWorkspace=result, Filename=f"{self.__class__.__name__}-{result}-mismatch.nxs")
return False
return True

is_curves_match = validate_group(result_curves, reference_curves)
is_params_match = validate_group(result_params, reference_params)
return is_curves_match and is_params_match

def cleanup(self):
AnalysisDataService.clear()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e508561a750eb6064ff40f11fba8d31b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
45c39b9e17ab1978975817bc3a296e39
Loading