|
SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
|
Container for elemental concentration data of a single sediment sample. More...
#include <elemental_profile.h>


Public Member Functions | |
| Elemental_Profile () | |
| Default constructor - creates empty profile. | |
| Elemental_Profile (const Elemental_Profile &other) | |
| Copy constructor - deep copy of profile. | |
| Elemental_Profile & | operator= (const Elemental_Profile &other) |
| Copy assignment operator. | |
| double | GetValue (const string &name) const |
| Get element concentration by name. | |
| bool | SetValue (const string &name, double val) |
| Set concentration value for existing element. | |
| bool | AppendElement (const string &name, double val=0.0) |
| Add new element to profile. | |
| bool | Contains (const string &name) const |
| Check if element exists in profile. | |
| vector< double > | GetAllValues () const |
| Get all concentration values as vector. | |
| vector< string > | GetElementNames () const |
| Get list of all element names. | |
| bool | SetMarked (const string &name, bool marked) |
| Set marked status for an element. | |
| bool | IsMarked (const string &name) const |
| Check if element is marked. | |
| double | GetMinimum () const |
| Get minimum concentration value. | |
| double | GetMaximum () const |
| Get maximum concentration value. | |
| double | CalculateDotProduct (const CMBVector &weights) const |
| Calculate dot product with weight vector. | |
| CMBVector | SortByConcentration (bool ascending=true) const |
| Sort elements by concentration value. | |
| vector< string > | SelectTopElements (int n, bool ascending=true) const |
| Select top N elements by concentration. | |
| Elemental_Profile | CreateAnalysisProfile (const map< string, element_information > *elementinfo=nullptr, bool keep_isotope_bases=false) 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. | |
| 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 | IsIncludedInAnalysis () const |
| Check if profile is included in analysis. | |
| void | SetIncludedInAnalysis (bool included) |
| Set analysis inclusion status. | |
| string | ToString () const override |
| Convert profile to string representation. | |
| QTableWidget * | ToTable () override |
| Create Qt table widget representation. | |
| std::unique_ptr< QTableWidget > | CreateTableUnique () const |
| Create table widget with automatic memory management. | |
| bool | writetofile (QFile *file) override |
| Write profile to file. | |
| bool | Read (const QStringList &string_list) override |
| Read profile from string list. | |
| QJsonObject | toJsonObject () const override |
| Serialize to JSON object. | |
| bool | ReadFromJsonObject (const QJsonObject &json) override |
| Deserialize from JSON object. | |
| bool | ReadFromJsonObject (const QJsonObject &json, QString &error) |
| Reads the profile, refusing any value that is not a finite number. | |
| Public Member Functions inherited from Interface | |
| Interface () | |
| Default constructor. | |
| Interface (const Interface &intf) | |
| Copy constructor. | |
| Interface & | operator= (const Interface &intf) |
| Assignment operator. | |
| string | GetNotes () const |
| Get the notes/annotations associated with this object. | |
| void | SetNotes (const string ¬e) |
| Set the notes for this object, replacing any existing notes. | |
| void | AppendtoNotes (const string ¬e) |
| Append a note to existing notes. | |
| void | ClearNotes () |
| Clear all notes associated with this object. | |
| void | SetLimit (_range lowhigh, const double &value) |
| Set upper or lower limit for value highlighting. | |
| void | SetOption (options_key opt, bool val) |
| Set a configuration option. | |
| bool | Option (options_key opt) |
| Get the current value of a configuration option. | |
| options & | GetOptions () |
| Get reference to the options structure. | |
| QString | XAxisLabel () const |
| Get the X-axis label. | |
| QString | YAxisLabel () const |
| Get the Y-axis label. | |
| bool | SetXAxisLabel (const QString &label) |
| Set the X-axis label. | |
| bool | SetYAxisLabel (const QString &label) |
| Set the Y-axis label. | |
Private Attributes | |
| bool | included_in_analysis_ = true |
| Whether profile should be included in analysis. | |
| map< string, bool > | marked_elements_ |
| Map tracking marked elements for quality control. | |
Additional Inherited Members | |
| Public Attributes inherited from Interface | |
| double | lowlimit {} |
| Lower threshold for value highlighting (when enabled). | |
| double | highlimit {} |
| Upper threshold for value highlighting (when enabled). | |
| bool | highlightoutsideoflimit = false |
| Flag indicating whether to highlight values outside defined limits. | |
Container for elemental concentration data of a single sediment sample.
Stores and manipulates elemental concentration data ("fingerprint") for one sediment sample. Inherits from std::map<string,double> to provide map-like access where keys are element names and values are concentrations.
Key capabilities:
Definition at line 117 of file elemental_profile.h.
| Elemental_Profile::Elemental_Profile | ( | ) |
Default constructor - creates empty profile.
Default constructor - creates empty elemental profile.
Initializes an empty profile with no elements.The profile is marked as included in analysis by default.
Definition at line 35 of file elemental_profile.cpp.
References Interface::Interface(), included_in_analysis_, and marked_elements_.
Referenced by Elemental_Profile(), ApplyOrganicMatterAndSizeCorrections(), CreateAnalysisProfile(), CreateCorrectedProfile(), ExtractChemicalElements(), ExtractElements(), and operator=().
| Elemental_Profile::Elemental_Profile | ( | const Elemental_Profile & | other | ) |
Copy constructor - deep copy of profile.
Copy constructor - creates deep copy of profile.
| other | Profile to copy |
Creates an independent copy of another profile, including all element concentrations, marked status flags, and analysis inclusion setting.
| other | Profile to copy from |
Definition at line 62 of file elemental_profile.cpp.
References Elemental_Profile(), Interface::Interface(), included_in_analysis_, and marked_elements_.
| bool Elemental_Profile::AppendElement | ( | const string & | element_name, |
| double | value = 0.0 ) |
Add new element to profile.
| name | Element name (must be unique) |
| val | Initial concentration (default: 0.0) |
Adds a new element with its concentration to the profile. The element must not already exist. Use SetValue() to update existing elements.
| element_name | Name of the element (must be unique) |
| value | Initial concentration value (default: 0.0) |
Definition at line 570 of file elemental_profile.cpp.
References marked_elements_.
Referenced by SourceSinkData::DifferentiationPower(), SourceSinkData::DifferentiationPower_Percentage(), SourceSinkData::GetCalculatedElementMeans(), SourceSinkData::GetCalculatedElementMu(), SourceSinkData::GetCalculatedElementSigma(), SourceSinkData::GetEstimatedElementMean(), SourceSinkData::GetEstimatedElementMu(), SourceSinkData::GetEstimatedElementSigma(), SourceSinkData::GetObservedElementalProfile(), SourceSinkData::GetObservedElementalProfile_Isotope(), SourceSinkData::GetPredictedElementalProfile(), SourceSinkData::GetPredictedElementalProfile_Isotope(), Read(), Elemental_Profile_Set::SelectTopElementsAggregate(), and SourceSinkData::t_TestPValue().
| Elemental_Profile Elemental_Profile::ApplyOrganicMatterAndSizeCorrections | ( | const vector< double > & | reference_om_size, |
| const MultipleLinearRegressionSet * | regression_models, | ||
| const map< string, element_information > * | element_info = nullptr ) const |
Apply organic matter and particle size corrections.
Corrects element concentrations for organic matter content and particle size effects using multiple linear regression models. Critical for ensuring differences reflect source variation rather than sample characteristics.
| reference_om_size | Vector: [organic_matter_%, mean_particle_size_um] |
| regression_models | MLR models: element_name -> MLR(OM, size) |
| elementinfo | Element metadata to identify OM and size elements |
For each element with a regression model:
Corrects element concentrations for organic matter content and particle size effects using multiple linear regression models. Critical for ensuring differences reflect source variation rather than sample characteristics.
| reference_om_size | Vector: [organic_matter_%, mean_particle_size_um] |
| regression_models | MLR models: element_name -> MLR(OM, size) |
| element_info | Element metadata to identify OM and size elements |
Definition at line 920 of file elemental_profile.cpp.
References Elemental_Profile(), element_information::isotope, linear, mlr, element_information::organic_carbon, element_information::particle_size, and element_information::Role.
Referenced by Elemental_Profile_Set::ApplyOrganicMatterAndSizeCorrections(), and CreateCorrectedProfile().
| double Elemental_Profile::CalculateDotProduct | ( | const CMBVector & | weights | ) | const |
Calculate dot product with weight vector.
Computes sum(concentration[i] * weights[i]) for all elements. Used in chemical mass balance and discriminant analysis.
| weights | Weight vector (must match profile size) |
Computes sum(concentration[i] * weights[i]) for all elements. Used in chemical mass balance and discriminant analysis calculations.
| weights | Weight vector (must match profile size) |
Definition at line 1005 of file elemental_profile.cpp.
| bool Elemental_Profile::Contains | ( | const string & | element_name | ) | const |
Check if element exists in profile.
| name | Element name to check |
| element_name | Name of element to check |
Definition at line 899 of file elemental_profile.cpp.
| Elemental_Profile Elemental_Profile::CreateAnalysisProfile | ( | const map< string, element_information > * | elementinfo = nullptr, |
| bool | keep_isotope_bases = false ) const |
Create profile with only analyzed elements.
Filters based on element_information metadata, excluding:
| elementinfo | Element metadata (nullptr includes all) |
Definition at line 150 of file elemental_profile.cpp.
References Elemental_Profile(), element_information::do_not_include, element_information::include_in_analysis, included_in_analysis_, element_information::isotope, marked_elements_, name, element_information::organic_carbon, element_information::particle_size, and element_information::Role.
Referenced by Elemental_Profile_Set::AppendProfile(), and CreateCorrectedProfile().
| Elemental_Profile 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.
Comprehensive transformation combining element filtering and corrections.
| exclude_elements | If true, apply element_information filters |
| apply_corrections | If true, apply OM/size corrections |
| reference_om_size | Reference [OM%, size] for corrections |
| regression_models | MLR models for corrections |
| elementinfo | Element metadata for filtering |
Definition at line 258 of file elemental_profile.cpp.
References Elemental_Profile(), ApplyOrganicMatterAndSizeCorrections(), and CreateAnalysisProfile().
| std::unique_ptr< QTableWidget > Elemental_Profile::CreateTableUnique | ( | ) | const |
Create table widget with automatic memory management.
| Elemental_Profile Elemental_Profile::ExtractChemicalElements | ( | const map< string, element_information > * | elementinfo, |
| bool | include_isotopes = false ) const |
Extract chemical elements only (exclude isotopes, metadata).
| elementinfo | Element metadata for role classification |
| include_isotopes | true to include isotopes, false to exclude |
Definition at line 348 of file elemental_profile.cpp.
References Elemental_Profile(), element_information::element, element_information::isotope, and element_information::Role.
| Elemental_Profile Elemental_Profile::ExtractElements | ( | const vector< string > & | element_names | ) | const |
Extract subset of specified elements.
| element_names | Elements to extract |
Definition at line 439 of file elemental_profile.cpp.
References Elemental_Profile().
| vector< double > Elemental_Profile::GetAllValues | ( | ) | const |
Get all concentration values as vector.
Get all concentration values as a vector.
Extracts all concentration values in map order (typically alphabetical by element name). Element names are not included - use GetElementNames() to get corresponding names.
Definition at line 593 of file elemental_profile.cpp.
Get list of all element names.
Definition at line 881 of file elemental_profile.cpp.
Referenced by Conductor::ExecuteAutoSelect(), and GeneralChart::PlotPredictedConcentration().
| double Elemental_Profile::GetMaximum | ( | ) | const |
Get maximum concentration value.
| std::logic_error | if profile is empty (after refactoring) |
Definition at line 835 of file elemental_profile.cpp.
Referenced by GeneralChart::PlotPredictedConcentration().
| double Elemental_Profile::GetMinimum | ( | ) | const |
Get minimum concentration value.
| std::logic_error | if profile is empty (after refactoring) |
Definition at line 860 of file elemental_profile.cpp.
Referenced by GeneralChart::PlotPredictedConcentration().
| double Elemental_Profile::GetValue | ( | const string & | element_name | ) | const |
Get element concentration by name.
| name | Element name (e.g., "Al", "Fe", "206Pb/207Pb") |
| element_name | Name of the element |
| std::out_of_range | if element does not exist |
Definition at line 468 of file elemental_profile.cpp.
Referenced by SourceSinkData::ObservedDataforSelectedSample(), SourceSinkData::ObservedDataforSelectedSample_Isotope(), and SourceSinkData::ObservedDataforSelectedSample_Isotope_delta().
|
inline |
Check if profile is included in analysis.
Definition at line 404 of file elemental_profile.h.
References included_in_analysis_.
Referenced by SelectSampleTableModel::data(), and toJsonObject().
| bool Elemental_Profile::IsMarked | ( | const string & | element_name | ) | const |
Check if element is marked.
| name | Element name |
| element_name | Name of the element |
Definition at line 543 of file elemental_profile.cpp.
References marked_elements_.
| Elemental_Profile & Elemental_Profile::operator= | ( | const Elemental_Profile & | other | ) |
Copy assignment operator.
| other | Profile to assign from |
Definition at line 88 of file elemental_profile.cpp.
References Elemental_Profile(), included_in_analysis_, marked_elements_, and Interface::operator=().
|
overridevirtual |
Read profile from string list.
| string_list | List of "Element:Value" strings |
Reimplemented from Interface.
Definition at line 791 of file elemental_profile.cpp.
References AppendElement(), and parseNumericCell().
|
overridevirtual |
Deserialize from JSON object.
Deserialize profile from JSON object.
| json | JSON representation |
Loads profile data from JSON, supporting two formats:
| json_object | JSON representation of profile |
Reimplemented from Interface.
Definition at line 725 of file elemental_profile.cpp.
References ReadFromJsonObject().
Referenced by Results::ReadFromJson(), ReadFromJsonObject(), and Elemental_Profile_Set::ReadFromJsonObject().
| bool Elemental_Profile::ReadFromJsonObject | ( | const QJsonObject & | json, |
| QString & | error ) |
Reads the profile, refusing any value that is not a finite number.
| error | Set to "constituent 'X': <reason>" if a value is refused |
Definition at line 731 of file elemental_profile.cpp.
References parseNumericJson(), SetIncludedInAnalysis(), Interface::SetXAxisLabel(), and Interface::SetYAxisLabel().
Select top N elements by concentration.
Identifies highest (or lowest) concentrated elements. Useful for focusing analysis on dominant tracers.
| n | Number of elements to select |
| ascending | true to select lowest, false for highest |
Returns the N highest (or lowest) concentrated elements. Useful for focusing analysis on dominant tracers.
| n | Number of elements to select |
| ascending | true to select lowest values, false for highest |
Definition at line 1078 of file elemental_profile.cpp.
References CMBVector::Label(), and SortByConcentration().
|
inline |
Set analysis inclusion status.
| included | true to include, false to exclude |
Definition at line 411 of file elemental_profile.h.
References included_in_analysis_.
Referenced by ReadFromJsonObject(), and SelectSampleTableModel::setData().
| bool Elemental_Profile::SetMarked | ( | const string & | element_name, |
| bool | marked ) |
Set marked status for an element.
Marking system allows flagging suspicious values without removing them. Marked elements can be filtered in downstream analyses.
| name | Element name |
| marked | true to mark, false to unmark |
Marks or unmarks an element for quality control purposes. Marked elements can be filtered in downstream analyses without removing them from the profile.
| element_name | Name of the element |
| marked | true to mark, false to unmark |
Definition at line 525 of file elemental_profile.cpp.
References marked_elements_.
| bool Elemental_Profile::SetValue | ( | const string & | name, |
| double | val ) |
Set concentration value for existing element.
| name | Element name (must already exist) |
| val | New concentration value |
Definition at line 502 of file elemental_profile.cpp.
| CMBVector Elemental_Profile::SortByConcentration | ( | bool | ascending = true | ) | const |
Sort elements by concentration value.
| ascending | true for ascending order, false for descending |
Creates a CMBVector containing elements sorted by their concentration. Uses selection sort algorithm (O(n²) - consider std::sort for large profiles).
| ascending | true for ascending order (low to high), false for descending |
Definition at line 1034 of file elemental_profile.cpp.
References CMBVector::append().
Referenced by SelectTopElements().
|
overridevirtual |
Serialize to JSON object.
Serialize profile to JSON object.
Creates a JSON representation including element concentrations, analysis inclusion flag, and axis labels.
Reimplemented from Interface.
Definition at line 692 of file elemental_profile.cpp.
References IsIncludedInAnalysis(), Interface::XAxisLabel(), and Interface::YAxisLabel().
|
overridevirtual |
Convert profile to string representation.
Reimplemented from Interface.
Definition at line 617 of file elemental_profile.cpp.
Referenced by writetofile().
|
overridevirtual |
Create Qt table widget representation.
Reimplemented from Interface.
Definition at line 650 of file elemental_profile.cpp.
References Interface::highlightoutsideoflimit, Interface::highlimit, Interface::lowlimit, and Interface::YAxisLabel().
|
overridevirtual |
Write profile to file.
| file | Open QFile for writing |
Writes the string representation of the profile to an open file.
| file | Pointer to open QFile for writing |
Reimplemented from Interface.
Definition at line 820 of file elemental_profile.cpp.
References ToString().
|
private |
Whether profile should be included in analysis.
Used for quality control - allows excluding problematic samples without deleting them from dataset.
Definition at line 488 of file elemental_profile.h.
Referenced by Elemental_Profile(), Elemental_Profile(), CreateAnalysisProfile(), IsIncludedInAnalysis(), operator=(), and SetIncludedInAnalysis().
|
private |
Map tracking marked elements for quality control.
Elements can be flagged as outliers or requiring attention without removing them from the profile.
Definition at line 496 of file elemental_profile.h.
Referenced by Elemental_Profile(), Elemental_Profile(), AppendElement(), CreateAnalysisProfile(), IsMarked(), operator=(), and SetMarked().