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// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
24
25#ifndef ELEMENTAL_PROFILE_H
26#define ELEMENTAL_PROFILE_H
27
28#include <map>
29#include <string>
30#include <vector>
31#include <memory>
32#include "interface.h"
34
35 // Bring std types into scope for compatibility
36using std::string;
37using std::vector;
38using std::map;
39
40// Forward declarations
41class QTableWidget;
42class QJsonObject;
43class QFile;
44class CMBVector;
45
72
117class Elemental_Profile : public map<string, double>, public Interface
118{
119public:
120 // =========================================================================
121 // CONSTRUCTION AND ASSIGNMENT
122 // =========================================================================
123
130
137
145
146 // Default destructor is sufficient (Rule of Zero for other members)
147
148 // =========================================================================
149 // ELEMENT ACCESS AND MODIFICATION
150 // =========================================================================
151
167 double GetValue(const string& name) const;
168
183 bool SetValue(const string& name, double val);
184
198 bool AppendElement(const string& name, double val = 0.0);
199
205 bool Contains(const string& name) const;
206
212 vector<double> GetAllValues() const;
213
218 vector<string> GetElementNames() const;
219
220 // =========================================================================
221 // QUALITY CONTROL - MARKING SYSTEM
222 // =========================================================================
223
237 bool SetMarked(const string& name, bool marked);
238
245 bool IsMarked(const string& name) const;
246
247 // =========================================================================
248 // STATISTICAL OPERATIONS
249 // =========================================================================
250
257 double GetMinimum() const;
258
265 double GetMaximum() const;
266
279 double CalculateDotProduct(const CMBVector& weights) const;
280
288 CMBVector SortByConcentration(bool ascending = true) const;
289
301 vector<string> SelectTopElements(int n, bool ascending = true) const;
302
303 // =========================================================================
304 // PROFILE EXTRACTION AND FILTERING
305 // =========================================================================
306
320 const map<string, element_information>* elementinfo = nullptr,
321 bool keep_isotope_bases = false) const;
322
331 const map<string, element_information>* elementinfo,
332 bool include_isotopes = false) const;
333
342 Elemental_Profile ExtractElements(const vector<string>& element_names) const;
343
344 // =========================================================================
345 // CORRECTIONS AND TRANSFORMATIONS
346 // =========================================================================
347
371 const vector<double>& reference_om_size,
372 const MultipleLinearRegressionSet* regression_models,
373 const map<string, element_information>* elementinfo = nullptr) const;
374
390 bool exclude_elements,
391 bool apply_corrections,
392 const vector<double>& reference_om_size,
393 const MultipleLinearRegressionSet* regression_models = nullptr,
394 const map<string, element_information>* elementinfo = nullptr) const;
395
396 // =========================================================================
397 // ANALYSIS INCLUSION FLAGS
398 // =========================================================================
399
405
411 void SetIncludedInAnalysis(bool included) { included_in_analysis_ = included; }
412
413 // =========================================================================
414 // SERIALIZATION AND I/O (from Interface base class)
415 // =========================================================================
416
422 string ToString() const override;
423
433 QTableWidget* ToTable() override;
434
440 std::unique_ptr<QTableWidget> CreateTableUnique() const;
441
447 bool writetofile(QFile* file) override;
448
454 bool Read(const QStringList& string_list) override;
455
460 QJsonObject toJsonObject() const override;
461
468 bool ReadFromJsonObject(const QJsonObject& json) override;
469
475 bool ReadFromJsonObject(const QJsonObject& json, QString& error);
476
477private:
478 // =========================================================================
479 // PRIVATE MEMBER VARIABLES
480 // =========================================================================
481
489
496 map<string, bool> marked_elements_;
497};
498
499// =============================================================================
500// DEPRECATED METHOD ALIASES (for backward compatibility)
501// =============================================================================
502// These will be removed in v3.0
503
504namespace {
505 // Provide deprecated aliases during transition period
506 // Usage: auto val = profile.Val("Al"); // Warns but works
507}
508
509#endif // ELEMENTAL_PROFILE_H
Vector class with string labels for Chemical Mass Balance analysis.
Definition cmbvector.h:20
Elemental_Profile & operator=(const Elemental_Profile &other)
Copy assignment operator.
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.
Elemental_Profile CreateAnalysisProfile(const map< string, element_information > *elementinfo=nullptr, bool keep_isotope_bases=false) const
Create profile with only analyzed elements.
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.
Interface()
Default constructor.
Definition interface.cpp:6
Metadata describing an element's role and properties in analysis.
double standard_ratio
Standard isotopic ratio for normalization.
enum element_information::role Role
string notes
Free-text notes, e.g. why it was excluded.
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.