SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
Elemental_Profile Class Reference

Container for elemental concentration data of a single sediment sample. More...

#include <elemental_profile.h>

Inheritance diagram for Elemental_Profile:
Inheritance graph
Collaboration diagram for Elemental_Profile:
Collaboration graph

Public Member Functions

 Elemental_Profile ()
 Default constructor - creates empty profile.
 
 Elemental_Profile (const Elemental_Profile &other)
 Copy constructor - deep copy of profile.
 
Elemental_Profileoperator= (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) 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.
 
- Public Member Functions inherited from Interface
 Interface ()
 Default constructor.
 
 Interface (const Interface &intf)
 Copy constructor.
 
Interfaceoperator= (const Interface &intf)
 Assignment operator.
 
string GetNotes () const
 Get the notes/annotations associated with this object.
 
void SetNotes (const string &note)
 Set the notes for this object, replacing any existing notes.
 
void AppendtoNotes (const string &note)
 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.
 
optionsGetOptions ()
 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.
 

Detailed Description

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:

  • Storage of element concentrations (ppm, %, or other units)
  • Quality control marking system for flagging outliers
  • Statistical operations (sorting, ranking, dot products)
  • Correction algorithms (organic matter, particle size effects)
  • Multiple export formats (JSON, table, text)
  • Subsetting and filtering operations

Usage Example

// Create profile for a sediment sample
sample.AppendElement("Al", 8.5); // 8.5% aluminum
sample.AppendElement("Fe", 4.2); // 4.2% iron
sample.AppendElement("Pb", 25.3); // 25.3 ppm lead
// Check element existence and retrieve value
if (sample.Contains("Al")) {
double al = sample.GetValue("Al");
}
// Flag suspicious value
sample.SetMarked("Pb", true);
// Extract subset
vector<string> metals = {"Fe", "Pb", "Cu", "Zn"};
Elemental_Profile metals_only = sample.ExtractElements(metals);
Container for elemental concentration data of a single sediment sample.
Elemental_Profile ExtractElements(const vector< string > &element_names) const
Extract subset of specified elements.
bool SetMarked(const string &name, bool marked)
Set marked status for an element.
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.
bool Contains(const string &name) const
Check if element exists in profile.
Note
Thread Safety: This class is NOT thread-safe. External synchronization required for concurrent access.
Future versions will replace public inheritance with composition to avoid issues with std::map's non-virtual destructor.
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 113 of file elemental_profile.h.

Constructor & Destructor Documentation

◆ Elemental_Profile() [1/2]

Elemental_Profile::Elemental_Profile ( )

Default constructor - creates empty profile.

Default constructor - creates empty elemental profile.

Postcondition
Profile is empty (size() == 0)
Profile included in analysis (IsIncludedInAnalysis() == true)

Initializes an empty profile with no elements.The profile is marked as included in analysis by default.

Postcondition
size() == 0
IsIncludedInAnalysis() == true
No elements are marked
Note
Uses member initializer list for efficiency
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 30 of file elemental_profile.cpp.

References string.

Referenced by ExtractChemicalElements().

◆ Elemental_Profile() [2/2]

Elemental_Profile::Elemental_Profile ( const Elemental_Profile other)

Copy constructor - deep copy of profile.

Copy constructor - creates deep copy of profile.

Parameters
otherProfile to copy
Postcondition
*this is independent copy of other

Creates an independent copy of another profile, including all element concentrations, marked status flags, and analysis inclusion setting.

Parameters
otherProfile to copy from
Postcondition
*this contains all data from other
size() == other.size()
IsIncludedInAnalysis() == other.IsIncludedInAnalysis()
Modifications to *this do not affect other
Note
Copy constructor calls base class copy constructors first, then copies member variables

Definition at line 57 of file elemental_profile.cpp.

References string.

Member Function Documentation

◆ AppendElement()

bool Elemental_Profile::AppendElement ( const string &  element_name,
double  value = 0.0 
)

Add new element to profile.

Parameters
nameElement name (must be unique)
valInitial concentration (default: 0.0)
Returns
true if added, false if element already exists
Precondition
Element must not exist: Contains(name) == false
Postcondition
If successful: Contains(name) == true && GetValue(name) == val
If successful: IsMarked(name) == false
Warning
Logs error to console if element already exists

Adds a new element with its concentration to the profile. The element must not already exist. Use SetValue() to update existing elements.

Parameters
element_nameName of the element (must be unique)
valueInitial concentration value (default: 0.0)
Returns
true if added successfully, false if element already exists
Postcondition
If successful: Contains(element_name) == true
If successful: GetValue(element_name) == value
If successful: IsMarked(element_name) == false
Note
To update existing elements, use SetValue() instead
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 552 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(), MainWindow::ReadExcel(), Elemental_Profile_Set::SelectTopElementsAggregate(), and SourceSinkData::t_TestPValue().

◆ ApplyOrganicMatterAndSizeCorrections()

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.

Parameters
reference_om_sizeVector: [organic_matter_%, mean_particle_size_um]
regression_modelsMLR models: element_name -> MLR(OM, size)
elementinfoElement metadata to identify OM and size elements
Returns
New profile with corrected concentrations

For each element with a regression model:

  • Linear: C_corrected = C + (OM_ref - OM)*beta1 + (size_ref - size)*beta2
  • Power: C_corrected = C * (OM_ref/OM)^beta1 * (size_ref/size)^beta2
Warning
Negative corrected values indicate problems with correction model
Note
Reference: Collins & Walling (2002) - Selecting fingerprint properties for discriminating sediment sources. J. Hydrology, 261, 218-244.

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.

Parameters
reference_om_sizeVector: [organic_matter_%, mean_particle_size_um]
regression_modelsMLR models: element_name -> MLR(OM, size)
element_infoElement metadata to identify OM and size elements
Returns
New profile with corrected concentrations
Note
Organic carbon and particle size elements are excluded from output
Warning
Negative corrected values indicate problems with correction model
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 878 of file elemental_profile.cpp.

References 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().

◆ CalculateDotProduct()

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.

Parameters
weightsWeight vector (must match profile size)
Returns
Dot product value
Warning
Returns -999 if size mismatch (should throw exception)
Note
Used in fingerprinting source contribution calculations

Computes sum(concentration[i] * weights[i]) for all elements. Used in chemical mass balance and discriminant analysis calculations.

Parameters
weightsWeight vector (must match profile size)
Returns
Dot product value, or -999 if size mismatch
Warning
Returns -999 for size mismatch (should throw exception instead)
Note
Element order matches map iterator order (alphabetical)
Todo:
Replace magic number with exception for size mismatch
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 959 of file elemental_profile.cpp.

◆ Contains()

bool Elemental_Profile::Contains ( const string &  element_name) const

Check if element exists in profile.

Parameters
nameElement name to check
Returns
true if element exists, false otherwise
Parameters
element_nameName of element to check
Returns
true if element exists, false otherwise
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 857 of file elemental_profile.cpp.

◆ CreateAnalysisProfile()

Elemental_Profile Elemental_Profile::CreateAnalysisProfile ( const map< string, element_information > *  elementinfo = nullptr) const

Create profile with only analyzed elements.

Filters based on element_information metadata, excluding:

  • Elements with include_in_analysis = false
  • Elements with role = do_not_include
  • Particle size indicators
  • Organic carbon measures
Parameters
elementinfoElement metadata (nullptr includes all)
Returns
New filtered profile
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 145 of file elemental_profile.cpp.

References element_information::do_not_include, element_information::include_in_analysis, included_in_analysis_, marked_elements_, element_information::organic_carbon, element_information::particle_size, and element_information::Role.

Referenced by Elemental_Profile_Set::AppendProfile(), and CreateCorrectedProfile().

◆ 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.

Parameters
exclude_elementsIf true, apply element_information filters
apply_correctionsIf true, apply OM/size corrections
reference_om_sizeReference [OM%, size] for corrections
regression_modelsMLR models for corrections
elementinfoElement metadata for filtering
Returns
New corrected and filtered profile
Note
Consider using separate operations for clarity
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 240 of file elemental_profile.cpp.

References ApplyOrganicMatterAndSizeCorrections(), and CreateAnalysisProfile().

◆ CreateTableUnique()

