Skip to content

Commit

Permalink
fix bug: in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
h0anle committed Sep 25, 2024
1 parent 7494507 commit dbd1a39
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
48 changes: 24 additions & 24 deletions app/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,30 +2411,30 @@ def decompress(data, dtype):
return np.frombuffer(decompressed, dtype=dtype)

def plot_baseline_dynamically(ax, spectrum):
"""Evaluate and plot baseline points and line dynamically"""
if not spectrum.baseline.is_subtracted:
x_bl = spectrum.x
y_bl = spectrum.y if spectrum.baseline.attached else None
if len(spectrum.baseline.points[0]) == 0:
return
# Clear any existing baseline plot
for line in ax.lines:
if line.get_label() == "Baseline":
line.remove()
# Evaluate the baseline
attached = spectrum.baseline.attached
baseline_values = spectrum.baseline.eval(x_bl, y_bl,
attached=attached)
ax.plot(x_bl, baseline_values, 'r')

# Plot the attached baseline points
if spectrum.baseline.attached and y_bl is not None:
attached_points = spectrum.baseline.attached_points(x_bl, y_bl)
ax.plot(attached_points[0], attached_points[1], 'ko',
mfc='none')
else:
ax.plot(spectrum.baseline.points[0],
spectrum.baseline.points[1], 'ko', mfc='none', ms=5)
"""Evaluate and plot baseline points and line dynamically"""
if not spectrum.baseline.is_subtracted:
x_bl = spectrum.x
y_bl = spectrum.y if spectrum.baseline.attached else None
if len(spectrum.baseline.points[0]) == 0:
return
# Clear any existing baseline plot
for line in ax.lines:
if line.get_label() == "Baseline":
line.remove()
# Evaluate the baseline
attached = spectrum.baseline.attached
baseline_values = spectrum.baseline.eval(x_bl, y_bl,
attached=attached)
ax.plot(x_bl, baseline_values, 'r')

# Plot the attached baseline points
if spectrum.baseline.attached and y_bl is not None:
attached_points = spectrum.baseline.attached_points(x_bl, y_bl)
ax.plot(attached_points[0], attached_points[1], 'ko',
mfc='none')
else:
ax.plot(spectrum.baseline.points[0],
spectrum.baseline.points[1], 'ko', mfc='none', ms=5)

def populate_spectrum_listbox(spectrum, spectrum_name, checked_states):
""" Populate the listbox with spectrums with colors"""
Expand Down
1 change: 1 addition & 0 deletions app/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def setup_baseline_controls(self):
self.ui.cb_attached.stateChanged.connect(self.get_baseline_settings)
self.ui.noise.valueChanged.connect(self.get_baseline_settings)
self.ui.rbtn_linear.toggled.connect(self.get_baseline_settings)
self.ui.rbtn_polynomial.clicked.connect(self.get_baseline_settings)
self.ui.degre.valueChanged.connect(self.get_baseline_settings)

self.ui.btn_copy_bl.clicked.connect(self.copy_baseline)
Expand Down
2 changes: 2 additions & 0 deletions app/spectrums.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def setup_baseline_controls(self):
self.ui.btn_copy_bl_2.clicked.connect(self.copy_baseline)
self.ui.btn_paste_bl_2.clicked.connect(self.paste_baseline_handler)
self.ui.sub_baseline_2.clicked.connect(self.subtract_baseline_handler)
self.get_baseline_settings()

def open_spectra(self, spectra=None, file_paths=None):
"""Open and load raw spectral data"""
Expand Down Expand Up @@ -153,6 +154,7 @@ def open_spectra(self, spectra=None, file_paths=None):
spectrum.correction_value = 0

spectrum.baseline.mode = "Linear"
spectrum.baseline.sigma = 5
self.spectrums.append(spectrum)

QTimer.singleShot(100, self.upd_spectra_list)
Expand Down

0 comments on commit dbd1a39

Please sign in to comment.