コード例 #1
0
 def set_transmission_workspaces_on_output(self, transmission_bundles,
                                           fit_state):
     for transmission_bundle in transmission_bundles:
         fit_performed = fit_state[DataType.to_string(
             transmission_bundle.data_type)].fit_type != FitType.NoFit
         calculated_transmission_workspace = transmission_bundle.calculated_transmission_workspace
         unfitted_transmission_workspace = transmission_bundle.unfitted_transmission_workspace
         if transmission_bundle.data_type is DataType.Can:
             if does_can_workspace_exist_on_ads(
                     calculated_transmission_workspace):
                 # The workspace is cloned here because the transmission runs are diagnostic output so even though
                 # the values already exist they need to be labelled seperately for each reduction.
                 calculated_transmission_workspace = CloneWorkspace(
                     calculated_transmission_workspace, StoreInADS=False)
             if does_can_workspace_exist_on_ads(
                     unfitted_transmission_workspace):
                 unfitted_transmission_workspace = CloneWorkspace(
                     unfitted_transmission_workspace, StoreInADS=False)
             if fit_performed:
                 self.setProperty(
                     "OutputWorkspaceCalculatedTransmissionCan",
                     calculated_transmission_workspace)
             self.setProperty("OutputWorkspaceUnfittedTransmissionCan",
                              unfitted_transmission_workspace)
         elif transmission_bundle.data_type is DataType.Sample:
             if fit_performed:
                 self.setProperty("OutputWorkspaceCalculatedTransmission",
                                  calculated_transmission_workspace)
             self.setProperty("OutputWorkspaceUnfittedTransmission",
                              unfitted_transmission_workspace)
         else:
             raise RuntimeError(
                 "SANSSingleReduction: The data type {0} should be"
                 " sample or can.".format(transmission_bundle.data_type))
コード例 #2
0
    def set_reduced_can_count_and_norm_on_output(self, output_bundles_parts):
        """
        Sets the reduced can count and norm group workspaces on the output properties.
        The reduced can workspaces can be:
        1. LAB Can Count
        2. LAB Can Norm
        3. HAB Can Count
        4. HAB Can Norm

        :param output_bundles_parts: a list containing a single list of output bundle parts
        """
        # Find the partial output bundles fo LAB Can and HAB Can if they exist
        output_bundles_part = output_bundles_parts[0]
        for output_bundle_part in output_bundles_part:
            if output_bundle_part.data_type is DataType.CAN:
                reduction_mode = output_bundle_part.reduction_mode
                output_workspace_count = output_bundle_part.output_workspace_count
                output_workspace_norm = output_bundle_part.output_workspace_norm
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace_norm is not None and output_workspace_count is not None and \
                        not does_can_workspace_exist_on_ads(output_workspace_norm) and \
                        not does_can_workspace_exist_on_ads(output_workspace_count):
                    if reduction_mode is ReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceLABCanNorm", output_workspace_norm)
                    elif reduction_mode is ReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceHABCanNorm", output_workspace_norm)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a partial can.".format(reduction_mode))
コード例 #3
0
    def set_reduced_can_workspace_on_output(self, output_bundles, output_bundles_part):
        """
        Sets the reduced can workspaces on the output properties.

        The reduced can workspaces can be:
        1. LAB Can
        2. LAB Can Count
        3. LAB Can Norm
        4. HAB Can
        5. HAB Can Count
        6. HAB Can Norm
        :param output_bundles: a list of output bundles
        :param output_bundles_part: a list of partial output bundles
        """
        # Find the LAB Can and HAB Can entries if they exist
        for output_bundle in output_bundles:
            if output_bundle.data_type is DataType.Can:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace is not None and not does_can_workspace_exist_on_ads(output_workspace):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCan", output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCan", output_bundle.output_workspace)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a can.".format(reduction_mode))

        # Find the partial output bundles fo LAB Can and HAB Can if they exist
        for output_bundle_part in output_bundles_part:
            if output_bundle_part.data_type is DataType.Can:
                reduction_mode = output_bundle_part.reduction_mode
                output_workspace_count = output_bundle_part.output_workspace_count
                output_workspace_norm = output_bundle_part.output_workspace_norm
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace_norm is not None and output_workspace_count is not None and \
                        not does_can_workspace_exist_on_ads(output_workspace_norm) and \
                        not does_can_workspace_exist_on_ads(output_workspace_count):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceLABCanNorm", output_workspace_norm)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceHABCanNorm", output_workspace_norm)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a partial can.".format(reduction_mode))