std::unique_ptr< QTableWidget > Elemental_Profile::CreateTableUnique ( ) const

Create table widget with automatic memory management.

Returns
std::unique_ptr to QTableWidget
Note
Preferred over CreateTable() for automatic cleanup

◆ ExtractChemicalElements()

Elemental_Profile Elemental_Profile::ExtractChemicalElements ( const map< string, element_information > *  elementinfo,
bool  include_isotopes = false 
) const

Extract chemical elements only (exclude isotopes, metadata)

Parameters
elementinfoElement metadata for role classification
include_isotopestrue to include isotopes, false to exclude
Returns
Profile with only element/isotope data
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 330 of file elemental_profile.cpp.

References Elemental_Profile(), element_information::element, element_information::isotope, and element_information::Role.

◆ ExtractElements()

Elemental_Profile Elemental_Profile::ExtractElements ( const vector< string > &  element_names) const

Extract subset of specified elements.

Parameters
element_namesElements to extract
Returns
New profile with requested elements
Note
Elements not in profile are silently skipped
Postcondition
Return size <= element_names.size()
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 421 of file elemental_profile.cpp.

◆ GetAllValues()

vector< double > Elemental_Profile::GetAllValues ( ) const

Get all concentration values as vector.

Get all concentration values as a vector.

Returns
Vector of all concentration values in map order
Note
Order matches iterator order (typically alphabetical)

Extracts all concentration values in map order (typically alphabetical by element name). Element names are not included - use GetElementNames() to get corresponding names.

Returns
Vector of all concentration values
Note
Order matches iterator order of underlying map
To get element names in same order, use GetElementNames()
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 575 of file elemental_profile.cpp.

◆ GetElementNames()

vector< string > Elemental_Profile::GetElementNames ( ) const

Get list of all element names.

Returns
Vector of element names in map order
Vector of element names in map order (typically alphabetical)
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 839 of file elemental_profile.cpp.

Referenced by Conductor::ExecuteAutoSelect(), and GeneralChart::PlotPredictedConcentration().

◆ GetMaximum()

double Elemental_Profile::GetMaximum ( ) const

Get maximum concentration value.

Returns
Maximum concentration across all elements
Exceptions
std::logic_errorif profile is empty (after refactoring)
Warning
Current implementation returns -1e12 if empty (should be fixed)
Returns
Maximum concentration across all elements
-1e12 if profile is empty (should be fixed to throw exception)
Note
Returns arbitrary minimum if profile is empty
Todo:
Consider throwing std::logic_error if empty
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 793 of file elemental_profile.cpp.

Referenced by GeneralChart::PlotPredictedConcentration().

◆ GetMinimum()

double Elemental_Profile::GetMinimum ( ) const

Get minimum concentration value.

Returns
Minimum concentration across all elements
Exceptions
std::logic_errorif profile is empty (after refactoring)
Warning
Current implementation returns 1e12 if empty (should be fixed)
Returns
Minimum concentration across all elements
1e12 if profile is empty (should be fixed to throw exception)
Note
Returns arbitrary maximum if profile is empty
Todo:
Consider throwing std::logic_error if empty
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 818 of file elemental_profile.cpp.

Referenced by GeneralChart::PlotPredictedConcentration().

◆ GetValue()

double Elemental_Profile::GetValue ( const string &  element_name) const

Get element concentration by name.

Parameters
nameElement name (e.g., "Al", "Fe", "206Pb/207Pb")
Returns
Concentration value, or -1 if element not found
Warning
Returns -1 for missing elements. Use Contains() to check first, or consider using at() which throws on missing elements.
Logs error to console if element not found (not ideal for library)
Note
Prefer: if (Contains(name)) { double v = GetValue(name); }
See also
Contains() to check existence
SetValue() to modify value
Parameters
element_nameName of the element
Returns
Element concentration
Exceptions
std::out_of_rangeif element does not exist
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 450 of file elemental_profile.cpp.

Referenced by SourceSinkData::InitializeParametersAndObservations(), SourceSinkData::ObservedDataforSelectedSample(), SourceSinkData::ObservedDataforSelectedSample_Isotope(), and SourceSinkData::ObservedDataforSelectedSample_Isotope_delta().

