Skip to content

Commit

Permalink
Merge branch 'main' into test_range
Browse files Browse the repository at this point in the history
  • Loading branch information
patquem authored Aug 12, 2024
2 parents bf932a7 + 47fd257 commit 7a9460e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions fitspy/app/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ def remove(self, delete_tabview=True):
if self.current_spectrum is not None:
self.current_spectrum.remove_models()
self.current_spectrum.baseline.points = [[], []]

if delete_tabview: # expensive operation when doing a lot of times
self.paramsview.delete()
self.statsview.delete()
Expand Down Expand Up @@ -961,6 +962,7 @@ def add_items(self, fnames=None):

spectrum = Spectrum()
spectrum.fname = fname

spectrum.preprocess()
self.spectra.append(spectrum)

Expand Down Expand Up @@ -1006,6 +1008,7 @@ def update(self, fname=None):
self.update_markers(fname)

self.current_spectrum, _ = self.spectra.get_objects(fname)
self.current_spectrum.preprocess()

self.show_plot = False
self.set_range()
Expand Down
2 changes: 1 addition & 1 deletion fitspy/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def apply_model(self, model_dict, fnames=None, ncpus=1,
spectrum.fit()
queue_incr.put(1)
else:
fit_mp(spectra, ncpus, queue_incr)
fit_mp(spectra, ncpus, queue_incr, fit_only)

self.pbar_index = 0 # reinitialize pbar_index after the calculation
thread.join()
Expand Down
1 change: 0 additions & 1 deletion fitspy/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def load_profile(self, fname):

def apply_range(self, range_min=None, range_max=None):
""" Apply range to the raw spectrum """

self.range_min = range_min or self.range_min
self.range_max = range_max or self.range_max

Expand Down
3 changes: 2 additions & 1 deletion fitspy/utils_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initializer(queue_incr):
shared_queue = queue_incr


def fit_mp(spectra, ncpus, queue_incr):
def fit_mp(spectra, ncpus, queue_incr, fit_only):
""" Multiprocessing fit function applied to spectra """
args = []
for spectrum in spectra:
Expand All @@ -47,4 +47,5 @@ def fit_mp(spectra, ncpus, queue_incr):
spectrum.baseline.y_eval = res[2]
spectrum.baseline.is_subtracted = res[3]
spectrum.result_fit = dill.loads(res[4])

spectrum.reassign_params()

0 comments on commit 7a9460e

Please sign in to comment.