diff --git a/notebook/Resolution comparison.ipynb b/notebook/Resolution comparison.ipynb index 49593c70ed6eab8501c9c1fd83e08f077d0f8a51..7e499b01d947718521649e0fd5e20966ff11467a 100644 Binary files a/notebook/Resolution comparison.ipynb and b/notebook/Resolution comparison.ipynb differ diff --git a/pes_to_spec/model.py b/pes_to_spec/model.py index 3f692681cde5ed862c6f75aa1cfbfb797f36af20..644f4696169d26006964f2e65bd38fb158d1c7e9 100644 --- a/pes_to_spec/model.py +++ b/pes_to_spec/model.py @@ -518,6 +518,19 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator): y[channel] = [np.pad(y[channel][j], ((0, 0), (0, 2*self.delta_tof - y[channel][j].shape[1]))) for j in range(len(y[channel]))] y[channel] = np.stack(y[channel], axis=1) + + # roll data in the first pulse to check best shift + shifts = np.arange(-3, 3+1) + chi2 = {ch: np.zeros_like(shifts, dtype=np.float32) + for ch in y.keys()} + for i, s in enumerate(shifts): + meanX = {ch: np.mean(np.roll(y[ch][:,0,:], s, axis=-1), axis=0, keepdims=True) + for ch in y.keys()} + for ch in y.keys(): + chi2[ch] = np.sum(((meanX[ch] - self.mean[ch][:,0,:])/self.std[ch][:,0,:])**2) + shift = {ch: shifts[np.argmin(chi2[ch])] + for ch in y.keys()} + if not keep_dictionary_structure: selected = list(y.values()) if pulse_energy is not None: