def plot_efficiency(self): if self.type_of_zp == PHASE_ZP: if self.energy_plot == 1: if self.plot_canvas[5] is None: self.plot_canvas[5] = oasysgui.plotWindow(roi=False, control=False, position=True, logScale=False) self.tab[5].layout().addWidget(self.plot_canvas[5] ) self.plot_canvas[5].clear() self.plot_canvas[5].setDefaultPlotLines(True) self.plot_canvas[5].setActiveCurveColor(color='blue') self.plot_canvas[5].setGraphTitle('Thickness: ' + str(self.zone_plate_thickness) + " nm") self.plot_canvas[5].getXAxis().setLabel('Energy [eV]') self.plot_canvas[5].getYAxis().setLabel('Efficiency [%]') x_values = numpy.linspace(self.energy_from, self.energy_to, 100) y_values = numpy.zeros(100) for index in range(len(x_values)): y_values[index], _, _ = ZonePlate.calculate_efficiency(ShadowPhysics.getWavelengthFromEnergy(x_values[index])/10, self.zone_plate_material, self.zone_plate_thickness) y_values = numpy.round(100.0*y_values, 3) self.plot_canvas[5].addCurve(x_values, y_values, "Efficiency vs Energy", symbol='', color='blue', replace=True) else: if not self.plot_canvas[5] is None: self.plot_canvas[5].clear() if self.thickness_plot == 1: if self.plot_canvas[6] is None: self.plot_canvas[6] = oasysgui.plotWindow(roi=False, control=False, position=True, logScale=False) self.tab[6].layout().addWidget(self.plot_canvas[6] ) self.plot_canvas[6].setDefaultPlotLines(True) self.plot_canvas[6].setActiveCurveColor(color='blue') self.plot_canvas[6].setGraphTitle('Energy: ' + str(round(ShadowPhysics.getEnergyFromWavelength(self.avg_wavelength*10), 3)) + " eV") self.plot_canvas[6].getXAxis().setLabel('Thickness [nm]') self.plot_canvas[6].getYAxis().setLabel('Efficiency [%]') x_values = numpy.linspace(self.thickness_from, self.thickness_to, 100) y_values = numpy.zeros(100) for index in range(len(x_values)): y_values[index], _, _ = ZonePlate.calculate_efficiency(self.avg_wavelength, self.zone_plate_material, x_values[index]) y_values = numpy.round(100*y_values, 3) self.plot_canvas[6].addCurve(x_values, y_values, "Efficiency vs Thickness", symbol='', color='blue', replace=True) else: if not self.plot_canvas[6] is None: self.plot_canvas[6].clear() else: if not self.plot_canvas[5] is None: self.plot_canvas[5].clear() if not self.plot_canvas[6] is None: self.plot_canvas[6].clear()
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""): if numpy.sum(y) == 0: raise Exception(title + ": no data to plot (all Y column values==0)") if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow( roi=False, control=False, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor( color='blue') self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(True) self.tabs[tabs_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) XRayServerPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle) self.progressBarSet(progressBarValue)
def plot_data1D(self, dataX, dataY, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""): self.undulator_tab[tabs_canvas_index].layout().removeItem( self.undulator_tab[tabs_canvas_index].layout().itemAt(0)) self.und_plot_canvas[plot_canvas_index] = oasysgui.plotWindow() self.und_plot_canvas[plot_canvas_index].addCurve( dataX, dataY, ) self.und_plot_canvas[plot_canvas_index].resetZoom() self.und_plot_canvas[plot_canvas_index].setXAxisAutoScale(True) self.und_plot_canvas[plot_canvas_index].setYAxisAutoScale(True) self.und_plot_canvas[plot_canvas_index].setGraphGrid(False) self.und_plot_canvas[plot_canvas_index].setXAxisLogarithmic(False) self.und_plot_canvas[plot_canvas_index].setYAxisLogarithmic(False) self.und_plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.und_plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.und_plot_canvas[plot_canvas_index].setGraphTitle(title) self.undulator_tab[tabs_canvas_index].layout().addWidget( self.und_plot_canvas[plot_canvas_index])
def __init__(self, workspace_units_to_cm): super(ScanHistoWidget, self).__init__(workspace_units_to_cm) self.plot_canvas = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=True, logScale=False, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=True, position=True, roi=False, mask=False, fit=True) layout = QVBoxLayout() layout.addWidget(self.plot_canvas) self.setLayout(layout)
def __init__(self, x_scale_factor=1.0, y_scale_factor=1.0): super(SRWPlot.Detailed1DWidget, self).__init__() self.plot_canvas = gui.plotWindow(roi=False, control=False, position=True, logScale=False) self.plot_canvas.setDefaultPlotLines(True) self.plot_canvas.setActiveCurveColor(color='blue') self.plot_canvas.setMinimumWidth(590 * x_scale_factor) self.plot_canvas.setMaximumWidth(590 * x_scale_factor) self.info_box = SRWPlot.InfoBoxWidget(x_scale_factor, y_scale_factor, is_2d=False) layout = QGridLayout() layout.addWidget(self.info_box, 0, 1, 1, 1) layout.addWidget(self.plot_canvas, 0, 0, 1, 1) layout.setColumnMinimumWidth(0, 600 * x_scale_factor) layout.setColumnMinimumWidth(1, 230 * x_scale_factor) self.setLayout(layout)
def plot_xy_fast(self, beam_out, progressBarValue, var_x, var_y, plot_canvas_index, title, xtitle, ytitle, is_footprint=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow( roi=False, control=False, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(False) self.plot_canvas[plot_canvas_index].setActiveCurveColor( color='blue') self.tab[plot_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) ShadowPlot.plotxy_preview(self.plot_canvas[plot_canvas_index], beam_out._beam, var_x, var_y, nolost=1, title=title, xtitle=xtitle, ytitle=ytitle, conv=self.workspace_units_to_cm, is_footprint=is_footprint) self.progressBarSet(progressBarValue)
def plot_wiggler_histo(self, progressBarValue, x, y, plot_canvas_index, title, xtitle, ytitle, is_log_log=False): if self.wiggler_plot_canvas[plot_canvas_index] is None: self.wiggler_plot_canvas[plot_canvas_index] = oasysgui.plotWindow( roi=False, control=False, position=True) self.wiggler_plot_canvas[plot_canvas_index].setDefaultPlotLines( True) self.wiggler_plot_canvas[plot_canvas_index].setActiveCurveColor( color='blue') self.wiggler_tab[plot_canvas_index].layout().addWidget( self.wiggler_plot_canvas[plot_canvas_index]) matplotlib.rcParams['axes.formatter.useoffset'] = 'False' self.wiggler_plot_canvas[plot_canvas_index].addCurve( x, y, title, symbol='', color='blue', replace=True) #'+', '^', ',' self.wiggler_plot_canvas[plot_canvas_index].setInteractiveMode( mode='zoom') if not title is None: self.wiggler_plot_canvas[plot_canvas_index].setGraphTitle(title) if not xtitle is None: self.wiggler_plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) if not ytitle is None: self.wiggler_plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.wiggler_plot_canvas[plot_canvas_index].replot() if is_log_log: order_of_magnitude_min = numpy.floor(numpy.log10(min(y))) order_of_magnitude_max = numpy.floor(numpy.log10(max(y))) if numpy.abs(order_of_magnitude_max - order_of_magnitude_min) > 0: factor = 1.2 self.wiggler_plot_canvas[ plot_canvas_index].setXAxisLogarithmic(True) self.wiggler_plot_canvas[ plot_canvas_index].setYAxisLogarithmic(True) else: factor = 1.005 self.wiggler_plot_canvas[ plot_canvas_index].setXAxisLogarithmic(False) self.wiggler_plot_canvas[ plot_canvas_index].setYAxisLogarithmic(False) else: factor = 1.0 self.wiggler_plot_canvas[plot_canvas_index].setGraphYLimits( min(y), max(y) * factor) self.progressBarSet(progressBarValue)
def plot_histo_hybrid(self, progressBarValue, scaled_array, plot_canvas_index, title, xtitle, ytitle, var): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow( roi=False, control=False, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor( color='blue') self.plot_canvas[plot_canvas_index].setInteractiveMode(mode='zoom') self.tab[plot_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) factor = ShadowPlot.get_factor(var, self.workspace_units_to_cm) self.plot_canvas[plot_canvas_index].addCurve( scaled_array.scale * factor, scaled_array.np_array, "crv_" + ytitle, symbol='', color="blue", replace=True) #'+', '^', ',' self.plot_canvas[plot_canvas_index]._backend.ax.get_yaxis( ).get_major_formatter().set_useOffset(True) self.plot_canvas[plot_canvas_index]._backend.ax.get_yaxis( ).get_major_formatter().set_scientific(True) self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.plot_canvas[plot_canvas_index].setGraphTitle(title) self.plot_canvas[plot_canvas_index].replot() self.progressBarSet(progressBarValue)
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", log_x=False, log_y=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow( roi=False, control=True, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor( color='blue') self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(log_x) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(log_y) self.tab[tabs_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) WiserPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle) self.progressBarSet(progressBarValue)
def calculate_heigth_profile(self, not_interactive_mode=False): try: sys.stdout = EmittingStream(textWritten=self.writeStdOut) self.check_fields() if self.error_type_y == profiles_simulation.FIGURE_ERROR: rms_y = self.rms_y * 1e-9 # from nm to m else: rms_y = self.rms_y * 1e-6 # from urad to rad xx, yy = profiles_simulation.simulate_profile_1D( step=self.step_y * self.workspace_units_to_m, mirror_length=self.dimension_y * self.workspace_units_to_m, random_seed=self.montecarlo_seed_y, error_type=self.error_type_y, profile_type=1 - self.kind_of_profile_y, rms=rms_y, correlation_length=self.correlation_length_y * self.workspace_units_to_m, power_law_exponent_beta=self.power_law_exponent_beta_y) xx_to_plot = xx / self.workspace_units_to_m # to user units yy_to_plot = yy * 1e9 # nm self.yy = yy / self.workspace_units_to_m # to user units ny = yy.size slope = numpy.zeros(ny) for i in range(ny - 1): step = xx[i + 1] - xx[i] slope[i] = numpy.arctan((yy[i + 1] - yy[i]) / step) slope[ny - 1] = slope[ny - 2] sloperms = slope.std() title = ' Slope error rms in Z direction: %f $\mu$rad' % ( sloperms * 1e6) if self.plot_canvas is None: self.plot_canvas = oasysgui.plotWindow(roi=False, control=False, position=False) self.plot_canvas.setDefaultPlotLines(True) self.plot_canvas.setActiveCurveColor(color='blue') self.plot_tab.layout().addWidget(self.plot_canvas) WiserPlot.plot_histo(self.plot_canvas, xx_to_plot, yy_to_plot, title, "X [" + self.workspace_units_label + "]", "Z [nm]") QMessageBox.information( self, "QMessageBox.information()", "Height Profile calculated: if the result is satisfactory,\nclick \'Generate Height Profile File\' to complete the operation ", QMessageBox.Ok) except Exception as exception: QMessageBox.critical(self, "Error", exception.args[0], QMessageBox.Ok) raise exception
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", log_x=False, log_y=False, color='blue', replace=True, control=False): matplotlib.rcParams['axes.formatter.useoffset']='False' if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor(color="#00008B") self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index]) self.plot_canvas[plot_canvas_index].addCurve(x, y, title, symbol='', color=color, xlabel=xtitle, ylabel=ytitle, replace=replace) #'+', '^', ',' if not xtitle is None: self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) if not ytitle is None: self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) if not title is None: self.plot_canvas[plot_canvas_index].setGraphTitle(title) self.plot_canvas[plot_canvas_index].setInteractiveMode('zoom',color='orange') self.plot_canvas[plot_canvas_index].resetZoom() self.plot_canvas[plot_canvas_index].replot() self.plot_canvas[plot_canvas_index].setActiveCurve(title) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(log_x) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(log_y) if min(y) < 0: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.2, max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.01, max(y)*1.01) else: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.01) self.progressBarSet(progressBarValue)
def plot_histo_fast(self, beam_out, progressBarValue, var, plot_canvas_index, title, xtitle, ytitle): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor(color='blue') self.tab[plot_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index]) ShadowPlot.plot_histo_preview(self.plot_canvas[plot_canvas_index], beam_out._beam, var, 1, 23, title, xtitle, ytitle, conv=self.workspace_units_to_cm) self.progressBarSet(progressBarValue)
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""): if numpy.sum(y) == 0: raise Exception(title + ": no data to plot (all Y column values==0)") if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor(color='blue') self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(True) self.tabs[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index]) XRayServerPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle) self.progressBarSet(progressBarValue)
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", log_x=False, log_y=False, color='blue', replace=True, control=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor(color="#00008B") self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index]) XoppyPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle, color, replace) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(log_x) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(log_y) if min(y) < 0: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.2, max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.01, max(y)*1.01) else: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.01) self.progressBarSet(progressBarValue)
def plot_data1D(dataX, dataY, title="", xtitle="", ytitle=""): plot_canvas = oasysgui.plotWindow() plot_canvas.addCurve(dataX, dataY) plot_canvas.resetZoom() plot_canvas.setXAxisAutoScale(True) plot_canvas.setYAxisAutoScale(True) plot_canvas.setGraphGrid(False) plot_canvas.setXAxisLogarithmic(False) plot_canvas.setYAxisLogarithmic(False) plot_canvas.setGraphXLabel(xtitle) plot_canvas.setGraphYLabel(ytitle) plot_canvas.setGraphTitle(title) plot_canvas.show()
def __init__(self, parent=None): super(QWidget, self).__init__(parent=parent) self.plot_canvas = oasysgui.plotWindow(roi=False, control=False, position=True, logScale=False) self.plot_canvas.setFixedWidth(700) self.plot_canvas.setFixedHeight(520) self.plot_canvas.setDefaultPlotLines(True) self.plot_canvas.setDefaultPlotPoints(True) self.ax2 = self.plot_canvas._backend.ax.twinx() layout = QVBoxLayout() layout.addWidget(self.plot_canvas) self.setLayout(layout)
def plot_data1D(self, dataX, dataY, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""): self.tab[tabs_canvas_index].layout().removeItem(self.tab[tabs_canvas_index].layout().itemAt(0)) self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow() self.plot_canvas[plot_canvas_index].addCurve(dataX, dataY,) self.plot_canvas[plot_canvas_index].resetZoom() self.plot_canvas[plot_canvas_index].setXAxisAutoScale(True) self.plot_canvas[plot_canvas_index].setYAxisAutoScale(True) self.plot_canvas[plot_canvas_index].setGraphGrid(False) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(False) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(False) self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.plot_canvas[plot_canvas_index].setGraphTitle(title) self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index])
def plot_data1D(self, dataX, dataY, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", control=False, xlog=False, ylog=False): self.tab[tabs_canvas_index].layout().removeItem(self.tab[tabs_canvas_index].layout().itemAt(0)) self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) self.plot_canvas[plot_canvas_index].addCurve(dataX, dataY) self.plot_canvas[plot_canvas_index].resetZoom() self.plot_canvas[plot_canvas_index].setXAxisAutoScale(True) self.plot_canvas[plot_canvas_index].setYAxisAutoScale(True) self.plot_canvas[plot_canvas_index].setGraphGrid(False) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(xlog) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(ylog) self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.plot_canvas[plot_canvas_index].setGraphTitle(title) self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index])
def initializeTabs(self): self.tabs = oasysgui.tabWidget(self.mainArea) self.tab = [ oasysgui.createTabPage(self.tabs, "Info"), oasysgui.createTabPage(self.tabs, "Heights Profile"), oasysgui.createTabPage(self.tabs, "Slopes Profile"), oasysgui.createTabPage(self.tabs, "PSD Heights"), oasysgui.createTabPage(self.tabs, "CSD Heights"), oasysgui.createTabPage(self.tabs, "ACF"), oasysgui.createTabPage(self.tabs, "Generated 1D Profile"), ] for tab in self.tab: tab.setFixedHeight(self.IMAGE_HEIGHT) tab.setFixedWidth(self.IMAGE_WIDTH) self.plot_canvas = [None, None, None, None, None, None] self.plot_canvas[0] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[0].setDefaultPlotLines(True) self.plot_canvas[0].setActiveCurveColor(color='blue') self.plot_canvas[0].setGraphYLabel("Z [nm]") self.plot_canvas[0].setGraphTitle("Heights Profile") self.plot_canvas[0].setInteractiveMode(mode='zoom') self.plot_canvas[1] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[1].setDefaultPlotLines(True) self.plot_canvas[1].setActiveCurveColor(color='blue') self.plot_canvas[1].setGraphYLabel("Zp [$\mu$rad]") self.plot_canvas[1].setGraphTitle("Slopes Profile") self.plot_canvas[1].setInteractiveMode(mode='zoom') self.plot_canvas[2] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[2].setDefaultPlotLines(True) self.plot_canvas[2].setActiveCurveColor(color='blue') self.plot_canvas[2].setGraphXLabel("f [m^-1]") self.plot_canvas[2].setGraphYLabel("PSD [m^3]") self.plot_canvas[2].setGraphTitle( "Power Spectral Density of Heights Profile") self.plot_canvas[2].setInteractiveMode(mode='zoom') self.plot_canvas[2].setXAxisLogarithmic(True) self.plot_canvas[2].setYAxisLogarithmic(True) self.plot_canvas[3] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[3].setDefaultPlotLines(True) self.plot_canvas[3].setActiveCurveColor(color='blue') self.plot_canvas[3].setGraphXLabel("f [m^-1]") self.plot_canvas[3].setGraphYLabel("CSD [m^3]") self.plot_canvas[3].setGraphTitle( "Cumulative Spectral Density of Heights Profile") self.plot_canvas[3].setInteractiveMode(mode='zoom') self.plot_canvas[3].setXAxisLogarithmic(True) self.plot_canvas[4] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[4].setDefaultPlotLines(True) self.plot_canvas[4].setActiveCurveColor(color='blue') self.plot_canvas[4].setGraphXLabel("Length [m]") self.plot_canvas[4].setGraphYLabel("ACF") self.plot_canvas[4].setGraphTitle( "Autocovariance Function of Heights Profile") self.plot_canvas[4].setInteractiveMode(mode='zoom') self.plot_canvas[5] = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas[5].setDefaultPlotLines(True) self.plot_canvas[5].setActiveCurveColor(color='blue') self.plot_canvas[5].setGraphYLabel("Z [nm]") self.plot_canvas[5].setGraphTitle("Heights Profile") self.plot_canvas[5].setInteractiveMode(mode='zoom') self.profileInfo = oasysgui.textArea(height=self.IMAGE_HEIGHT - 5, width=400) profile_box = oasysgui.widgetBox(self.tab[0], "", addSpace=True, orientation="horizontal", height=self.IMAGE_HEIGHT, width=410) profile_box.layout().addWidget(self.profileInfo) for index in range(0, 6): self.tab[index + 1].layout().addWidget(self.plot_canvas[index]) self.tabs.setCurrentIndex(1)
def __init__(self, parent=None, file_name="", dimension=2): QDialog.__init__(self, parent) self.setWindowTitle('File: Surface Error Profile') layout = QVBoxLayout(self) if dimension == 2: figure = Figure(figsize=(100, 100)) figure.patch.set_facecolor('white') axis = figure.add_subplot(111, projection='3d') axis.set_xlabel("X [m]") axis.set_ylabel("Y [m]") axis.set_zlabel("Z [nm]") figure_canvas = FigureCanvasQTAgg(figure) figure_canvas.setFixedWidth(500) figure_canvas.setFixedHeight(500) x_coords, y_coords, z_values = read_error_profile_file(file_name, dimension=2) x_to_plot, y_to_plot = numpy.meshgrid(x_coords, y_coords) axis.plot_surface(x_to_plot, y_to_plot, (z_values * 1e9).T, rstride=1, cstride=1, cmap=cm.autumn, linewidth=0.5, antialiased=True) sloperms = profiles_simulation.slopes(z_values, x_coords, y_coords, return_only_rms=1) title = ' Slope error rms in X direction: %f $\mu$rad' % (sloperms[0]*1e6) + '\n' + \ ' Slope error rms in Y direction: %f $\mu$rad' % (sloperms[1]*1e6) + '\n' + \ ' Figure error rms in X direction: %f nm' % (round(z_values[:, 0].std()*1e9, 6)) + '\n' + \ ' Figure error rms in Y direction: %f nm' % (round(z_values[0, :].std()*1e9, 6)) axis.set_title(title) figure_canvas.draw() axis.mouse_init() elif dimension == 1: figure_canvas = gui.plotWindow(resetzoom=False, autoScale=False, logScale=False, grid=False, curveStyle=False, colormap=False, aspectRatio=False, yInverted=False, copy=False, save=False, print_=False, control=False, position=False, roi=False, mask=False, fit=False) figure_canvas.setDefaultPlotLines(True) figure_canvas.setActiveCurveColor(color='blue') figure_canvas.setMinimumWidth(500) figure_canvas.setMaximumWidth(500) x_coords, z_values = read_error_profile_file(file_name, dimension=1) figure_canvas.addCurve(x_coords, z_values * 1e9, "Height Error Profile", symbol='', color='blue', replace=True) #'+', '^', ',' figure_canvas.setGraphXLabel("X [m]") figure_canvas.setGraphYLabel("Height Error [nm]") figure_canvas.setGraphTitle("Height Error Profile") figure_canvas.replot() bbox = QDialogButtonBox(QDialogButtonBox.Ok) bbox.accepted.connect(self.accept) layout.addWidget(figure_canvas) layout.addWidget(bbox)
def __init__(self): self.runaction = OWAction("Start", self) self.runaction.triggered.connect(self.startLoop) self.addAction(self.runaction) self.runaction = OWAction("Stop", self) self.runaction.triggered.connect(self.stopLoop) self.addAction(self.runaction) self.runaction = OWAction("Suspend", self) self.runaction.triggered.connect(self.suspendLoop) self.addAction(self.runaction) self.runaction = OWAction("Restart", self) self.runaction.triggered.connect(self.restartLoop) self.addAction(self.runaction) self.setFixedWidth(1200) self.setFixedHeight(710) button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=True, orientation="horizontal") self.start_button = gui.button(button_box, self, "Start", callback=self.startLoop) self.start_button.setFixedHeight(35) stop_button = gui.button(button_box, self, "Stop", callback=self.stopLoop) stop_button.setFixedHeight(35) font = QFont(stop_button.font()) font.setBold(True) stop_button.setFont(font) palette = QPalette(stop_button.palette()) # make a copy of the palette palette.setColor(QPalette.ButtonText, QColor('red')) stop_button.setPalette(palette) # assign new palette self.stop_button = stop_button button_box = oasysgui.widgetBox(self.controlArea, "", addSpace=True, orientation="horizontal") suspend_button = gui.button(button_box, self, "Suspend", callback=self.suspendLoop) suspend_button.setFixedHeight(35) font = QFont(suspend_button.font()) font.setBold(True) suspend_button.setFont(font) palette = QPalette( suspend_button.palette()) # make a copy of the palette palette.setColor(QPalette.ButtonText, QColor('orange')) suspend_button.setPalette(palette) # assign new palette self.re_start_button = gui.button(button_box, self, "Restart", callback=self.restartLoop) self.re_start_button.setFixedHeight(35) self.re_start_button.setEnabled(False) tabs = oasysgui.tabWidget(self.controlArea) tab_loop = oasysgui.createTabPage(tabs, "Loop Management") tab_und = oasysgui.createTabPage(tabs, "Undulator") left_box_2 = oasysgui.widgetBox(tab_und, "Parameters From Syned", addSpace=False, orientation="vertical", width=385, height=560) oasysgui.lineEdit(left_box_2, self, "electron_energy", "Ring Energy [GeV]", labelWidth=260, valueType=float, orientation="horizontal").setReadOnly(True) oasysgui.lineEdit(left_box_2, self, "number_of_periods", "Number of Periods", labelWidth=260, valueType=float, orientation="horizontal").setReadOnly(True) oasysgui.lineEdit(left_box_2, self, "period_length", "Undulator Period [m]", labelWidth=260, valueType=float, orientation="horizontal").setReadOnly(True) oasysgui.lineEdit(left_box_2, self, "K_vertical", "K Vertical", labelWidth=260, valueType=float, orientation="horizontal").setReadOnly(True) oasysgui.lineEdit(left_box_2, self, "K_horizontal", "K Horizontal", labelWidth=260, valueType=float, orientation="horizontal").setReadOnly(True) left_box_1 = oasysgui.widgetBox(tab_loop, "", addSpace=False, orientation="vertical", width=385, height=560) oasysgui.lineEdit(left_box_1, self, "seed_increment", "Source Montecarlo Seed Increment", labelWidth=250, valueType=int, orientation="horizontal") gui.separator(left_box_1) gui.comboBox(left_box_1, self, "autobinning", label="Energy Binning", items=[ "Manual", "Automatic (Constant Power)", "Automatic (Constant Energy)" ], labelWidth=150, callback=self.set_Autobinning, sendSelectedValue=False, orientation="horizontal") self.autobinning_box_1 = oasysgui.widgetBox(left_box_1, "", addSpace=False, orientation="vertical", height=50) self.autobinning_box_2 = oasysgui.widgetBox(left_box_1, "", addSpace=False, orientation="vertical", height=140) # ---------------------------------------------- gui.button(self.autobinning_box_1, self, "Compute Bins", callback=self.calculate_energy_binnings) oasysgui.widgetLabel(self.autobinning_box_1, "Energy From, Energy To, Energy Step [eV]") # ---------------------------------------------- oasysgui.lineEdit(self.autobinning_box_2, self, "auto_n_step", "Number of Steps", labelWidth=250, valueType=int, orientation="horizontal") oasysgui.lineEdit(self.autobinning_box_2, self, "auto_perc_total_power", "% Total Power", labelWidth=250, valueType=float, orientation="horizontal") gui.comboBox(self.autobinning_box_2, self, "send_power_step", label="Send Power Step", items=["No", "Yes"], labelWidth=350, sendSelectedValue=False, orientation="horizontal") button_box = oasysgui.widgetBox(self.autobinning_box_2, "", addSpace=False, orientation="horizontal") gui.button(button_box, self, "Reload Spectrum and Filters", callback=self.read_spectrum_and_filters_file) gui.button(button_box, self, "Reload Spectrum Only", callback=self.read_spectrum_file_only) oasysgui.widgetLabel( self.autobinning_box_2, "Energy Value [eV], Energy Step [eV], Power Step [W]") def write_text(): self.energies = self.text_area.toPlainText() self.text_area = oasysgui.textArea(height=95, width=385, readOnly=False) self.text_area.setText(self.energies) self.text_area.setStyleSheet( "background-color: white; font-family: Courier, monospace;") self.text_area.textChanged.connect(write_text) left_box_1.layout().addWidget(self.text_area) gui.separator(left_box_1) self.le_number_of_new_objects = oasysgui.lineEdit( left_box_1, self, "total_new_objects", "Total Energy Values", labelWidth=250, valueType=int, orientation="horizontal") self.le_number_of_new_objects.setReadOnly(True) font = QFont(self.le_number_of_new_objects.font()) font.setBold(True) self.le_number_of_new_objects.setFont(font) palette = QPalette(self.le_number_of_new_objects.palette() ) # make a copy of the palette palette.setColor(QPalette.Text, QColor('dark blue')) palette.setColor(QPalette.Base, QColor(243, 240, 160)) self.le_number_of_new_objects.setPalette(palette) self.le_number_of_new_objects = oasysgui.lineEdit( left_box_1, self, "number_of_new_objects", "Current Binning Energy Values", labelWidth=250, valueType=int, orientation="horizontal") self.le_number_of_new_objects.setReadOnly(True) font = QFont(self.le_number_of_new_objects.font()) font.setBold(True) self.le_number_of_new_objects.setFont(font) palette = QPalette(self.le_number_of_new_objects.palette() ) # make a copy of the palette palette.setColor(QPalette.Text, QColor('dark blue')) palette.setColor(QPalette.Base, QColor(243, 240, 160)) self.le_number_of_new_objects.setPalette(palette) gui.separator(left_box_1) le_current_value = oasysgui.lineEdit(left_box_1, self, "total_current_new_object", "Total New " + self.get_object_name(), labelWidth=250, valueType=int, orientation="horizontal") le_current_value.setReadOnly(True) font = QFont(le_current_value.font()) font.setBold(True) le_current_value.setFont(font) palette = QPalette( le_current_value.palette()) # make a copy of the palette palette.setColor(QPalette.Text, QColor('dark blue')) palette.setColor(QPalette.Base, QColor(243, 240, 160)) le_current_value.setPalette(palette) le_current_value = oasysgui.lineEdit(left_box_1, self, "current_new_object", "Current Binning New " + self.get_object_name(), labelWidth=250, valueType=int, orientation="horizontal") le_current_value.setReadOnly(True) font = QFont(le_current_value.font()) font.setBold(True) le_current_value.setFont(font) palette = QPalette( le_current_value.palette()) # make a copy of the palette palette.setColor(QPalette.Text, QColor('dark blue')) palette.setColor(QPalette.Base, QColor(243, 240, 160)) le_current_value.setPalette(palette) le_current_value = oasysgui.lineEdit(left_box_1, self, "current_energy_value", "Current Energy Value", labelWidth=250, valueType=float, orientation="horizontal") le_current_value.setReadOnly(True) font = QFont(le_current_value.font()) font.setBold(True) le_current_value.setFont(font) palette = QPalette( le_current_value.palette()) # make a copy of the palette palette.setColor(QPalette.Text, QColor('dark blue')) palette.setColor(QPalette.Base, QColor(243, 240, 160)) le_current_value.setPalette(palette) gui.rubber(self.controlArea) tabs = oasysgui.tabWidget(self.mainArea) tabs.setFixedHeight(self.height() - 15) tabs.setFixedWidth(775) tab_plot = oasysgui.createTabPage(tabs, "Cumulated Power") tab_flux = oasysgui.createTabPage(tabs, "Spectral Flux") tab_fil = oasysgui.createTabPage(tabs, "Filter") self.cumulated_power_plot = oasysgui.plotWindow(tab_plot, position=True) self.cumulated_power_plot.setFixedHeight(self.height() - 20) self.cumulated_power_plot.setFixedWidth(775) self.cumulated_power_plot.setGraphXLabel("Energy [eV]") self.cumulated_power_plot.setGraphYLabel("Cumulated Power [W]") self.cumulated_power_plot.setGraphTitle("Cumulated Power") self.spectral_flux_plot = oasysgui.plotWindow(tab_flux, position=True) self.spectral_flux_plot.setFixedHeight(self.height() - 20) self.spectral_flux_plot.setFixedWidth(775) self.spectral_flux_plot.setGraphXLabel("Energy [eV]") self.spectral_flux_plot.setGraphYLabel("Flux [ph/s/.1%bw]") self.spectral_flux_plot.setGraphTitle("Spectral Flux") self.filter_plot = oasysgui.plotWindow(tab_fil, position=True) self.filter_plot.setFixedHeight(self.height() - 20) self.filter_plot.setFixedWidth(775) self.filter_plot.setGraphXLabel("Energy [eV]") self.filter_plot.setGraphYLabel("Intensity Factor") self.filter_plot.setGraphTitle("Filter on Flux") self.set_Autobinning()
def calculate(self): if ShadowCongruence.checkEmptyBeam(self.input_beam): if ShadowCongruence.checkGoodBeam(self.input_beam): beam_to_analize = self.input_beam._beam if self.image_plane == 1: new_shadow_beam = self.input_beam.duplicate(history=False) dist = 0.0 if self.image_plane_rel_abs_position == 1: # relative dist = self.image_plane_new_position else: # absolute historyItem = self.input_beam.getOEHistory( oe_number=self.input_beam._oe_number) if historyItem is None: image_plane = 0.0 elif self.input_beam._oe_number == 0: image_plane = 0.0 else: image_plane = historyItem._shadow_oe_end._oe.T_IMAGE dist = self.image_plane_new_position - image_plane new_shadow_beam._beam.retrace(dist) beam_to_analize = new_shadow_beam._beam if self.mode == 2: center = [self.center_x, self.center_z] else: center = [0.0, 0.0] if self.y_range == 1: if self.y_range_min >= self.y_range_max: raise Exception( "Y range min cannot be greater or than Y range max" ) ticket = ST.focnew(beam_to_analize, mode=self.mode, center=center) self.focnewInfo.setText(ticket["text"]) if self.plot_canvas_x is None: self.plot_canvas_x = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas_x.setDefaultPlotLines(True) self.plot_canvas_x.setActiveCurveColor(color='blue') self.plot_canvas_x.setInteractiveMode(mode='zoom') self.plot_canvas_x.toolBar().setVisible(False) self.plot_canvas_z = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas_z.setDefaultPlotLines(True) self.plot_canvas_z.setActiveCurveColor(color='red') self.plot_canvas_z.setInteractiveMode(mode='zoom') self.plot_canvas_z.toolBar().setVisible(False) self.plot_canvas_t = oasysgui.plotWindow(roi=False, control=False, position=True) self.plot_canvas_t.setDefaultPlotLines(True) self.plot_canvas_t.setActiveCurveColor(color='green') self.plot_canvas_t.setInteractiveMode(mode='zoom') self.plot_canvas_t.toolBar().setVisible(False) gridLayout = QtWidgets.QGridLayout() gridLayout.addWidget(self.plot_canvas_x, 0, 0) gridLayout.addWidget(self.plot_canvas_z, 0, 1) gridLayout.addWidget(self.plot_canvas_t, 1, 0) widget = QtWidgets.QWidget() widget.setLayout(gridLayout) self.image_box.layout().addWidget(widget) if self.y_range == 0: y = numpy.linspace(-10.0, 10.0, 1001) else: y = numpy.linspace(self.y_range_min, self.y_range_max, self.y_npoints) pos = [0.25, 0.15, 0.7, 0.75] self.plot_canvas_x.addCurve( y, 2.35 * ST.focnew_scan(ticket["AX"], y) * ShadowPlot.get_factor(1, self.workspace_units_to_cm), "x (tangential)", symbol='', color="blue", replace=True) #'+', '^', ',' self.plot_canvas_x._backend.ax.get_yaxis().get_major_formatter( ).set_useOffset(True) self.plot_canvas_x._backend.ax.get_yaxis().get_major_formatter( ).set_scientific(True) self.plot_canvas_x._backend.ax.set_position(pos) self.plot_canvas_x._backend.ax2.set_position(pos) self.plot_canvas_x.setGraphXLabel("Y [" + self.workspace_units_label + "]") self.plot_canvas_x.setGraphYLabel("2.35*<X> [$\mu$m]") self.plot_canvas_x._backend.ax.set_title( "X", horizontalalignment='left') self.plot_canvas_x.replot() self.plot_canvas_z.addCurve( y, 2.35 * ST.focnew_scan(ticket["AZ"], y) * ShadowPlot.get_factor(3, self.workspace_units_to_cm), "z (sagittal)", symbol='', color="red", replace=False) #'+', '^', ',' self.plot_canvas_z._backend.ax.get_yaxis().get_major_formatter( ).set_useOffset(True) self.plot_canvas_z._backend.ax.get_yaxis().get_major_formatter( ).set_scientific(True) self.plot_canvas_z._backend.ax.set_position(pos) self.plot_canvas_z._backend.ax2.set_position(pos) self.plot_canvas_z.setGraphXLabel("Y [" + self.workspace_units_label + "]") self.plot_canvas_z.setGraphYLabel("2.35*<Z> [$\mu$m]") self.plot_canvas_z._backend.ax.set_title( "Z", horizontalalignment='left') self.plot_canvas_z.replot() self.plot_canvas_t.addCurve( y, 2.35 * ST.focnew_scan(ticket["AT"], y) * ShadowPlot.get_factor(1, self.workspace_units_to_cm), "combined x,z", symbol='', color="green", replace=True) #'+', '^', ',' self.plot_canvas_t._backend.ax.get_yaxis().get_major_formatter( ).set_useOffset(True) self.plot_canvas_t._backend.ax.get_yaxis().get_major_formatter( ).set_scientific(True) self.plot_canvas_t._backend.ax.set_position(pos) self.plot_canvas_t._backend.ax2.set_position(pos) self.plot_canvas_t.setGraphXLabel("Y [" + self.workspace_units_label + "]") self.plot_canvas_t.setGraphYLabel("2.35*<X,Z> [$\mu$m]") self.plot_canvas_t._backend.ax.set_title( "X,Z (Combined)", horizontalalignment='left') self.plot_canvas_t.replot()
def plot_1D(self, plot_canvas, profile_1D, last_index=-1, show=False, replace=True, profile_name="z pos #1", control=False, color='blue'): if plot_canvas is None: plot_canvas = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=True, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=True) plot_canvas.setDefaultPlotLines(True) plot_canvas.setActiveCurveColor(color="#00008B") title = "Radial Intensity Profile" xtitle = "Radius [m]" ytitle = "Intensity [A.U.]" plot_canvas.setGraphTitle(title) plot_canvas.setGraphXLabel(xtitle) plot_canvas.setGraphYLabel(ytitle) rcParams['axes.formatter.useoffset'] = 'False' radius = numpy.arange(0, self.max_radius, self.step) plot_canvas.addCurve(radius[:last_index], profile_1D[:last_index], profile_name, symbol='', color=color, xlabel=xtitle, ylabel=ytitle, replace=replace) #'+', '^', ',' plot_canvas.setInteractiveMode('zoom', color='orange') plot_canvas.resetZoom() plot_canvas.replot() plot_canvas.setActiveCurve("Radial Intensity Profile") if show: plot_canvas.show() return plot_canvas
def __init__(self, show_automatic_box=True): super().__init__() geom = QApplication.desktop().availableGeometry() self.setGeometry( QRect(round(geom.width() * 0.05), round(geom.height() * 0.05), round(min(geom.width() * 0.98, self.WIDGET_WIDTH)), round(min(geom.height() * 0.95, self.WIDGET_HEIGHT)))) gen_box = gui.widgetBox(self.mainArea, "Beamline Info", addSpace=True, orientation="horizontal") tabs_setting = oasysgui.tabWidget(gen_box) tabs_setting.setFixedHeight(self.WIDGET_HEIGHT - 60) tabs_setting.setFixedWidth(self.WIDGET_WIDTH - 60) tab_sys = oasysgui.createTabPage(tabs_setting, "Sys Info") tab_sys_plot_side = oasysgui.createTabPage(tabs_setting, "Sys Plot (Side View)") tab_sys_plot_top = oasysgui.createTabPage(tabs_setting, "Sys Plot (Top View)") tab_mir = oasysgui.createTabPage(tabs_setting, "OE Info") tab_sou = oasysgui.createTabPage(tabs_setting, "Source Info") tab_dis = oasysgui.createTabPage(tabs_setting, "Distances Summary") tab_scr = oasysgui.createTabPage(tabs_setting, "Python Script") tab_out = oasysgui.createTabPage(tabs_setting, "System Output") self.sysInfo = oasysgui.textArea() self.sysInfo.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.sysPlotSide = oasysgui.plotWindow(tab_sys_plot_side) self.sysPlotSide.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.sysPlotTop = oasysgui.plotWindow(tab_sys_plot_top) self.sysPlotTop.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.mirInfo = oasysgui.textArea() self.mirInfo.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.sourceInfo = oasysgui.textArea() self.sourceInfo.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.distancesSummary = oasysgui.textArea() self.distancesSummary.setMaximumHeight(self.WIDGET_HEIGHT - 100) self.pythonScript = oasysgui.textArea(readOnly=False) self.pythonScript.setMaximumHeight(self.WIDGET_HEIGHT - 300) sys_box = oasysgui.widgetBox(tab_sys, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) sys_box.layout().addWidget(self.sysInfo) sys_plot_side_box = oasysgui.widgetBox(tab_sys_plot_side, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) sys_plot_side_box.layout().addWidget(self.sysPlotSide) sys_plot_top_box = oasysgui.widgetBox(tab_sys_plot_top, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) sys_plot_top_box.layout().addWidget(self.sysPlotTop) mir_box = oasysgui.widgetBox(tab_mir, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) mir_box.layout().addWidget(self.mirInfo) source_box = oasysgui.widgetBox(tab_sou, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) source_box.layout().addWidget(self.sourceInfo) dist_box = oasysgui.widgetBox(tab_dis, "", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) dist_box.layout().addWidget(self.distancesSummary) script_box = oasysgui.widgetBox(tab_scr, "", addSpace=True, orientation="vertical", height=self.WIDGET_HEIGHT - 80, width=self.WIDGET_WIDTH - 80) script_box.layout().addWidget(self.pythonScript) console_box = oasysgui.widgetBox(script_box, "", addSpace=True, orientation="vertical", height=150, width=self.WIDGET_WIDTH - 80) self.console = PythonConsole(self.__dict__, self) console_box.layout().addWidget(self.console) self.shadow_output = oasysgui.textArea() out_box = oasysgui.widgetBox(tab_out, "System Output", addSpace=True, orientation="horizontal", height=self.WIDGET_HEIGHT - 80) out_box.layout().addWidget(self.shadow_output) ############################# button_box = oasysgui.widgetBox(tab_scr, "", addSpace=True, orientation="horizontal") gui.button(button_box, self, "Run Script", callback=self.execute_script, height=40) gui.button(button_box, self, "Save Script to File", callback=self.save_script, height=40)
def __init__(self): super(TotalFilterCalculator, self).__init__() self.runaction = OWAction("Calculate Total Filter", self) self.runaction.triggered.connect(self.calculate_total_filter) self.addAction(self.runaction) self.setFixedWidth(1200) self.setFixedHeight(710) self.controlArea.setFixedWidth(self.CONTROL_AREA_WIDTH) box0 = oasysgui.widgetBox(self.controlArea, "", orientation="horizontal", width=self.CONTROL_AREA_WIDTH - 5) gui.button(box0, self, "Calculate Total Filter", callback=self.calculate_total_filter, height=45) box1 = oasysgui.widgetBox(self.controlArea, "Energy Range", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5) oasysgui.lineEdit(box1, self, "energy_from", "Energy From [eV]", labelWidth=250, orientation="horizontal", valueType=float) oasysgui.lineEdit(box1, self, "energy_to", "Energy to [eV]", labelWidth=250, orientation="horizontal", valueType=float) oasysgui.lineEdit(box1, self, "energy_nr", "Nr. of energies", labelWidth=250, orientation="horizontal", valueType=int) box1 = oasysgui.widgetBox(self.controlArea, "Input Data", orientation="vertical", width=self.CONTROL_AREA_WIDTH - 5) items = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] def build_combo(container, master, field_name, label, has_combo=True, combo_field_name=None, cb_items=items): box = gui.widgetBox(container, "", orientation="horizontal") gui.checkBox(box, master, "check_" + field_name, label="" if has_combo else label) if has_combo: gui.comboBox( box, master, "n_" + field_name if not combo_field_name else combo_field_name, label=label, items=cb_items, labelWidth=350, sendSelectedValue=False, orientation="horizontal") box.setEnabled(False) return box self.cb_ref_1 = build_combo(box1, self, "ref_1", label="Nr. of Mirror Reflectivity #1") self.cb_ref_2 = build_combo(box1, self, "ref_2", label="Nr. of Mirror Reflectivity #2") self.cb_ref_3 = build_combo(box1, self, "ref_3", label="Nr. of Mirror Reflectivity #3") gui.separator(box1) self.cb_dif_1 = build_combo(box1, self, "dif_1", label="Nr. of Diffraction Profile #1") self.cb_dif_2 = build_combo(box1, self, "dif_2", label="Nr. of Diffraction Profile #2") gui.separator(box1) self.cb_mul_1 = build_combo(box1, self, "mul_1", label="Nr. of MultiLayer Reflectivity #1") self.cb_mul_2 = build_combo(box1, self, "mul_2", label="Nr. of MultiLayer Reflectivity #2") gui.separator(box1) self.cb_pow_1 = build_combo(box1, self, "pow_1", label="Power Widget Input", combo_field_name="abs_tran", cb_items=["Absorbed", "Transmitted"]) gui.rubber(self.controlArea) tabs = oasysgui.tabWidget(self.mainArea) tabs.setFixedHeight(self.height() - 15) tabs.setFixedWidth(770) tab_fil = oasysgui.createTabPage(tabs, "Total Filter") self.filter_plot = oasysgui.plotWindow(tab_fil, position=True) self.filter_plot.setFixedHeight(self.height() - 60) self.filter_plot.setFixedWidth(760) self.filter_plot.setGraphXLabel("Energy [eV]") self.filter_plot.setGraphYLabel("Intensity Factor") self.filter_plot.setGraphTitle("Total Filter")
def plot_data1D(x, y, title="", xtitle="", ytitle="", log_x=False, log_y=False, color='blue', replace=True, control=False, xrange=None, yrange=None, symbol=''): plot_widget_id = oasysgui.plotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) plot_widget_id.setDefaultPlotLines(True) plot_widget_id.setActiveCurveColor(color='blue') plot_widget_id.setGraphXLabel(xtitle) plot_widget_id.setGraphYLabel(ytitle) plot_widget_id.addCurve(x, y, title, symbol=symbol, color=color, xlabel=xtitle, ylabel=ytitle, replace=replace) # '+', '^', ',' if not xtitle is None: plot_widget_id.setGraphXLabel(xtitle) if not ytitle is None: plot_widget_id.setGraphYLabel(ytitle) if not title is None: plot_widget_id.setGraphTitle(title) plot_widget_id.resetZoom() plot_widget_id.replot() plot_widget_id.setActiveCurve(title) plot_widget_id.setXAxisLogarithmic(log_x) plot_widget_id.setYAxisLogarithmic(log_y) if xrange is not None: plot_widget_id.setGraphXLimits(xrange[0], xrange[1]) if yrange is not None: plot_widget_id.setGraphYLimits(yrange[0], yrange[1]) if min(y) < 0: if log_y: plot_widget_id.setGraphYLimits(min(y) * 1.2, max(y) * 1.2) else: plot_widget_id.setGraphYLimits(min(y) * 1.01, max(y) * 1.01) else: if log_y: plot_widget_id.setGraphYLimits(min(y), max(y) * 1.2) else: plot_widget_id.setGraphYLimits(min(y) * 0.99, max(y) * 1.01) return plot_widget_id
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", log_x=False, log_y=False, color='blue', replace=True, control=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = oasysgui.plotWindow( parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor( color="#00008B") self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.tab[tabs_canvas_index].layout().addWidget( self.plot_canvas[plot_canvas_index]) XoppyPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle, color, replace) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(log_x) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(log_y) if min(y) < 0: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits( min(y) * 1.2, max(y) * 1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits( min(y) * 1.01, max(y) * 1.01) else: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits( min(y), max(y) * 1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits( min(y), max(y) * 1.01) self.progressBarSet(progressBarValue)