SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
cmbtimeseriesset.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
4#ifndef CMBTimeSeriesSet_H
5#define CMBTimeSeriesSet_H
6
7#include "TimeSeriesSet.h"
8#include "interface.h"
9
19class CMBTimeSeriesSet : public TimeSeriesSet<double>, public Interface
20{
21public:
26
31 CMBTimeSeriesSet(int n);
32
38 CMBTimeSeriesSet(int n, int m);
39
45
52
58 CMBTimeSeriesSet& operator=(const TimeSeriesSet<double>& mp);
59
64 CMBTimeSeriesSet(const TimeSeriesSet<double>& mp);
65
70 QJsonObject toJsonObject() const override;
71
77 bool ReadFromJsonObject(const QJsonObject& jsonobject) override;
78
83 string ToString() const override;
84
90 bool writetofile(QFile*) override;
91
101 QTableWidget* ToTable() override;
102
112 void AppendLastContribution(int colnumber, const string& name);
113
119 void SetObservedValue(int i, const double& value)
120 {
121 if (i < size())
122 observed_value[i] = value;
123 }
124
130 double ObservedValue(int i)
131 {
132 if (i < size())
133 return observed_value[i];
134 else
135 return 0;
136 }
137
143 double ObservedValue(const string& variable_name)
144 {
145 for (int i = 0; i < size(); i++)
146 {
147 if (getSeriesName(i) == variable_name)
148 return observed_value[i];
149 }
150 return 0;
151 }
152
158 string Label(unsigned int i) const
159 {
160 if (i < labels.size())
161 return labels[i];
162 else if (i < maxnumpoints())
163 return aquiutils::numbertostring(at(0).getTime(i));
164 else
165 return "";
166 }
167
174 string Label(unsigned int i, unsigned int j) const
175 {
176 if (i < labels.size())
177 return labels[i];
178 else if (i < maxnumpoints())
179 return aquiutils::numbertostring(at(j).getTime(i));
180 else
181 return "";
182 }
183
189 void SetLabel(unsigned int i, const string& label)
190 {
191 if (i < maxnumpoints())
192 {
193 labels.resize(maxnumpoints());
194 labels[i] = label;
195 }
196 else
197 return;
198 }
199
200private:
203};
204
205#endif // CMBTimeSeriesSet_H
string Label(unsigned int i, unsigned int j) const
Gets label for time point in specific series.
CMBTimeSeriesSet & operator=(const CMBTimeSeriesSet &mp)
Assignment operator from CMBTimeSeriesSet.
void SetLabel(unsigned int i, const string &label)
Sets custom label for time point.
double ObservedValue(const string &variable_name)
Gets observed value for named series.
CMBTimeSeriesSet()
Default constructor - creates an empty time series set.
bool writetofile(QFile *) override
Writes time series set to file.
vector< string > labels
Custom labels for time points.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes time series set from JSON format.
vector< double > observed_value
Observed values for comparison with modeled series.
QJsonObject toJsonObject() const override
Serializes time series set to JSON format.
string Label(unsigned int i) const
Gets label for time point (uses custom labels if set).
CMBTimeSeriesSet(int n, int m)
Constructs with specified number of series and points.
void AppendLastContribution(int colnumber, const string &name)
Appends a final contribution series calculated from existing series.
QTableWidget * ToTable() override
Creates a QTableWidget for displaying time series set data.
void SetObservedValue(int i, const double &value)
Sets observed value for comparison at specified index.
string ToString() const override
Converts time series set to CSV-formatted string.
double ObservedValue(int i)
Gets observed value at specified index.
Interface()
Default constructor.
Definition interface.cpp:6
STL class.