コード例 #1
0
ファイル: SANSWorkflowTest.py プロジェクト: trnielsen/mantid
    def test_reactor_sans_resolution(self):
        ReactorSANSResolution(InputWorkspace=self.test_ws, OutputWorkspace=self.test_ws)
        
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[0], 0.0052567, 4)
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[1], 0.0088109, 4)
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[2], 0.0126872, 4)

        if mtd.workspaceExists(self.test_ws):
            mtd.deleteWorkspace(self.test_ws)
コード例 #2
0
    def test_reactor_sans_resolution(self):
        ReactorSANSResolution(InputWorkspace=self.test_ws, OutputWorkspace=self.test_ws)
        
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[0], 0.0453773, 4)
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[1], 0.0840184, 4)
        self.assertAlmostEqual(mantid[self.test_ws].dataDx(0)[2], 0.124066, 4)

        if mtd.workspaceExists(self.test_ws):
            mtd.deleteWorkspace(self.test_ws)
コード例 #3
0
 def test_child_alg_variation(self):
     """
         Call signature variation for Child Algorithm execution
     """
     algm = DummyAlg2()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest2")
     algm.setRethrows(True)
     algm.execute()
     self.assertTrue(mtd.workspaceExists("ChildAlgtest2"))
     mtd.deleteWorkspace("ChildAlgtest2")
コード例 #4
0
 def test_child_alg_wksp_transfer(self):
     """
         Check that we can execute a Child Algorithm and pass
         ownership of an output workspace to the parent algo. 
     """
     algm = DummyAlg2()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest")
     algm.setRethrows(True)
     algm.execute()
     self.assertTrue(mtd.workspaceExists("ChildAlgtest"))
     mtd.deleteWorkspace("ChildAlgtest")
コード例 #5
0
ファイル: ReducerTest.py プロジェクト: trnielsen/mantid
 def test_parameter_variation(self):
     """
         Similar to previous test, but the algo function is passed as a string
     """
     r = Reducer()
     r.append_step("LoadAscii", "AsciiExample.txt", None)
     for item in r._reduction_steps:
         result = item.execute(r, "test2")
         
     # Check that the workspace was created
     self.assertNotEqual(mtd["test2"], None)
     mtd.deleteWorkspace("test2")
コード例 #6
0
 def test_python_alg_property_using_python_alg(self):
     """
         Declare, set and get an algorithm property from a python algorithm
     """
     algm_par = DummyAlg2()
     algm_par.initialize()
     
     algm = DummyAlg()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest")
     algm._setAlgorithmProperty("Algo", algm_par)
     algm.execute()
     self.assertEqual(str(algm._getAlgorithmProperty("Algo")), "DummyAlg2.1()")
     self.assertTrue(mtd.workspaceExists("ChildAlgtest"))
     mtd.deleteWorkspace("ChildAlgtest")
コード例 #7
0
ファイル: ReducerTest.py プロジェクト: trnielsen/mantid
 def test_pars_variation(self):
     """
         Variations for parameter specification
     """
     r = Reducer()
     # An algorithm with a mandatory property that is NOT InputWorkspace or OutputWorkspace
     r.append_step(LoadAscii, Filename="AsciiExample.txt", OutputWorkspace=None)
     # Algorithm with InputWorkspace and OutputWorkspace
     r.append_step(ConvertToHistogram, None, None)
     for item in r._reduction_steps:
         result = item.execute(r, "test2")
         
     # Check that the workspace was created
     self.assertNotEqual(mtd["test2"], None)
     mtd.deleteWorkspace("test2")
コード例 #8
0
ファイル: ReducerTest.py プロジェクト: trnielsen/mantid
 def test_append_step(self):
     """
         Test that a Mantid algorithm function can be added to a Reducer object
     """
     r = Reducer()
     # An algorithm with a mandatory property that is NOT InputWorkspace or OutputWorkspace
     r.append_step(LoadAscii, "AsciiExample.txt", None)
     # Algorithm with InputWorkspace and OutputWorkspace
     r.append_step(ConvertToHistogram, None, None)
     for item in r._reduction_steps:
         result = item.execute(r, "test2")
         
     # Check that the workspace was created
     self.assertNotEqual(mtd["test2"], None)
     mtd.deleteWorkspace("test2")
コード例 #9
0
 def setUp(self):
     
     self.test_ws = "sans_workflow_ws"
     if mtd.workspaceExists(self.test_ws):
         mtd.deleteWorkspace(self.test_ws)
     
     CreateWorkspace(self.test_ws, DataX=[0.1,0.2,0.3], DataY=[1.0,1.0,1.0], DataE=[0.1,0.1,0.1], NSpec=1, UnitX="MomentumTransfer") 
     LoadInstrument(Filename="BIOSANS_Definition.xml", Workspace=self.test_ws)
     mantid[self.test_ws].getRun().addProperty_dbl("wavelength", 6.0, True)
     mantid[self.test_ws].getRun().addProperty_dbl("wavelength-spread", 0.1, True)
     mantid[self.test_ws].getRun().addProperty_dbl("source-aperture-diameter", 40, True)
     mantid[self.test_ws].getRun().addProperty_dbl("sample-aperture-diameter", 40, True)
     mantid[self.test_ws].getRun().addProperty_dbl("source-sample-distance", 11000, True)
     mantid[self.test_ws].getRun().addProperty_dbl("sample_detector_distance", 6000, True)        
     self.assertEqual(mantid[self.test_ws].dataDx(0)[0], 0)
     self.assertEqual(mantid[self.test_ws].dataDx(0)[1], 0)
     self.assertEqual(mantid[self.test_ws].dataDx(0)[2], 0)
