-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port EQSANSQ2DTest to new Python API Refs #7469
- Loading branch information
1 parent
3d7ba07
commit 115f315
Showing
3 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 22 additions & 20 deletions
42
Code/Mantid/Framework/WorkflowAlgorithms/test/EQSANSQ2DTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
import unittest | ||
from mantidsimple import * | ||
from mantid.simpleapi import * | ||
|
||
class EQSANSQ2DTest(unittest.TestCase): | ||
|
||
def setUp(self): | ||
|
||
self.test_ws_name = "EQSANS_test_ws" | ||
x = [1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.] | ||
y = 491520*[0.1] | ||
y = 491520*[0.1] | ||
CreateWorkspace(OutputWorkspace=self.test_ws_name,DataX=x,DataY=y,DataE=y,NSpec='49152',UnitX='Wavelength') | ||
LoadInstrument(self.test_ws_name, InstrumentName="EQSANS") | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("sample_detector_distance", 4000.0, 'mm', True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("beam_center_x", 96, 'pixel', True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("beam_center_y", 128, 'pixel', True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("wavelength_min", 1, "Angstrom", True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("wavelength_max", 11, "Angstrom", True) | ||
mtd[self.test_ws_name].getRun().addProperty_int("is_frame_skipping", 0, True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("wavelength_min_frame2", 5, "Angstrom", True) | ||
mtd[self.test_ws_name].getRun().addProperty_dbl("wavelength_max_frame2", 10, "Angstrom", True) | ||
LoadInstrument(Workspace=self.test_ws_name, InstrumentName="EQSANS") | ||
|
||
run = mtd[self.test_ws_name].mutableRun() | ||
|
||
run.addProperty("sample_detector_distance", 4000.0, 'mm', True) | ||
run.addProperty("beam_center_x", 96.0, 'pixel', True) | ||
run.addProperty("beam_center_y", 128.0, 'pixel', True) | ||
run.addProperty("wavelength_min", 1.0, "Angstrom", True) | ||
run.addProperty("wavelength_max", 11.0, "Angstrom", True) | ||
run.addProperty("is_frame_skipping", 0, True) | ||
run.addProperty("wavelength_min_frame2", 5.0, "Angstrom", True) | ||
run.addProperty("wavelength_max_frame2", 10.0, "Angstrom", True) | ||
|
||
def tearDown(self): | ||
if mtd.workspaceExists(self.test_ws_name): | ||
mtd.deleteWorkspace(self.test_ws_name) | ||
if self.test_ws_name in mtd: | ||
DeleteWorkspace(Workspace=self.test_ws_name) | ||
|
||
def test_q2d(self): | ||
EQSANSQ2D(self.test_ws_name) | ||
EQSANSQ2D(InputWorkspace=self.test_ws_name) | ||
ReplaceSpecialValues(InputWorkspace=self.test_ws_name+"_Iqxy",OutputWorkspace=self.test_ws_name+"_Iqxy",NaNValue=0,NaNError=0) | ||
Integration(self.test_ws_name+"_Iqxy", "__tmp") | ||
SumSpectra("__tmp", "summed") | ||
self.assertAlmostEquals(mtd["summed"].dataY(0)[0], 7.24077, 6) | ||
Integration(InputWorkspace=self.test_ws_name+"_Iqxy", OutputWorkspace="__tmp") | ||
SumSpectra(InputWorkspace="__tmp", OutputWorkspace="summed") | ||
self.assertAlmostEquals(mtd["summed"].readY(0)[0], 7.24077, 6) | ||
for ws in ["__tmp", "summed"]: | ||
if mtd.workspaceExists(ws): | ||
mtd.deleteWorkspace(ws) | ||
|
||
if mtd.doesExist(ws): | ||
DeleteWorkspace(Workspace=ws) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |