Пример #1
0
def get_final_output_workspaces(output_bundles, parent_alg):
    """
    This function provides the final steps for the data reduction.

    The final steps are:
    1. Can Subtraction (if required)
    2. Data clean up (if required)
    :param output_bundles: A set of outputBundles
    :param parent_alg: a handle to the parent algorithm.
    :return: a map of ReductionMode vs final output workspaces.
    """

    reduction_mode_vs_output_bundles = get_reduction_mode_vs_output_bundles(
        output_bundles)

    # For each reduction mode, we need to perform a can subtraction (and potential cleaning of the workspace)
    final_output_workspaces = {}
    for reduction_mode, output_bundles in reduction_mode_vs_output_bundles.items(
    ):
        # Find the sample and the can in the data collection
        output_sample_workspace = next(
            (output_bundle.output_workspace
             for output_bundle in output_bundles if is_sample(output_bundle)),
            None)
        output_can_workspace = next(
            (output_bundle.output_workspace
             for output_bundle in output_bundles if is_can(output_bundle)),
            None)
        # Perform the can subtraction
        if output_can_workspace is not None:
            final_output_workspace = perform_can_subtraction(
                output_sample_workspace, output_can_workspace, parent_alg)
        else:
            final_output_workspace = output_sample_workspace

        # Tidy up the workspace by removing start/end-NANs and start/end-INFs
        final_output_workspace = strip_end_nans(final_output_workspace,
                                                parent_alg)
        final_output_workspaces.update(
            {reduction_mode: final_output_workspace})

    # Finally add sample log information
    # TODO: Add log information

    return final_output_workspaces
Пример #2
0
def get_final_output_workspaces(output_bundles, parent_alg):
    """
    This function provides the final steps for the data reduction.

    The final steps are:
    1. Can Subtraction (if required)
    2. Data clean up (if required)
    :param output_bundles: A set of outputBundles
    :param parent_alg: a handle to the parent algorithm.
    :return: a map of ReductionMode vs final output workspaces.
    """

    reduction_mode_vs_output_bundles = get_reduction_mode_vs_output_bundles(output_bundles)

    # For each reduction mode, we need to perform a can subtraction (and potential cleaning of the workspace)
    final_output_workspaces = {}
    for reduction_mode, output_bundles in reduction_mode_vs_output_bundles.items():
        # Find the sample and the can in the data collection
        output_sample_workspace = next((output_bundle.output_workspace for output_bundle in output_bundles
                                        if is_sample(output_bundle)), None)
        output_can_workspace = next((output_bundle.output_workspace for output_bundle in output_bundles
                                     if is_can(output_bundle)), None)
        # Perform the can subtraction
        if output_can_workspace is not None:
            final_output_workspace = perform_can_subtraction(output_sample_workspace, output_can_workspace, parent_alg)
        else:
            final_output_workspace = output_sample_workspace

        # Tidy up the workspace by removing start/end-NANs and start/end-INFs
        final_output_workspace = strip_end_nans(final_output_workspace, parent_alg)
        final_output_workspaces.update({reduction_mode: final_output_workspace})

    # Finally add sample log information
    # TODO: Add log information

    return final_output_workspaces