Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def fit_clicked(self):
# clear old fit results in the text box self._mw.fit_result_TextBrowser.clear()
# remove old fit from the graph
self._mw.signal_plot_ViewWidget.removeItem(self.fit_image)
# get selected fit function from the ComboBox
current_fit_function = self._mw.fit_function_ComboBox.currentText()
fit_x, fit_y, fit_result = self._pulsed_measurement_logic.do_fit(current_fit_function)
# plot the fit only if there is data available
if fit_x != [] and fit_x != []:
self.fit_image = pg.PlotDataItem(fit_x, fit_y,pen='r')
self._mw.signal_plot_ViewWidget.addItem(self.fit_image,pen='r')
self._mw.fit_result_TextBrowser.setPlainText(fit_result)
return
def refresh_lasertrace_plot(self):
points = extend_to_origin(curve.points)
item = pg.PlotCurveItem(
points.fpr, points.tpr, pen=pen, shadowPen=shadow_pen,
name=name, antialias=True
)
sp = pg.ScatterPlotItem(
curve.points.fpr, curve.points.tpr, symbol=symbol,
size=symbol_size, pen=shadow_pen,
name=name
)
sp.setParentItem(item)
hull = extend_to_origin(curve.hull)
hull_item = pg.PlotDataItem(
hull.fpr, hull.tpr, pen=pen, antialias=True
)
return PlotCurve(curve, item, hull_item)
ydata = self.leemdat.dat3d[ymp, xmp, :]
if self.smoothLEEMplot:
ydata = LF.smooth(ydata, window_len=self.LEEMWindowLen, window_type=self.LEEMWindowType)
brush = QtGui.QBrush(self.qcolors[self.LEEMclicks - 1])
rad = 8
x = pos.x() - rad/2 # offset for QRectF
y = pos.y() - rad/2 # offset for QRectF
circ = self.LEEMimageplotwidget.scene().addEllipse(x, y, rad, rad, brush=brush)
# print("Click at x={0}, y={1}".format(x, y))
self.LEEMcircs.append(circ)
self.LEEMselections.append((xmp, ymp)) # (x, y format)
pen = pg.mkPen(self.qcolors[self.LEEMclicks - 1], width=self.LEEM_Linewidth)
pdi = pg.PlotDataItem(xdata, ydata, pen=pen)
yaxis = self.staticLEEMplot.getAxis("left")
# y axis is 'arbitrary units'; we don't want kilo or mega arbitrary units etc...
yaxis.enableAutoSIPrefix(False)
self.staticLEEMplot.addItem(pdi)
self.staticLEEMplot.setTitle("LEEM-I(V)")
self.staticLEEMplot.setLabel('bottom', 'Energy', units='eV', **self.labelStyle)
self.staticLEEMplot.setLabel('left', 'Intensity', units='a.u.', **self.labelStyle)
if not self.staticLEEMplot.isVisible():
self.staticLEEMplot.show()
def create_items(self, positions, intensities, name=None, baseline=0):
# create new ones on each Position:
self.line_items = []
for ind, position in enumerate(positions):
self.line_items.append(pg.PlotDataItem(x=[position, position],
y=[baseline, intensities[ind]],
pen=self.pen,
antialias=False))
self.line_visible.append(True)
self.plot_item.addItem(self.line_items[ind])
if name is not None:
try:
self.legend_item.addItem(self.ref_legend_line, name)
self.name = name
except IndexError:
pass
def plot_curves(self, target, clf_idx):
if (target, clf_idx) not in self._curve_data:
curve = liftCurve_from_results(self.results, clf_idx, target)
color = self.colors[clf_idx]
pen = QPen(color, 1)
pen.setCosmetic(True)
shadow_pen = QPen(pen.color().lighter(160), 2.5)
shadow_pen.setCosmetic(True)
item = pg.PlotDataItem(
curve.points[0],
curve.points[1],
pen=pen,
shadowPen=shadow_pen,
symbol="+",
symbolSize=3,
symbolPen=shadow_pen,
antialias=True,
)
hull_item = pg.PlotDataItem(
curve.hull[0], curve.hull[1], pen=pen, antialias=True
)
self._curve_data[target, clf_idx] = PlotCurve(curve, item, hull_item)
return self._curve_data[target, clf_idx]
attr = primary + "_" + self.S_VALS[s_units]
for ntwk in ntwk_list:
s = getattr(ntwk, attr)
for n in range(ntwk.s.shape[2]):
for m in range(ntwk.s.shape[1]):
if trace > 0:
if not n == n_ or not m == m_:
continue
c = next(colors)
label = ntwk.name
if ntwk.s.shape[1] > 1:
label += " - S{:d}{:d}".format(m + 1, n + 1)
if "db" in attr:
splot = pg.PlotDataItem(pen=pg.mkPen(c), name=label)
if not np.any(s[:, m, n] == -np.inf):
splot.setData(ntwk.f, s[:, m, n])
self.plot.addItem(splot)
else:
self.plot.plot(ntwk.f, s[:, m, n], pen=pg.mkPen(c), name=label)
self.plot.setLabel("left", s_units)
axisOrder='row-major')
self.xy_refocus_image.set_image_extent(((self._optimizer_logic._initial_pos_x - 0.5 * self._optimizer_logic.refocus_XY_size,
self._optimizer_logic._initial_pos_x + 0.5 * self._optimizer_logic.refocus_XY_size),
(self._optimizer_logic._initial_pos_y - 0.5 * self._optimizer_logic.refocus_XY_size,
self._optimizer_logic._initial_pos_y + 0.5 * self._optimizer_logic.refocus_XY_size)))
self.depth_refocus_image = pg.PlotDataItem(
x=self._optimizer_logic._zimage_Z_values,
y=self._optimizer_logic.z_refocus_line[:, self._optimizer_logic.opt_channel],
pen=pg.mkPen(palette.c1, style=QtCore.Qt.DotLine),
symbol='o',
symbolPen=palette.c1,
symbolBrush=palette.c1,
symbolSize=7
)
self.depth_refocus_fit_image = pg.PlotDataItem(
x=self._optimizer_logic._fit_zimage_Z_values,
y=self._optimizer_logic.z_fit_data,
pen=pg.mkPen(palette.c2)
)
# Add the display item to the xy and depth ViewWidget, which was defined in the UI file.
self._mw.xy_refocus_ViewWidget_2.addItem(self.xy_refocus_image)
self._mw.depth_refocus_ViewWidget_2.addItem(self.depth_refocus_image)
# Labelling axes
self._mw.xy_refocus_ViewWidget_2.setLabel('bottom', 'X position', units='m')
self._mw.xy_refocus_ViewWidget_2.setLabel('left', 'Y position', units='m')
self._mw.depth_refocus_ViewWidget_2.addItem(self.depth_refocus_fit_image)
self._mw.depth_refocus_ViewWidget_2.setLabel('bottom', 'Z position', units='m')
# Set the range of the axis of each plot.
self.plt.setXRange( t_min, t_max, padding=0.0 )
self.plt.setYRange( ang_min, ang_max, padding=0.0 )
# If the core contains no Wind/MFI magnetic field data, return.
if ( self.core.n_mfi <= 0 ) :
return
# Generate and display each curve for the plot.
self.crv_colat = PlotDataItem( self.core.mfi_s,
self.core.mfi_b_colat,
pen=self.pen_crv_colat )
self.crv_lon = PlotDataItem( self.core.mfi_s,
self.core.mfi_b_lon,
pen=self.pen_crv_lon )
self.plt.addItem( self.crv_colat )
self.plt.addItem( self.crv_lon )
self.plt.setYRange( b_min, b_max, padding=0.0 )
# If the core contains no Wind/MFI magnetic field data, return.
if ( self.core.n_mfi <= 0 ) :
return
# Generate and display each curve for the plot.
self.crv_m = PlotDataItem( self.core.mfi_s,
self.core.mfi_b,
pen=self.pen_crv_m )
self.crv_n = PlotDataItem( self.core.mfi_s,
[ -b for b in self.core.mfi_b ],
pen=self.pen_crv_n )
self.crv_x = PlotDataItem( self.core.mfi_s,
self.core.mfi_b_x,
pen=self.pen_crv_x )
self.crv_y = PlotDataItem( self.core.mfi_s,
self.core.mfi_b_y,
pen=self.pen_crv_y )
self.crv_z = PlotDataItem( self.core.mfi_s,
self.core.mfi_b_z,
pen=self.pen_crv_z )
self.plt.addItem( self.crv_m )
self.plt.addItem( self.crv_n )
self.plt.addItem( self.crv_x )
self.plt.addItem( self.crv_y )
self.plt.addItem( self.crv_z )
def __init__(self, parent_plot):
KiteSubplot.__init__(self, parent_plot)
self.plot.setLabels(
bottom=('Distance', 'm'),
left='Covariance (m<sup>2</sup>)')
self.cov_spectral = pg.PlotDataItem(antialias=True)
self.cov_spectral.setZValue(10)
self.cov_spatial = pg.PlotDataItem(antialias=True)
self.cov_model = pg.PlotDataItem(
antialias=True,
pen=pen_covariance_model)
self.variance = self.VarianceLine(
pen=pen_variance,
angle=0, movable=True, hoverPen=pen_variance_highlight,
label='Variance: {value:.5f}',
labelOpts={'position': .975,
'anchors': ((1., 0.), (1., 1.)),
'color': pg.mkColor(255, 255, 255, 155)})
self.variance.setToolTip('Move to change variance')
self.variance.sigPositionChangeFinished.connect(self.setVariance)
self.addItem(self.cov_spectral)
self.addItem(self.cov_spatial)
self.addItem(self.cov_model)