コード例 #1
0
def append_to_sans_file_tag(workspace, to_append):
    """
    Appends a string to the existing sans file tag.

    :param workspace: the workspace which contains the sample logs with the sans file tag.
    :param to_append: the additional tag
    """
    if has_tag(SANS_FILE_TAG, workspace):
        value = get_tag(SANS_FILE_TAG, workspace)
        value += to_append
        set_tag(SANS_FILE_TAG, value, workspace)
コード例 #2
0
def append_to_sans_file_tag(workspace, to_append):
    """
    Appends a string to the existing sans file tag.

    :param workspace: the workspace which contains the sample logs with the sans file tag.
    :param to_append: the additional tag
    """
    if has_tag(SANS_FILE_TAG, workspace):
        value = get_tag(SANS_FILE_TAG, workspace)
        value += to_append
        set_tag(SANS_FILE_TAG, value, workspace)
コード例 #3
0
ファイル: log_tagger_test.py プロジェクト: ethoeng/mantid
    def test_that_can_read_and_write_tag_in_sample_logs(self):
        # Arrange
        ws1 = SANSLogTaggerTest._provide_sample_workspace()
        tag1 = "test"
        value1 = 123

        # Act + Assert
        self.assertFalse(has_tag(tag1, ws1))
        set_tag(tag1, value1, ws1)
        self.assertTrue(has_tag(tag1, ws1))
        self.assertEqual(get_tag(tag1, ws1), value1)
コード例 #4
0
ファイル: log_tagger_test.py プロジェクト: DanNixon/mantid
    def test_that_can_read_and_write_tag_in_sample_logs(self):
        # Arrange
        ws1 = SANSLogTaggerTest._provide_sample_workspace()
        tag1 = "test"
        value1 = 123

        # Act + Assert
        self.assertFalse(has_tag(tag1, ws1))
        set_tag(tag1, value1, ws1)
        self.assertTrue(has_tag(tag1, ws1))
        self.assertTrue(get_tag(tag1, ws1) == value1)
コード例 #5
0
ファイル: load_data.py プロジェクト: patrick-huyphan/mantid
def is_calibration_correct(workspace, calibration_file):
    """
    Check if the calibration has been applied. If no calibration has been specified then none should be have
    been applied.

    :param workspace: the workspace to check.
    :param calibration_file: the path to the calibration file.
    :return: True if the calibration file matches or if none was set and the path is empty, else False
    """
    has_calibration = has_tag(CALIBRATION_WORKSPACE_TAG, workspace)
    return (has_calibration and calibration_file == get_tag(CALIBRATION_WORKSPACE_TAG, workspace)) or\
           (not has_calibration and not calibration_file)
コード例 #6
0
ファイル: load_data.py プロジェクト: DanNixon/mantid
def is_calibration_correct(workspace, calibration_file):
    """
    Check if the calibration has been applied. If no calibration has been specified then none should be have
    been applied.

    :param workspace: the workspace to check.
    :param calibration_file: the path to the calibration file.
    :return: True if the calibration file matches or if none was set and the path is empty, else False
    """
    has_calibration = has_tag(CALIBRATION_WORKSPACE_TAG, workspace)
    return (has_calibration and calibration_file == get_tag(CALIBRATION_WORKSPACE_TAG, workspace)) or\
           (not has_calibration and not calibration_file)
コード例 #7
0
def has_calibration_already_been_applied(workspace, full_file_path):
    """
    Checks if particular calibration, defined by the file path has been applied to a workspace.

    :param workspace: The workspace which might have been calibrated
    :param full_file_path: An absolute file path to the calibration file.
    :return: True if the calibration has been applied else False
    """
    has_calibration_applied = False
    if has_tag(CALIBRATION_WORKSPACE_TAG, workspace):
        value = get_tag(CALIBRATION_WORKSPACE_TAG, workspace)
        has_calibration_applied = value == full_file_path
    return has_calibration_applied
