Skip to content

Commit 1f92adc

Browse files
authored
Merge pull request #238 from aglowacki/master
updates and bug fixes
2 parents 209258c + c2c24c1 commit 1f92adc

37 files changed

Lines changed: 1412 additions & 600 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ set(libxrf_fit_SOURCE
306306
set(XRF_IO_HEADERS
307307
src/core/mem_info.h
308308
src/support/mdautils-1.4.1/mda-load.h
309+
src/io/file/file_scan.h
309310
src/io/file/mda_io.h
310311
src/io/file/mca_io.h
311312
src/io/file/hdf5_io.h
@@ -314,7 +315,6 @@ set(XRF_IO_HEADERS
314315
src/io/file/aps/aps_fit_params_import.h
315316
src/io/file/aps/aps_roi.h
316317
src/io/file/esrf/edf_io.h
317-
src/io/file/file_scan.h
318318
src/io/file/hl_file_io.h
319319
src/io/net/basic_serializer.h
320320
src/workflow/source.h
@@ -333,12 +333,12 @@ set(XRF_IO_HEADERS
333333
set(XRF_IO_SOURCE
334334
${VISUAL_INC}
335335
src/core/mem_info.cpp
336+
src/io/file/file_scan.cpp
336337
src/support/mdautils-1.4.1/mda_loader.c
337338
src/io/file/aps/aps_fit_params_import.cpp
338339
src/io/file/mda_io.cpp
339340
src/io/file/hdf5_io.cpp
340341
src/io/file/netcdf_io.cpp
341-
src/io/file/file_scan.cpp
342342
src/io/file/hl_file_io.cpp
343343
src/io/file/aps/aps_roi.cpp
344344
src/io/net/basic_serializer.cpp

src/core/defines.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ const std::string STR_SCAN_TYPE_TIME_BASED_2D_MAP = "TIME_BASED_XRF_MAPS";
218218

219219
const std::string STR_SR_CURRENT = "SR_Current";
220220
const std::string STR_US_IC = "US_IC";
221+
const std::string STR_US_IC_FULL = "UPSTREAM_IONCHAMBER";
221222
const std::string STR_US_FM = "US_FM";
222223
const std::string STR_DS_IC = "DS_IC";
224+
const std::string STR_DS_IC_FULL = "DOWNSTREAM_IONCHAMBER";
223225
const std::string STR_CFG_2 = "CFG_2";
224226
const std::string STR_CFG_3 = "CFG_3";
225227
const std::string STR_CFG_4 = "CFG_4";
@@ -352,6 +354,16 @@ const std::string STR_MAP_ROI_INT_SPEC_FILENAME = "File_Name";
352354
const std::string STR_BNL_PARAM_DWELL = "param_dwell";
353355
const std::string STR_BNL_INCIDENT_ENERGY = "instrument_mono_incident_energy";
354356

357+
//Xspress3 scaler names
358+
const std::string STR_ARRAY_COUNTER = "array_counter";
359+
const std::string STR_RESET_TICKS = "reset_ticks";
360+
const std::string STR_RESET_COUNT = "reset_count";
361+
const std::string STR_EVENT_WIDTH = "event_width";
362+
const std::string STR_WINDOW0 = "window0";
363+
const std::string STR_WINDOW1 = "window1";
364+
const std::string STR_DEADTIME_PERC = "dead_time_percent";
365+
const std::string STR_DEADTIME_FACT = "dead_time_factor";
366+
355367
//}
356368

357369
//}// namespace keys

src/core/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ int set_dir_and_files(Command_Line_Parser& clp, data_struct::Analysis_Job<T_real
464464
}
465465

466466
// search for h5 files in img.dat directory but filter out and mda files associated with them.
467-
for (auto& itr : io::file::File_Scan::inst()->find_all_dataset_files(dataset_dir + "img.dat" + DIR_END_CHAR, ".h5"))
467+
for (auto& itr : io::file::File_Scan::inst()->find_all_dataset_files_by_ext(dataset_dir + "img.dat" + DIR_END_CHAR, ".h5"))
468468
{
469469
bool found = false;
470470
size_t idx = itr.find(".h5");

src/core/process_streaming.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ DLL_EXPORT data_struct::Stream_Block<T_real>* proc_spectra_block( data_struct::S
7373
{
7474
stream_block->fitting_blocks[itr.first].fit_counts[el_itr.first] = counts_dict[el_itr.first] / stream_block->spectra->elapsed_livetime();
7575
}
76-
if(counts_dict.count(STR_NUM_ITR) > 0)
76+
if(counts_dict.contains(STR_NUM_ITR))
7777
{
7878
stream_block->fitting_blocks[itr.first].fit_counts[STR_NUM_ITR] = counts_dict[STR_NUM_ITR];
7979
}
80-
if(counts_dict.count(STR_RESIDUAL) > 0)
80+
if(counts_dict.contains(STR_RESIDUAL))
8181
{
8282
stream_block->fitting_blocks[itr.first].fit_counts[STR_RESIDUAL] = counts_dict[STR_RESIDUAL];
8383
}

src/core/process_whole.cpp

Lines changed: 68 additions & 58 deletions
Large diffs are not rendered by default.

src/core/process_whole.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ DLL_EXPORT bool fit_single_spectra(fitting::routines::Base_Fit_Routine<T_real>*
222222
//save count / sec
223223
for (auto& itr : *out_fit_counts)
224224
{
225-
if (counts_dict.count(itr.first) > 0)
225+
if (counts_dict.contains(itr.first))
226226
{
227227
itr.second(i, j) = counts_dict[itr.first] / spectra->elapsed_livetime();
228228
}
@@ -232,12 +232,12 @@ DLL_EXPORT bool fit_single_spectra(fitting::routines::Base_Fit_Routine<T_real>*
232232

233233
(*out_fit_counts)[STR_RESIDUAL](i, j) = counts_dict[STR_RESIDUAL];
234234
// add total fluorescense yield
235-
if (out_fit_counts->count(STR_TOTAL_FLUORESCENCE_YIELD))
235+
if (out_fit_counts->contains(STR_TOTAL_FLUORESCENCE_YIELD))
236236
{
237237
(*out_fit_counts)[STR_TOTAL_FLUORESCENCE_YIELD](i, j) = spectra->sum() / spectra->elapsed_livetime();
238238
}
239239
// add sum coherent and compton
240-
if (out_fit_counts->count(STR_SUM_ELASTIC_INELASTIC_AMP) > 0 && counts_dict.count(STR_COHERENT_SCT_AMPLITUDE) > 0 && counts_dict.count(STR_COMPTON_AMPLITUDE) > 0)
240+
if (out_fit_counts->contains(STR_SUM_ELASTIC_INELASTIC_AMP) && counts_dict.contains(STR_COHERENT_SCT_AMPLITUDE) && counts_dict.contains(STR_COMPTON_AMPLITUDE) )
241241
{
242242
(*out_fit_counts)[STR_SUM_ELASTIC_INELASTIC_AMP](i, j) = counts_dict[STR_COHERENT_SCT_AMPLITUDE] + counts_dict[STR_COMPTON_AMPLITUDE];
243243
}
@@ -448,7 +448,7 @@ void find_quantifier_scalers(std::unordered_map<std::string, double>& pv_map, Qu
448448
for (auto& itr : pv_map)
449449
{
450450
double multiplier = (T_real)1.0;
451-
if(pv_map.count(itr.first+"_SCALE_FACTOR") > 0)
451+
if(pv_map.contains(itr.first+"_SCALE_FACTOR"))
452452
{
453453
multiplier = pv_map.at(itr.first+"_SCALE_FACTOR");
454454
}
@@ -464,7 +464,7 @@ void find_quantifier_scalers(std::unordered_map<std::string, double>& pv_map, Qu
464464
T_real summed_val = 0.0;
465465
for (const auto& sitr : itr.scalers_to_sum)
466466
{
467-
if (pv_map.count(sitr) > 0)
467+
if (pv_map.contains(sitr))
468468
{
469469
summed_val += pv_map.at(sitr);
470470
}
@@ -479,15 +479,15 @@ void find_quantifier_scalers(std::unordered_map<std::string, double>& pv_map, Qu
479479
{
480480
quantification_standard->sr_current = itr.second;
481481
}
482-
else if (itr.first == STR_US_IC)
482+
else if (itr.first == STR_US_IC || itr.first == STR_US_IC_FULL)
483483
{
484484
quantification_standard->US_IC = itr.second;
485485
}
486486
else if (itr.first == STR_US_FM)
487487
{
488488
quantification_standard->US_FM = itr.second;
489489
}
490-
else if (itr.first == STR_DS_IC)
490+
else if (itr.first == STR_DS_IC || itr.first == STR_DS_IC_FULL)
491491
{
492492
quantification_standard->DS_IC = itr.second;
493493
}
@@ -702,7 +702,7 @@ DLL_EXPORT void iterate_datasets_and_update(data_struct::Analysis_Job<T_real>& a
702702

703703

704704
// Can scan for all hdf5 files in img.dat but will have to do it for multiple ext and filter out by detector num and avg
705-
//for (auto& itr : io::file::File_Scan::inst()->find_all_dataset_files(analysis_job.output_dir + "img.dat", ".hdf5"))
705+
//for (auto& itr : io::file::File_Scan::inst()->find_all_dataset_files_by_ext(analysis_job.output_dir + "img.dat", ".hdf5"))
706706
//{
707707
// hdf5_dataset_list.push_back(analysis_job.output_dir + "img.dat" + DIR_END_CHAR + itr);
708708
//}

src/data_struct/analysis_job.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ template<typename T_real>
121121
Detector<T_real>* Analysis_Job<T_real>::get_detector(int detector_num)
122122
{
123123
Detector<T_real>* detector = nullptr;
124-
if(detectors_meta_data.count(detector_num) > 0)
124+
if(detectors_meta_data.contains(detector_num))
125125
{
126126
detector = &(detectors_meta_data.at(detector_num));
127127
}

src/data_struct/detector.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Detector<T_real>::~Detector()
103103
template<typename T_real>
104104
void Detector<T_real>::append_element(Fitting_Routines routine, std::string quant_scaler, std::string name, T_real weight)
105105
{
106-
if (fitting_quant_map.count(routine) == 0)
106+
if (fitting_quant_map.contains(routine) == false)
107107
{
108108
fitting_quant_map[routine] = Fitting_Quantification_Struct<T_real>();
109109
}
@@ -114,7 +114,7 @@ void Detector<T_real>::append_element(Fitting_Routines routine, std::string quan
114114
data_struct::Electron_Shell shell = get_shell_by_name(name);
115115
fitting_quant_map.at(routine).update_weight_if_greater(shell, element->number, weight);
116116

117-
if (fitting_quant_map.at(routine).quant_scaler_map.count(quant_scaler) > 0)
117+
if (fitting_quant_map.at(routine).quant_scaler_map.contains(quant_scaler))
118118
{
119119
all_element_quants[routine][quant_scaler][name] = &(fitting_quant_map.at(routine).quant_scaler_map.at(quant_scaler).curve_quant_map[shell][element->number - 1]);
120120
}
@@ -134,9 +134,9 @@ void Detector<T_real>::update_element_quants(Fitting_Routines routine,
134134
Quantification_Model<T_real>* quantification_model,
135135
T_real ic_quantifier)
136136
{
137-
if (fitting_quant_map.count(routine) > 0)
137+
if (fitting_quant_map.contains(routine))
138138
{
139-
if (fitting_quant_map.at(routine).quant_scaler_map.count(quantifier_scaler) > 0)
139+
if (fitting_quant_map.at(routine).quant_scaler_map.contains(quantifier_scaler) )
140140
{
141141
for (const auto& shell_itr : Shells_Quant_List)
142142
{
@@ -170,7 +170,7 @@ void Detector<T_real>::update_element_quants(Fitting_Routines routine,
170170
name += "_M";
171171
}
172172
// with 2 standards we can have weights from another standard so we have to check if we have counts
173-
if (standard->element_counts.at(routine).count(name) > 0)
173+
if (standard->element_counts.at(routine).contains(name))
174174
{
175175
if (ic_quantifier == 0.0)
176176
{
@@ -216,9 +216,9 @@ void Detector<T_real>::avg_element_quants(Fitting_Routines routine,
216216
std::string quantifier_scaler,
217217
std::unordered_map<int, float>& element_amt_dict)
218218
{
219-
if (fitting_quant_map.count(routine) > 0)
219+
if (fitting_quant_map.contains(routine))
220220
{
221-
if (fitting_quant_map.at(routine).quant_scaler_map.count(quantifier_scaler) > 0)
221+
if (fitting_quant_map.at(routine).quant_scaler_map.contains(quantifier_scaler))
222222
{
223223
for (const auto& shell_itr : Shells_Quant_List)
224224
{
@@ -346,9 +346,9 @@ void Detector<T_real>::update_calibration_curve(Fitting_Routines routine,
346346
Quantification_Model<T_real>* quantification_model,
347347
T_real val)
348348
{
349-
if (fitting_quant_map.count(routine) > 0)
349+
if (fitting_quant_map.contains(routine))
350350
{
351-
if (fitting_quant_map.at(routine).quant_scaler_map.count(quantifier_scaler) > 0)
351+
if (fitting_quant_map.at(routine).quant_scaler_map.contains(quantifier_scaler))
352352
{
353353
fitting_quant_map.at(routine).quantifier_map[quantifier_scaler] = val;
354354
for (const auto& shell_itr : Shells_Quant_List)

src/data_struct/element_info.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@ template<typename T_real>
428428
T_real Element_Info_Map<T_real>::calc_beta(std::string element_name, T_real density, T_real energy)
429429
{
430430
T_real beta = 0.0;
431-
if (_name_element_info_map.count(element_name) > 0)
431+
if (_name_element_info_map.contains(element_name))
432432
{
433433
beta = _name_element_info_map.at(element_name)->calc_beta(density, energy);
434434
}
435-
else if(Henke_Compound_Density_Map<T_real>.count(element_name) > 0)
435+
else if(Henke_Compound_Density_Map<T_real>.contains(element_name) )
436436
{
437437
beta = calc_compound_beta(element_name, density, energy);
438438
}
@@ -484,7 +484,7 @@ T_real Element_Info_Map<T_real>::calc_compound_beta(std::string compound_name, T
484484
//beta += element_info->calc_beta(density, energy);
485485

486486
T_real amt = std::atof(str_amt.c_str());
487-
if (amt > 0 && Element_Weight<T_real>.count(element_info->number) > 0)
487+
if (amt > 0 && Element_Weight<T_real>.contains(element_info->number) )
488488
{
489489
T_real weight = Element_Weight<T_real>.at(element_info->number);
490490
atwt += (amt * weight);
@@ -533,7 +533,7 @@ template<typename T_real>
533533
bool Element_Info_Map<T_real>::is_element(std::string element_name)
534534
{
535535
bool ret = false;
536-
if (_name_element_info_map.count(element_name) > 0)
536+
if (_name_element_info_map.contains(element_name) )
537537
ret = true;
538538
return ret;
539539
}

src/data_struct/element_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class DLL_EXPORT Element_Info_Map
138138

139139
//void set_energies(float* energy_arr, int num_energies);
140140

141-
bool contains(std::string element_name) {return _name_element_info_map.count(element_name) > 0 ? true : false; }
141+
bool contains(std::string element_name) {return _name_element_info_map.contains(element_name); }
142142

143143
std::vector<float> _energies;
144144

0 commit comments

Comments
 (0)