NANDRAD Data Model Library
Version 2.0
NANDRAD
|
Class LinearSplineParameter stores a linear spline curve, the corresponding parameter name and a unit name of both dependend and independend quantity (xUnit, yUnit).
Note that the read and write functions perform unit conversions on the values, so that the linear spline actually holds values always in Base-SI units (according to the IBK Unit-Definition).
So when reading a linear spline that defines temperatures in C, the actual spline will then contain the values in K.
Definition at line 45 of file NANDRAD_LinearSplineParameter.h.
#include <NANDRAD_LinearSplineParameter.h>
Public Types | |
enum | interpolationMethod_t { I_CONSTANT, I_LINEAR, NUM_I } |
Interpolation method to be used for this linear spline parameter. More... | |
enum | wrapMethod_t { C_CONTINUOUS, C_CYCLIC, NUM_C } |
How to treat the values in multi-year simulations. More... | |
Public Member Functions | |
LinearSplineParameter () | |
Default Constructor. More... | |
LinearSplineParameter (const std::string &name, const interpolationMethod_t intPol, const std::vector< double > &xVals, const std::vector< double > yVals, const IBK::Unit &xUnit, const IBK::Unit &yUnit) | |
Constructor with values. More... | |
LinearSplineParameter (const std::string &name, const interpolationMethod_t intPol, const IBK::Path &tsvFilePath) | |
Constructor with data file . More... | |
void | readXML (const TiXmlElement *element) |
TiXmlElement * | writeXML (TiXmlElement *parent) const |
void | checkAndInitialize (const std::string &expectedName, const IBK::Unit &targetXUnit, const IBK::Unit &targetYUnit, const IBK::Unit &limitYUnit, double minYVal, bool isGreaterEqual, double maxYVal, bool isLessEqual, const char *const errmsg, bool skipUnitChecks=false) |
Function to check for correct parametrization of linear spline parameters. More... | |
void | readTsv () |
Reads externally referenced tsv-file. More... | |
Public Attributes | |
std::string | m_name |
Parameter name (in context of schedules used as scheduled quantity). More... | |
interpolationMethod_t | m_interpolationMethod = NUM_I |
Interpolation method to be used when computing values of this spline. More... | |
wrapMethod_t | m_wrapMethod = NUM_C |
Whether to wrap time around in multi-year simulations (cyclic use) or to assume continuous data. More... | |
IBK::LinearSpline | m_values |
Data vectors including linear spline functionality (i.e. More... | |
IBK::Unit | m_xUnit |
Unit of the x-values. More... | |
IBK::Unit | m_yUnit |
Unit of the y-values. More... | |
IBK::Path | m_tsvFile |
Path to tsv-file, the file will be read during checkAndInitialize() call. More... | |
Private Member Functions | |
void | convert2BaseUnits () |
Converts x and y values from display/input/output units (m_xUnit and m_yUnit) to their respective base SI units. More... | |
Interpolation method to be used for this linear spline parameter.
Definition at line 49 of file NANDRAD_LinearSplineParameter.h.
How to treat the values in multi-year simulations.
Definition at line 56 of file NANDRAD_LinearSplineParameter.h.
|
inline |
Default Constructor.
Definition at line 65 of file NANDRAD_LinearSplineParameter.h.
|
inline |
Constructor with values.
Definition at line 68 of file NANDRAD_LinearSplineParameter.h.
|
inline |
Constructor with data file .
Definition at line 81 of file NANDRAD_LinearSplineParameter.h.
void NANDRAD::LinearSplineParameter::checkAndInitialize | ( | const std::string & | expectedName, |
const IBK::Unit & | targetXUnit, | ||
const IBK::Unit & | targetYUnit, | ||
const IBK::Unit & | limitYUnit, | ||
double | minYVal, | ||
bool | isGreaterEqual, | ||
double | maxYVal, | ||
bool | isLessEqual, | ||
const char *const | errmsg, | ||
bool | skipUnitChecks = false |
||
) |
Function to check for correct parametrization of linear spline parameters.
This function checks if the spline is actually defined, i.e. m_name is not empty. Then it tests, wether there is a valid tsv-filepath given, reads the according file and sets m_values and the units Then it is checked if the x and y value units can be converted to targetX and targetY units. This can be skipped by setting skipUnitChecks to true, which may be useful if the target units are not yet known. These target units must be SI base units. It then converts the input data into the target (base SI) units, using the convert2BaseUnits() function.
Note: the m_xUnit and m_yUnit members are not modified here! Then, the spline is generated, hereby testing for monotonically increasing x-values. Finally, the y-value ranges are being checked.
void NANDRAD::LinearSplineParameter::readTsv | ( | ) |
Reads externally referenced tsv-file.
m_tsvFile is expected to contain a valid absolute path, optionally with trailing ?n column identifier.
|
private |
Converts x and y values from display/input/output units (m_xUnit and m_yUnit) to their respective base SI units.
std::string NANDRAD::LinearSplineParameter::m_name |
Parameter name (in context of schedules used as scheduled quantity).
Definition at line 123 of file NANDRAD_LinearSplineParameter.h.
interpolationMethod_t NANDRAD::LinearSplineParameter::m_interpolationMethod = NUM_I |
Interpolation method to be used when computing values of this spline.
Definition at line 125 of file NANDRAD_LinearSplineParameter.h.
wrapMethod_t NANDRAD::LinearSplineParameter::m_wrapMethod = NUM_C |
Whether to wrap time around in multi-year simulations (cyclic use) or to assume continuous data.
Definition at line 127 of file NANDRAD_LinearSplineParameter.h.
IBK::LinearSpline NANDRAD::LinearSplineParameter::m_values |
Data vectors including linear spline functionality (i.e.
interpolation at any given value). When this class is used as data container, the x and y values are stored in the units m_xUnit and m_yUnit. However, after the call to checkAndInitialize(), the values are stored in the respective Base-SI units of the input/output units m_xUnit and m_yUnit. For example, if m_yUnit is 'C' (degree C), then the spline holds values in 'K' (degree Kelvin).
Definition at line 135 of file NANDRAD_LinearSplineParameter.h.
IBK::Unit NANDRAD::LinearSplineParameter::m_xUnit |
Unit of the x-values.
Definition at line 137 of file NANDRAD_LinearSplineParameter.h.
IBK::Unit NANDRAD::LinearSplineParameter::m_yUnit |
Unit of the y-values.
Definition at line 139 of file NANDRAD_LinearSplineParameter.h.
IBK::Path NANDRAD::LinearSplineParameter::m_tsvFile |
Path to tsv-file, the file will be read during checkAndInitialize() call.
Path may have an appended column identifier, starting with 1 for the first data column after the time column.
Definition at line 143 of file NANDRAD_LinearSplineParameter.h.