コード例 #8
0
ファイル: calibration.py プロジェクト: mantidproject/mantid
def has_calibration_already_been_applied(workspace, full_file_path):
    """
    Checks if particular calibration, defined by the file path has been applied to a workspace.

    :param workspace: The workspace which might have been calibrated
    :param full_file_path: An absolute file path to the calibration file.
    :return: True if the calibration has been applied else False
    """
    has_calibration_applied = False
    if has_tag(CALIBRATION_WORKSPACE_TAG, workspace):
        value = get_tag(CALIBRATION_WORKSPACE_TAG, workspace)
        has_calibration_applied = value == full_file_path
    return has_calibration_applied
コード例 #9
0
def does_can_workspace_exist_on_ads(can_workspace):
    """
    Checks if a can workspace already exists on the ADS, based on the stored hash

    :param can_workspace: a handle to the can workspace
    :return: True if the workspace exists on the ADS else False
    """
    if not has_tag(REDUCED_CAN_TAG, can_workspace):
        return False

    hash_value_to_compare = get_tag(REDUCED_CAN_TAG, can_workspace)

    for workspace in get_ads_workspace_references():
        if has_hash(REDUCED_CAN_TAG, hash_value_to_compare, workspace):
            return True
    return False
コード例 #10
0
ファイル: general_functions.py プロジェクト: DanNixon/mantid
def does_can_workspace_exist_on_ads(can_workspace):
    """
    Checks if a can workspace already exists on the ADS, based on the stored hash

    :param can_workspace: a handle to the can workspace
    :return: True if the workspace exists on the ADS else False
    """
    if not has_tag(REDUCED_CAN_TAG, can_workspace):
        return False

    hash_value_to_compare = get_tag(REDUCED_CAN_TAG, can_workspace)

    for workspace in get_ads_workspace_references():
        if has_hash(REDUCED_CAN_TAG, hash_value_to_compare, workspace):
            return True
    return False
コード例 #11
0
ファイル: load_data.py プロジェクト: DanNixon/mantid
def get_workspaces_from_ads_if_exist(file_tags, full_calibration_file_path, workspaces):
    """
    Retrieves workspaces from the ADS depending on their file tags and calibration file tags which would have been
    set by the sans loading mechanism when they were loaded the first time.

    :param file_tags: a list of file tags which we look for on the workspaces on the ADS
    :param full_calibration_file_path: the calibration file name which we look for on the workspaces on the ADS
    :param workspaces: a list of workspaces which is being updated in this function.
    """
    for workspace_name in AnalysisDataService.getObjectNames():
        workspace = AnalysisDataService.retrieve(workspace_name)
        try:
            if has_tag(SANS_FILE_TAG, workspace):
                file_tag = get_tag(SANS_FILE_TAG, workspace)
                if file_tag in file_tags and is_calibration_correct(workspace, full_calibration_file_path):
                    workspaces.append(workspace)
        except RuntimeError:
            continue
コード例 #12
0
def get_workspaces_from_ads_if_exist(file_tags, full_calibration_file_path, workspaces):
    """
    Retrieves workspaces from the ADS depending on their file tags and calibration file tags which would have been
    set by the sans loading mechanism when they were loaded the first time.

    :param file_tags: a list of file tags which we look for on the workspaces on the ADS
    :param full_calibration_file_path: the calibration file name which we look for on the workspaces on the ADS
    :param workspaces: a list of workspaces which is being updated in this function.
    """
    for workspace_name in AnalysisDataService.getObjectNames():
        workspace = AnalysisDataService.retrieve(workspace_name)
        try:
            if has_tag(SANS_FILE_TAG, workspace):
                file_tag = get_tag(SANS_FILE_TAG, workspace)
                if file_tag in file_tags and is_calibration_correct(workspace, full_calibration_file_path):
                    workspaces.append(workspace)
        except RuntimeError:
            continue