Skip to content
Snippets Groups Projects
Commit a5388fee authored by Johannes Niskanen's avatar Johannes Niskanen
Browse files

Some nasty bugs fixed.

parent 36ac54ed
No related branches found
No related tags found
2 merge requests!198Alignment of spectra,!188P2866 updates
......@@ -536,21 +536,23 @@ class hRIXS:
# if the leftover tail is more than a half of full length, add it too
if data.spectrum.shape[0]%ImageGrouping > ImageGrouping/2:
spectra.append(np.sum(data.spectrum[Ngroups*ImageGrouping::].to_numpy(),axis=0))
xhits.append(np.hstack(xhits[Ngroups*ImageGrouping::].to_numpy()))
xhits.append(np.hstack(data.xhits[Ngroups*ImageGrouping::].to_numpy()))
elif ImageGrouping.lower() == 'run' or ImageGrouping.lower() == 'runs':
#********************************************
# Group data by runs
#********************************************
energy = data_list[0].energy.to_numpy()
spectra = []
xhits = []
for rundata in data_list:
runspectrum = np.zeros(energy.shape)
runxhits = []
for spec,hits in zip(rundata.spectrum,rundata.xhits):
runspectrum += spec.to_numpy()
runxhits.append(hits.to_numpy())
for spec,hits in zip(rundata.spectrum.to_numpy(),rundata.xhits.to_numpy()):
runspectrum += spec
runxhits.append(hits)
runxhits = np.hstack(runxhits)
spectra.append(runspectrum)
xhits.append(np.hstack(runxhits))
xhits.append(runxhits)
else:
raise Exception('align_readouts() needs a reasonable grouping argument')
#********************************************
......@@ -597,6 +599,9 @@ class hRIXS:
maxpos = np.argmax(corr)
shift = maxpos-corr_len
peak_posis.append(x[maxipos0+shift])
#********************************************
# Alignment based on Gaussian fitting
#********************************************
elif method.lower() == 'gauss_fit':
if fit_tol == None:
raise Exception('Gauss fit requires a tolerance value.')
......@@ -673,7 +678,7 @@ class hRIXS:
ret.append(np.interp(grid,x,y))
spectrum_aligned = np.array(ret)
elif method.lower() == 'gauss_fit':
e0 = peak_posis[0]
e0 = int(peak_posis[0])
energy_aligned = np.linspace(self.Y_RANGE.start, self.Y_RANGE.stop, self.BINS)-e0
ret = []
for position,hits in zip(peak_posis,xhits):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment