-
Notifications
You must be signed in to change notification settings - Fork 21
/
CorrelationModel.h
204 lines (178 loc) · 7.65 KB
/
CorrelationModel.h
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
//##################################################################
//
// FILENAME: CorrelationModel.h
//
// CLASSIFICATION: Unclassified
//
// DESCRIPTION:
//
// Header for the covariance model base class used in the CSM
// interface. Intended for replacement models to recreate cross
// covariance calculations; most calling applications will use
// the CSM cross covariance method. The covariance model is
// passed as the base class and cast to the appropriate derived
// class for use.
//
// LIMITATIONS: None
//
// SOFTWARE HISTORY:
// Date Author Comment
// ----------- ------ -------
// 29-Mar-2012 SCM Refactored interface
// 30-Oct-2012 SCM Renamed to CorrelationModel.h
// 14-Nov-2012 SCM Added NoCorrelationModel.
// 06-Dec 2012 JPK Replaced "UNKNOWN" with CSM_UNKNOWN
// 17-Dec-2012 BAH Documentation updates.
// 12-Feb-2013 JPK Renamed CovarianceModel to
// CorrelationModel
// 18-Feb-2013 JPK Added getDecorrelationEventTime() and
// setDecorrelationEventTime(). Implemented
// getNumCorrelationParameterGroups().
// 20-Sep-2019 JPK Added setFormat() and
// setNumCorrelationParameterGroups()
//
// NOTES:
//
//#####################################################################
#ifndef __CSM_CORRELATIONMODEL_H
#define __CSM_CORRELATIONMODEL_H
#include <string>
#include "csm.h"
#include "Error.h"
namespace csm
{
class CSM_EXPORT_API CorrelationModel
{
public:
virtual ~CorrelationModel() {}
//> A virtual destructor is needed so derived class destructors will
// be called when the base class object is destroyed.
//<
const std::string& format() const { return theFormat; }
virtual size_t getNumSensorModelParameters() const = 0;
//> Returns the number of model parameters. The returned value
// will be the same as the value of numSMParams passed to the
// constructor when the derived object was created.
//<
inline size_t getNumCorrelationParameterGroups() const;
//> Returns the number of correlation parameter groups. The returned
// value will be the same as the value of numCPGroups passed to the
// constructor when this object was created.
//<
virtual int getCorrelationParameterGroup(size_t smParamIndex) const = 0;
//> Returns the index of the correlation parameter group to which the
// model parameter given by smParamIndex belongs. If the model
// parameter does not belong to a group, the return value will be -1.
//
// The smParamIndex must be less than getNumSensorModelParameters().
//<
virtual double getCorrelationCoefficient(size_t cpGroupIndex,
double deltaTime) const = 0;
//> Computes the correlation coefficient for the correlation parameter
// group given by cpGroupIndex for the given deltaTime.
// The deltaTime argument represents the difference in time, in seconds,
// for which the correlation is calculated.
//
// The cpGroupIndex must be less than getNumCorrelationParameterGroups().
//
// Notes:
//
// The deltaTime argument should be positive, but the method uses the
// absolute value of the argument, so a negative deltaTime is acceptable.
//
// If the computed correlation coefficient is outside the range [-1, 1],
// the method will "clamp" the returned value to the nearest number
// within that range. For example, if the correlation coefficient
// equation evaluates to 1.1 for a given deltaTime,
// the value 1.0 will be returned.
//<
const std::string& getDecorrelationEventTime(size_t cpGroupIndex) const;
//> This method returns the decorrelation event time for the specified
// parameter group index. The returned string follows the ISO 8601 standard.
//
//- Precision Format Example
//- year yyyy "1961"
//- month yyyymm "196104"
//- day yyyymmdd "19610420"
//- hour yyyymmddThh "19610420T20"
//- minute yyyymmddThhmm "19610420T2000"
//- second yyyymmddThhmmss "19610420T200000"
// If no decorrelation event time has been set for the specified
// parameter group, the returned string will be empty.
// If the specified parameter group index is outside the range of available
// parameter groups, an exception will be thrown.
//<
void setDecorrelationEventTime(const std::string& decorrelationEventTime,
size_t cpGroupIndex);
//> This method sets the decorrelation event time for the specified
// parameter group index. The provided string should follow the ISO 8601
// standard.
//
//- Precision Format Example
//- year yyyy "1961"
//- month yyyymm "196104"
//- day yyyymmdd "19610420"
//- hour yyyymmddThh "19610420T20"
//- minute yyyymmddThhmm "19610420T2000"
//- second yyyymmddThhmmss "19610420T200000"
// By default, the decorrelation event time for all groups is set to an
// empty string. If the specified parameter group index is outside the
// range of available parameter groups, an exception will be thrown.
//<
protected:
CorrelationModel(const std::string& format,
size_t numCPGroups);
void setFormat(const std::string& format);
void setNumCorrelationParameterGroups(size_t numCorrGroups);
private:
CorrelationModel()
:
theFormat (CSM_UNKNOWN),
theDecorrelationEventTimes ()
{}
//> This is the default constructor. It is declared private to prevent
// its use.
//<
std::string theFormat;
//> This data member is a string identifying the "format" for the
// current derived CorrelationModel.
//<
std::vector<std::string> theDecorrelationEventTimes;
//> This data member is a vector of strings which represent the
// decorrelation event times for each group of parameters.
//<
};
inline size_t CorrelationModel::getNumCorrelationParameterGroups() const
{
return theDecorrelationEventTimes.size();
}
//***
// CLASS: NoCorrelationModel
//> The NoCorrelationModel class is needed for sensor models that do not have
// a covariance model because the RasterGM::getCorrelationModel() method
// returns a const reference.
//<
//***
class CSM_EXPORT_API NoCorrelationModel : public CorrelationModel
{
public:
NoCorrelationModel() : CorrelationModel("NONE",0) {}
virtual ~NoCorrelationModel() {}
virtual size_t getNumSensorModelParameters() const { return 0; }
virtual int getCorrelationParameterGroup(size_t smParamIndex) const
{
// there can be no smParamIndex that is less than getNumSensorModelParameters()
throw Error(Error::INDEX_OUT_OF_RANGE,
"Invalid index parameter",
"csm::NoCorrelationModel::getNumSensorModelParameters");
}
virtual double getCorrelationCoefficient(size_t cpGroupIndex, double deltaTime) const
{
// there can be no cpGroupIndex that is less than getNumCorrelationParameterGroups()
throw Error(Error::INDEX_OUT_OF_RANGE,
"Invalid index parameter",
"csm::NoCorrelationModel::getCorrelationCoefficient");
}
};
} // namespace csm
#endif