New schemes: Extending
- Options from the schemes namelist can be retrieved by using
iOptions.getValue("attributeName",
mAttributeName) in the constructor.
This is the simplest approach. An existing scheme can be extended by adding options to the scheme. The new options are retrived and stored in
the constructor. For example, an option to log transform the ensemble values before doing a bias-correction could be added as follows:
1 CorrectorNew::CorrectorNew(const Options& iOptions, const Data& iData) const :
2 mDoLogTransform(false) // Set the default value here
3 {
4 // Retrive the log transform option (if specified)
5 iOptions.getValue("doLogTransform", mDoLogTransform);
6 }
7 void CorrectorNew::correctCore(const Parameters& iParameters, Ensemble& iEnsemble) const {
8 // Correct each ensemble member
9 for(int i = 0; i < iEnsemble.size(); i++) {
10 ...
11 float correction = ...
12 // Add correction to ensemble members
13 if(mDoLogTransform) {
14 // This is the new code for the log transform option
15 float log = log(iEnsemble[i]);
16 log = log + correction;
17 iEnsemble[i] = exp(log);
18 }
19 else {
20 iEnsemble[i] = iEnsemble[i] + correction;
21 }
22 }
23 }
Note that this requires that
bool mDoLogTransform; be added as a protected variable to the header file for this correction
scheme.