Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_model(self, f=None):
self.read_parameters()
fit = Fit(self.data, self.functions)
if self.plot_checkbox.isChecked():
x = fit.x
else:
xmin, xmax = self.get_limits()
x = np.linspace(xmin, xmax, 1001)
return NXdata(NXfield(fit.get_model(x, f), name='model'),
NXfield(x, name=fit.data.nxaxes[0].nxname),
title='Fit Results')
def display_logo(self):
"""Display the NeXpy logo in the plotting pane."""
self.plot(NXdata(logo, title='NeXpy'), image=True)
self.ax.xaxis.set_visible(False)
self.ax.yaxis.set_visible(False)
self.ax.title.set_visible(False)
self.draw()
grid_locator2=locator)
if self.number < 101:
plotview = self
plotviews[self.label] = self
self.plotviews = plotviews
self.projection_panel = None
self.customize_panel = None
if self.label != "Main":
self.add_menu_action()
self.show()
#Add dummy NXdata group to ensure properties resolve properly
self.data = self.plotdata = NXdata((0,1), [(0,1)])
#Display the NeXpy logo in the plotting window
self.figure.clf()
self.ax.imshow(logo)
self.ax.axes.get_xaxis().set_visible(False)
self.ax.axes.get_yaxis().set_visible(False)
self.draw()
else:
self.errors = None
plotdata = NXdata(self.signal, self.axes[0], self.errors)
else:
self.xaxis = self.axis[self.ndim-1]
self.yaxis = self.axis[self.ndim-2]
if self.ndim > 2:
self.zaxis = self.axis[self.ndim-3]
self.zaxis.lo = self.zaxis.hi = self.zaxis.min
for i in range(self.ndim-3):
self.axis[i].lo = self.axis[i].hi \
= self.axis[i].data.min()
else:
self.zaxis = None
self.vaxis = self.axis['signal']
plotdata = NXdata(self.signal, [self.axes[i] for i in [-2,-1]])
plotdata['title'] = self.data.nxtitle
return plotdata
else:
self.errors = None
plotdata = NXdata(self.signal, self.axes[0], self.errors)
else:
self.xaxis = self.axis[self.ndim-1]
self.yaxis = self.axis[self.ndim-2]
if self.ndim > 2:
for i in range(self.ndim-2):
self.axis[i].lo = self.axis[i].hi \
= np.float(self.axis[i].data[idx[i]])
self.zaxis = self.axis[self.ndim - 3]
self.zaxis.lo = self.zaxis.hi = self.axis[self.ndim - 3].lo
else:
self.zaxis = None
self.vaxis = self.axis['signal']
plotdata = NXdata(self.signal, [self.axes[i] for i in [-2,-1]])
plotdata['title'] = self.data.nxtitle
return plotdata
Qb = np.linspace(qmin, qmax, NQ)
Eb = np.linspace(emin, emax, NE)
#histogram and normalize
norm, nbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb))
hist, hbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb), weights=datain)
if self.entry['data'].nxerrors:
histe, hbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb), weights=errorsin*errorsin)
histe = histe**0.5
err = histe/norm
I = NXfield(hist/norm, name='S(Q,E)')
Qb = NXfield(Qb[:-1]+dQ/2., name='Q')
Eb = NXfield(Eb[:-1]+dE/2., name='E')
result = NXdata(I, (Eb, Qb))
if self.entry.data.nxerrors:
result.errors = NXfield(err)
return result
Qb = np.linspace(qmin, qmax, NQ)
Eb = np.linspace(emin, emax, NE)
#histogram and normalize
norm, nbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb))
hist, hbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb), weights=datain)
if self.entry['data'].nxerrors:
histe, hbin = np.histogramdd((Ein,Qin), bins=(Eb,Qb), weights=errorsin*errorsin)
histe = histe**0.5
err = histe/norm
I = NXfield(hist/norm, name='S(Q,E)')
Qb = NXfield(Qb[:-1]+dQ/2., name='Q')
Eb = NXfield(Eb[:-1]+dE/2., name='E')
result = NXdata(I, (Eb, Qb))
if self.entry.data.nxerrors:
result.errors = NXfield(err)
return result
self.axis['signal'] = NXPlotAxis(self.signal)
for i in range(self.ndim):
if over:
self.axis[i].set_data(self.axes[i], self.shape[i])
else:
self.axis[i] = NXPlotAxis(self.axes[i], i, self.shape[i])
if self.ndim == 1:
self.xaxis = self.axis[0]
self.yaxis = self.axis['signal']
if self.data.nxerrors and self.data.nxerrors != self.data.nxsignal:
self.errors = self.data.nxerrors
else:
self.errors = None
plotdata = NXdata(self.signal, self.axes[0], self.errors)
else:
self.xaxis = self.axis[self.ndim-1]
self.yaxis = self.axis[self.ndim-2]
if self.ndim > 2:
for i in range(self.ndim-2):
self.axis[i].lo = self.axis[i].hi \
= np.float(self.axis[i].data[idx[i]])
self.zaxis = self.axis[self.ndim - 3]
self.zaxis.lo = self.zaxis.hi = self.axis[self.ndim - 3].lo
else:
self.zaxis = None
self.vaxis = self.axis['signal']
plotdata = NXdata(self.signal, [self.axes[i] for i in [-2,-1]])
plotdata['title'] = self.data.nxtitle