Skip to content

Commit 37d6d6d

Browse files
authored
Merge pull request #233 from aglowacki/master
Pull request for 2.0 alpha release
2 parents 44f3e4a + d268d60 commit 37d6d6d

7 files changed

Lines changed: 391 additions & 83 deletions

File tree

src/core/defines.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ const std::string STR_SCAN_TYPE_POLAR_XANES = "POLAR_XANES";
214214
const std::string STR_SCAN_TYPE_2D_MAP = "XRF_MAPS";
215215
const std::string STR_SCAN_TYPE_XRF_SINGLE_MCA = "XRF_SINGLE_MCA";
216216
const std::string STR_SCAN_TYPE_2D_EMD = "XRF_2D_EMD";
217+
const std::string STR_SCAN_TYPE_TIME_BASED_2D_MAP = "TIME_BASED_XRF_MAPS";
217218

218219
const std::string STR_SR_CURRENT = "SR_Current";
219220
const std::string STR_US_IC = "US_IC";
@@ -226,6 +227,9 @@ const std::string STR_CFG_5 = "CFG_5";
226227

227228
const std::string STR_POLARITY_PATTERN = "POLARITY_PATTERN";
228229

230+
const std::string STR_SCALER_OVERRIDE = "SCALER_OVERRIDE";
231+
const std::string STR_TIME_NORM_SCALER_OVERRIDE = "TIME_NORMALIZED_SCALER_OVERRIDE";
232+
229233
const std::string STR_K_A_LINES = "K Alpha";
230234
const std::string STR_K_B_LINES = "K Beta";
231235
const std::string STR_L_LINES = "L Lines";
@@ -273,6 +277,7 @@ const std::string STR_OUTPUT_COUNTS = "Output_Counts";
273277

274278
const std::string STR_MAPS = "MAPS";
275279
const std::string STR_SCAN = "Scan";
280+
const std::string STR_INTERFEROMETER = "Interferometer";
276281
const std::string STR_SPECTRA = "Spectra";
277282
const std::string STR_LHCP_SPECTRA = "LHCP_Spectra";
278283
const std::string STR_RHCP_SPECTRA = "RHCP_Spectra";

src/core/process_whole.h

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,31 +207,41 @@ DLL_EXPORT bool fit_single_spectra(fitting::routines::Base_Fit_Routine<T_real>*
207207
size_t i,
208208
size_t j)
209209
{
210-
std::unordered_map<std::string, T_real> counts_dict;
211-
fit_routine->fit_spectra(model, spectra, elements_to_fit, counts_dict);
212-
//save count / sec
213-
for (auto& itr : *out_fit_counts)
210+
if(spectra->size() == 0)
214211
{
215-
if (counts_dict.count(itr.first) > 0)
212+
for (auto& itr : *out_fit_counts)
216213
{
217-
itr.second(i, j) = counts_dict[itr.first] / spectra->elapsed_livetime();
214+
itr.second(i, j) = 0;
218215
}
219-
//(*out_fit_counts)[el_itr.first](i, j) = counts_dict[el_itr.first] / spectra->elapsed_livetime();
216+
return false;
220217
}
221-
(*out_fit_counts)[STR_NUM_ITR](i, j) = counts_dict[STR_NUM_ITR];
222-
223-
(*out_fit_counts)[STR_RESIDUAL](i, j) = counts_dict[STR_RESIDUAL];
224-
// add total fluorescense yield
225-
if (out_fit_counts->count(STR_TOTAL_FLUORESCENCE_YIELD))
226-
{
227-
(*out_fit_counts)[STR_TOTAL_FLUORESCENCE_YIELD](i, j) = spectra->sum() / spectra->elapsed_livetime();
228-
}
229-
// add sum coherent and compton
230-
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)
218+
else
231219
{
232-
(*out_fit_counts)[STR_SUM_ELASTIC_INELASTIC_AMP](i, j) = counts_dict[STR_COHERENT_SCT_AMPLITUDE] + counts_dict[STR_COMPTON_AMPLITUDE];
233-
}
220+
std::unordered_map<std::string, T_real> counts_dict;
221+
fit_routine->fit_spectra(model, spectra, elements_to_fit, counts_dict);
222+
//save count / sec
223+
for (auto& itr : *out_fit_counts)
224+
{
225+
if (counts_dict.count(itr.first) > 0)
226+
{
227+
itr.second(i, j) = counts_dict[itr.first] / spectra->elapsed_livetime();
228+
}
229+
//(*out_fit_counts)[el_itr.first](i, j) = counts_dict[el_itr.first] / spectra->elapsed_livetime();
230+
}
231+
(*out_fit_counts)[STR_NUM_ITR](i, j) = counts_dict[STR_NUM_ITR];
234232

233+
(*out_fit_counts)[STR_RESIDUAL](i, j) = counts_dict[STR_RESIDUAL];
234+
// add total fluorescense yield
235+
if (out_fit_counts->count(STR_TOTAL_FLUORESCENCE_YIELD))
236+
{
237+
(*out_fit_counts)[STR_TOTAL_FLUORESCENCE_YIELD](i, j) = spectra->sum() / spectra->elapsed_livetime();
238+
}
239+
// 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)
241+
{
242+
(*out_fit_counts)[STR_SUM_ELASTIC_INELASTIC_AMP](i, j) = counts_dict[STR_COHERENT_SCT_AMPLITUDE] + counts_dict[STR_COMPTON_AMPLITUDE];
243+
}
244+
}
235245
return true;
236246
}
237247

