示例#1
0
    def plot_result(self):
        """
            Plot the scaled data sets
        """
        low_xmin = util._check_and_get_float_line_edit(self._content.low_min_edit)
        low_xmax = util._check_and_get_float_line_edit(self._content.low_max_edit)
        med_xmin = util._check_and_get_float_line_edit(self._content.medium_min_edit)
        med_xmax = util._check_and_get_float_line_edit(self._content.medium_max_edit)

        ws_list = []
        if self._low_q_data is not None:
            xmin,_ = self._low_q_data.get_skipped_range()
            self._low_q_data.apply_scale(xmin, low_xmax)
            ws_list.append(self._low_q_data.get_scaled_ws())

        if self._medium_q_data is not None:
            _,xmax = self._medium_q_data.get_skipped_range()
            if self._high_q_data is not None:
                xmax = med_xmax
            self._medium_q_data.apply_scale(low_xmin, xmax)
            ws_list.append(self._medium_q_data.get_scaled_ws())

        if self._high_q_data is not None:
            _,xmax = self._high_q_data.get_skipped_range()
            self._high_q_data.apply_scale(med_xmin, xmax)
            ws_list.append(self._high_q_data.get_scaled_ws())

        if len(ws_list)>0:
            g = mantidplot.graph(self._graph)
            if g is None or not self._plotted:
                g = mantidplot.plotSpectrum(ws_list, [0], True)
                g.setName(self._graph)
                self._plotted = True
示例#2
0
    def plot_result(self):
        """
            Plot the scaled data sets
        """
        low_xmin = util._check_and_get_float_line_edit(self._content.low_min_edit)
        low_xmax = util._check_and_get_float_line_edit(self._content.low_max_edit)
        med_xmin = util._check_and_get_float_line_edit(self._content.medium_min_edit)
        med_xmax = util._check_and_get_float_line_edit(self._content.medium_max_edit)

        ws_list = []
        if self._low_q_data is not None:
            xmin, _ = self._low_q_data.get_skipped_range()
            self._low_q_data.apply_scale(xmin, low_xmax)
            ws_list.append(self._low_q_data.get_scaled_ws())

        if self._medium_q_data is not None:
            _, xmax = self._medium_q_data.get_skipped_range()
            if self._high_q_data is not None:
                xmax = med_xmax
            self._medium_q_data.apply_scale(low_xmin, xmax)
            ws_list.append(self._medium_q_data.get_scaled_ws())

        if self._high_q_data is not None:
            _, xmax = self._high_q_data.get_skipped_range()
            self._high_q_data.apply_scale(med_xmin, xmax)
            ws_list.append(self._high_q_data.get_scaled_ws())

        if len(ws_list) > 0:
            g = mantidplot.graph(self._graph)
            if g is None or not self._plotted:
                g = mantidplot.plotSpectrum(ws_list, [0], True)
                g.setName(self._graph)
                self._plotted = True
示例#3
0
    def on_processed_clicked(self):
        """
        Prepares the batch reduction.

        0. Validate rows and create dummy workspace if it does not exist
        1. Sets up the states
        2. Adds a dummy input workspace
        3. Adds row index information
        """
        try:
            self._view.disable_buttons()
            self._processing = True
            self.sans_logger.information("Starting processing of batch table.")

            # 1. Set up the states and convert them into property managers
            selected_rows = self._view.get_selected_rows()
            selected_rows = selected_rows if selected_rows else range(
                self._table_model.get_number_of_rows())
            for row in selected_rows:
                self._table_model.reset_row_state(row)
            self.update_view_from_table_model()
            states, errors = self.get_states(row_index=selected_rows)

            for row, error in errors.items():
                self.on_processing_error(row, error)

            if not states:
                self.on_processing_finished(None)
                return

            # 4. Create the graph if continuous output is specified
            if mantidplot:
                if self._view.plot_results and not mantidplot.graph(
                        self.output_graph):
                    mantidplot.newGraph(self.output_graph)

            # Check if optimizations should be used
            use_optimizations = self._view.use_optimizations

            # Get the output mode
            output_mode = self._view.output_mode

            # Check if results should be plotted
            plot_results = self._view.plot_results

            # Get the name of the graph to output to
            output_graph = self.output_graph

            self.progress = 0
            setattr(self._view, 'progress_bar_value', self.progress)
            setattr(self._view, 'progress_bar_maximum', len(states))
            self.batch_process_runner.process_states(states, use_optimizations,
                                                     output_mode, plot_results,
                                                     output_graph)

        except Exception as e:
            self._view.enable_buttons()
            self.sans_logger.error("Process halted due to: {}".format(str(e)))
            self.display_warning_box('Warning', 'Process halted', str(e))
