NANDRAD Data Model Library  Version 2.0
NANDRAD
NANDRAD::LinearSplineParameter Class Reference

Detailed Description

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...
 

Member Enumeration Documentation

◆ interpolationMethod_t

Interpolation method to be used for this linear spline parameter.

Definition at line 49 of file NANDRAD_LinearSplineParameter.h.

◆ wrapMethod_t

How to treat the values in multi-year simulations.

Definition at line 56 of file NANDRAD_LinearSplineParameter.h.

Constructor & Destructor Documentation

◆ LinearSplineParameter() [1/3]

NANDRAD::LinearSplineParameter::LinearSplineParameter ( )
inline

Default Constructor.

Definition at line 65 of file NANDRAD_LinearSplineParameter.h.

◆ LinearSplineParameter() [2/3]

NANDRAD::LinearSplineParameter::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 
)
inline

Constructor with values.

Definition at line 68 of file NANDRAD_LinearSplineParameter.h.

◆ LinearSplineParameter() [3/3]

NANDRAD::LinearSplineParameter::LinearSplineParameter ( const std::string &  name,
const interpolationMethod_t  intPol,
const IBK::Path &  tsvFilePath 
)
inline

Constructor with data file .

Definition at line 81 of file NANDRAD_LinearSplineParameter.h.

Member Function Documentation

◆ checkAndInitialize()

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.

Note
To ensure consistent object state, the x and y units are updated after the value conversion. Hence, if you need m_xUnit and m_yUnit to represent input/output units, do not call this function!

◆ readTsv()

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.

◆ convert2BaseUnits()

void NANDRAD::LinearSplineParameter::convert2BaseUnits ( )
private

Converts x and y values from display/input/output units (m_xUnit and m_yUnit) to their respective base SI units.

Warning
The m_xUnit and m_yUnit will not be changed and thus be inconsistent afterwards with the values in the m_values spline (similarly to IBK::Parameter).

Member Data Documentation

◆ m_name

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.

◆ m_interpolationMethod

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.

◆ m_wrapMethod

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.

◆ m_values

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).

Warning
Do not call checkAndInitialize() on original data containers - always create a copy first!

Definition at line 135 of file NANDRAD_LinearSplineParameter.h.

◆ m_xUnit

IBK::Unit NANDRAD::LinearSplineParameter::m_xUnit

Unit of the x-values.

Definition at line 137 of file NANDRAD_LinearSplineParameter.h.

◆ m_yUnit

IBK::Unit NANDRAD::LinearSplineParameter::m_yUnit

Unit of the y-values.

Definition at line 139 of file NANDRAD_LinearSplineParameter.h.

◆ m_tsvFile

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.


The documentation for this class was generated from the following file: