From 8df7b42135e701d5f05cc86cccf206a955f3a05e Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 26 Sep 2024 07:05:07 -0500 Subject: [PATCH] Fixed issues with labeled spectra not clearing properly. Changed default optimizer to mpfit. Change default optimization preset to fit with tails --- src/data_struct/analysis_job.cpp | 4 ++-- src/fitting/models/gaussian_model.cpp | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/data_struct/analysis_job.cpp b/src/data_struct/analysis_job.cpp index d7d12e02..bbd6ff8a 100644 --- a/src/data_struct/analysis_job.cpp +++ b/src/data_struct/analysis_job.cpp @@ -57,13 +57,13 @@ namespace data_struct template Analysis_Job::Analysis_Job() { - _optimizer = &_lmfit_optimizer; + _optimizer = &_mpfit_optimizer; optimize_fit_routine = OPTIMIZE_FIT_ROUTINE::ALL_PARAMS; _last_init_sample_size = 0; _first_init = true; num_threads = std::thread::hardware_concurrency(); //default mode for which parameters to fit when optimizing fit parameters - optimize_fit_params_preset = fitting::models::Fit_Params_Preset::BATCH_FIT_NO_TAILS; + optimize_fit_params_preset = fitting::models::Fit_Params_Preset::BATCH_FIT_WITH_TAILS; quick_and_dirty = false; generate_average_h5 = false; add_v9_layout = false; diff --git a/src/fitting/models/gaussian_model.cpp b/src/fitting/models/gaussian_model.cpp index 85203fc3..d5f2570a 100644 --- a/src/fitting/models/gaussian_model.cpp +++ b/src/fitting/models/gaussian_model.cpp @@ -352,12 +352,9 @@ const Spectra Gaussian_Model::model_spectrum(const Fit_Parameter if (labeled_spectras != nullptr) // if this stucture is not null then initialize { + labeled_spectras->clear(); for (auto& itr : spectra_labels) { - if (labeled_spectras->count(itr) > 1) - { - labeled_spectras->erase(itr); - } labeled_spectras->insert({ itr, Spectra(energy_range.count()) }); } } @@ -430,12 +427,9 @@ const std::tuple, std::vector>> Gaussia if (labeled_spectras != nullptr) // if this stucture is not null then initialize { + labeled_spectras->clear(); for (auto& itr : spectra_labels) { - if (labeled_spectras->count(itr) > 1) - { - labeled_spectras->erase(itr); - } labeled_spectras->insert({ itr, Spectra(energy_range.count()) }); } } @@ -574,7 +568,7 @@ const Spectra Gaussian_Model::model_spectrum_element(const Fit_P if (false == std::isfinite(pre_faktor)) { - logE << "Prefactor = " << pre_faktor << "\n"; + logE << "Prefactor = " << pre_faktor << " for "<full_name()<<" . Log10 Value = "<< fitp->at(element_to_fit->full_name()).value <<"\n"; spectra_model = (ArrayTr)(spectra_model).unaryExpr([](T_real v) { return std::numeric_limits::quiet_NaN(); }); return spectra_model; }