示例#4
0
        def connect(self,
                    ws,
                    call_back,
                    xmin=None,
                    xmax=None,
                    range_min=None,
                    range_max=None,
                    x_title=None,
                    log_scale=False,
                    ws_output_base=None):
            if not IS_IN_MANTIDPLOT:
                print "RangeSelector cannot be used output MantidPlot"
                return

            self._call_back = call_back
            self._ws_output_base = ws_output_base

            mantidplot.app.connect(
                mantidplot.app.mantidUI,
                QtCore.SIGNAL("x_range_update(double,double)"),
                self._call_back)
            g = mantidplot.graph(self._graph)

            if g is not None:
                g.close()

            g = mantidplot.plotSpectrum(ws, [0], True)
            g.setName(self._graph)
            l = g.activeLayer()
            try:
                title = ws[0].replace("_", " ")
                title.strip()
            except:
                title = " "
            l.setTitle(" ")
            l.setCurveTitle(0, title)
            if log_scale:
                l.logYlinX()
            if x_title is not None:
                l.setXTitle(x_title)
            if xmin is not None and xmax is not None:
                l.setScale(2, xmin, xmax)

            if range_min is not None and range_max is not None:
                mantidplot.selectMultiPeak(g, False, range_min, range_max)
            else:
                mantidplot.selectMultiPeak(g, False)
示例#5
0
        def connect(self, ws, call_back, xmin=None, xmax=None, 
                    range_min=None, range_max=None, x_title=None,
                    log_scale=False,
                    ws_output_base=None):
            if not IS_IN_MANTIDPLOT:
                print "RangeSelector cannot be used output MantidPlot"
                return
            
            self._call_back = call_back
            self._ws_output_base = ws_output_base
            
            mantidplot.app.connect(mantidplot.app.mantidUI,
                             QtCore.SIGNAL("x_range_update(double,double)"),
                             self._call_back)
            g = mantidplot.graph(self._graph)

            if g is not None:
                g.close()
                
            g = mantidplot.plotSpectrum(ws, [0], True)
            g.setName(self._graph)        
            l=g.activeLayer()
            try:
                title = ws[0].replace("_"," ")
                title.strip()
            except:
                title = " "
            l.setTitle(" ")
            l.setCurveTitle(0, title)
            if log_scale:
                l.logYlinX()
            if x_title is not None:
                l.setXTitle(x_title)
            if xmin is not None and xmax is not None:
                l.setScale(2,xmin,xmax)
                
            if range_min is not None and range_max is not None:
                mantidplot.selectMultiPeak(g, False, range_min, range_max)
            else:
                mantidplot.selectMultiPeak(g, False)
示例#6
0
    def plot_result(self):
        """
            Plot the scaled data sets
        """
        pol_dict = {
            "Off Off": ReflData.OFF_OFF,
            "On Off": ReflData.ON_OFF,
            "Off On": ReflData.OFF_ON,
            "On On": ReflData.ON_ON
        }

        for pol in pol_dict.keys():
            s = Stitcher()
            ws_list = []
            for item in self._workspace_list:
                d = item.get_user_data(pol_dict[pol])
                if d is not None:
                    ws_list.append(d.get_scaled_ws())
                    s.append(d)

            if len(ws_list) > 0:
                combined_ws = "ref_%s" % pol.replace(" ", "_")
                if self._settings.instrument_name == "REFL":
                    combined_ws = "ref_combined"
                s.get_scaled_data(combined_ws)

                plot_name = '%s: %s' % (self._graph, pol)
                g = mantidplot.graph(plot_name)
                if g is not None:
                    continue
                g = mantidplot.plotSpectrum(ws_list, [0], True)
                g.setName(plot_name)
                l = g.activeLayer()
                l.logYlinX()
                if self._settings.instrument_name == "REFL":
                    l.setTitle("Reflectivity")
                else:
                    l.setTitle("Polarization state: %s" % pol)
示例#7
0
    def plot_result(self):
        """
            Plot the scaled data sets
        """
        pol_dict = {"Off Off" : ReflData.OFF_OFF,
                    "On Off" : ReflData.ON_OFF,
                    "Off On" : ReflData.OFF_ON,
                    "On On"  : ReflData.ON_ON }

        for pol in pol_dict.keys():
            s = Stitcher()
            ws_list = []
            for item in self._workspace_list:
                d = item.get_user_data( pol_dict[pol] )
                if d is not None:
                    ws_list.append(d.get_scaled_ws())
                    s.append(d)

            if len(ws_list)>0:
                combined_ws = "ref_%s" % pol.replace(" ", "_")
                if self._settings.instrument_name == "REFL":
                    combined_ws = "ref_combined"
                s.get_scaled_data(combined_ws)

                plot_name = '%s: %s' % (self._graph, pol)
                g = mantidplot.graph(plot_name)
                if g is not None:
                    continue
                g = mantidplot.plotSpectrum(ws_list, [0], True)
                g.setName(plot_name)
                l=g.activeLayer()
                l.logYlinX()
                if self._settings.instrument_name == "REFL":
                    l.setTitle("Reflectivity")
                else:
                    l.setTitle("Polarization state: %s" % pol)