VAPOR3 3.9.4
Statistics.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2016 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: Statistics.h
10//
11// Author: Samuel Li
12// National Center for Atmospheric Research
13// PO 3000, Boulder, Colorado
14//
15// Date: November 2017
16//
17// Description: Implements the Statistics class.
18//
19#ifdef WIN32
20 #pragma warning(disable : 4100)
21#endif
22
23#ifndef STATISTICS_H
24 #define STATISTICS_H
25
26 #include <qdialog.h>
27 #include <qwidget.h>
28 #include <vapor/DataMgr.h>
29 #include <vapor/Grid.h>
31 #include "ui_statsWindow.h"
32 #include <RangeCombos.h>
33 #include <StatisticsParams.h>
34 #include "PWidgets.h"
35
36namespace VAPoR {
37class ParamsMgr;
38class DataMgr;
39} // namespace VAPoR
40
41class Statistics : public QDialog, public Ui_StatsWindow {
42 Q_OBJECT
43
44public:
45 Statistics(QWidget *parent);
48 void showMe();
49 bool Update();
50
51protected:
52 // Keeps the current variables shown and their statistical values.
53 // Invalid values are stored as std::nan("1");
54 //
55 class ValidStats {
56 public:
57 bool AddVariable(std::string &);
58 bool RemoveVariable(std::string &);
60 std::string GetVariableName(int i);
61
62 bool Add3MStats(std::string &, const float *); // Min, Max, Mean
63 bool AddMedian(std::string &, float);
64 bool AddStddev(std::string &, float);
65 bool AddCount(std::string &, long);
66
67 // invalid values are represented as nan.
68 bool Get3MStats(std::string &, float *);
69 bool GetMedian(std::string &, float *);
70 bool GetStddev(std::string &, float *);
71 bool GetCount(std::string &, long *);
72
73 bool InvalidAll(); // keep existing variables, but set values to nan
74 bool Clear(); // clear all variables and values.
75
76 // keeps the current parameters, and make them public.
80
83 bool SetCurrentExtents(const std::vector<float> &min, const std::vector<float> &max);
84 bool SetCurrentExtents(const std::vector<double> &min, const std::vector<double> &max);
85
86 private:
87 std::vector<std::string> _variables;
88 std::vector<float> _values[5]; // 0: min
89 // 1: max
90 // 2: mean
91 // 3: median
92 // 4: stddev
93 std::vector<long> _count; // number of samples
94
95 int _getVarIdx(std::string &); // -1: not exist
96 // >=0: a valid index
97 }; // finish class ValidStats
98
99 bool Connect(); // connect slots
100
101private slots:
102 void _newVarChanged(int);
103 void _removeVarChanged(int);
104 void _newCalcChanged(int);
105 void _removeCalcChanged(int);
106 void _minTSChanged(int);
107 void _maxTSChanged(int);
108 void _updateButtonClicked();
109 void _geometryValueChanged();
110 void _dataSourceChanged(int);
111 void _autoUpdateClicked(int);
112 void _exportTextClicked();
113
114private:
115 ValidStats _validStats;
116 VAPoR::ControlExec * _controlExec;
117 std::vector<PWidget *> _pw;
118
119 void _updateStatsTable();
120
121 // calculations should put results in _validStats directly.
122 bool _calc3M(std::string); // min, max, mean
123 bool _calcMedian(std::string);
124 bool _calcStddev(std::string);
125};
126#endif
std::string currentDataSourceName
Definition: Statistics.h:77
bool Get3MStats(std::string &, float *)
bool Add3MStats(std::string &, const float *)
bool AddCount(std::string &, long)
bool GetMedian(std::string &, float *)
bool SetCurrentExtents(const std::vector< double > &min, const std::vector< double > &max)
bool SetCurrentExtents(const std::vector< float > &min, const std::vector< float > &max)
bool RemoveVariable(std::string &)
bool AddStddev(std::string &, float)
bool GetStddev(std::string &, float *)
bool HaveSameParams(const VAPoR::StatisticsParams *rhs) const
bool GetCount(std::string &, long *)
bool AddVariable(std::string &)
std::string GetVariableName(int i)
bool UpdateMyParams(const VAPoR::StatisticsParams *rhs)
std::vector< float > currentExtentMin
Definition: Statistics.h:78
bool AddMedian(std::string &, float)
std::vector< float > currentExtentMax
Definition: Statistics.h:78
bool Update()
int initControlExec(VAPoR::ControlExec *ce)
Statistics(QWidget *parent)
void showMe()
bool Connect()
Provides API for VAPOR visualizer User Interfaces (UIs)