Esempio n. 1
0
def get_sample_log(workspace, log_name):
    table = s_api.CreateLogPropertyTable(workspace,
                                         log_name,
                                         EnableLogging=False)
    log_value = table.cell(0, 0) if table else None
    s_api.DeleteWorkspace(table, EnableLogging=False)
    return log_value
Esempio n. 2
0
    def _can_merge(self, wsnames):
        """
        Checks whether given workspaces can be merged
        """
        # mandatory properties must be identical
        result = api.CompareSampleLogs(wsnames, self.mandatory_properties[1:],
                                       0.01)
        if len(result) > 0:
            raise RuntimeError("Sample logs " + result + " do not match!")

        # chopper_speed can vary about 10 and for some reason it is string (will be corrected in the future)
        cstable = api.CreateLogPropertyTable(wsnames, 'chopper_speed')
        chopper_speeds = [int(val) for val in cstable.column(0)]
        if max(chopper_speeds) - min(
                chopper_speeds) > 10:  # not within tolerance of 10 rpm
            self.log().warning(
                "Chopper speeds do not match! Chopper speeds are: " +
                " ,".join([str(val) for val in chopper_speeds]))
        api.DeleteWorkspace(cstable)

        # timing (x-axis binning) must match
        # is it possible to use WorkspaceHelpers::matchingBins from python?
        self.timingsMatch(wsnames)

        # Check sample logs for must have properties
        for wsname in wsnames:
            wks = api.AnalysisDataService.retrieve(wsname)
            run = wks.getRun()
            for prop in self.must_have_properties:
                if not run.hasProperty(prop):
                    message = "Error: Workspace " + wsname + " does not have property " + prop +\
                        ". Cannot merge."
                    self.log().error(message)
                    raise RuntimeError(message)

        # warnig if optional properties are not identical must be given
        result = api.CompareSampleLogs(wsnames, self.optional_properties, 0.01)
        if len(result) > 0:
            self.log().warning("Sample logs " + result + " do not match!")

        return True