SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
cmbvectorsetset.cpp
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#include "cmbvectorsetset.h"
5#include <QFile>
6#include <gsl/gsl_cdf.h>
7
17{
18 map<string,CMBVectorSet>::operator=(mp);
20 return *this;
21}
23{
24 QJsonObject out;
25 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
26 {
27 out[QString::fromStdString(it->first)]=it->second.toJsonObject();
28 }
29 return out;
30}
31bool CMBVectorSetSet::ReadFromJsonObject(const QJsonObject &jsonobject)
32{
33 for(const QString& key: jsonobject.keys() ) {
34 CMBVectorSet column;
35 column.ReadFromJsonObject(jsonobject[key].toObject());
36 operator[](key.toStdString()) = column;
37 }
38 return true;
39}
41{
42 string s;
43 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
44 {
45 s+= "\n";
46 s+=it->first + ":\n";
47 s+=it->second.ToString()+="\n";
48 }
49 return s;
50}
51
52unsigned int CMBVectorSetSet::MaxSize() const
53{
54 int max_size=0;
55 for (map<string,CMBVectorSet>::const_iterator it = begin(); it!=end();it++)
56 {
57 if (it->second.MaxSize()>max_size)
58 max_size = it->second.MaxSize();
59 }
60 return max_size;
61}
62
64{
65 double out = -1e23;
66 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
67 {
68 out = std::max(out,it->second.max());
69 }
70 return out;
71};
73{
74 double out = 1e23;
75 for (map<string,CMBVectorSet>::const_iterator it = cbegin(); it!=cend();it++)
76 {
77 out = std::min(out,it->second.min());
78 }
79 return out;
80}
81
82
84{
85 QTableWidget *tablewidget = new QTableWidget();
86 tablewidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
87 int column_count=0;
88 for (map<string,CMBVectorSet>::iterator vectorset=begin(); vectorset!=end(); vectorset++)
89 column_count += vectorset->second.size();
90 tablewidget->setColumnCount(column_count*2);
91 tablewidget->setRowCount(MaxSize());
92 QStringList rowheaders;
93 QStringList colheaders;
94 int colno = 0;
95 for (map<string,CMBVectorSet>::iterator vectorset=begin(); vectorset!=end(); vectorset++)
96 {
97 for (map<string,CMBVector>::iterator column=vectorset->second.begin(); column!=vectorset->second.end(); column++)
98 {
99 colheaders<<QString::fromStdString(vectorset->first)+":"+QString::fromStdString(column->first)<<QString::fromStdString(vectorset->first)+":"+QString::fromStdString(column->first)+"-Value";
100 for (int i=0; i<column->second.getsize(); i++)
101 {
102 tablewidget->setItem(i,colno*2,new QTableWidgetItem(QString::fromStdString(column->second.Label(i))));
103 tablewidget->setItem(i,colno*2+1,new QTableWidgetItem(QString::number(column->second[i])));
104 }
105 colno++;
106 }
107 }
108
109 tablewidget->setHorizontalHeaderLabels(colheaders);
110 //tablewidget->setVerticalHeaderLabels(rowheaders);
111 return tablewidget;
112}
114{
115 file->write(QString::fromStdString(ToString()).toUtf8());
116 return true;
117}
118
119string CMBVectorSetSet::Label(const string &vectorset,const string &column, int j) const
120{
121 if (count(vectorset)!=0)
122 return (at(vectorset).Label(column,j));
123 else
124 return "";
125}
126double CMBVectorSetSet::valueAt(const string &vectorset, const string &columnlabel, int j) const
127{
128 if (count(columnlabel)!=0)
129 return (at(vectorset).valueAt(columnlabel,j));
130 else
131 return 0;
132}
133CMBVector &CMBVectorSetSet::GetColumn(const string &vectorset, const string &columnlabel)
134{
135 return at(vectorset).GetColumn(columnlabel);
136}
137void CMBVectorSetSet::Append(const string &columnlabel,const CMBVectorSet &vectorset)
138{
139 this->operator[](columnlabel) = vectorset;
140}
141
double min() const
Finds the minimum value across all vectors in all sets.
CMBVector & GetColumn(const string &vectorset, const string &columnlabel)
Gets reference to a named column vector within a vector set.
double max() const
Finds the maximum value across all vectors in all sets.
string ToString() const override
Converts vector set set to string representation.
double valueAt(const string &vectorset, const string &columnlabel, int j) const
Gets value at specified position in a column within a vector set.
QTableWidget * ToTable() override
Creates a QTableWidget for displaying vector set set data.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes vector set set from JSON format.
string Label(const string &vectorset, const string &column, int j) const
Gets label at specified position in a column within a vector set.
void Append(const string &columnlabel, const CMBVectorSet &vectorset)
Adds or replaces a vector set in the collection.
CMBVectorSetSet()
Default constructor - creates an empty vector set set.
unsigned int MaxSize() const
Finds the maximum size among all vectors in all sets.
bool writetofile(QFile *file) override
Writes vector set set to file.
QJsonObject toJsonObject() const override
Serializes vector set set to JSON format.
CMBVectorSetSet & operator=(const CMBVectorSetSet &mp)
Assignment operator.
Collection of named CMBVector objects for multi-variable analysis.
bool ReadFromJsonObject(const QJsonObject &jsonobject) override
Deserializes vector set from JSON format.
Vector class with string labels for Chemical Mass Balance analysis.
Definition cmbvector.h:20
Interface()
Default constructor.
Definition interface.cpp:6
Interface & operator=(const Interface &intf)
Assignment operator.
STL class.