src/data_struct/scaler_lookup.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,28 @@ void Scaler_Lookup::add_beamline_scaler(const std::string& beamline, const std::
113113

114114
// ----------------------------------------------------------------------------
115115

116+
void Scaler_Lookup::add_override_beamline_scaler(const std::string& beamline, const std::string& scaler_label, const std::string& scaler_pv, bool is_time_normalized)
117+
{
118+
if (is_time_normalized)
119+
{
120+
for(auto itr: _beamline_map[beamline].time_normalized_scaler_pv_label_map)
121+
{
122+
_beamline_map[beamline].time_normalized_scaler_pv_label_map.erase(scaler_label);
123+
}
124+
_beamline_map[beamline].time_normalized_scaler_pv_label_map[scaler_pv] = scaler_label;
125+
}
126+
else
127+
{
128+
for(auto itr: _beamline_map[beamline].time_normalized_scaler_pv_label_map)
129+
{
130+
_beamline_map[beamline].scaler_pv_label_map.erase(scaler_label);
131+
}
132+
_beamline_map[beamline].scaler_pv_label_map[scaler_pv] = scaler_label;
133+
}
134+
}
135+
136+
// ----------------------------------------------------------------------------
137+
116138
void Scaler_Lookup::add_timing_info(const std::string& beamline, const std::string& time_pv, double clock)
117139
{
118140
_beamline_map[beamline].timing_info[time_pv] = clock;

src/data_struct/scaler_lookup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class DLL_EXPORT Scaler_Lookup
8181

8282
void add_summed_scaler(const std::string& beamline, const std::string& scaler_label, const std::vector<std::string>& scaler_list);
8383

84+
void add_override_beamline_scaler(const std::string& beamline, const std::string& scaler_label, const std::string& scaler_pv, bool is_time_normalized);
85+
8486
bool search_for_timing_info(const std::vector<std::string>& pv_list, std::string& out_pv, double& out_clock, std::string& out_beamline);
8587

8688
bool search_for_timing_info(const std::unordered_map<std::string, double>& pv_map, std::string& out_pv, double& out_clock, std::string& out_beamline);

src/io/file/aps/aps_fit_params_import.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
5252
#include "core/defines.h"
5353
#include "data_struct/params_override.h"
5454
#include "data_struct/element_info.h"
55+
#include "data_struct/scaler_lookup.h"
5556
#include <string>
5657
#include <iostream>
5758
#include <fstream>
@@ -829,6 +830,36 @@ DLL_EXPORT bool load_parameters_override(std::string path, Params_Override<T_rea
829830
value.erase(std::remove(value.begin(), value.end(), ' '), value.end());
830831
params_override->polarity_pattern = value;
831832
}
833+
else if(tag == STR_SCALER_OVERRIDE)
834+
{
835+
std::string scaler_beamline;
836+
std::string scaler_name;
837+
std::string str_value;
838+
std::getline(strstream, scaler_beamline, ',');
839+
scaler_beamline.erase(std::remove_if(scaler_beamline.begin(), scaler_beamline.end(), ::isspace), scaler_beamline.end());
840+
std::getline(strstream, scaler_name, ',');
841+
scaler_name.erase(std::remove_if(scaler_name.begin(), scaler_name.end(), ::isspace), scaler_name.end());
842+
std::getline(strstream, str_value, ',');
843+
str_value.erase(std::remove(str_value.begin(), str_value.end(), '\n'), str_value.end());
844+
str_value.erase(std::remove(str_value.begin(), str_value.end(), '\r'), str_value.end());
845+
str_value.erase(std::remove(str_value.begin(), str_value.end(), ' '), str_value.end());
846+
data_struct::Scaler_Lookup::inst()->add_beamline_scaler(scaler_beamline, scaler_name, str_value, false);
847+
}
848+
else if(tag == STR_TIME_NORM_SCALER_OVERRIDE)
849+
{
850+
std::string scaler_beamline;
851+
std::string scaler_name;
852+
std::string str_value;
853+
std::getline(strstream, scaler_beamline, ',');
854+
scaler_beamline.erase(std::remove_if(scaler_beamline.begin(), scaler_beamline.end(), ::isspace), scaler_beamline.end());
855+
std::getline(strstream, scaler_name, ',');
856+
scaler_name.erase(std::remove_if(scaler_name.begin(), scaler_name.end(), ::isspace), scaler_name.end());
857+
std::getline(strstream, str_value, ',');
858+
str_value.erase(std::remove(str_value.begin(), str_value.end(), '\n'), str_value.end());
859+
str_value.erase(std::remove(str_value.begin(), str_value.end(), '\r'), str_value.end());
860+
str_value.erase(std::remove(str_value.begin(), str_value.end(), ' '), str_value.end());
861+
data_struct::Scaler_Lookup::inst()->add_beamline_scaler(scaler_beamline, scaler_name, str_value, true);
862+
}
832863

833864
}
834865
catch (std::exception& e)

0 commit comments

Comments
 (0)