File: dataVariables.h

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (143 lines) | stat: -rw-r--r-- 5,522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/***********************************************/
/**
* @file dataVariables.h
*
* @brief Create variables to evaluate a matrix/grid/timeSeries.
*
* @author Torsten Mayer-Guerr
* @date 2018-06-18
*
*/
/***********************************************/

#ifndef __GROOPS_DATAVARIABLES__
#define __GROOPS_DATAVARIABLES__

// Latex documentation
#ifdef DOCSTRING_Parser
static const char *docstringParserDataVariables = R"(
\subsection{Variables for data}\label{general.parser:dataVariables}
Some programs (e.g. \program{FunctionsCalculate}, \program{InstrumentArcCalculate},
\program{GriddedDataCalculate}, or the plot programs)
read data (\file{matrix}{matrix}) or \file{gridded data}{griddedData}
and evaluate input/output expressions for each data row.
For these kind of expressions additional variables are automatically defined for each data column
(\verb|X| stands for the data column number: $0\ldots n$):
\begin{itemize}
\item \verb|index|: the row number, starting with zero
\item \verb|dataX|: the value itself
\item \verb|dataXcount|: number of rows
\item \verb|dataXmin|
\item \verb|dataXmax|
\item \verb|dataXsum|
\item \verb|dataXmean|
\item \verb|dataXrms|: root mean square
\item \verb|dataXstd|: standard deviation
\item \verb|dataXmedian|
\item \verb|dataXmad|: median absolute deviation
\item \verb|dataXstep|: the minimal difference between two neighboring data points in the column
\end{itemize}
For \file{gridded data}{griddedData} input the following variables are additionally defined for each data point:
\begin{itemize}
\item \verb|longitude| in degrees
\item \verb|latitude| in degrees
\item \verb|height| in meters
\item \verb|cartesianX| coordinate in meters
\item \verb|cartesianY| coordinate in meters
\item \verb|cartesianZ| coordinate in meters
\item \verb|area| of the unit sphere
\item \verb|dataXwmean|: area-weighted mean
\item \verb|dataXwrms|: area-weighted root mean square
\item \verb|dataXwstd|: area-weighted standard deviation
\end{itemize}
)";
#endif

/***********************************************/

#include "base/importStd.h"
#include "base/matrix.h"
#include "expressionParser.h"

/** @addtogroup parserGroup */
/// @{

/***********************************************/

/** @brief Create variables to loop over intervals.
* @ingroup parserGroup
* The following variable are created:
* index, loopTime, loopTimeStart, loopTimeEnd. */
void addTimeVariables(VariableList &varList);

/** @brief Compute the values of the variables of a temporal loop.
* @ingroup parserGroup */
void evaluateTimeVariables(UInt index, const Time &timeStart, const Time &timeEnd, VariableList &varList);

/***********************************************/

/** @brief Create variables to evaluate a vector.
* @ingroup parserGroup
* The following variable are created:
* prefix, prefixmean, prefixmedian, prefixrms, prefixstd, prefixmad, prefixmin, prefixmax, prefixstep
* @param prefix to build parameter names.
* @param data The vector for which the variables are created.
* @param varList The @a VariableList to which the variables are added. */
void addDataVariables(const std::string &prefix, const_MatrixSliceRef data, VariableList &varList);

class Time;
void addDataVariables(const std::string &prefix, const std::vector<Time> &times, VariableList &varList);

void addDataVariables(const std::string &prefix, const_MatrixSliceRef data, const_MatrixSliceRef weight, VariableList &varList);

/** @brief Create variables to evaluate a matrix.
* @ingroup parserGroup
* The following variable are created if they occur in @a usedName
* index,
* data, data0, data1, ...
* data0mean, data0median, data0rms, data0std, data0mad, data0min, data0max, data0step
* data1mean, data1median, data1rms, data1std, data1mad, data1min, data1max, data1step
* ...
* @param data The matrix for which the variables are created.
* @param varList The @a VariableList to which the variables are added. */
void addDataVariables(const_MatrixSliceRef data, VariableList &varList);

/** @brief Compute the values of the variables of a matrix.
* @ingroup parserGroup */
void evaluateDataVariables(const_MatrixSliceRef data, UInt row, VariableList &varList);

/** @brief Set status to undefined of the variables of a matrix.
* @ingroup parserGroup */
void undefineDataVariables(const_MatrixSliceRef data, VariableList &varList);

/***********************************************/

class GriddedData;
class GriddedDataRectangular;
/** @brief Create variables to evaluate a grid.
* @ingroup parserGroup
* The following variable are created
* longitude, latitude, height, area,
* index,
* data, data0, data1, ...
* data0mean, data0rms, data0std, data0min, data0max,
* data1mean, data1rms, data1std, data1min, data1max, ... */
void addDataVariables(const GriddedData            &grid, VariableList &varList);
void addDataVariables(const GriddedDataRectangular &grid, VariableList &varList);

/** @brief Compute the values of the variables of a grid.
* @ingroup parserGroup */
void evaluateDataVariables(const GriddedData            &grid, UInt row, VariableList &varList);
void evaluateDataVariables(const GriddedDataRectangular &grid, UInt row, UInt col, VariableList &varList);

/** @brief Set status to undefined of the variables of a grid.
* @ingroup parserGroup */
void undefineDataVariables(const GriddedData            &grid, VariableList &varList);
void undefineDataVariables(const GriddedDataRectangular &grid, VariableList &varList);

/***********************************************/

/// @}

#endif /* __GROOPS__ */