コード例 #1
0
ファイル: DNSMergeRuns.py プロジェクト: stothe2/mantid
    def _can_merge(self):
        """
        checks whether it is possible to merge the given list of workspaces
        """
        # list of workspaces must not be empty
        if not self.workspace_names:
            message = "No workspace names has been specified! Nothing to merge."
            self.log().error(message)
            raise RuntimeError(message)

        # workspaces must exist
        mlzutils.ws_exist(self.workspace_names, self.log())

        # all workspaces must be either normalized or not normalized, but not mixed
        self._are_normalized()

        # if data are not normalized, normalization workspaces must exist
        if not self.is_normalized:
            wslist = [wsname + '_NORM' for wsname in self.workspace_names]
            mlzutils.ws_exist(wslist, self.log())

        # they must have the same dimensions
        mlzutils.same_dimensions(self.workspace_names)

        # and the same wavelength
        self._same_wavelength()

        # algorithm must warn if some properties_to_compare are different
        ws1 = api.AnalysisDataService.retrieve(self.workspace_names[0])
        run1 = ws1.getRun()
        for wsname in self.workspace_names[1:]:
            wks = api.AnalysisDataService.retrieve(wsname)
            run = wks.getRun()
            mlzutils.compare_properties(run1, run, self.properties_to_compare, self.log())
        return True
コード例 #2
0
ファイル: DNSDetEffCorrVana.py プロジェクト: stothe2/mantid
    def PyExec(self):
        # Input
        self.dataws = api.mtd[self.getPropertyValue("InputWorkspace")]
        self.outws_name = self.getPropertyValue("OutputWorkspace")
        self.vanaws = api.mtd[self.getPropertyValue("VanaWorkspace")]
        self.bkgws = api.mtd[self.getPropertyValue("BkgWorkspace")]
        self.vana_mean_name = self.getPropertyValue("VanadiumMean")

        # check dimensions
        wslist = [self.dataws.getName(), self.vanaws.getName(), self.bkgws.getName()]
        mlzutils.same_dimensions(wslist)
        # check if the _NORM workspaces exist
        wslist = [self.vanaws.getName() + '_NORM', self.bkgws.getName() + '_NORM']
        mlzutils.ws_exist(wslist, self.log())

        # check sample logs, produce warnings if different
        drun = self.dataws.getRun()
        vrun = self.vanaws.getRun()
        brun = self.bkgws.getRun()
        mlzutils.compare_properties(drun, vrun, self.properties_to_compare, self.log())
        mlzutils.compare_properties(vrun, brun, self.properties_to_compare, self.log())
        # apply correction
        outws = self._vana_correct()
        if not outws:
            raise RuntimeError("Correction failed. Invalid VanadiumMean workspace dimensions.")

        # copy sample logs from data workspace to the output workspace
        api.CopyLogs(InputWorkspace=self.dataws.getName(), OutputWorkspace=outws.getName(),
                     MergeStrategy='MergeReplaceExisting')
        self.setProperty("OutputWorkspace", outws)

        # clone the normalization workspace for data if it exists
        if api.mtd.doesExist(self.dataws.getName()+'_NORM'):
            api.CloneWorkspace(InputWorkspace=self.dataws.getName()+'_NORM', OutputWorkspace=self.outws_name+'_NORM')
        self.log().debug('DNSDetEffCorrVana: OK. The result has been saved to ' + self.outws_name)

        return
コード例 #3
0
    def _can_correct(self):
        """
        checks whether FR correction is possible with the given list of workspaces
        """
        # list of workspaces must not be empty
        if not self.input_workspaces:
            message = "No workspace names has been specified! Nothing for FR correction."
            self.log().error(message)
            raise RuntimeError(message)
        # workspaces and normalization workspaces must exist
        wslist = self.input_workspaces.values()
        # for data workspaces normalization is not mandatory
        dataws_names = [self.input_workspaces['SF_Data'], self.input_workspaces['NSF_Data']]
        for wsname in self.input_workspaces.values():
            if wsname not in dataws_names:
                wslist.append(wsname + '_NORM')

        mlzutils.ws_exist(wslist, self.log())

        # they must have the same dimensions
        mlzutils.same_dimensions(self.input_workspaces.values())

        # and the same polarisation
        self._same_polarisation()

        # check validity of flipper status
        self._flipper_valid()

        # algorithm must warn if some properties_to_compare are different
        ws1 = api.AnalysisDataService.retrieve(self.input_workspaces.values()[0])
        run1 = ws1.getRun()
        for wsname in self.input_workspaces.values()[1:]:
            wks = api.AnalysisDataService.retrieve(wsname)
            run = wks.getRun()
            mlzutils.compare_properties(run1, run, self.properties_to_compare, self.log())
        return True