◆ IsIncludedInAnalysis()

bool Elemental_Profile::IsIncludedInAnalysis ( ) const
inline

Check if profile is included in analysis.

Returns
true if profile should be included in fingerprinting
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 399 of file elemental_profile.h.

References included_in_analysis_.

Referenced by SelectSampleTableModel::data(), and toJsonObject().

◆ IsMarked()

bool Elemental_Profile::IsMarked ( const string &  element_name) const

Check if element is marked.

Parameters
nameElement name
Returns
true if marked, false if unmarked or doesn't exist
Warning
Returns false for both unmarked AND non-existent elements
Parameters
element_nameName of the element
Returns
true if marked, false if unmarked or doesn't exist
Note
Returns false for both unmarked elements and non-existent elements
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 525 of file elemental_profile.cpp.

References marked_elements_.

◆ operator=()

Elemental_Profile & Elemental_Profile::operator= ( const Elemental_Profile other)

Copy assignment operator.

Parameters
otherProfile to assign from
Returns
Reference to *this
Postcondition
*this contains copy of other's data
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 83 of file elemental_profile.cpp.

References included_in_analysis_, marked_elements_, and Interface::operator=().

◆ Read()

bool Elemental_Profile::Read ( const QStringList &  string_list)
overridevirtual

Read profile from string list.

Parameters
string_listList of "Element:Value" strings
Returns
true on success

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 753 of file elemental_profile.cpp.

References AppendElement().

◆ ReadFromJsonObject()

bool Elemental_Profile::ReadFromJsonObject ( const QJsonObject &  json_object)
overridevirtual

Deserialize from JSON object.

Deserialize profile from JSON object.

Parameters
jsonJSON representation
Returns
true on success
Postcondition
Profile cleared and repopulated from JSON

Loads profile data from JSON, supporting two formats:

  1. Full format with "Include" and "Element Contents" fields
  2. Legacy format with elements directly in root object
Parameters
json_objectJSON representation of profile
Returns
true on success (always succeeds currently)
Postcondition
Profile is cleared and repopulated from JSON
Marked elements are reset (not stored in JSON)
Note
Bug fixed: YAxisLabel was being set to XAxisLabel value

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 707 of file elemental_profile.cpp.

References SetIncludedInAnalysis(), Interface::SetXAxisLabel(), and Interface::SetYAxisLabel().

Referenced by Results::ReadFromJson(), and Elemental_Profile_Set::ReadFromJsonObject().

◆ SelectTopElements()

vector< string > Elemental_Profile::SelectTopElements ( int  n,
bool  ascending = true 
) const

Select top N elements by concentration.

Identifies highest (or lowest) concentrated elements. Useful for focusing analysis on dominant tracers.

Parameters
nNumber of elements to select
ascendingtrue to select lowest, false for highest
Returns
Vector of element names
Postcondition
Return size <= min(n, profile.size())

Returns the N highest (or lowest) concentrated elements. Useful for focusing analysis on dominant tracers.

Parameters
nNumber of elements to select
ascendingtrue to select lowest values, false for highest
Returns
Vector of element names (up to N elements)
Postcondition
Return size <= min(n, profile.size())
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 1032 of file elemental_profile.cpp.

References CMBVector::Label(), and SortByConcentration().

◆ SetIncludedInAnalysis()

void Elemental_Profile::SetIncludedInAnalysis ( bool  included)
inline

Set analysis inclusion status.

Parameters
includedtrue to include, false to exclude
Note
Excluded profiles retained in dataset but skipped in calculations
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 406 of file elemental_profile.h.

References included_in_analysis_.

Referenced by ReadFromJsonObject(), and SelectSampleTableModel::setData().

◆ SetMarked()

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.

Parameters
nameElement name
markedtrue to mark, false to unmark
Returns
true if successful, false if element doesn't exist
Precondition
Element must exist
Postcondition
If successful: IsMarked(name) == marked

Marks or unmarks an element for quality control purposes. Marked elements can be filtered in downstream analyses without removing them from the profile.

Parameters
element_nameName of the element
markedtrue to mark, false to unmark
Returns
true if successful, false if element doesn't exist
Note
Element must exist in profile before it can be marked
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 507 of file elemental_profile.cpp.

References marked_elements_.

◆ SetValue()

bool Elemental_Profile::SetValue ( const string &  name,
double  val 
)

Set concentration value for existing element.

Parameters
nameElement name (must already exist)
valNew concentration value
Returns
true if successful, false if element doesn't exist
Precondition
Element must exist: Contains(name) == true
Postcondition
If successful: GetValue(name) == val
Warning
Logs error to console if element not found
See also
AppendElement() to add new elements
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 484 of file elemental_profile.cpp.

◆ SortByConcentration()

CMBVector Elemental_Profile::SortByConcentration ( bool  ascending = true) const

Sort elements by concentration value.

Parameters
ascendingtrue for ascending order, false for descending
Returns
CMBVector with sorted element names and values
Note
Returns new object; original profile unchanged

Creates a CMBVector containing elements sorted by their concentration. Uses selection sort algorithm (O(nē) - consider std::sort for large profiles).

Parameters
ascendingtrue for ascending order (low to high), false for descending
Returns
CMBVector with sorted element names and values
Note
Original profile unchanged (const method)
Performance: O(nē) - fine for typical profile sizes (<100 elements)
Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 988 of file elemental_profile.cpp.

References CMBVector::append().

Referenced by SelectTopElements().

◆ toJsonObject()

QJsonObject Elemental_Profile::toJsonObject ( ) const
overridevirtual

Serialize to JSON object.

Serialize profile to JSON object.

Returns
QJsonObject containing profile data

Creates a JSON representation including element concentrations, analysis inclusion flag, and axis labels.

Returns
QJsonObject containing profile data
Note
Format: {"Include": bool, "Element Contents": {name: value, ...}, "XAxisLabel": string, "YAxisLabel": string}

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 674 of file elemental_profile.cpp.

References IsIncludedInAnalysis(), Interface::XAxisLabel(), and Interface::YAxisLabel().

◆ ToString()

string Elemental_Profile::ToString ( ) const
overridevirtual

Convert profile to string representation.

Returns
String with "Element:Value" pairs separated by newlines
Note
Format: "Al:8.5\nFe:4.2\n..."

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 599 of file elemental_profile.cpp.

Referenced by writetofile().

◆ ToTable()

QTableWidget * Elemental_Profile::ToTable ( )
overridevirtual

Create Qt table widget representation.

Returns
Pointer to new QTableWidget
Warning
CALLER TAKES OWNERSHIP - must delete or set Qt parent
Note
Consider using CreateTableUnique() for automatic memory management
See also
CreateTableUnique() for smart pointer version

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 632 of file elemental_profile.cpp.

References Interface::highlightoutsideoflimit, Interface::highlimit, Interface::lowlimit, and Interface::YAxisLabel().

◆ writetofile()

bool Elemental_Profile::writetofile ( QFile *  file)
overridevirtual

Write profile to file.

Parameters
fileOpen QFile for writing
Returns
true on success

Writes the string representation of the profile to an open file.

Parameters
filePointer to open QFile for writing
Returns
true on success (always succeeds currently)
Note
File must be opened for writing before calling this method
Writes in "Element:Value\n" format for each element

Reimplemented from Interface.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 778 of file elemental_profile.cpp.

References ToString().

Member Data Documentation

◆ included_in_analysis_

bool Elemental_Profile::included_in_analysis_ = true
private

Whether profile should be included in analysis.

Used for quality control - allows excluding problematic samples without deleting them from dataset.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 476 of file elemental_profile.h.

Referenced by CreateAnalysisProfile(), IsIncludedInAnalysis(), operator=(), and SetIncludedInAnalysis().

◆ marked_elements_

map<string, bool> Elemental_Profile::marked_elements_
private

Map tracking marked elements for quality control.

Elements can be flagged as outliers or requiring attention without removing them from the profile.

Examples
/home/runner/work/SedSat3/SedSat3/src/elemental_profile.cpp.

Definition at line 484 of file elemental_profile.h.

Referenced by AppendElement(), CreateAnalysisProfile(), IsMarked(), operator=(), and SetMarked().


The documentation for this class was generated from the following files: