コード例 #1
0
    def plot_histo(self,
                   beam_out,
                   progressBarValue,
                   var,
                   plot_canvas_index,
                   title,
                   xtitle,
                   ytitle,
                   xum=""):
        if self.plot_canvas[plot_canvas_index] is None:
            self.plot_canvas[
                plot_canvas_index] = ShadowPlot.DetailedHistoWidget()
            self.tab[plot_canvas_index].layout().addWidget(
                self.plot_canvas[plot_canvas_index])

        self.plot_canvas[plot_canvas_index].plot_histo(
            beam_out._beam,
            var,
            1,
            None,
            23,
            title,
            xtitle,
            ytitle,
            xum=xum,
            conv=self.workspace_units_to_cm)

        self.progressBarSet(progressBarValue)
コード例 #2
0
    def replace_fig(self, beam, var, xrange, title, xtitle, ytitle, xum):
        if self.plot_canvas is None:
            if self.iterative_mode < 2:
                self.plot_canvas = ShadowPlot.DetailedHistoWidget(
                    y_scale_factor=1.14)
            else:
                if self.plot_type == 0:
                    self.plot_canvas = ScanHistoWidget(
                        self.workspace_units_to_cm)
                elif self.plot_type == 1:
                    self.plot_canvas = Scan3DHistoWidget(
                        self.workspace_units_to_cm,
                        type=Scan3DHistoWidget.PlotType.LINES
                        if self.plot_type_3D == 0 else
                        Scan3DHistoWidget.PlotType.SURFACE)

                self.plot_canvas_stats = DoublePlotWidget(parent=None)
                self.image_box_stats.layout().addWidget(self.plot_canvas_stats)

            self.image_box.layout().addWidget(self.plot_canvas)

        if self.iterative_mode == 0:
            self.last_ticket = None
            self.current_histo_data = None
            self.current_stats = None
            self.last_histo_data = None
            self.histo_index = -1
            self.plot_canvas.plot_histo(beam._beam,
                                        var,
                                        self.rays,
                                        xrange,
                                        self.weight_column_index,
                                        title,
                                        xtitle,
                                        ytitle,
                                        nbins=self.number_of_bins,
                                        xum=xum,
                                        conv=self.workspace_units_to_cm)

        elif self.iterative_mode == 1:
            self.current_histo_data = None
            self.current_stats = None
            self.last_histo_data = None
            self.histo_index = -1
            self.last_ticket = self.plot_canvas.plot_histo(
                beam._beam,
                var,
                self.rays,
                xrange,
                self.weight_column_index,
                title,
                xtitle,
                ytitle,
                nbins=self.number_of_bins,
                xum=xum,
                conv=self.workspace_units_to_cm,
                ticket_to_add=self.last_ticket)
        else:
            if not beam.scanned_variable_data is None:
                self.last_ticket = None
                self.histo_index += 1

                um = beam.scanned_variable_data.get_scanned_variable_um()
                um = " " + um if um.strip() == "" else " [" + um + "]"

                histo_data = self.plot_canvas.plot_histo(
                    beam=beam,
                    col=var,
                    nbins=self.number_of_bins,
                    title=title,
                    xtitle=xtitle,
                    ytitle=ytitle,
                    histo_index=self.histo_index,
                    scan_variable_name=beam.scanned_variable_data.
                    get_scanned_variable_display_name() + um,
                    scan_variable_value=beam.scanned_variable_data.
                    get_scanned_variable_value(),
                    offset=0.0 if self.last_histo_data is None else
                    self.last_histo_data.offset,
                    xrange=xrange,
                    show_reference=False,
                    add_labels=self.add_labels == 1,
                    has_colormap=self.has_colormap == 1)
                scanned_variable_value = beam.scanned_variable_data.get_scanned_variable_value(
                )

                if isinstance(scanned_variable_value, str):
                    histo_data.scan_value = self.histo_index + 1
                else:
                    histo_data.scan_value = beam.scanned_variable_data.get_scanned_variable_value(
                    )

                if not histo_data.bins is None:
                    if self.current_histo_data is None:
                        self.current_histo_data = HistogramDataCollection(
                            histo_data)
                    else:
                        self.current_histo_data.add_histogram_data(histo_data)

                if self.current_stats is None:
                    self.current_stats = StatisticalDataCollection(histo_data)
                else:
                    self.current_stats.add_statistical_data(histo_data)

                self.last_histo_data = histo_data

                if self.sigma_fwhm_size == 0:
                    sizes = self.current_stats.get_sigmas()
                    label_size = "Sigma " + xum
                else:
                    sizes = self.current_stats.get_fwhms()
                    label_size = "FWHM " + xum

                if self.absolute_relative_intensity == 0:  #relative
                    if self.peak_integral_intensity == 0:  # peak
                        intensities = self.current_stats.get_relative_peak_intensities(
                        )
                        label_intensity = "Relative Peak Intensity"
                    else:
                        intensities = self.current_stats.get_relative_integral_intensities(
                        )
                        label_intensity = "Relative Integral Intensity"
                else:
                    if self.peak_integral_intensity == 0:  # peak
                        intensities = self.current_stats.get_absolute_peak_intensities(
                        )
                        label_intensity = "Absolute Peak Intensity"
                    else:
                        intensities = self.current_stats.get_absolute_integral_intensities(
                        )
                        label_intensity = "Absolute Integral Intensity"

                self.plot_canvas_stats.plotCurves(
                    self.current_stats.get_scan_values(), sizes, intensities,
                    "Statistics",
                    beam.scanned_variable_data.
                    get_scanned_variable_display_name() + um, label_size,
                    label_intensity)
