def PyExec(self):
        # 1. Get the index of the batch reduction
        index = self.getProperty("RowIndex").value

        if index == Property.EMPTY_INT:
            return

        # 2. Get the state for the index from the PropertyManagerDataService
        property_manager_service = PropertyManagerService()
        state = property_manager_service.get_single_state_from_pmds(
            index_to_retrieve=index)
        # 3. Get some global settings
        use_optimizations = self.getProperty("UseOptimizations").value
        output_mode_as_string = self.getProperty("OutputMode").value
        output_mode = OutputMode.from_string(output_mode_as_string)
        plot_results = self.getProperty('PlotResults').value
        output_graph = self.getProperty('OutputGraph').value

        # 3. Run the sans_batch script
        sans_batch = SANSBatchReduction()
        sans_batch(states=state,
                   use_optimizations=use_optimizations,
                   output_mode=output_mode,
                   plot_results=plot_results,
                   output_graph=output_graph)
Esempio n. 2
0
    def get_processing_options(self):
        """
        Creates a processing string for the data processor widget

        :return: A processing string for the data processor widget
        """
        global_options = ""

        # Check if optimizations should be used
        optimization_selection = "UseOptimizations=1" if self._view.use_optimizations else "UseOptimizations=0"
        global_options += optimization_selection

        # Get the output mode
        output_mode = self._view.output_mode
        output_mode_selection = "OutputMode=" + OutputMode.to_string(
            output_mode)
        global_options += ","
        global_options += output_mode_selection

        return global_options
    def PyExec(self):
        # 1. Get the index of the batch reduction
        index = self.getProperty("RowIndex").value

        if index == Property.EMPTY_INT:
            return

        # 2. Get the state for the index from the PropertyManagerDataService
        property_manager_service = PropertyManagerService()
        state = property_manager_service.get_single_state_from_pmds(index_to_retrieve=index)
        # 3. Get some global settings
        use_optimizations = self.getProperty("UseOptimizations").value
        output_mode_as_string = self.getProperty("OutputMode").value
        output_mode = OutputMode.from_string(output_mode_as_string)
        plot_results = self.getProperty('PlotResults').value
        output_graph = self.getProperty('OutputGraph').value

        # 3. Run the sans_batch script
        sans_batch = SANSBatchReduction()
        sans_batch(states=state, use_optimizations=use_optimizations, output_mode=output_mode, plot_results=plot_results
                   , output_graph=output_graph)
def create_properties():
    properties = [algorithm_list_entry(column_name="SampleScatter",
                                       algorithm_property="SampleScatter",
                                       description='The run number of the scatter sample',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="ssp",
                                       algorithm_property="SampleScatterPeriod",
                                       description='The sample scatter period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="SampleTrans",
                                       algorithm_property="SampleTransmission",
                                       description='The run number of the transmission sample',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="stp",
                                       algorithm_property="SampleTransmissionPeriod",
                                       description='The sample transmission period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="SampleDirect",
                                       algorithm_property="SampleDirect",
                                       description='The run number of the direct sample',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="sdp",
                                       algorithm_property="SampleDirectPeriod",
                                       description='The sample direct period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="CanScatter",
                                       algorithm_property="CanScatter",
                                       description='The run number of the scatter can',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="csp",
                                       algorithm_property="CanScatterPeriod",
                                       description='The can scatter period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="CanTrans",
                                       algorithm_property="CanTransmission",
                                       description='The run number of the transmission can',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="ctp",
                                       algorithm_property="CanTransmissionPeriod",
                                       description='The can transmission period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="CanDirect",
                                       algorithm_property="CanDirect",
                                       description='The run number of the direct can',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="cdp",
                                       algorithm_property="CanDirectPeriod",
                                       description='The can direct period',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="",
                                       algorithm_property="UseOptimizations",
                                       description='If optimizations should be used.',
                                       show_value=False,
                                       default=False,
                                       prefix='',
                                       property_type=bool),
                  algorithm_list_entry(column_name="OutputName",
                                       algorithm_property="OutputName",
                                       description='An optional custom output workspace name.',
                                       show_value=False,
                                       default='',
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="User File",
                                       algorithm_property="UserFile",
                                       description=('The user file to use, this will override GUI changes for this row.'
                                                    ' If left unspecified default will be used'),
                                       show_value=False,
                                       default="",
                                       prefix='',
                                       property_type=str),
                  algorithm_list_entry(column_name="",
                                       algorithm_property="RowIndex",
                                       description='The row index (which is automatically populated by the GUI)',
                                       show_value=False,
                                       default=Property.EMPTY_INT,
                                       prefix='',
                                       property_type=int),
                  algorithm_list_entry(column_name="",
                                       algorithm_property="OutputMode",
                                       description='The output mode.',
                                       show_value=False,
                                       default=OutputMode.to_string(OutputMode.PublishToADS),
                                       prefix='',
                                       property_type=bool)
                  ]
    return properties