コード例 #10
0
 def test_cpp_alg_property_using_python_alg(self):
     """
         Declare, set and get a C++ algorithm from a python algorithm
     """
     algm_par = mtd._createAlgProxy("CreateWorkspace")
     algm_par.setPropertyValues(OutputWorkspace="test", DataX=1, DataY=1, DataE=1)
     algm_par.initialize()
     
     algm = DummyAlg()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest")
     algm._setAlgorithmProperty("Algo", algm_par._getHeldObject())
     algm.execute()
     self.assertEqual(str(algm._getAlgorithmProperty("Algo")), 
                      "CreateWorkspace.1(OutputWorkspace=test,DataX=1,DataY=1,DataE=1)")
     self.assertTrue(mtd.workspaceExists("ChildAlgtest"))
     mtd.deleteWorkspace("ChildAlgtest")
コード例 #11
0
 def test_algp_property_using_public_API(self):
     """
         Declare, set and get an algorithm property from a python algorithm
         using the public API. Only works if the algorithm owning the AlgorithmProperty
         is a PythonAlgorithm.
     """
     algm_par = mtd._createAlgProxy("CreateWorkspace")
     algm_par.setPropertyValues(OutputWorkspace="test", DataX=1, DataY=1, DataE=1)
     algm_par.initialize()
     
     algm = DummyAlg()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest")
     algm.setProperty("Algo", algm_par._getHeldObject())
     algm.execute()
     self.assertEqual(str(algm._getAlgorithmProperty("Algo")), 
                      "CreateWorkspace.1(OutputWorkspace=test,DataX=1,DataY=1,DataE=1)")
     self.assertTrue(mtd.workspaceExists("ChildAlgtest"))
     mtd.deleteWorkspace("ChildAlgtest")
コード例 #12
0
ファイル: ReducerTest.py プロジェクト: trnielsen/mantid
    def test_output_wksp(self):
        """
            Similar to previous test, but we specify the output workspace
        """
        r = Reducer()
        # An algorithm with a mandatory property that is NOT InputWorkspace or OutputWorkspace
        r.append_step(LoadAscii, "AsciiExample.txt", None)
        # Algorithm with InputWorkspace and OutputWorkspace
        r.append_step(ConvertToHistogram, None, None)
        
        r._reduction_steps[0].execute(r, "test2")

        r._reduction_steps[1].execute(r, "test2", "test3")
            
        # Check that the workspace was created
        self.assertNotEqual(mtd["test2"], None)
        self.assertNotEqual(mtd["test3"], None)
        mtd.deleteWorkspace("test2")
        mtd.deleteWorkspace("test3")
コード例 #13
0
 def test_cpp_alg_property_using_python_alg_and_execute_the_propertied_algorithm(self):
     """
         Declare, seta C++ algorithm from a python algorithm.
         Then, in the "super" python algorithm, run the "sub" algorithm that
         was passed as a parameter
     """
     algm_par = mtd._createAlgProxy("CreateWorkspace")
     algm_par.setPropertyValues(OutputWorkspace="test", DataX=1, DataY=1, DataE=1)
     algm_par.initialize()
     
     algm = DummyAlg3()
     algm.initialize()
     algm.setPropertyValue("OutputWorkspace", "ChildAlgtest")
     algm._setAlgorithmProperty("Algo", algm_par._getHeldObject())
     algm.execute()
     # THe algorithm created the workspace name given in the PROPERTY ...
     self.assertTrue(mtd.workspaceExists("test"))
     mtd.deleteWorkspace("test")
     # ... not the one given as a parameter of DummyAlg3, because that's not the way that algo was written
     self.assertFalse(mtd.workspaceExists("ChildAlgtest"))
コード例 #14
0
                                OutputWorkspace=weighted_MDEW,
                                LorentzCorrection='1',
                                OutputDimensions='Q (sample frame)',
                                SplitInto='2',
                                SplitThreshold='50',
                                MaxRecursionDepth='11')
#
# Find the requested number of peaks.  Once the peaks are found, we no longer
# need the weighted MD event workspace, so delete it.
#
distance_threshold = 0.9 * 6.28 / float(max_d)
FindPeaksMD(InputWorkspace=weighted_MDEW,
            MaxPeaks=num_peaks_to_find,
            OutputWorkspace=peaks_ws,
            PeakDistanceThreshold=distance_threshold)
mtd.deleteWorkspace(weighted_MDEW)

#
# Find a Niggli UB matrix that indexes the peaks in this run
#
FindUBUsingFFT(PeaksWorkspace=peaks_ws,
               MinD=min_d,
               MaxD=max_d,
               Tolerance=tolerance)
IndexPeaks(PeaksWorkspace=peaks_ws, Tolerance=tolerance)

#
# Save UB and peaks file, so if something goes wrong latter, we can at least
# see these partial results
#
SaveIsawUB(InputWorkspace=peaks_ws, Filename=run_niggli_matrix_file)