コード例 #3
0
    def replace_fig(self, beam, var, xrange, title, xtitle, ytitle, xum):
        if self.plot_canvas is None:
            self.plot_canvas = ShadowPlot.DetailedHistoWidget(
                y_scale_factor=1.14)
            self.image_box.layout().addWidget(self.plot_canvas)

        try:
            if self.autosave == 1:
                if self.autosave_file is None:
                    self.autosave_file = ShadowPlot.HistogramHdf5File(
                        congruence.checkDir(self.autosave_file_name))
                elif self.autosave_file.filename != congruence.checkFileName(
                        self.autosave_file_name):
                    self.autosave_file.close()
                    self.autosave_file = ShadowPlot.HistogramHdf5File(
                        congruence.checkDir(self.autosave_file_name))

            if self.keep_result == 1:
                self.cumulated_ticket, last_ticket = self.plot_canvas.plot_histo(
                    beam,
                    var,
                    self.rays,
                    xrange,
                    self.weight_column_index,
                    title,
                    xtitle,
                    ytitle,
                    nbins=self.number_of_bins,
                    xum=xum,
                    conv=self.workspace_units_to_cm,
                    ticket_to_add=self.cumulated_ticket)

                self.plotted_ticket = self.cumulated_ticket

                if self.autosave == 1:
                    self.autosave_prog_id += 1
                    self.autosave_file.write_coordinates(self.cumulated_ticket)
                    dataset_name = self.weight_column.itemText(
                        self.weight_column_index)

                    self.autosave_file.add_histogram(self.cumulated_ticket,
                                                     dataset_name=dataset_name)

                    if self.autosave_partial_results == 1:
                        if last_ticket is None:
                            self.autosave_file.add_histogram(
                                self.cumulated_ticket,
                                plot_name="Histogram #" +
                                str(self.autosave_prog_id),
                                dataset_name=dataset_name)
                        else:
                            self.autosave_file.add_histogram(
                                last_ticket,
                                plot_name="Histogram #" +
                                str(self.autosave_prog_id),
                                dataset_name=dataset_name)

                    self.autosave_file.flush()
            else:
                ticket, _ = self.plot_canvas.plot_histo(
                    beam,
                    var,
                    self.rays,
                    xrange,
                    self.weight_column_index,
                    title,
                    xtitle,
                    ytitle,
                    nbins=self.number_of_bins,
                    xum=xum,
                    conv=self.workspace_units_to_cm)

                self.cumulated_ticket = None
                self.plotted_ticket = ticket

                if self.autosave == 1:
                    self.autosave_prog_id += 1
                    self.autosave_file.write_coordinates(ticket)
                    self.autosave_file.add_histogram(
                        ticket,
                        dataset_name=self.weight_column.itemText(
                            self.weight_column_index))
                    self.autosave_file.flush()

        except Exception as e:
            if not self.IS_DEVELOP:
                raise Exception(
                    "Data not plottable: No good rays or bad content")
            else:
                raise e
