Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#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
qmax = Q.max()
emin = E.min()
emax = E.max()
NQ = int((qmax-qmin)/dQ) + 1
NE = int((emax-emin)/dE) + 1
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
"""
if self.ndim > 2:
idx=[np.s_[0] if s==1 else np.s_[:] for s in self.data.nxsignal.shape]
for i in range(len(idx)):
if idx.count(slice(None,None,None)) > 2:
idx[i] = 0
self.signal = self.data.nxsignal[tuple(idx)][()]
elif self.rgb_image:
self.signal = self.data.nxsignal[()]
else:
self.signal = self.data.nxsignal[()].reshape(self.shape)
if self.data.plot_axes is not None:
axes = self.data.plot_axes
else:
axes = [NXfield(np.arange(self.shape[i]), name='Axis%s'%i)
for i in range(self.ndim)]
self.axes = [NXfield(axes[i].nxdata, name=axes[i].nxname,
attrs=axes[i].safe_attrs) for i in range(self.ndim)]
if over:
self.axis['signal'].set_data(self.signal)
else:
self.axis = {}
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])
qmax = Q.max()
emin = E.min()
emax = E.max()
NQ = int((qmax-qmin)/dQ) + 1
NE = int((emax-emin)/dE) + 1
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
for i in range(len(idx)):
if idx.count(slice(None,None,None)) > 2:
idx[i] = 0
self.signal = self.data.nxsignal[tuple(idx)][()]
elif self.rgb_image:
self.signal = self.data.nxsignal[()]
else:
self.signal = self.data.nxsignal[()].reshape(self.shape)
if self.data.plot_axes is not None:
axes = self.data.plot_axes
else:
axes = [NXfield(np.arange(self.shape[i]), name='Axis%s'%i)
for i in range(self.ndim)]
self.axes = [NXfield(axes[i].nxdata, name=axes[i].nxname,
attrs=axes[i].safe_attrs) for i in range(self.ndim)]
if over:
self.axis['signal'].set_data(self.signal)
else:
self.axis = {}
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])
self.axis[i].dim = i
if self.ndim == 1:
def plot_axis(axis):
return NXfield(axis.nxvalue, name=axis.nxname, attrs=axis.attrs)
axis_name = self.axis_boxes[axis].currentText()