def plot_xy(self, beam_out, progressBarValue, var_x, var_y, plot_canvas_index, title, xtitle, ytitle, xum="", yum="", is_footprint=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[ plot_canvas_index] = ShadowPlot.DetailedPlotWidget() self.tab[plot_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) self.plot_canvas[plot_canvas_index].plot_xy( beam_out._beam, var_x, var_y, title, xtitle, ytitle, xum=xum, yum=yum, conv=self.workspace_units_to_cm, is_footprint=is_footprint) self.progressBarSet(progressBarValue)
def replace_fig(self, beam, var_x, var_y, title, xtitle, ytitle, xrange, yrange, nbins, nolost, xum, yum): if self.plot_canvas is None: self.plot_canvas = ShadowPlot.DetailedPlotWidget(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.PlotXYHdf5File(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.PlotXYHdf5File(congruence.checkDir(self.autosave_file_name)) if self.keep_result == 1: self.cumulated_ticket, last_ticket = self.plot_canvas.plot_xy(beam, var_x, var_y, title, xtitle, ytitle, xrange=xrange, yrange=yrange, nbins=nbins, nolost=nolost, xum=xum, yum=yum, conv=self.workspace_units_to_cm, ref=self.weight_column_index, 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_plot_xy(self.cumulated_ticket, dataset_name=dataset_name) if self.autosave_partial_results == 1: if last_ticket is None: self.autosave_file.add_plot_xy(self.cumulated_ticket, plot_name="Plot XY #" + str(self.autosave_prog_id), dataset_name=dataset_name) else: self.autosave_file.add_plot_xy(last_ticket, plot_name="Plot X #" + str(self.autosave_prog_id), dataset_name=dataset_name) self.autosave_file.flush() else: ticket, _ = self.plot_canvas.plot_xy(beam, var_x, var_y, title, xtitle, ytitle, xrange=xrange, yrange=yrange, nbins=nbins, nolost=nolost, xum=xum, yum=yum, conv=self.workspace_units_to_cm, ref=self.weight_column_index) 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_plot_xy(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