def _get_pixel_adjustment_workspace(pixel_adjustment_file, component, idf_path): """ This get the pixel-by-pixel adjustment of the workspace :param pixel_adjustment_file: full file path to the pixel adjustment file :param component: the component which is currently being investigated :param idf_path: the idf path :return: the pixel adjustment workspace """ if pixel_adjustment_file: load_name = "LoadRKH" load_options = { "Filename": pixel_adjustment_file, "OutputWorkspace": EMPTY_NAME, "FirstColumnValue": "SpectrumNumber" } load_alg = create_unmanaged_algorithm(load_name, **load_options) load_alg.execute() output_workspace = load_alg.getProperty("OutputWorkspace").value if not idf_path: raise ValueError("No IDF path was found in the provided state") # Add an instrument to the workspace instrument_name = "LoadInstrument" instrument_options = { "Workspace": output_workspace, "Filename": idf_path, "RewriteSpectraMap": False } instrument_alg = create_unmanaged_algorithm( instrument_name, **instrument_options) instrument_alg.execute() # Crop to the required detector crop_name = "CropToComponent" component_to_crop = DetectorType(component) component_to_crop = get_component_name(output_workspace, component_to_crop) crop_options = { "InputWorkspace": output_workspace, "OutputWorkspace": EMPTY_NAME, "ComponentNames": component_to_crop } crop_alg = create_unmanaged_algorithm(crop_name, **crop_options) crop_alg.execute() pixel_adjustment_workspace = crop_alg.getProperty( "OutputWorkspace").value else: pixel_adjustment_workspace = None return pixel_adjustment_workspace
def crop_workspace(component, workspace): crop_name = "CropToComponent" component_to_crop = DetectorType(component) component_to_crop = get_component_name(workspace, component_to_crop) crop_options = {"InputWorkspace": workspace, "OutputWorkspace": EMPTY_NAME, "ComponentNames": component_to_crop} crop_alg = create_unmanaged_algorithm(crop_name, **crop_options) crop_alg.execute() output_workspace = crop_alg.getProperty("OutputWorkspace").value return output_workspace
def _get_cropped_workspace(self, component): scatter_workspace = self.getProperty("SampleScatterWorkspace").value alg_name = "CropToComponent" component_to_crop = DetectorType(component) component_to_crop = get_component_name(scatter_workspace, component_to_crop) crop_options = {"InputWorkspace": scatter_workspace, "OutputWorkspace": EMPTY_NAME, "ComponentNames": component_to_crop} crop_alg = create_child_algorithm(self, alg_name, **crop_options) crop_alg.execute() output_workspace = crop_alg.getProperty("OutputWorkspace").value return output_workspace
def _get_component(self, workspace): component_as_string = self.getProperty("Component").value component = DetectorType.from_string(component_as_string) return get_component_name(workspace, component)
def _get_component(self, workspace): component = DetectorType(self.component) return get_component_name(workspace, component)
def test_that_can_get_component_name_for_larmor(self): workspace = self._get_workspace("LARMOR00002260") self.assertTrue("DetectorBench" == get_component_name(workspace, DetectorType.HAB))
def test_that_can_get_component_name_for_loq(self): workspace = self._get_workspace("LOQ48127") self.assertTrue("HAB" == get_component_name(workspace, DetectorType.HAB)) self.assertTrue("main-detector-bank" == get_component_name(workspace, DetectorType.LAB))
def test_that_can_get_component_name_for_sans2d(self): workspace = self._get_workspace("SANS2D00022024") self.assertTrue("front-detector" == get_component_name(workspace, DetectorType.HAB)) self.assertTrue("rear-detector" == get_component_name(workspace, DetectorType.LAB))
def _get_component(self, workspace): component_as_string = self.getProperty("Component").value component = DetectorType.from_string(component_as_string) return get_component_name(workspace, component)