Skip to content

Commit

Permalink
Merge pull request #335 from dmgav/json-issue
Browse files Browse the repository at this point in the history
Resolved multiple issues with PyXRF
  • Loading branch information
dmgav authored Feb 6, 2025
2 parents 938db81 + 66be934 commit 5d06d62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 14 additions & 2 deletions pyxrf/core/map_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ def compute_selected_rois(
# is interest. The output of this function is tested to match the
# output of 'snip_method' to make sure the functions are equivalent.


_default_con_val_no_bin = 3
_default_con_val_bin = 5
_default_iter_num_no_bin = 3
Expand Down Expand Up @@ -1225,6 +1226,7 @@ def snip_method_numba(
geoscience applications", Nuclear Instruments and Methods in
Physics Research Section B, vol. 34, 1998.
"""

# clean input a bit
if con_val is None:
if spectral_binning is None:
Expand Down Expand Up @@ -1319,7 +1321,12 @@ def _clip(arr, vmin, vmax):
temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0

bg_index = background > temp
background[bg_index] = temp[bg_index]
# The following numpy based line of code stopped working with numba v0.61.0
# background[bg_index] = temp[bg_index]
# The following code is the workaround. Seems fast enough.
for n in range(len(background)):
if bg_index[n]:
background[n] = temp[n]

current_width = window_p
max_current_width = np.amax(current_width)
Expand All @@ -1331,7 +1338,12 @@ def _clip(arr, vmin, vmax):
temp = (background[lo_index.astype(np.int32)] + background[hi_index.astype(np.int32)]) / 2.0

bg_index = background > temp
background[bg_index] = temp[bg_index]
# The following numpy based line of code stopped working with numba v0.61.0
# background[bg_index] = temp[bg_index]
# The following code is the workaround. Seems fast enough.
for n in range(len(background)):
if bg_index[n]:
background[n] = temp[n]

# decrease the width and repeat
current_width = current_width / decrease_factor
Expand Down
8 changes: 5 additions & 3 deletions pyxrf/model/lineplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,9 +1499,11 @@ def _show_preview_spectrum_plot(self):
# Completely redraw the plot each time the function is called
self.prepare_preview_spectrum_plot()

# Remove all lines from the plot
while len(self._lines_preview):
self._lines_preview.pop().remove()
# Remove all lines from the plot. This is not really needed, since the axes are cleared.
# while len(self._lines_preview):
# _ = self._lines_preview.pop()
# if _.axes is not None:
# _.remove()

# The list of color names
color_names = get_color_name()
Expand Down

0 comments on commit 5d06d62

Please sign in to comment.