def create_properties(show_periods=True):
    if show_periods:
        properties = [algorithm_list_entry(column_name="SampleScatter",
                                           algorithm_property="SampleScatter",
                                           description='The run number of the scatter sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="ssp",
                                           algorithm_property="SampleScatterPeriod",
                                           description='The sample scatter period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="SampleTrans",
                                           algorithm_property="SampleTransmission",
                                           description='The run number of the transmission sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="stp",
                                           algorithm_property="SampleTransmissionPeriod",
                                           description='The sample transmission period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="SampleDirect",
                                           algorithm_property="SampleDirect",
                                           description='The run number of the direct sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="sdp",
                                           algorithm_property="SampleDirectPeriod",
                                           description='The sample direct period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanScatter",
                                           algorithm_property="CanScatter",
                                           description='The run number of the scatter can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="csp",
                                           algorithm_property="CanScatterPeriod",
                                           description='The can scatter period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanTrans",
                                           algorithm_property="CanTransmission",
                                           description='The run number of the transmission can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="ctp",
                                           algorithm_property="CanTransmissionPeriod",
                                           description='The can transmission period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanDirect",
                                           algorithm_property="CanDirect",
                                           description='The run number of the direct can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="cdp",
                                           algorithm_property="CanDirectPeriod",
                                           description='The can direct period',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="UseOptimizations",
                                           description='If optimizations should be used.',
                                           show_value=False,
                                           default=False,
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="PlotResults",
                                           description='If results should be plotted.',
                                           show_value=False,
                                           default=False,
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="OutputName",
                                           algorithm_property="OutputName",
                                           description='An optional custom output workspace name.',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="User File",
                                           algorithm_property="UserFile",
                                           description=('The user file to use, this will override GUI changes for this row.'
                                                        ' If left unspecified default will be used'),
                                           show_value=False,
                                           default="",
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="RowIndex",
                                           description='The row index (which is automatically populated by the GUI)',
                                           show_value=False,
                                           default=Property.EMPTY_INT,
                                           prefix='',
                                           property_type=int),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="OutputMode",
                                           description='The output mode.',
                                           show_value=False,
                                           default=OutputMode.to_string(OutputMode.PublishToADS),
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="OutputGraph",
                                           description='The name of the graph to output to.',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str)
                      ]
    else:
        properties = [algorithm_list_entry(column_name="SampleScatter",
                                           algorithm_property="SampleScatter",
                                           description='The run number of the scatter sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="SampleTrans",
                                           algorithm_property="SampleTransmission",
                                           description='The run number of the transmission sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="SampleDirect",
                                           algorithm_property="SampleDirect",
                                           description='The run number of the direct sample',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanScatter",
                                           algorithm_property="CanScatter",
                                           description='The run number of the scatter can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanTrans",
                                           algorithm_property="CanTransmission",
                                           description='The run number of the transmission can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="CanDirect",
                                           algorithm_property="CanDirect",
                                           description='The run number of the direct can',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="UseOptimizations",
                                           description='If optimizations should be used.',
                                           show_value=False,
                                           default=False,
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="PlotResults",
                                           description='If results should be plotted.',
                                           show_value=False,
                                           default=False,
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="OutputName",
                                           algorithm_property="OutputName",
                                           description='An optional custom output workspace name.',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="User File",
                                           algorithm_property="UserFile",
                                           description=('The user file to use, this will override GUI changes for this row.'
                                                        ' If left unspecified default will be used'),
                                           show_value=False,
                                           default="",
                                           prefix='',
                                           property_type=str),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="RowIndex",
                                           description='The row index (which is automatically populated by the GUI)',
                                           show_value=False,
                                           default=Property.EMPTY_INT,
                                           prefix='',
                                           property_type=int),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="OutputMode",
                                           description='The output mode.',
                                           show_value=False,
                                           default=OutputMode.to_string(OutputMode.PublishToADS),
                                           prefix='',
                                           property_type=bool),
                      algorithm_list_entry(column_name="",
                                           algorithm_property="OutputGraph",
                                           description='The name of the graph to output to.',
                                           show_value=False,
                                           default='',
                                           prefix='',
                                           property_type=str)
                      ]
    return properties