コード例 #4
0
    def set_reduced_can_workspace_on_output(self, output_bundles, output_bundles_part):
        """
        Sets the reduced can workspaces on the output properties.

        The reduced can workspaces can be:
        1. LAB Can
        2. LAB Can Count
        3. LAB Can Norm
        4. HAB Can
        5. HAB Can Count
        6. HAB Can Norm
        :param output_bundles: a list of output bundles
        :param output_bundles_part: a list of partial output bundles
        """
        # Find the LAB Can and HAB Can entries if they exist
        for output_bundle in output_bundles:
            if output_bundle.data_type is DataType.Can:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace is not None and not does_can_workspace_exist_on_ads(output_workspace):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCan", output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCan", output_bundle.output_workspace)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a can.".format(reduction_mode))

        # Find the partial output bundles fo LAB Can and HAB Can if they exist
        for output_bundle_part in output_bundles_part:
            if output_bundle_part.data_type is DataType.Can:
                reduction_mode = output_bundle_part.reduction_mode
                output_workspace_count = output_bundle_part.output_workspace_count
                output_workspace_norm = output_bundle_part.output_workspace_norm
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace_norm is not None and output_workspace_count is not None and \
                        not does_can_workspace_exist_on_ads(output_workspace_norm) and \
                        not does_can_workspace_exist_on_ads(output_workspace_count):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceLABCanNorm", output_workspace_norm)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCanCount", output_workspace_count)
                        self.setProperty("OutputWorkspaceHABCanNorm", output_workspace_norm)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a partial can.".format(reduction_mode))
コード例 #5
0
    def set_reduced_can_workspace_on_output(self, completed_event_bundled):
        """
        Sets the reduced can workspaces on the output properties.

        The reduced can workspaces can be either LAB or HAB
        :param completed_event_bundled: a list containing output bundles
        """
        # Find the LAB Can and HAB Can entries if they exist
        lab_groups = WorkspaceGroup()
        hab_groups = WorkspaceGroup()

        for bundle in completed_event_bundled:
            if bundle.output_bundle.data_type is DataType.CAN:
                reduction_mode = bundle.output_bundle.reduction_mode
                output_workspace = bundle.output_bundle.output_workspace
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.

                if output_workspace is not None and not does_can_workspace_exist_on_ads(
                        output_workspace):
                    if reduction_mode is ReductionMode.LAB:
                        lab_groups.addWorkspace(output_workspace)
                    elif reduction_mode is ReductionMode.HAB:
                        hab_groups.addWorkspace(output_workspace)
                    else:
                        raise RuntimeError(
                            "SANSSingleReduction: The reduction mode {0} should not"
                            " be set with a can.".format(reduction_mode))

        self._set_prop_if_group_has_data("OutputWorkspaceLABCan", lab_groups)
        self._set_prop_if_group_has_data("OutputWorkspaceHABCan", hab_groups)
コード例 #6
0
    def set_reduced_can_workspace_on_output(self, output_bundles):
        """
        Sets the reduced can workspaces on the output properties.

        The reduced can workspaces can be:
        1. LAB Can
        4. HAB Can
        :param output_bundles: a list containing a single list of output bundles
        """
        # Find the LAB Can and HAB Can entries if they exist
        output_bundles = output_bundles[0]
        for output_bundle in output_bundles:
            if output_bundle.data_type is DataType.CAN:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace is not None and not does_can_workspace_exist_on_ads(output_workspace):
                    if reduction_mode is ReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCan", output_workspace)
                    elif reduction_mode is ReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCan", output_bundle.output_workspace)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a can.".format(reduction_mode))
コード例 #7
0
    def set_transmission_workspaces_on_output(self, completed_event_slices,
                                              fit_state):
        calc_can, calc_sample = WorkspaceGroup(), WorkspaceGroup()
        unfit_can, unfit_sample = WorkspaceGroup(), WorkspaceGroup()

        output_hab_or_lab = None
        for bundle in completed_event_slices:
            if output_hab_or_lab is not None and output_hab_or_lab != bundle.output_bundle.reduction_mode:
                continue  # The transmission workspace for HAB/LAB is the same, so only output one
            output_hab_or_lab = bundle.output_bundle.reduction_mode
            calculated_transmission_workspace = bundle.transmission_bundle.calculated_transmission_workspace
            unfitted_transmission_workspace = bundle.transmission_bundle.unfitted_transmission_workspace
            if bundle.transmission_bundle.data_type is DataType.CAN:
                if does_can_workspace_exist_on_ads(
                        calculated_transmission_workspace):
                    # The workspace is cloned here because the transmission runs are diagnostic output so even though
                    # the values already exist they need to be labelled separately for each reduction.
                    calculated_transmission_workspace = CloneWorkspace(
                        calculated_transmission_workspace, StoreInADS=False)
                if does_can_workspace_exist_on_ads(
                        unfitted_transmission_workspace):
                    unfitted_transmission_workspace = CloneWorkspace(
                        unfitted_transmission_workspace, StoreInADS=False)
                if calculated_transmission_workspace:
                    calc_can.addWorkspace(calculated_transmission_workspace)
                if unfitted_transmission_workspace:
                    unfit_can.addWorkspace(unfitted_transmission_workspace)

            elif bundle.transmission_bundle.data_type is DataType.SAMPLE:
                if calculated_transmission_workspace:
                    calc_sample.addWorkspace(calculated_transmission_workspace)
                if unfitted_transmission_workspace:
                    unfit_sample.addWorkspace(unfitted_transmission_workspace)
            else:
                raise RuntimeError(
                    "SANSSingleReduction: The data type {0} should be"
                    " sample or can.".format(
                        bundle.transmission_bundle.data_type))

        self._set_prop_if_group_has_data(
            "OutputWorkspaceCalculatedTransmission", calc_sample)
        self._set_prop_if_group_has_data("OutputWorkspaceUnfittedTransmission",
                                         unfit_sample)
        self._set_prop_if_group_has_data(
            "OutputWorkspaceCalculatedTransmissionCan", calc_can)
        self._set_prop_if_group_has_data(
            "OutputWorkspaceUnfittedTransmissionCan", unfit_can)
コード例 #8
0
    def set_reduced_can_count_and_norm_on_output(self, completed_event_slices):
        """
        Sets the reduced can count and norm group workspaces on the output properties.
        This includes the HAB/LAB counts and Norms

        :param completed_event_slices: a list containing a single list of output bundle parts
        """
        # Find the partial output bundles fo LAB Can and HAB Can if they exist
        lab_can_counts, hab_can_counts = WorkspaceGroup(), WorkspaceGroup()
        lab_can_norms, hab_can_norms = WorkspaceGroup(), WorkspaceGroup()

        for bundle in completed_event_slices:
            if bundle.output_bundle.data_type is DataType.CAN:
                reduction_mode = bundle.parts_bundle.reduction_mode
                output_workspace_count = bundle.parts_bundle.output_workspace_count
                output_workspace_norm = bundle.parts_bundle.output_workspace_norm
                # Make sure that the output workspace is not None which can be the case if there has never been a
                # can set for the reduction.
                if output_workspace_norm is not None and output_workspace_count is not None and \
                        not does_can_workspace_exist_on_ads(output_workspace_norm) and \
                        not does_can_workspace_exist_on_ads(output_workspace_count):
                    if reduction_mode is ReductionMode.LAB:
                        lab_can_counts.addWorkspace(output_workspace_count)
                        lab_can_norms.addWorkspace(output_workspace_norm)
                    elif reduction_mode is ReductionMode.HAB:
                        hab_can_counts.addWorkspace(output_workspace_count)
                        hab_can_norms.addWorkspace(output_workspace_norm)
                    else:
                        raise RuntimeError(
                            "SANSSingleReduction: The reduction mode {0} should not"
                            " be set with a partial can.".format(
                                reduction_mode))

        self._set_prop_if_group_has_data("OutputWorkspaceLABCanCount",
                                         lab_can_counts)
        self._set_prop_if_group_has_data("OutputWorkspaceLABCanNorm",
                                         lab_can_norms)
        self._set_prop_if_group_has_data("OutputWorkspaceHABCanCount",
                                         hab_can_counts)
        self._set_prop_if_group_has_data("OutputWorkspaceHABCanNorm",
                                         hab_can_norms)
コード例 #9
0
 def set_can_and_sam_on_output(self, completed_event_slices):
     """
     Sets the reduced can and sample workspaces.
     These is the LAB/HAB can and sample
     Cans are also output for optimization, so check for double output.
     :param output_bundles: a list containing a single list of output_bundles
     """
     lab_cans, hab_cans = WorkspaceGroup(), WorkspaceGroup()
     lab_samples, hab_samples = WorkspaceGroup(), WorkspaceGroup()
     for bundle in completed_event_slices:
         reduction_mode = bundle.output_bundle.reduction_mode
         output_workspace = bundle.output_bundle.output_workspace
         if bundle.output_bundle.data_type is DataType.CAN:
             if output_workspace is not None and not does_can_workspace_exist_on_ads(
                     output_workspace):
                 if reduction_mode is ReductionMode.LAB:
                     lab_cans.addWorkspace(output_workspace)
                 elif reduction_mode is ReductionMode.HAB:
                     hab_cans.addWorkspace(output_workspace)
                 else:
                     raise RuntimeError(
                         "SANSSingleReduction: The reduction mode {0} should not"
                         " be set with a can.".format(reduction_mode))
         elif bundle.output_bundle.data_type is DataType.SAMPLE:
             if output_workspace is not None and not does_can_workspace_exist_on_ads(
                     output_workspace):
                 if reduction_mode is ReductionMode.LAB:
                     lab_samples.addWorkspace(output_workspace)
                 elif reduction_mode is ReductionMode.HAB:
                     hab_samples.addWorkspace(output_workspace)
                 else:
                     raise RuntimeError(
                         "SANSSingleReduction: The reduction mode {0} should not"
                         " be set with a sample.".format(reduction_mode))
     self._set_prop_if_group_has_data("OutputWorkspaceLABCan", lab_cans)
     self._set_prop_if_group_has_data("OutputWorkspaceHABCan", hab_cans)
     self._set_prop_if_group_has_data("OutputWorkspaceLABSample",
                                      lab_samples)
     self._set_prop_if_group_has_data("OutputWorkspaceHABSample",
                                      hab_samples)
コード例 #10
0
 def set_transmission_workspaces_on_output(self, transmission_bundles, fit_state):
     for transmission_bundle in transmission_bundles:
         fit_performed = fit_state[DataType.to_string(transmission_bundle.data_type)].fit_type != FitType.NoFit
         calculated_transmission_workspace = transmission_bundle.calculated_transmission_workspace
         unfitted_transmission_workspace = transmission_bundle.unfitted_transmission_workspace
         if transmission_bundle.data_type is DataType.Can:
             if does_can_workspace_exist_on_ads(calculated_transmission_workspace):
                 # The workspace is cloned here because the transmission runs are diagnostic output so even though
                 # the values already exist they need to be labelled seperately for each reduction.
                 calculated_transmission_workspace = CloneWorkspace(calculated_transmission_workspace, StoreInADS=False)
             if does_can_workspace_exist_on_ads(unfitted_transmission_workspace):
                 unfitted_transmission_workspace = CloneWorkspace(unfitted_transmission_workspace, StoreInADS=False)
             if fit_performed:
                 self.setProperty("OutputWorkspaceCalculatedTransmissionCan", calculated_transmission_workspace)
             self.setProperty("OutputWorkspaceUnfittedTransmissionCan", unfitted_transmission_workspace)
         elif transmission_bundle.data_type is DataType.Sample:
             if fit_performed:
                 self.setProperty("OutputWorkspaceCalculatedTransmission", calculated_transmission_workspace)
             self.setProperty("OutputWorkspaceUnfittedTransmission", unfitted_transmission_workspace)
         else:
             raise RuntimeError("SANSSingleReduction: The data type {0} should be"
                                " sample or can.".format(transmission_bundle.data_type))
コード例 #11
0
    def set_can_and_sam_on_output(self, output_bundles):
        '''
        Sets the reduced can and sam workspaces.
        These can be:
        1. LAB Can
        2. HAB Can
        3. LAB Sample
        4. HAB Sample
        Cans are also output for optimization, so check for double output.
        :param output_bundles: a list of output_bundles
        '''

        for output_bundle in output_bundles:
            if output_bundle.data_type is DataType.Can:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace

                if output_workspace is not None and not does_can_workspace_exist_on_ads(
                        output_workspace):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCan",
                                         output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCan",
                                         output_bundle.output_workspace)
                    else:
                        raise RuntimeError(
                            "SANSSingleReduction: The reduction mode {0} should not"
                            " be set with a can.".format(reduction_mode))

            elif output_bundle.data_type is DataType.Sample:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace

                if output_workspace is not None:
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABSample",
                                         output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABSample",
                                         output_bundle.output_workspace)
                    else:
                        raise RuntimeError(
                            "SANSSingleReduction: The reduction mode {0} should not"
                            " be set with a sample.".format(reduction_mode))
コード例 #12
0
    def set_reduced_can_workspace_on_output(self, output_bundles):
        """
        Sets the reduced can group workspaces on the output properties.
        The reduced can workspaces can be:
        LAB Can or
        HAB Can

        :param output_bundles: a list of output bundles
        """
        workspace_group_lab_can = WorkspaceGroup()
        workspace_group_hab_can = WorkspaceGroup()
        # Find the LAB Can and HAB Can entries if they exist
        for component_bundle in output_bundles:
            for output_bundle in component_bundle:
                if output_bundle.data_type is DataType.Can:
                    reduction_mode = output_bundle.reduction_mode
                    output_workspace = output_bundle.output_workspace
                    # Make sure that the output workspace is not None which can be the case if there has never been a
                    # can set for the reduction.
                    if output_workspace is not None and not does_can_workspace_exist_on_ads(
                            output_workspace):
                        name = self._get_output_workspace_name(
                            output_bundle.state,
                            output_bundle.reduction_mode,
                            can=True)
                        AnalysisDataService.addOrReplace(
                            name, output_workspace)
                        if reduction_mode is ISISReductionMode.LAB:
                            workspace_group_lab_can.addWorkspace(
                                output_workspace)
                        elif reduction_mode is ISISReductionMode.HAB:
                            workspace_group_hab_can.addWorkspace(
                                output_workspace)
                        else:
                            raise RuntimeError(
                                "SANSSingleReduction: The reduction mode {0} should not"
                                " be set with a can.".format(reduction_mode))
        if workspace_group_lab_can.size() > 0:
            # LAB group workspace is non-empty, so we want to set it as output
            self.setProperty("OutputWorkspaceLABCan", workspace_group_lab_can)
        if workspace_group_hab_can.size() > 0:
            self.setProperty("OutputWorkspaceHABCan", workspace_group_hab_can)
コード例 #13
0
    def set_can_and_sam_on_output(self, output_bundles):
        '''
        Sets the reduced can and sam workspaces.
        These can be:
        1. LAB Can
        2. HAB Can
        3. LAB Sample
        4. HAB Sample
        Cans are also output for optimization, so check for double output.
        :param output_bundles: a list of output_bundles
        '''

        for output_bundle in output_bundles:
            if output_bundle.data_type is DataType.Can:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace

                if output_workspace is not None and not does_can_workspace_exist_on_ads(output_workspace):
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABCan", output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABCan", output_bundle.output_workspace)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a can.".format(reduction_mode))

            elif output_bundle.data_type is DataType.Sample:
                reduction_mode = output_bundle.reduction_mode
                output_workspace = output_bundle.output_workspace

                if output_workspace is not None:
                    if reduction_mode is ISISReductionMode.LAB:
                        self.setProperty("OutputWorkspaceLABSample", output_workspace)
                    elif reduction_mode is ISISReductionMode.HAB:
                        self.setProperty("OutputWorkspaceHABSample", output_bundle.output_workspace)
                    else:
                        raise RuntimeError("SANSSingleReduction: The reduction mode {0} should not"
                                           " be set with a sample.".format(reduction_mode))
コード例 #14
0
    def set_can_and_sam_on_output(self, output_bundles):
        """
        Sets the reduced can and sam workspaces.
        These can be:
        1. LAB Can
        2. HAB Can
        3. LAB Sample
        4. HAB Sample
        Cans are also output for optimization, so check for double output.
        :param output_bundles: a list of output_bundles
        """
        workspace_group_lab_can = WorkspaceGroup()
        workspace_group_hab_can = WorkspaceGroup()
        workspace_group_lab_sample = WorkspaceGroup()
        workspace_group_hab_sample = WorkspaceGroup()

        for component_bundle in output_bundles:
            for output_bundle in component_bundle:
                if output_bundle.data_type is DataType.Can:
                    reduction_mode = output_bundle.reduction_mode
                    output_workspace = output_bundle.output_workspace

                    if output_workspace is not None and not does_can_workspace_exist_on_ads(
                            output_workspace):
                        can_name = self._get_output_workspace_name(
                            output_bundle.state,
                            output_bundle.reduction_mode,
                            can=True)
                        AnalysisDataService.addOrReplace(
                            can_name, output_workspace)
                        if reduction_mode is ISISReductionMode.LAB:
                            workspace_group_lab_can.addWorkspace(
                                output_workspace)
                        elif reduction_mode is ISISReductionMode.HAB:
                            workspace_group_hab_can.addWorkspace(
                                output_workspace)
                        else:
                            raise RuntimeError(
                                "SANSSingleReduction: The reduction mode {0} should not"
                                " be set with a can.".format(reduction_mode))
                elif output_bundle.data_type is DataType.Sample:
                    reduction_mode = output_bundle.reduction_mode
                    output_workspace = output_bundle.output_workspace

                    if output_workspace is not None:
                        sample_name = self._get_output_workspace_name(
                            output_bundle.state,
                            output_bundle.reduction_mode,
                            sample=True)
                        AnalysisDataService.addOrReplace(
                            sample_name, output_workspace)
                        if reduction_mode is ISISReductionMode.LAB:
                            workspace_group_lab_sample.addWorkspace(
                                output_workspace)
                        elif reduction_mode is ISISReductionMode.HAB:
                            workspace_group_hab_sample.addWorkspace(
                                output_workspace)
                        else:
                            raise RuntimeError(
                                "SANSSingleReduction: The reduction mode {0} should not"
                                " be set with a sample.".format(
                                    reduction_mode))

        if workspace_group_hab_can.size() > 0:
            self.setProperty("OutputWorkspaceHABCan", workspace_group_hab_can)
        if workspace_group_hab_sample.size() > 0:
            self.setProperty("OutputWorkspaceHABSample",
                             workspace_group_hab_sample)
        if workspace_group_lab_can.size() > 0:
            self.setProperty("OutputWorkspaceLABCan", workspace_group_lab_can)
        if workspace_group_lab_sample.size() > 0:
            self.setProperty("OutputWorkspaceLABSample",
                             workspace_group_lab_sample)
コード例 #15
0
    def set_reduced_can_count_and_norm_on_output(self, output_bundles_parts):
        """
        Sets the reduced can count and norm group workspaces on the output properties.
        The reduced can workspaces can be:
        1. LAB Can Count
        2. LAB Can Norm
        3. HAB Can Count
        4. HAB Can Norm

        :param output_bundles_parts: a list of output bundle parts
        """
        workspace_group_lab_can_count = WorkspaceGroup()
        workspace_group_lab_can_norm = WorkspaceGroup()
        workspace_group_hab_can_count = WorkspaceGroup()
        workspace_group_hab_can_norm = WorkspaceGroup()
        # Find the partial output bundles fo LAB Can and HAB Can if they exist
        for event_slice_bundles in output_bundles_parts:
            for output_bundle_part in event_slice_bundles:
                if output_bundle_part.data_type is DataType.Can:
                    reduction_mode = output_bundle_part.reduction_mode
                    output_workspace_count = output_bundle_part.output_workspace_count
                    output_workspace_norm = output_bundle_part.output_workspace_norm
                    # Make sure that the output workspace is not None which can be the case if there has never been a
                    # can set for the reduction.
                    if output_workspace_norm is not None and output_workspace_count is not None and \
                            not does_can_workspace_exist_on_ads(output_workspace_norm) and \
                            not does_can_workspace_exist_on_ads(output_workspace_count):
                        name = self._get_output_workspace_name(
                            output_bundle_part.state,
                            output_bundle_part.reduction_mode)
                        count_name = name + "_hab_can_count"
                        norm_name = name + "_hab_can_norm"
                        AnalysisDataService.addOrReplace(
                            count_name, output_workspace_count)
                        AnalysisDataService.addOrReplace(
                            norm_name, output_workspace_norm)
                        if reduction_mode is ISISReductionMode.LAB:
                            workspace_group_lab_can_count.addWorkspace(
                                output_workspace_count)
                            workspace_group_lab_can_norm.addWorkspace(
                                output_workspace_norm)
                        elif reduction_mode is ISISReductionMode.HAB:
                            workspace_group_hab_can_count.addWorkspace(
                                output_workspace_count)
                            workspace_group_hab_can_norm.addWorkspace(
                                output_workspace_norm)
                        else:
                            raise RuntimeError(
                                "SANSSingleReduction: The reduction mode {0} should not"
                                " be set with a partial can.".format(
                                    reduction_mode))
        if workspace_group_lab_can_count.size() > 0:
            self.setProperty("OutputWorkspaceLABCanCount",
                             workspace_group_lab_can_count)
        if workspace_group_lab_can_norm.size() > 0:
            self.setProperty("OutputWorkspaceLABCanNorm",
                             workspace_group_lab_can_norm)
        if workspace_group_hab_can_count.size() > 0:
            self.setProperty("OutputWorkspaceHABCanCount",
                             workspace_group_hab_can_count)
        if workspace_group_hab_can_norm.size() > 0:
            self.setProperty("OutputWorkspaceHABCanNorm",
                             workspace_group_hab_can_norm)