Skip to content

Commit

Permalink
Merge pull request #140 from aglowacki/master
Browse files Browse the repository at this point in the history
Bugfix in netcdf loading spectra volume times and io counts
  • Loading branch information
Arthur Glowacki authored May 9, 2022
2 parents 517c203 + d9db0d0 commit 411cde5
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 557 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ set(XRF_IO_HEADERS
src/core/mem_info.h
src/support/mdautils-1.4.1/mda-load.h
src/io/file/mda_io.h
src/io/file/mca_io.h
src/io/file/mca_io.h
src/io/file/hdf5_io.h
src/io/file/netcdf_io.h
src/io/file/csv_io.h
Expand All @@ -292,13 +292,13 @@ set(XRF_IO_HEADERS
src/workflow/xrf/detector_sum_spectra_source.h
src/workflow/xrf/spectra_stream_saver.h
src/workflow/xrf/spectra_net_streamer.h
src/core/process_streaming.h
src/core/process_whole.h
)
src/core/process_streaming.h
src/core/process_whole.h
)

set(XRF_IO_SOURCE
${VISUAL_INC}
src/core/mem_info.cpp
src/core/mem_info.cpp
src/support/zmq/zmq.hpp
src/support/mdautils-1.4.1/mda_loader.c
src/io/file/mda_io.cpp
Expand Down
11 changes: 2 additions & 9 deletions src/core/process_whole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool optimize_integrated_fit_params(data_struct::Analysis_Job* analysis_job,

if (params_override != nullptr)
{
//load the quantification standard dataset
//load the standard dataset
if (false == io::load_and_integrate_spectra_volume(analysis_job->dataset_directory, dataset_filename, detector_num, &int_spectra, params_override))
{
logE << "In optimize_integrated_dataset loading dataset" << dataset_filename << " for detector" << detector_num << "\n";
Expand Down Expand Up @@ -332,7 +332,7 @@ void proc_spectra(data_struct::Spectra_Volume* spectra_volume,
start = std::chrono::system_clock::now();
if (override_params->elements_to_fit.size() < 1)
{
logE<<"No elements to fit. Check maps_fit_parameters_override.txt0 - 3 exist"<<"\n";
logE<<"No elements to fit. Check maps_fit_parameters_override.txt0 - 7 exist"<<"\n";
continue;
}

Expand Down Expand Up @@ -848,13 +848,6 @@ bool perform_quantification(data_struct::Analysis_Job* analysis_job)
{
fitting::routines::Base_Fit_Routine *fit_routine = fit_itr.second;

// update e_cal_ratio for elements in standards by average value
for (auto& s_itr : detector->quantification_standards)
{
Quantification_Standard* quantification_standard = &(s_itr.second);
detector->update_element_quants(fit_itr.first, quant_itr.first, quantification_standard, &quantification_model, quant_itr.second);
}

logI << Fitting_Routine_To_Str.at(fit_itr.first) << " "<< quant_itr.first << "\n";
Fit_Parameters fit_params;
fit_params.add_parameter(Fit_Param("quantifier", 0.0, std::numeric_limits<real_t>::max(), 1.0, 0.1, E_Bound_Type::FIT));
Expand Down
23 changes: 21 additions & 2 deletions src/data_struct/detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,27 @@ void Detector::update_element_quants(Fitting_Routines routine,

real_t counts = standard->element_counts.at(routine).at(name);
real_t e_cal_factor = (eq_itr.weight * (ic_quantifier));
real_t e_cal = e_cal_factor / counts;
eq_itr.e_cal_ratio = (real_t)1.0 / e_cal;
if (counts > 0.)
{
real_t e_cal = e_cal_factor / counts;
if (eq_itr.e_cal_ratio == 0.)
{
eq_itr.e_cal_ratio = (real_t)1.0 / e_cal;
}
else // else avg the two
{
real_t second_cal_ratio = (real_t)1.0 / e_cal;
eq_itr.e_cal_ratio += second_cal_ratio;
eq_itr.e_cal_ratio *= 0.5;
}
}
else
{
if (eq_itr.e_cal_ratio == 0.)
{
eq_itr.e_cal_ratio = 1.0e-10;
}
}
}
}
}
Expand Down
11 changes: 0 additions & 11 deletions src/data_struct/spectra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,5 @@ ArrayXr snip_background(const Spectra* const spectra,

}

void gen_energy_vector(real_t number_channels, real_t energy_offset, real_t energy_slope, std::vector<real_t> *out_vec)
{

out_vec->resize(number_channels);
for(int i=0; i<number_channels; i++)
{
(*out_vec)[i] = (i * energy_slope) + energy_offset;
}

}

} //namespace data_struct

2 changes: 0 additions & 2 deletions src/data_struct/spectra.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ DLL_EXPORT ArrayXr convolve1d(const ArrayXr& arr, const ArrayXr& boxcar);
DLL_EXPORT ArrayXr snip_background(const Spectra * const spectra, real_t energy_offset, real_t energy_linear, real_t energy_quadratic, real_t width, real_t xmin, real_t xmax);


DLL_EXPORT void gen_energy_vector(real_t number_channels, real_t energy_offset, real_t energy_slope, std::vector<real_t> *out_vec);

typedef std::function<void(size_t, size_t, size_t, size_t, size_t, data_struct::Spectra*, void*)> IO_Callback_Func_Def;


Expand Down
Loading

0 comments on commit 411cde5

Please sign in to comment.