forked from IPKM/nmreval
fix edit dialog for spectra
This commit is contained in:
parent
185dd160f1
commit
661ab81d7e
@ -778,7 +778,6 @@ class SignalContainer(ExperimentContainer):
|
||||
self._data.apod(*apod)
|
||||
|
||||
if fourier[0] is not None:
|
||||
print(fourier)
|
||||
if fourier[0]:
|
||||
if phase[0] is not None:
|
||||
self._data.manual_phase(*phase)
|
||||
|
@ -96,7 +96,7 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
self._all_freq = True
|
||||
|
||||
fid = data.copy()
|
||||
spec = self._temp_fft(fid.x, fid.y)
|
||||
spec = self._temp_fft_time(fid.x, fid.y, self.baseline_box.isChecked())
|
||||
|
||||
x_len = data.x.size
|
||||
self.zf_spinbox.setMaximum(min(2**17//x_len, 3))
|
||||
@ -128,7 +128,7 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
def _update_bl(self):
|
||||
if self.baseline_box.isChecked():
|
||||
for y in self._tmp_data_bl:
|
||||
y -= y[int(-0.12*y.size):].mean()
|
||||
self._temp_baseline(y)
|
||||
else:
|
||||
for i, d in enumerate(self.data):
|
||||
self._tmp_data_bl[i] = d.y.copy()
|
||||
@ -200,7 +200,7 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
ph1 = self.ph1_spinbox.value()
|
||||
|
||||
for i, (x, y) in enumerate(self._tmp_data_ap):
|
||||
x_fft, y_fft = self._temp_fft(x, y)
|
||||
x_fft, y_fft = self._temp_fft_time(x, y, self.baseline_box.isChecked())
|
||||
|
||||
if ph0 != 0:
|
||||
y = self._temp_phase(x, y, ph0, 0, 0)
|
||||
@ -213,7 +213,7 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
else:
|
||||
self.pvt_line.hide()
|
||||
for i, (x, y) in enumerate(self._tmp_data_ap):
|
||||
self._tmp_data_ph[i] = x, y, *self._temp_fft(x, y)
|
||||
self._tmp_data_ph[i] = x, y, *self._temp_fft_time(x, y, self.baseline_box.isChecked())
|
||||
|
||||
self._update_plots()
|
||||
|
||||
@ -225,6 +225,15 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
self.graphs[i][2].setData(x=xf, y=yf.real)
|
||||
self.graphs[i][3].setData(x=xf, y=yf.imag)
|
||||
|
||||
@staticmethod
|
||||
def _temp_baseline_time(y):
|
||||
y -= y[int(-0.12 * y.size):].mean()
|
||||
|
||||
@staticmethod
|
||||
def _temp_baseline_freq(y):
|
||||
region = int(0.12 * y.size)
|
||||
y -= np.mean([y[-region:], y[:region]])
|
||||
|
||||
@staticmethod
|
||||
def _temp_phase(x: np.ndarray, y: np.ndarray, ph0: float, ph1: float, pvt: float) -> np.ndarray:
|
||||
phase_correction = np.exp(-1j * (ph0 + ph1 * (x - pvt) / x.max()) * pi / 180.)
|
||||
@ -254,12 +263,19 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
return _y
|
||||
|
||||
@staticmethod
|
||||
def _temp_fft(x: np.ndarray, y: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
|
||||
def _temp_fft_time(x: np.ndarray, y: np.ndarray, baseline: bool = False) -> tuple[np.ndarray, np.ndarray]:
|
||||
y_fft = fftshift(fft(y))
|
||||
x_fft = fftshift(fftfreq(len(x), d=x[1]-x[0]))
|
||||
|
||||
if baseline:
|
||||
QPreviewDialog._temp_baseline_freq(y_fft)
|
||||
|
||||
return x_fft, y_fft
|
||||
|
||||
@staticmethod
|
||||
def _temp_fft_freq(x: np.ndarray, y: np.ndarray, _=None):
|
||||
return x, y
|
||||
|
||||
def move_line(self, evt):
|
||||
self.pivot_lineedit.setText(f'{evt.value():.5g}')
|
||||
|
||||
@ -329,6 +345,8 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
|
||||
self.data = []
|
||||
self.graphs = []
|
||||
self.freq_graph.removeItem(self.pvt_line)
|
||||
self.time_graph.removeItem(self.pvt_line)
|
||||
|
||||
self.blockSignals(False)
|
||||
|
||||
@ -374,3 +392,14 @@ class QPreviewDialog(QtWidgets.QDialog, Ui_ApodEdit):
|
||||
self.zerofill_box.setVisible(self._all_time)
|
||||
self.apod_box.setVisible(self._all_time)
|
||||
self.shift_box.setVisible(self._all_time)
|
||||
|
||||
self._temp_baseline = self._temp_baseline_time if self._all_time else self._temp_baseline_freq
|
||||
self._temp_fft = self._temp_fft_time if self._all_time else self._temp_fft_freq
|
||||
|
||||
self.freq_graph.setVisible(self._all_time)
|
||||
if self._all_freq:
|
||||
self.time_graph.addItem(self.pvt_line)
|
||||
else:
|
||||
self.freq_graph.addItem(self.pvt_line)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user