Skip to content

Commit

Permalink
Sketch out implementation of batch activity/shielding fitting.
Browse files Browse the repository at this point in the history
Start implementation of being able to use fit-peaks and shielding/src model from an exemplar, to refit these quantities for different, but similar, files, from the command line.
Right now more of a proof of concept stage - I'm sure a ton of edge cases arent handled, the output is just partially dumped to stdout (no formatting, no reporting, etc), and a ton of things arent complete, or implemented, or correct.
  • Loading branch information
wcjohns committed Mar 13, 2024
1 parent c222a9d commit 939c18d
Show file tree
Hide file tree
Showing 5 changed files with 803 additions and 76 deletions.
60 changes: 58 additions & 2 deletions InterSpec/BatchActivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ namespace SpecUtils
class Measurement;
}//namespace SpecUtils


namespace ShieldingSourceFitCalc
{
struct ModelFitResults;
}

/** The functions necessary to batch-fit activity and shielding. */
namespace BatchActivity
Expand All @@ -68,8 +71,61 @@ namespace BatchActivity

struct BatchActivityFitResult
{
enum class ResultCode
{
CouldntInitializeStaticResources,
NoExemplar,
CouldntOpenExemplar,
CouldntOpenInputFile,
CouldntOpenBackgroundFile,
NoInputSrcShieldModel,
ForegroundSampleNumberUnderSpecified,
BackgroundSampleNumberUnderSpecified,

ForegroundPeakFitFailed,
NoFitForegroundPeaks,
NoDetEffFnct,
InvalidDistance,
InvalidGeometry,
InvalidFitOptions,
ExemplarUsedBackSubButNoBackground,
NoShieldingsNode,
ErrorParsingShielding,
MissingNuclidesNode,
InvalidNuclideNode,
NoSourceNuclides,

FitNotSuccessful,
DidNotFitAllSources,

UnknownStatus,
Success
};//enum class ResultCode

ResultCode m_result_code;
std::string m_error_msg;
std::vector<std::string> m_warnings;

std::string m_filename;
std::shared_ptr<const SpecMeas> m_foreground_file;
std::set<int> m_foreground_sample_numbers; ///!< right now limited to single sample - may change in future
std::shared_ptr<const SpecUtils::Measurement> m_foreground;

std::shared_ptr<const SpecMeas> m_exemplar_file;
std::set<int> m_exemplar_sample_numbers; ///!< right now limited to single sample - may change in future
std::shared_ptr<const SpecUtils::Measurement> m_exemplar;

std::shared_ptr<const SpecMeas> m_background_file; ///!< May be same as foreground or exemplar
std::set<int> m_background_sample_numbers; ///!< right now limited to single sample - may change in future
std::shared_ptr<const SpecUtils::Measurement> m_background;

BatchActivityFitOptions m_options;

// Blah blah blah
std::shared_ptr<const BatchPeak::BatchPeakFitResult> peak_fit_results;
std::shared_ptr<const BatchPeak::BatchPeakFitResult> m_peak_fit_results;
std::shared_ptr<const BatchPeak::BatchPeakFitResult> m_background_peak_fit_results;

std::shared_ptr<ShieldingSourceFitCalc::ModelFitResults> m_fit_results;
};//struct BatchActivityFitResult


Expand Down
6 changes: 6 additions & 0 deletions InterSpec/BatchPeak.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace BatchPeak
bool show_nonfit_peaks;
std::string output_dir;
std::string background_subtract_file;
std::set<int> background_subtract_samples;
};//struct BatchPeakFitOptions


Expand Down Expand Up @@ -109,13 +110,18 @@ namespace BatchPeak
@param cached_exemplar_n42 If non-null, then `exemplar_filename` will be ignored, and this file will be used; to avoid re-parsing
of the exemplar file over-and-over again.
@param filename The name of the spectrum file to fit peaks to.
@param cached_spectrum If you have already parsed/opened the `filename` spectrum file, you can provide it here to
avoid overhead of re-parsing it.
@param foreground_sample_numbers The sample numbers to fit the peaks to. If left empty, will try to automatically determine.
@param options The options to use for fitting peaks; note, not all options are used, as some of them are only applicable to
#fit_peaks_in_files
*/
BatchPeakFitResult fit_peaks_in_file( const std::string &exemplar_filename,
std::set<int> exemplar_sample_nums,
std::shared_ptr<const SpecMeas> cached_exemplar_n42,
const std::string &filename,
std::shared_ptr<SpecMeas> cached_spectrum,
std::set<int> foreground_sample_numbers,
const BatchPeakFitOptions &options );

}//namespace BatchPeak
Expand Down
Loading

0 comments on commit 939c18d

Please sign in to comment.