12#ifndef SEIMS_PARAMETER_INFO_H
13#define SEIMS_PARAMETER_INFO_H
25using namespace utils_math;
26using namespace utils_string;
43 ParamInfo(
string& name,
string& desc,
string& unit,
string& mid, T value,
string& change, T impact,
44 T maximum, T minimum,
bool isint);
47 ParamInfo(
string& name,
string& basicname,
string& desc,
string& unit,
string& source,
string& mid,
51 ParamInfo(
string& name,
string& basicname,
string& desc,
string& unit,
string& source,
string& mid,
53 bool isconst,
bool isoutput);
79 int Adjust1DRaster(
int n, T* data,
const int* units,
const vector<int>& selunits,
80 const int* lu,
const vector<int>& sellu);
84 const vector<int>& selunits,
const map<int, int>& impactIndexes,
85 const int* lu,
const vector<int>& sellu);
94 int Adjust2DRaster(
int n,
int lyrs, T** data,
const int* units,
const vector<int>& selunits,
95 const int* lu,
const vector<int>& sellu);
99 const vector<int>& selunits,
const map<int, int>& impactIndexes,
100 const int* lu,
const vector<int>& sellu);
153 Name(
""), BasicName(
""), Description(
""), Units(
""), Source(
""), ModuleID(
""),
155 Value(0), Change(
""), Impact(0), Maximum(0), Minimum(0), IsInteger(false),
156 DependPara(nullptr), ClimateType(
""),
157 IsConstant(false), IsOutput(false), OutputToOthers(false),
158 initialized(false), ImpactSeries() {
163 T impact, T maximum, T minimum,
bool isint):
164 Name(name), BasicName(
""), Description(desc), Units(unit), Source(
""), ModuleID(mid),
166 Value(value), Change(change), Impact(impact), Maximum(maximum), Minimum(minimum), IsInteger(isint),
167 DependPara(nullptr), ClimateType(
""),
168 IsConstant(false), IsOutput(false), OutputToOthers(false),
169 initialized(false), ImpactSeries() {
176 Name(name), BasicName(basicname), Description(desc), Units(unit), Source(source), ModuleID(mid),
177 Dimension(dim), Transfer(
TF_None),
178 Value(value), Change(
""), Impact(0), Maximum(0), Minimum(0), IsInteger(false),
179 DependPara(nullptr), ClimateType(climtype),
180 IsConstant(false), IsOutput(false), OutputToOthers(false),
181 initialized(false), ImpactSeries() {
188 bool isconst,
bool isoutput) :
189 Name(name), BasicName(basicname), Description(desc), Units(unit), Source(source), ModuleID(mid),
190 Dimension(dim), Transfer(tftype),
191 Value(0), Change(
""), Impact(0), Maximum(0), Minimum(0), IsInteger(false),
192 DependPara(nullptr), ClimateType(climtype),
193 IsConstant(isconst), IsOutput(isoutput), OutputToOthers(false),
194 initialized(false), ImpactSeries() {
203 Units = another.
Units;
208 Value = another.
Value;
225 if (DependPara !=
nullptr) {
226 DependPara =
nullptr;
271 T tmpImpact = ImpactSeries[curImpactIndex];
292#pragma omp parallel for
293 for (
int i = 0; i < n; i++) {
296 data[i] = GetAdjustedValue(data[i]);
303 Adjust1DArray(n, data);
308 const vector<int>& selunits,
309 const int* lu,
const vector<int>& sellu) {
311 for (
int i = 0; i < n; i++) {
316 int curunit = units[i];
318 if (find(selunits.begin(), selunits.end(), curunit) == selunits.end()) {
321 if (find(sellu.begin(), sellu.end(), curlu) == sellu.end()) {
324 data[i] = GetAdjustedValue(data[i]);
332 const vector<int>& selunits,
const map<int, int>& impactIndexes,
333 const int* lu,
const vector<int>& sellu) {
335 for (
int i = 0; i < n; i++) {
340 int curunit = units[i];
343 if (find(selunits.begin(), selunits.end(), curunit) == selunits.end()) {
346 if (find(sellu.begin(), sellu.end(), curlu) == sellu.end()) {
349 map<int, int>::const_iterator it = impactIndexes.find(curunit);
350 if (it == impactIndexes.end()) {
353 data[i] = GetAdjustedValueWithImpactIndexes(data[i], it->second);
361#pragma omp parallel for
362 for (
int i = 0; i < n; i++) {
363 Adjust1DArray(
CVT_INT(data[i][0]), data[i] + 1);
369#pragma omp parallel for
370 for (
int i = 0; i < n; i++) {
371 Adjust1DArray(lyrs, data[i]);
377 const int* units,
const vector<int>& selunits,
378 const int* lu,
const vector<int>& sellu) {
380 for (
int i = 0; i < n; i++) {
381 int curunit = units[i];
383 if (find(selunits.begin(), selunits.end(), curunit) == selunits.end()) {
386 if (find(sellu.begin(), sellu.end(), curlu) == sellu.end()) {
389 for (
int j = 0; j < lyrs; j++) {
390 data[i][j] = GetAdjustedValue(data[i][j]);
399 const int* units,
const vector<int>& selunits,
400 const map<int, int>& impactIndexes,
401 const int* lu,
const vector<int>& sellu) {
403 for (
int i = 0; i < n; i++) {
404 int curunit = units[i];
407 if (find(selunits.begin(), selunits.end(), curunit) == selunits.end()) {
410 if (find(sellu.begin(), sellu.end(), curlu) == sellu.end()) {
413 map<int, int>::const_iterator it = impactIndexes.find(curunit);
414 if (it == impactIndexes.end()) {
417 for (
int j = 0; j < lyrs; j++) {
418 data[i][j] = GetAdjustedValueWithImpactIndexes(data[i][j], it->second);
#define CVT_INT(param)
A reference to the postfix of executable file for RELWITHDEBINFO mode.
Definition: basic.h:325
#define NODATA_VALUE
Global utility definitions.
Definition: basic.h:245
bool IsInteger
is integer?
Definition: ParamInfo.h:129
int Adjust2DRasterWithImpactIndexes(int n, int lyrs, T **data, const int *units, const vector< int > &selunits, const map< int, int > &impactIndexes, const int *lu, const vector< int > &sellu)
Adjust 2D Raster on selected area, using impact index version.
Definition: ParamInfo.h:398
vector< T > ImpactSeries
If the BMP effectiveness is variable, set the values of impacts.
Definition: ParamInfo.h:143
string Source
Source, to identify which the parameters can be derived.
Definition: ParamInfo.h:111
T Minimum
Absolute minimum value.
Definition: ParamInfo.h:127
bool initialized
whether is initialized
Definition: ParamInfo.h:141
string Units
Units.
Definition: ParamInfo.h:109
ParamInfo()
Construct an empty instance.
Definition: ParamInfo.h:152
~ParamInfo()
Destructor.
Definition: ParamInfo.h:224
string ClimateType
Climate type.
Definition: ParamInfo.h:133
void Adjust1DArray(int n, T *data)
Adjust 1D array.
Definition: ParamInfo.h:291
T Value
Value.
Definition: ParamInfo.h:119
T GetAdjustedValueWithImpactIndexes(T pre_value, int curImpactIndex)
Adjust value with indexed impact.
Definition: ParamInfo.h:261
string Description
Description.
Definition: ParamInfo.h:107
T Maximum
Absolute maximum value.
Definition: ParamInfo.h:125
string Name
Name.
Definition: ParamInfo.h:103
dimensionTypes Dimension
Data dimension type.
Definition: ParamInfo.h:115
T Impact
Impact value.
Definition: ParamInfo.h:123
string ModuleID
Used by Module Ids.
Definition: ParamInfo.h:113
T GetAdjustedValue(T pre_value=NODATA_VALUE)
Return the adjusted value for this parameter.
Definition: ParamInfo.h:231
bool IsConstant
Is constant or not.
Definition: ParamInfo.h:135
ParamInfo * DependPara
Dependence parameters.
Definition: ParamInfo.h:131
void Adjust1DRaster(int n, T *data)
Adjust 1D Raster,.
Definition: ParamInfo.h:302
bool OutputToOthers
Is output to other modules or not.
Definition: ParamInfo.h:139
void Adjust2DRaster(int n, int lyrs, T **data)
Adjust 2D Raster.
Definition: ParamInfo.h:368
int Adjust1DRasterWithImpactIndexes(int n, T *data, const int *units, const vector< int > &selunits, const map< int, int > &impactIndexes, const int *lu, const vector< int > &sellu)
Adjust 1D Raster on selected area, using impact index version.
Definition: ParamInfo.h:331
bool IsOutput
Is output or not.
Definition: ParamInfo.h:137
transferTypes Transfer
Data transfer type.
Definition: ParamInfo.h:117
string BasicName
Basic name.
Definition: ParamInfo.h:105
void Adjust2DArray(int n, T **data)
Adjust 2D array.
Definition: ParamInfo.h:360
string Change
Change type.
Definition: ParamInfo.h:121
Class to store and manage parameter information from the parameter database.
Definition: ParamInfo.h:37
transferTypes
Float values be transferred across subbasins for MPI version.
Definition: MetadataInfoConst.h:86
dimensionTypes
enum of dimension data types
Definition: MetadataInfoConst.h:63
bool FloatEqual(T1 v1, T2 v2)
Whether v1 is equal to v2.
Definition: utils_math.h:141
bool StringMatch(const char *a, const char *b)
Match char ignore cases.
Common Cross-platform Geographic Library (CCGL)
Predefined string constants used in the code BE CAUTION, constant value must be aligned by SPACE,...
CONST_CHARS PARAM_CHANGE_VC
replace by a value
Definition: text.h:65
CONST_CHARS PARAM_CHANGE_AC
add a value
Definition: text.h:67
CONST_CHARS PARAM_CHANGE_RC
multiply a ratio, which is diff from SWAT: * (1+ratio)
Definition: text.h:66
CONST_CHARS PARAM_CHANGE_NC
no change
Definition: text.h:68
Useful math equations in CCGL.
Handling string related issues in CCGL.