Skip to content

Commit db2337a

Browse files
author
Arthur Glowacki
committed
Merge branch 'polar' of github.com:/aglowacki/XRF-Maps into polar
2 parents 04a2b14 + c99d097 commit db2337a

35 files changed

Lines changed: 197 additions & 251 deletions

src/core/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void set_optimizer(Command_Line_Parser& clp, data_struct::Analysis_Job<T_real>&
179179
// ----------------------------------------------------------------------------
180180

181181
template <typename T_real>
182-
void set_mem_limit(Command_Line_Parser& clp, data_struct::Analysis_Job<T_real>& analysis_job)
182+
void set_mem_limit(Command_Line_Parser& clp, [[maybe_unused]] data_struct::Analysis_Job<T_real>& analysis_job)
183183
{
184184
//check if we should set a ram memory limit
185185
if (clp.option_exists("--mem-limit"))
@@ -448,8 +448,8 @@ int set_dir_and_files(Command_Line_Parser& clp, data_struct::Analysis_Job<T_real
448448
continue;
449449
}
450450
logI<<dataset_dir << DIR_END_CHAR << itr << DIR_END_CHAR << "*.h5"<<"\n";
451-
std::vector<std::string> flist = io::file::File_Scan::inst()->find_all_dataset_files_by_list(dataset_dir + DIR_END_CHAR + itr + DIR_END_CHAR, search_ext_h5_list);
452-
for (const auto& fitr : flist)
451+
std::vector<std::string> flist1 = io::file::File_Scan::inst()->find_all_dataset_files_by_list(dataset_dir + DIR_END_CHAR + itr + DIR_END_CHAR, search_ext_h5_list);
452+
for (const auto& fitr : flist1)
453453
{
454454
//logI<<fitr<<"\n";
455455
analysis_job.dataset_files.push_back(itr + DIR_END_CHAR + fitr);
@@ -957,8 +957,8 @@ int main(int argc, char* argv[])
957957

958958
// get location of where we are running from and use it to find ref files
959959
std::string exe_loc = std::string(argv[0]);
960-
int prog_idx = exe_loc.find("xrf_maps");
961-
if (prog_idx > 0)
960+
size_t prog_idx = exe_loc.find("xrf_maps");
961+
if (prog_idx != std::string::npos)
962962
{
963963
exe_loc = exe_loc.substr(0, prog_idx);
964964
}

src/core/process_whole.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool optimize_integrated_fit_params(data_struct::Analysis_Job<double> * analysis
127127
ret_val = false;
128128
break;
129129
}
130-
io::file::save_optimized_fit_params(analysis_job->output_dir, save_filename, detector_num, result, &out_fitp, &int_spectra, &(params_override->elements_to_fit));
130+
io::file::save_optimized_fit_params(analysis_job->output_dir, save_filename, (int)detector_num, result, &out_fitp, &int_spectra, &(params_override->elements_to_fit));
131131

132132
delete fit_routine;
133133
}
@@ -142,7 +142,7 @@ void generate_optimal_params(data_struct::Analysis_Job<double>* analysis_job)
142142
{
143143
std::unordered_map<int, data_struct::Fit_Parameters<double>> fit_params_avgs;
144144
std::unordered_map<int, data_struct::Params_Override<double>*> params;
145-
std::unordered_map<int, float> detector_file_cnt;
145+
std::unordered_map<size_t, float> detector_file_cnt;
146146
data_struct::Params_Override<double>* params_override = nullptr;
147147
data_struct::Spectra<double> int_spectra;
148148

@@ -463,7 +463,7 @@ bool perform_quantification(data_struct::Analysis_Job<double>* analysis_job, boo
463463
for(size_t detector_num : analysis_job->detector_num_arr)
464464
{
465465
data_struct::Detector<double>* detector = analysis_job->get_detector(detector_num);
466-
data_struct::Params_Override<double>* override_params = &(detector->fit_params_override_dict);
466+
//data_struct::Params_Override<double>* override_params = &(detector->fit_params_override_dict);
467467

468468

469469
load_and_fit_quatification_datasets(analysis_job, detector_num);
@@ -549,8 +549,8 @@ bool perform_quantification(data_struct::Analysis_Job<double>* analysis_job, boo
549549
}
550550

551551
// check if esrf dataset and remove folder
552-
int didx = dataset_file.find(DIR_END_CHAR);
553-
if (didx > -1)
552+
size_t didx = dataset_file.find(DIR_END_CHAR);
553+
if (didx != std::string::npos)
554554
{
555555
dataset_file = dataset_file.substr(didx + 1);
556556
}
@@ -783,7 +783,7 @@ void optimize_single_roi(data_struct::Analysis_Job<double>& analysis_job,
783783
// int specs loaded from v10 version
784784
std::unordered_map<std::string, data_struct::Spectra<double> > int_specs;
785785

786-
int slen = roi_file_name.size();
786+
size_t slen = roi_file_name.size();
787787
if (slen < 6)
788788
{
789789
logE << "Roi file name too short " << roi_file_name << ". Skipping file.\n";
@@ -804,7 +804,7 @@ void optimize_single_roi(data_struct::Analysis_Job<double>& analysis_job,
804804
// search for detector in list of int specs loaded
805805
for (const auto& spec_itr : int_specs)
806806
{
807-
int slen = spec_itr.first.length();
807+
slen = spec_itr.first.length();
808808
if (slen > 0 && spec_itr.first[slen - 1] == str_detector_num[0])
809809
{
810810
search_filename = spec_itr.first;

src/core/process_whole.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ DLL_EXPORT void proc_spectra(data_struct::Spectra_Volume<T_real>* spectra_volume
320320
cur_block++;
321321
}
322322

323-
std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
323+
end = std::chrono::system_clock::now();
324324
std::chrono::duration<double> elapsed_seconds = end - start;
325325
logI << "Fitting [ " << fit_routine->get_name() << " ] elapsed time: " << elapsed_seconds.count() << "s" << "\n";
326326

@@ -342,8 +342,8 @@ DLL_EXPORT void proc_spectra(data_struct::Spectra_Volume<T_real>* spectra_volume
342342
}
343343
// save png
344344
std::string dataset_fullpath = io::file::HDF5_IO::inst()->get_filename();
345-
int sidx = dataset_fullpath.find("img.dat");
346-
if (dataset_fullpath.length() > 0 && sidx > 0)
345+
size_t sidx = dataset_fullpath.find("img.dat");
346+
if (dataset_fullpath.length() > 0 && sidx != std::string::npos)
347347
{
348348
dataset_fullpath.replace(sidx, 7, "output"); // 7 = sizeof("img.dat")
349349
std::string str_path = dataset_fullpath + "_" + fit_routine->get_name() + ".png";
@@ -362,11 +362,10 @@ DLL_EXPORT void proc_spectra(data_struct::Spectra_Volume<T_real>* spectra_volume
362362
if (itr.first == data_struct::Fitting_Routines::GAUSS_MATRIX)
363363
{
364364
fitting::routines::Matrix_Optimized_Fit_Routine<T_real>* matrix_fit = (fitting::routines::Matrix_Optimized_Fit_Routine<T_real>*)fit_routine;
365-
io::file::HDF5_IO::inst()->save_max_10_spectra(fit_routine->get_name(),
366-
matrix_fit->energy_range(),
367-
matrix_fit->max_integrated_spectra(),
368-
matrix_fit->max_10_integrated_spectra(),
369-
matrix_fit->fitted_integrated_background());
365+
io::file::HDF5_IO::inst()->save_max_10_spectra(matrix_fit->energy_range(),
366+
matrix_fit->max_integrated_spectra(),
367+
matrix_fit->max_10_integrated_spectra(),
368+
matrix_fit->fitted_integrated_background());
370369
}
371370

372371
delete fit_job_queue;

src/data_struct/element_info.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace data_struct
5858

5959
Electron_Shell get_shell_by_name(std::string element_name)
6060
{
61-
int idx = element_name.find_last_of("_") + 1;
61+
size_t idx = element_name.find_last_of("_") + 1;
6262
std::string shell_type = element_name.substr(idx);
6363
if (idx == 0)
6464
{
@@ -457,11 +457,11 @@ T_real Element_Info_Map<T_real>::calc_compound_beta(std::string compound_name, T
457457
T_real atwt = 0.0;
458458
T_real f2 = 0;
459459
//"N:78.08,O:20.95,Ar:0.93"
460-
int idx = compound_name.find(",");
461-
while (idx > -1 || compound_name.length() > 0)
460+
size_t idx = compound_name.find(",");
461+
while (std::string::npos != idx || compound_name.length() > 0)
462462
{
463463
std::string sub_compound;
464-
if (idx > -1)
464+
if (std::string::npos != idx)
465465
{
466466
sub_compound = compound_name.substr(0, idx);
467467
compound_name = compound_name.substr(idx + 1);
@@ -473,8 +473,8 @@ T_real Element_Info_Map<T_real>::calc_compound_beta(std::string compound_name, T
473473
}
474474

475475

476-
int idx2 = sub_compound.find(":");
477-
if (idx2 > -1)
476+
size_t idx2 = sub_compound.find(":");
477+
if (std::string::npos != idx2)
478478
{
479479
std::string el_symb = sub_compound.substr(0, idx2);
480480
std::string str_amt = sub_compound.substr(idx2+1);

src/data_struct/fit_element_map.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Fit_Element_Map<T_real>::Fit_Element_Map(std::string name, Element_Info<T_real>*
7373

7474
size_t num_ratios = 1;
7575

76-
int idx = _full_name.find_last_of("_") + 1;
76+
size_t idx = _full_name.find_last_of("_") + 1;
7777
if(idx == 0)
7878
{
7979
_shell_type = Electron_Shell::K_SHELL;
@@ -341,7 +341,7 @@ void Fit_Element_Map<T_real>::set_as_pileup(std::string name, Element_Info<T_rea
341341
{
342342
if(_pileup_element_info == nullptr)
343343
{
344-
int idx = name.find_last_of("_") + 1;
344+
size_t idx = name.find_last_of("_") + 1;
345345
if(idx == 0)
346346
{
347347
_pileup_shell_type = "K";
@@ -364,7 +364,6 @@ void Fit_Element_Map<T_real>::set_as_pileup(std::string name, Element_Info<T_rea
364364
template<typename T_real>
365365
bool Fit_Element_Map<T_real>::check_binding_energy(T_real incident_energy, int energy_ratio_idx) const
366366
{
367-
T_real binding_e;
368367
if (_element_info != nullptr)
369368
{
370369
if( _pileup_element_info != nullptr)

src/data_struct/fit_parameters.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void Fit_Parameters<T_real>::from_array_d(const std::vector<double> &arr)
208208
{
209209
for(auto& itr : _params)
210210
{
211-
if (itr.second.opt_array_index > -1 && itr.second.opt_array_index < (int)arr.size())
211+
if (itr.second.opt_array_index != -1 && itr.second.opt_array_index < (int)arr.size())
212212
{
213213
itr.second.value = arr[itr.second.opt_array_index];
214214
}
@@ -224,7 +224,7 @@ void Fit_Parameters<T_real>::from_array(const T_real* arr, size_t arr_size)
224224
//logit_s<<"\n";
225225
for(auto& itr : _params)
226226
{
227-
if (itr.second.opt_array_index > -1 && itr.second.opt_array_index < (int)arr_size)
227+
if (itr.second.opt_array_index != -1 && itr.second.opt_array_index < (int)arr_size)
228228
{
229229
itr.second.value = arr[itr.second.opt_array_index];
230230
}
@@ -397,7 +397,7 @@ void Fit_Parameters<T_real>::print()
397397
for(const auto& itr : _params)
398398
{
399399
// 22 is len of longest name COHERENT_SCT_AMPLITUDE
400-
int spaces = 24 - itr.first.length();
400+
size_t spaces = 24 - itr.first.length();
401401
std::string name = itr.first;
402402
name.append(spaces, ' ');
403403
std::string value = std::to_string(itr.second.value);

src/data_struct/fit_parameters.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct DLL_EXPORT Fit_Param
112112
value = std::numeric_limits<T_real>::quiet_NaN();
113113
step_size = std::numeric_limits<T_real>::quiet_NaN();
114114
bound_type = E_Bound_Type::NOT_INIT;
115-
opt_array_index = -1;
115+
opt_array_index = (size_t)-1;
116116
}
117117

118118
Fit_Param(const Fit_Param& param)
@@ -134,7 +134,7 @@ struct DLL_EXPORT Fit_Param
134134
value = std::numeric_limits<T_real>::quiet_NaN();
135135
step_size = std::numeric_limits<T_real>::quiet_NaN();
136136
bound_type = E_Bound_Type::NOT_INIT;
137-
opt_array_index = -1;
137+
opt_array_index = (size_t)-1;
138138
}
139139

140140
Fit_Param(std::string name_, T_real val_)
@@ -145,7 +145,7 @@ struct DLL_EXPORT Fit_Param
145145
step_size = (T_real)0.000001;
146146
value = val_;
147147
bound_type = E_Bound_Type::FIXED;
148-
opt_array_index = -1;
148+
opt_array_index = (size_t)-1;
149149
}
150150

151151
Fit_Param(std::string name_, T_real val_, E_Bound_Type b_type)
@@ -156,7 +156,7 @@ struct DLL_EXPORT Fit_Param
156156
step_size = (T_real)0.000001;
157157
value = val_;
158158
bound_type = b_type;
159-
opt_array_index = -1;
159+
opt_array_index = (size_t)-1;
160160
}
161161

162162
Fit_Param(std::string name_, T_real min_, T_real max_, T_real val_, T_real step_size_, E_Bound_Type b_type)
@@ -167,7 +167,7 @@ struct DLL_EXPORT Fit_Param
167167
value = val_;
168168
bound_type = b_type;
169169
step_size = step_size_;
170-
opt_array_index = -1;
170+
opt_array_index = (size_t)-1;
171171
}
172172

173173
const std::string bound_type_str() const;
@@ -178,7 +178,7 @@ struct DLL_EXPORT Fit_Param
178178
T_real value;
179179
T_real step_size;
180180
E_Bound_Type bound_type;
181-
int opt_array_index;
181+
size_t opt_array_index;
182182
};
183183

184184
//-----------------------------------------------------------------------------

src/data_struct/spectra.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ DLL_EXPORT ArrayTr<T_real> convolve1d(const ArrayTr<T_real>& arr, const ArrayTr<
306306
out.setZero(n);
307307
for (size_t i = 0; i < n; ++i)
308308
{
309-
for (int j(min_v.size() - 1), k(i); j >= 0; --j)
309+
for (size_t j(min_v.size() - 1), k(i); j >= 0; --j)
310310
{
311311
out[i] += min_v[j] * max_v[k];
312312
++k;
313313
}
314314
}
315315
T_real norm = 1 / T_real(boxcar.size());
316-
int j = min_v.size() / 2;
316+
size_t j = min_v.size() / 2;
317317
for (size_t i = 0; i < n; i++)
318318
{
319319
new_background[j] = out[i] * norm;

src/data_struct/stream_block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ size_t Stream_Block<T_real>::dataset_hash()
218218
{
219219
return std::hash<std::string> {} ((*dataset_directory) + (*dataset_name)) + _detector;
220220
}
221-
return -1;
221+
return (size_t)-1;
222222
}
223223

224224
//-----------------------------------------------------------------------------

src/fitting/models/base_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DLL_EXPORT Base_Model
124124

125125
virtual void reset_to_default_fit_params() = 0;
126126

127-
virtual void update_fit_params_values(const Fit_Parameters<T_real> *fit_params) = 0;
127+
virtual void update_fit_params_values(const Fit_Parameters<T_real> * const fit_params) = 0;
128128

129129
virtual void print_fit_params() = 0;
130130

0 commit comments

Comments
 (0)