예제 #1
0
    def test_crop_in_tof_coverts_units(self):
        # Checks that crop_in_tof converts to TOF before cropping
        ws_list = []
        x_min = 100
        x_max = 200
        expected_number_of_bins = 20000  # Hard code number of expected bins for dSpacing

        for i in range(0, 3):
            out_name = "crop_banks_in_dSpacing-" + str(i)
            ws_list.append(
                mantid.CreateSampleWorkspace(OutputWorkspace=out_name,
                                             XMin=0,
                                             XMax=20000,
                                             BinWidth=1,
                                             XUnit="dSpacing"))

        # Crop a single workspace from d_spacing and check the number of bins
        tof_single_ws = common.crop_in_tof(ws_to_crop=ws_list[0],
                                           x_min=x_min,
                                           x_max=x_max)
        self.assertEqual(tof_single_ws.blocksize(), expected_number_of_bins)
        mantid.DeleteWorkspace(tof_single_ws)

        # Crop a list of workspaces in dSpacing
        cropped_ws_list = common.crop_in_tof(ws_to_crop=ws_list[1:],
                                             x_min=x_min,
                                             x_max=x_max)
        for ws in cropped_ws_list:
            self.assertEqual(ws.blocksize(), expected_number_of_bins)
            mantid.DeleteWorkspace(ws)
예제 #2
0
    def test_crop_in_tof(self):
        ws_list = []
        x_min = 100
        x_max = 500  # Crop to 0-500 microseconds for unit tests
        expected_number_of_bins = x_max - x_min

        for i in range(0, 3):
            out_name = "crop_banks_in_tof-" + str(i)
            ws_list.append(
                mantid.CreateSampleWorkspace(OutputWorkspace=out_name,
                                             XMin=0,
                                             XMax=600,
                                             BinWidth=1))

        # Crop a single workspace in TOF
        tof_single_ws = common.crop_in_tof(ws_to_crop=ws_list[0],
                                           x_min=x_min,
                                           x_max=x_max)
        self.assertEqual(tof_single_ws.blocksize(), expected_number_of_bins)
        mantid.DeleteWorkspace(tof_single_ws)

        # Crop a list of workspaces in TOF
        cropped_ws_list = common.crop_in_tof(ws_to_crop=ws_list[1:],
                                             x_min=x_min,
                                             x_max=x_max)
        for ws in cropped_ws_list:
            self.assertEqual(ws.blocksize(), expected_number_of_bins)
            mantid.DeleteWorkspace(ws)
예제 #3
0
    def test_crop_in_tof_by_fraction(self):
        ws_list = []
        x_min = 0.2
        x_max = 0.8  # Crop 20% from the front and back.
        expected_number_of_bins = 600 * x_max - 100 * (1 + x_min)

        for i in range(0, 3):
            out_name = "crop_banks_in_tof-" + str(i)
            ws_list.append(
                mantid.CreateSampleWorkspace(OutputWorkspace=out_name,
                                             XMin=100,
                                             XMax=600,
                                             BinWidth=1))

        # Crop a single workspace in TOF
        tof_single_ws = common.crop_in_tof(ws_to_crop=ws_list[0],
                                           x_min=x_min,
                                           x_max=x_max)
        self.assertEqual(tof_single_ws.blocksize(), expected_number_of_bins)
        mantid.DeleteWorkspace(tof_single_ws)

        # Crop a list of workspaces in TOF
        cropped_ws_list = common.crop_in_tof(ws_to_crop=ws_list[1:],
                                             x_min=x_min,
                                             x_max=x_max)
        for ws in cropped_ws_list:
            self.assertEqual(ws.blocksize(), expected_number_of_bins)
            mantid.DeleteWorkspace(ws)
예제 #4
0
    def test_crop_in_tof(self):
        ws_list = []
        x_min = 100
        x_max = 500  # Crop to 0-500 microseconds for unit tests
        expected_number_of_bins = x_max - x_min

        for i in range(0, 3):
            out_name = "crop_banks_in_tof-" + str(i)
            ws_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=0, XMax=600, BinWidth=1))

        # Crop a single workspace in TOF
        tof_single_ws = common.crop_in_tof(ws_to_crop=ws_list[0], x_min=x_min, x_max=x_max)
        self.assertEqual(tof_single_ws.blocksize(), expected_number_of_bins)
        mantid.DeleteWorkspace(tof_single_ws)

        # Crop a list of workspaces in TOF
        cropped_ws_list = common.crop_in_tof(ws_to_crop=ws_list[1:], x_min=x_min, x_max=x_max)
        for ws in cropped_ws_list:
            self.assertEqual(ws.blocksize(), expected_number_of_bins)
            mantid.DeleteWorkspace(ws)
예제 #5
0
    def test_crop_in_tof_coverts_units(self):
        # Checks that crop_in_tof converts to TOF before cropping
        ws_list = []
        x_min = 100
        x_max = 200
        expected_number_of_bins = 20000  # Hard code number of expected bins for dSpacing

        for i in range(0, 3):
            out_name = "crop_banks_in_dSpacing-" + str(i)
            ws_list.append(mantid.CreateSampleWorkspace(OutputWorkspace=out_name, XMin=0, XMax=20000, BinWidth=1,
                                                        XUnit="dSpacing"))

        # Crop a single workspace from d_spacing and check the number of bins
        tof_single_ws = common.crop_in_tof(ws_to_crop=ws_list[0], x_min=x_min, x_max=x_max)
        self.assertEqual(tof_single_ws.blocksize(), expected_number_of_bins)
        mantid.DeleteWorkspace(tof_single_ws)

        # Crop a list of workspaces in dSpacing
        cropped_ws_list = common.crop_in_tof(ws_to_crop=ws_list[1:], x_min=x_min, x_max=x_max)
        for ws in cropped_ws_list:
            self.assertEqual(ws.blocksize(), expected_number_of_bins)
            mantid.DeleteWorkspace(ws)
예제 #6
0
 def _crop_van_to_expected_tof_range(self, van_ws_to_crop):
     return common.crop_in_tof(
         ws_to_crop=van_ws_to_crop,
         x_min=self._inst_settings.van_tof_cropping[0],
         x_max=self._inst_settings.van_tof_cropping[-1])
예제 #7
0
파일: pearl.py 프로젝트: ebknudsen/mantid
 def _crop_raw_to_expected_tof_range(self, ws_to_crop):
     out_ws = common.crop_in_tof(
         ws_to_crop=ws_to_crop,
         x_min=self._inst_settings.raw_data_crop_vals[0],
         x_max=self._inst_settings.raw_data_crop_vals[-1])
     return out_ws
예제 #8
0
 def _crop_raw_to_expected_tof_range(self, ws_to_crop):
     raw_cropping_values = self._inst_settings.raw_tof_cropping_values
     return common.crop_in_tof(ws_to_crop, raw_cropping_values[0], raw_cropping_values[1])
예제 #9
0
 def _crop_van_to_expected_tof_range(self, van_ws_to_crop):
     return common.crop_in_tof(ws_to_crop=van_ws_to_crop, x_min=self._inst_settings.van_tof_cropping[0],
                               x_max=self._inst_settings.van_tof_cropping[-1])
예제 #10
0
파일: pearl.py 프로젝트: DanNixon/mantid
 def _crop_raw_to_expected_tof_range(self, ws_to_crop):
     out_ws = common.crop_in_tof(ws_to_crop=ws_to_crop, x_min=self._inst_settings.raw_data_crop_vals[0],
                                 x_max=self._inst_settings.raw_data_crop_vals[-1])
     return out_ws