def PyExec(self): workspace = get_input_workspace_as_copy_if_not_same_as_output_workspace( self) progress = Progress(self, start=0.0, end=1.0, nreports=3) # Convert the units into wavelength progress.report("Converting workspace to wavelength units.") workspace = self._convert_units_to_wavelength(workspace) # Get the rebin option rebin_type = RebinType.from_string(self.getProperty("RebinMode").value) rebin_string = self._get_rebin_string(workspace) if rebin_type is RebinType.Rebin: rebin_options = { "InputWorkspace": workspace, "PreserveEvents": True, "Params": rebin_string } else: rebin_options = { "InputWorkspace": workspace, "Params": rebin_string } # Perform the rebin progress.report("Performing rebin.") workspace = self._perform_rebin(rebin_type, rebin_options, workspace) append_to_sans_file_tag(workspace, "_toWavelength") self.setProperty("OutputWorkspace", workspace) progress.report("Finished converting to wavelength.")
def validateInputs(self): errors = dict() # Check the wavelength wavelength_low = self.getProperty("WavelengthLow").value wavelength_high = self.getProperty("WavelengthHigh").value if wavelength_low is not None and wavelength_high is not None and wavelength_low > wavelength_high: errors.update({"WavelengthLow": "The lower wavelength setting needs to be smaller " "than the higher wavelength setting."}) if wavelength_low is not None and wavelength_low < 0: errors.update({"WavelengthLow": "The wavelength cannot be smaller than 0."}) if wavelength_high is not None and wavelength_high < 0: errors.update({"WavelengthHigh": "The wavelength cannot be smaller than 0."}) wavelength_step = self.getProperty("WavelengthStep").value if wavelength_step is not None and wavelength_step < 0: errors.update({"WavelengthStep": "The wavelength step cannot be smaller than 0."}) # Check the workspace workspace = self.getProperty("InputWorkspace").value rebin_type = RebinType.from_string(self.getProperty("RebinMode").value) if rebin_type is RebinType.InterpolatingRebin and isinstance(workspace, EventWorkspace): errors.update({"RebinMode": "An interpolating rebin cannot be applied to an EventWorkspace."}) return errors
def PyExec(self): workspace = get_input_workspace_as_copy_if_not_same_as_output_workspace(self) progress = Progress(self, start=0.0, end=1.0, nreports=3) # Convert the units into wavelength progress.report("Converting workspace to wavelength units.") workspace = self._convert_units_to_wavelength(workspace) # Get the rebin option rebin_type = RebinType.from_string(self.getProperty("RebinMode").value) rebin_string = self._get_rebin_string(workspace) if rebin_type is RebinType.Rebin: rebin_options = {"InputWorkspace": workspace, "PreserveEvents": True, "Params": rebin_string} else: rebin_options = {"InputWorkspace": workspace, "Params": rebin_string} # Perform the rebin progress.report("Performing rebin.") workspace = self._perform_rebin(rebin_type, rebin_options, workspace) append_to_sans_file_tag(workspace, "_toWavelength") self.setProperty("OutputWorkspace", workspace) progress.report("Finished converting to wavelength.")
def validateInputs(self): errors = dict() # Check the wavelength wavelength_low = self.getProperty("WavelengthLow").value wavelength_high = self.getProperty("WavelengthHigh").value if wavelength_low is not None and wavelength_high is not None and wavelength_low > wavelength_high: errors.update({ "WavelengthLow": "The lower wavelength setting needs to be smaller " "than the higher wavelength setting." }) if wavelength_low is not None and wavelength_low < 0: errors.update( {"WavelengthLow": "The wavelength cannot be smaller than 0."}) if wavelength_high is not None and wavelength_high < 0: errors.update( {"WavelengthHigh": "The wavelength cannot be smaller than 0."}) wavelength_step = self.getProperty("WavelengthStep").value if wavelength_step is not None and wavelength_step < 0: errors.update({ "WavelengthStep": "The wavelength step cannot be smaller than 0." }) # Check the workspace workspace = self.getProperty("InputWorkspace").value rebin_type = RebinType.from_string(self.getProperty("RebinMode").value) if rebin_type is RebinType.InterpolatingRebin and isinstance( workspace, EventWorkspace): errors.update({ "RebinMode": "An interpolating rebin cannot be applied to an EventWorkspace." }) return errors