예제 #1
0
def add_calibration_tag_to_workspace(workspace, full_file_path):
    """
    Adds a calibration tag to the workspace, which is the file path to the calibration file

    This is used to determine if a calibration (and if the correct calibration) has been applied to a workspace.
    :param workspace: the workspace to which the calibration tag is added
    :param full_file_path: the full file path to the calibration file
    """
    set_tag(CALIBRATION_WORKSPACE_TAG, full_file_path, workspace)
예제 #2
0
def add_calibration_tag_to_workspace(workspace, full_file_path):
    """
    Adds a calibration tag to the workspace, which is the file path to the calibration file

    This is used to determine if a calibration (and if the correct calibration) has been applied to a workspace.
    :param workspace: the workspace to which the calibration tag is added
    :param full_file_path: the full file path to the calibration file
    """
    set_tag(CALIBRATION_WORKSPACE_TAG, full_file_path, workspace)
예제 #3
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)
예제 #4
0
    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)
예제 #5
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)
예제 #6
0
    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)
예제 #7
0
def tag_workspaces_with_file_names(workspaces, file_information, is_transmission, period,  is_monitor):
    """
    Set a sample log element for the used original file. Note that the calibration file name is set

    :param workspaces: a dict of workspaces
    :param file_information: a SANSFileInformation object
    :param is_transmission: if is transmission.
    :param period: the selected period.
    :param is_monitor: if we are dealing with a monitor
    """
    # Set tag for the original file name from which the workspace was loaded

    file_tags = get_expected_file_tags(file_information, is_transmission, period)
    if len(file_tags) != len(workspaces):
        raise RuntimeError("Issue while tagging the loaded data. The number of tags does not match the number "
                           "of workspaces.")
    for file_tag, workspace in zip(file_tags, workspaces):
        if not has_tag(SANS_FILE_TAG, workspace):
            if is_monitor:
                file_tag += MONITOR_SUFFIX
            set_tag(SANS_FILE_TAG, file_tag, workspace)
예제 #8
0
def tag_workspaces_with_file_names(workspaces, file_information, is_transmission, period,  is_monitor):
    """
    Set a sample log element for the used original file. Note that the calibration file name is set

    :param workspaces: a dict of workspaces
    :param file_information: a SANSFileInformation object
    :param is_transmission: if is transmission.
    :param period: the selected period.
    :param is_monitor: if we are dealing with a monitor
    """
    # Set tag for the original file name from which the workspace was loaded

    file_tags = get_expected_file_tags(file_information, is_transmission, period)
    if len(file_tags) != len(workspaces):
        raise RuntimeError("Issue while tagging the loaded data. The number of tags does not match the number "
                           "of workspaces.")
    for file_tag, workspace in zip(file_tags, workspaces):
        if not has_tag(SANS_FILE_TAG, workspace):
            if is_monitor:
                file_tag += MONITOR_SUFFIX
            set_tag(SANS_FILE_TAG, file_tag, workspace)