Esempio n. 1
0
 def test_simple(self):
     w = simpleapi.Load('CNCS_7860_event.nxs')
     result = simpleapi.CheckForSampleLogs(w)
     self.assertEqual(result, '')
     result = simpleapi.CheckForSampleLogs(w, 'Phase1')
     self.assertEqual(result, '')
     result = simpleapi.CheckForSampleLogs(w, 'Phrase1')
     self.assertNotEquals(result, '')
    def validateInputs(self):
        issues = dict()

        choice_tof = self.getProperty("ChoiceElasticTof").value
        vanaws_name = self.getPropertyValue("VanadiumWorkspace")
        inws = self.getProperty("InputWorkspace").value

        # instrument must be set, this can be moved to validator
        # after validators will work for WorkspaceGroups
        if not inws.getInstrument().getName():
            issues['InputWorkspace'] = "Instrument must be set."

        # X units must be TOF
        xunit = inws.getAxis(0).getUnit().unitID()
        if xunit != 'TOF':
            issues['InputWorkspace'] = "X axis units must be TOF. "

        # input workspace must have required sample logs
        err = api.CheckForSampleLogs(inws, ",".join(self.logs_to_check))
        if err:
            issues['InputWorkspace'] = err

        # if Vanadium will be used to find EPP, workspace must exist and have required sample logs
        if choice_tof == 'FitVanadium':
            if not api.AnalysisDataService.doesExist(vanaws_name):
                issues[
                    'VanadiumWorkspace'] = "Valid Vanadium Workspace must be given for choosen ElasticTof option."

            else:
                vanaws = api.AnalysisDataService.retrieve(vanaws_name)
                xunit = vanaws.getAxis(0).getUnit().unitID()
                if xunit != 'TOF':
                    issues['VanadiumWorkspace'] = "X axis units must be TOF. "
                err = api.CheckForSampleLogs(vanaws,
                                             ",".join(self.logs_to_check))
                if err:
                    issues['VanadiumWorkspace'] = err
                # required sample logs for sample and vanadium must be identical
                else:
                    result = api.CompareSampleLogs(
                        [inws.getName(), vanaws_name], self.logs_to_check,
                        0.01)
                    if len(result) > 0:
                        issues[
                            'VanadiumWorkspace'] = "Sample logs " + result + " must match for Vanadium and sample workspaces."
        # if EPP will be taken from sample logs, it must be > 0
        epp = inws.getRun().getProperty('EPP').value
        if float(epp) <= 0:
            issues['InputWorkspace'] = "EPP must be a positive number."

        return issues
Esempio n. 3
0
def try_get_sample_log(workspace, log_name):
    messages = s_api.CheckForSampleLogs(workspace, log_name, EnableLogging=False)
    return get_sample_log(workspace, log_name) if not messages else None