SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
elemental_profile.h
Go to the documentation of this file.
1
22#ifndef ELEMENTAL_PROFILE_H
23#define ELEMENTAL_PROFILE_H
24
25#include <map>
26#include <string>
27#include <vector>
28#include <memory>
29#include "interface.h"
31
32 // Bring std types into scope for compatibility
33using std::string;
34using std::vector;
35using std::map;
36
37// Forward declarations
38class QTableWidget;
39class QJsonObject;
40class QFile;
41class CMBVector;
42
68
113class Elemental_Profile : public map<string, double>, public Interface
114{
115public:
116 // =========================================================================
117 // CONSTRUCTION AND ASSIGNMENT
118 // =========================================================================
119
126
133
141
142 // Default destructor is sufficient (Rule of Zero for other members)
143
144 // =========================================================================
145 // ELEMENT ACCESS AND MODIFICATION
146 // =========================================================================
147
163 double GetValue(const string& name) const;
164
179 bool SetValue(const string& name, double val);
180
194 bool AppendElement(const string& name, double val = 0.0);
195
201 bool Contains(const string& name) const;
202
208 vector<double> GetAllValues() const;
209
214 vector<string> GetElementNames() const;
215
216 // =========================================================================
217 // QUALITY CONTROL - MARKING SYSTEM
218 // =========================================================================
219
233 bool SetMarked(const string& name, bool marked);
234
241 bool IsMarked(const string& name) const;
242
243 // =========================================================================
244 // STATISTICAL OPERATIONS
245 // =========================================================================
246
253 double GetMinimum() const;
254
261 double GetMaximum() const;
262
275 double CalculateDotProduct(const CMBVector& weights) const;
276
284 CMBVector SortByConcentration(bool ascending = true) const;
285
297 vector<string> SelectTopElements(int n, bool ascending = true) const;
298
299 // =========================================================================
300 // PROFILE EXTRACTION AND FILTERING
301 // =========================================================================
302
316 const map<string, element_information>* elementinfo = nullptr) const;
317
326 const map<string, element_information>* elementinfo,
327 bool include_isotopes = false) const;
328
337 Elemental_Profile ExtractElements(const vector<string>& element_names) const;
338
339 // =========================================================================
340 // CORRECTIONS AND TRANSFORMATIONS
341 // =========================================================================
342
366 const vector<double>& reference_om_size,
367 const MultipleLinearRegressionSet* regression_models,
368 const map<string, element_information>* elementinfo = nullptr) const;
369
385 bool exclude_elements,
386 bool apply_corrections,
387 const vector<double>& reference_om_size,
388 const MultipleLinearRegressionSet* regression_models = nullptr,
389 const map<string, element_information>* elementinfo = nullptr) const;
390
391 // =========================================================================
392 // ANALYSIS INCLUSION FLAGS
393 // =========================================================================
394
400
406 void SetIncludedInAnalysis(bool included) { included_in_analysis_ = included; }
407
408 // =========================================================================
409 // SERIALIZATION AND I/O (from Interface base class)
410 // =========================================================================
411
417 string ToString() const override;
418
428 QTableWidget* ToTable() override;
429
435 std::unique_ptr<QTableWidget> CreateTableUnique() const;
436
442 bool writetofile(QFile* file) override;
443
449 bool Read(const QStringList& string_list) override;
450
455 QJsonObject toJsonObject() const override;
456
463 bool ReadFromJsonObject(const QJsonObject& json) override;
464
465private:
466 // =========================================================================
467 // PRIVATE MEMBER VARIABLES
468 // =========================================================================
469
477
484 map<string, bool> marked_elements_;
485};
486
487// =============================================================================
488// DEPRECATED METHOD ALIASES (for backward compatibility)
489// =============================================================================
490// These will be removed in v3.0
491
492namespace {
493 // Provide deprecated aliases during transition period
494 // Usage: auto val = profile.Val("Al"); // Warns but works
495}
496
497#endif // ELEMENTAL_PROFILE_H
Vector class with string labels for Chemical Mass Balance analysis.
Definition cmbvector.h:17
Container for elemental concentration data of a single sediment sample.
Elemental_Profile & operator=(const Elemental_Profile &other)
Copy assignment operator.
Elemental_Profile CreateAnalysisProfile(const map< string, element_information > *elementinfo=nullptr) const
Create profile with only analyzed elements.
Elemental_Profile ExtractChemicalElements(const map< string, element_information > *elementinfo, bool include_isotopes=false) const
Extract chemical elements only (exclude isotopes, metadata)
Elemental_Profile ExtractElements(const vector< string > &element_names) const
Extract subset of specified elements.
Elemental_Profile ApplyOrganicMatterAndSizeCorrections(const vector< double > &reference_om_size, const MultipleLinearRegressionSet *regression_models, const map< string, element_information > *elementinfo=nullptr) const
Apply organic matter and particle size corrections.
bool IsMarked(const string &name) const
Check if element is marked.
map< string, bool > marked_elements_
Map tracking marked elements for quality control.
double GetMaximum() const
Get maximum concentration value.
vector< string > GetElementNames() const
Get list of all element names.
double CalculateDotProduct(const CMBVector &weights) const
Calculate dot product with weight vector.
CMBVector SortByConcentration(bool ascending=true) const
Sort elements by concentration value.
bool included_in_analysis_
Whether profile should be included in analysis.
double GetMinimum() const
Get minimum concentration value.
vector< double > GetAllValues() const
Get all concentration values as vector.
bool SetMarked(const string &name, bool marked)
Set marked status for an element.
QTableWidget * ToTable() override
Create Qt table widget representation.
void SetIncludedInAnalysis(bool included)
Set analysis inclusion status.
Elemental_Profile CreateCorrectedProfile(bool exclude_elements, bool apply_corrections, const vector< double > &reference_om_size, const MultipleLinearRegressionSet *regression_models=nullptr, const map< string, element_information > *elementinfo=nullptr) const
Create corrected profile with filtering and corrections.
bool AppendElement(const string &name, double val=0.0)
Add new element to profile.
double GetValue(const string &name) const
Get element concentration by name.
vector< string > SelectTopElements(int n, bool ascending=true) const
Select top N elements by concentration.
Elemental_Profile()
Default constructor - creates empty profile.
string ToString() const override
Convert profile to string representation.
bool writetofile(QFile *file) override
Write profile to file.
bool ReadFromJsonObject(const QJsonObject &json) override
Deserialize from JSON object.
QJsonObject toJsonObject() const override
Serialize to JSON object.
bool IsIncludedInAnalysis() const
Check if profile is included in analysis.
bool SetValue(const string &name, double val)
Set concentration value for existing element.
std::unique_ptr< QTableWidget > CreateTableUnique() const
Create table widget with automatic memory management.
bool Read(const QStringList &string_list) override
Read profile from string list.
bool Contains(const string &name) const
Check if element exists in profile.
Abstract base class providing common serialization and visualization interface.
Definition interface.h:65
Metadata describing an element's role and properties in analysis.
double standard_ratio
Standard isotopic ratio for normalization.
enum element_information::role Role
role
Classification of element types.
@ element
Standard chemical element concentration.
@ isotope
Isotopic ratio (e.g., 206Pb/207Pb)
@ organic_carbon
Organic carbon content.
@ particle_size
Particle size distribution parameter.
@ do_not_include
Exclude from all analyses.
bool include_in_analysis
Whether to include in statistical analyses.
string base_element
Parent element for isotopes.