コード例 #4
0
    def replace_fig(self, beam, var, xrange, title, xtitle, ytitle, xum):
        if self.plot_canvas is None:
            if self.iterative_mode < 2:
                self.plot_canvas = ShadowPlot.DetailedHistoWidget(
                    y_scale_factor=1.14)
            else:
                if self.plot_type == 0:
                    self.plot_canvas = ScanHistoWidget(
                        self.workspace_units_to_cm)
                elif self.plot_type == 1:
                    self.plot_canvas = Scan3DHistoWidget(
                        self.workspace_units_to_cm,
                        type=Scan3DHistoWidget.PlotType.LINES
                        if self.plot_type_3D == 0 else
                        Scan3DHistoWidget.PlotType.SURFACE)

                self.plot_canvas_stats = DoublePlotWidget(parent=None)
                self.image_box_stats.layout().addWidget(self.plot_canvas_stats)

            self.image_box.layout().addWidget(self.plot_canvas)

        try:
            if self.iterative_mode == 0:
                self.last_ticket = None
                self.current_histo_data = None
                self.current_stats = None
                self.last_histo_data = None
                self.histo_index = -1
                self.plot_canvas.plot_histo(beam._beam,
                                            var,
                                            self.rays,
                                            xrange,
                                            self.weight_column_index,
                                            title,
                                            xtitle,
                                            ytitle,
                                            nbins=self.number_of_bins,
                                            xum=xum,
                                            conv=self.workspace_units_to_cm)

            elif self.iterative_mode == 1:
                self.current_histo_data = None
                self.current_stats = None
                self.last_histo_data = None
                self.histo_index = -1
                self.last_ticket = self.plot_canvas.plot_histo(
                    beam._beam,
                    var,
                    self.rays,
                    xrange,
                    self.weight_column_index,
                    title,
                    xtitle,
                    ytitle,
                    nbins=self.number_of_bins,
                    xum=xum,
                    conv=self.workspace_units_to_cm,
                    ticket_to_add=self.last_ticket)
            else:
                if not beam.scanned_variable_data is None:
                    self.last_ticket = None
                    self.histo_index += 1
                    histo_data = self.plot_canvas.plot_histo(
                        beam=beam,
                        col=var,
                        nbins=self.number_of_bins,
                        title=title,
                        xtitle=xtitle,
                        ytitle=ytitle,
                        histo_index=self.histo_index,
                        scan_variable_name=beam.scanned_variable_data.
                        get_scanned_variable_display_name() + " [" +
                        beam.scanned_variable_data.get_scanned_variable_um() +
                        "]",
                        scan_variable_value=beam.scanned_variable_data.
                        get_scanned_variable_value(),
                        offset=0.0 if self.last_histo_data is None else
                        self.last_histo_data.offset,
                        xrange=xrange,
                        show_reference=False,
                        add_labels=self.add_labels == 1,
                        has_colormap=self.has_colormap == 1)
                    histo_data.scan_value = beam.scanned_variable_data.get_scanned_variable_value(
                    )

                    if not histo_data.bins is None:
                        if self.current_histo_data is None:
                            self.current_histo_data = HistogramDataCollection(
                                histo_data)
                        else:
                            self.current_histo_data.add_histogram_data(
                                histo_data)

                    if self.current_stats is None:
                        self.current_stats = StatisticalDataCollection(
                            histo_data)
                    else:
                        self.current_stats.add_statistical_data(histo_data)

                    self.last_histo_data = histo_data

                    self.plot_canvas_stats.plotCurves(
                        self.current_stats.get_scan_values(),
                        self.current_stats.get_sigmas() if self.stats_to_plot
                        == 0 else self.current_stats.get_fwhms(),
                        self.current_stats.get_relative_intensities(),
                        "Statistics",
                        beam.scanned_variable_data.
                        get_scanned_variable_display_name() + " [" +
                        beam.scanned_variable_data.get_scanned_variable_um() +
                        "]", "Sigma " +
                        xum if self.stats_to_plot == 0 else "FWHM " + xum,
                        "Relative Peak Intensity")

        except Exception as e:
            if self.IS_DEVELOP: raise e
            else:
                raise Exception(
                    "Data not plottable: No good rays or bad content")