def PyExec(self): alg = self.createChildAlgorithm('ChildAlg') alg.initialize() args = {} kwargs = {} set_properties(alg, *args, **kwargs) alg.execute()
def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, set the algorithm properties replacing the input and output workspaces. The execution will work for any combination of mandatory/optional properties. @param reducer: Reducer object managing the reduction @param inputworkspace: input workspace name [optional] @param outputworkspace: output workspace name [optional] """ # If we don't have a data file, look up the workspace handle if self._data_file is None: if inputworkspace in reducer._data_files: data_file = reducer._data_files[inputworkspace] if data_file is None: return else: raise RuntimeError( "SANSReductionSteps.LoadRun doesn't recognize workspace handle %s" % inputworkspace) else: data_file = self._data_file alg = mantid.api.AlgorithmManager.create(algorithm) if not isinstance(alg, mantid.api.AlgorithmProxy): raise RuntimeError( "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(type(alg))) propertyOrder = alg.orderedProperties() # add the args to the kw list so everything can be set in a single way for (key, arg) in zip(propertyOrder[:len(args)], args): kwargs[key] = arg # Override input and output workspaces if "Workspace" in kwargs: kwargs["Workspace"] = inputworkspace if "OutputWorkspace" in kwargs: kwargs["OutputWorkspace"] = inputworkspace if "Filename" in kwargs: kwargs["Filename"] = data_file if "AlternateName" in kwargs and \ kwargs["AlternateName"] in propertyOrder: kwargs[kwargs["AlternateName"]] = data_file self.algorithm = alg mantid.set_properties(alg, *(), **kwargs) alg.execute() if "OutputMessage" in propertyOrder: return alg.getPropertyValue("OutputMessage") return "%s applied" % alg.name()
def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, set the algorithm properties replacing the input and output workspaces. The execution will work for any combination of mandatory/optional properties. @param reducer: Reducer object managing the reduction @param inputworkspace: input workspace name [optional] @param outputworkspace: output workspace name [optional] """ # If we don't have a data file, look up the workspace handle if self._data_file is None: if inputworkspace in reducer._data_files: data_file = reducer._data_files[inputworkspace] if data_file is None: return else: raise RuntimeError, "SANSReductionSteps.LoadRun doesn't recognize workspace handle %s" % workspace else: data_file = self._data_file alg = mantid.api.AlgorithmManager.create(algorithm) if not isinstance(alg, mantid.api.AlgorithmProxy): raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str( type(alg)) propertyOrder = alg.orderedProperties() # add the args to the kw list so everything can be set in a single way for (key, arg) in zip(propertyOrder[:len(args)], args): kwargs[key] = arg # Override input and output workspaces if "Workspace" in kwargs: kwargs["Workspace"] = inputworkspace if "OutputWorkspace" in kwargs: kwargs["OutputWorkspace"] = inputworkspace if "Filename" in kwargs: kwargs["Filename"] = data_file if "AlternateName" in kwargs and \ kwargs["AlternateName"] in propertyOrder: kwargs[kwargs["AlternateName"]] = data_file self.algorithm = alg simpleapi.set_properties(alg, *(), **kwargs) alg.execute() if "OutputMessage" in propertyOrder: return alg.getPropertyValue("OutputMessage") return "%s applied" % alg.name()
def _run_calibration_fit(self, *args, **kwargs): """ Runs EVSCalibrationFit using the AlgorithmManager. This allows the calibration script to be run directly from the script window after Mantid has started. @param args - positional arguments to the algorithm @param kwargs - key word arguments to the algorithm """ from mantid.simpleapi import set_properties alg = AlgorithmManager.create('EVSCalibrationFit') alg.initialize() alg.setRethrows(True) set_properties(alg, *args, **kwargs) alg.execute()
def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, set the algorithm properties replacing the input and output workspaces. The execution will work for any combination of mandatory/optional properties. @param reducer: Reducer object managing the reduction @param inputworkspace: input workspace name [optional] @param outputworkspace: output workspace name [optional] """ if outputworkspace is None: outputworkspace = inputworkspace alg = mantid.AlgorithmManager.create(algorithm) if not isinstance(alg, mantid.api.AlgorithmProxy): raise RuntimeError( "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str(type(alg))) propertyOrder = alg.orderedProperties() # add the args to the kw list so everything can be set in a single way for (key, arg) in zip(propertyOrder[:len(args)], args): kwargs[key] = arg # Override input and output workspaces if "Workspace" in kwargs: kwargs["Workspace"] = inputworkspace if "InputWorkspace" in kwargs: kwargs["InputWorkspace"] = inputworkspace if "OutputWorkspace" in kwargs: kwargs["OutputWorkspace"] = outputworkspace self.algorithm = alg mantid.set_properties(alg, *(), **kwargs) alg.execute() if "OutputMessage" in propertyOrder: return alg.getPropertyValue("OutputMessage") return "%s applied" % alg.name()
def execute(self, reducer, inputworkspace=None, outputworkspace=None): """ Create a new instance of the requested algorithm object, set the algorithm properties replacing the input and output workspaces. The execution will work for any combination of mandatory/optional properties. @param reducer: Reducer object managing the reduction @param inputworkspace: input workspace name [optional] @param outputworkspace: output workspace name [optional] """ if outputworkspace is None: outputworkspace = inputworkspace alg = mantid.AlgorithmManager.create(algorithm) if not isinstance(alg, mantid.api.AlgorithmProxy): raise RuntimeError, "Reducer expects an Algorithm object from FrameworkManager, found '%s'" % str( type(alg)) propertyOrder = alg.orderedProperties() # add the args to the kw list so everything can be set in a single way for (key, arg) in zip(propertyOrder[:len(args)], args): kwargs[key] = arg # Override input and output workspaces if "Workspace" in kwargs: kwargs["Workspace"] = inputworkspace if "InputWorkspace" in kwargs: kwargs["InputWorkspace"] = inputworkspace if "OutputWorkspace" in kwargs: kwargs["OutputWorkspace"] = outputworkspace self.algorithm = alg simpleapi.set_properties(alg, *(), **kwargs) alg.execute() if "OutputMessage" in propertyOrder: return alg.getPropertyValue("OutputMessage") return "%s applied" % alg.name()