nidas v1.2.3
|
Class describing a sampled variable. More...
#include <Variable.h>
Public Types | |
enum | var_type { CONTINUOUS , COUNTER , CLOCK , OTHER , WEIGHT } |
typedef enum nidas::core::Variable::var_type | type_t |
Public Member Functions | |
Variable () | |
Create a variable. | |
Variable (const Variable &) | |
Copy constructor. | |
Variable & | operator= (const Variable &) |
Assignment. | |
virtual | ~Variable () |
bool | operator== (const Variable &x) const |
Equivalence operator for Variable, checks equivalence of their length, the variables's names without any site suffix, and their sites. | |
bool | operator!= (const Variable &x) const |
bool | operator< (const Variable &x) const |
bool | closeMatch (const Variable &x) const |
A more loose check of the equivalence of two variables, This will also return a value of true if either Site is NULL. | |
void | setSite (const Site *val) |
Set the Site where this variable was measured. | |
const Site * | getSite () const |
Return the measurement site for this variable. | |
int | getStation () const |
Station number of this variable: | |
void | setStation (int val) |
type_t | getType () const |
void | setType (type_t val) |
const SampleTag * | getSampleTag () const |
What sample am I a part of? | |
void | setSampleTag (const SampleTag *val) |
Set the sample tag pointer. | |
float | getSampleRate () const |
Convenience routine to get the SampleTag rate. | |
void | setPrefix (const std::string &val) |
Set the name prefix. | |
const std::string & | getPrefix () const |
const std::string & | getSuffix () const |
Variable suffix, which is added to the name. | |
void | setSuffix (const std::string &val) |
const std::string & | getSiteSuffix () const |
Site suffix, which is added to the name. | |
void | setName (const std::string &val) |
Set the full name. | |
const std::string & | getName () const |
const std::string & | getNameWithoutSite () const |
Get the name without the site suffix. | |
void | setLongName (const std::string &val) |
Descriptive, long name, e.g. | |
const std::string & | getLongName () const |
void | setA2dChannel (int val) |
The A2D channel for this variable. | |
int | getA2dChannel () const |
void | setUnits (const std::string &val) |
The string discription of the units for this variable. | |
const std::string & | getUnits () const |
unsigned int | getLength () const |
How many values in this variable? | |
void | setLength (unsigned int val) |
void | setConverter (VariableConverter *val) |
Set the VariableConverter for this Variable. | |
const VariableConverter * | getConverter () const |
VariableConverter * | getConverter () |
float * | convert (dsm_time_t ttag, float *values, int nvalues=0, float *results=0) |
Apply the conversions for this Variable to the floats pointed to by values , putting the results in results , up to nvalues . | |
void | addParameter (Parameter *val) |
Add a parameter to this Variable. | |
const std::list< const Parameter * > & | getParameters () const |
Get full list of parameters. | |
const Parameter * | getParameter (const std::string &name) const |
Fetch a parameter by name. | |
void | setMissingValue (float val) |
float | getMissingValue () const |
void | setMinValue (float val) |
Set the minimum allowed value for this variable. | |
float | getMinValue () const |
void | setMaxValue (float val) |
float | getMaxValue () const |
void | setPlotRange (float minv, float maxv) |
void | getPlotRange (float &minv, float &maxv) const |
void | setDynamic (bool val) |
A dynamic variable is one that can come and go. | |
bool | isDynamic () const |
void | fromDOMElement (const xercesc::DOMElement *) |
xercesc::DOMElement * | toDOMParent (xercesc::DOMElement *parent, bool complete) const |
xercesc::DOMElement * | toDOMElement (xercesc::DOMElement *node, bool complete) const |
Static Public Member Functions | |
static const XMLCh * | getNamespaceURI () |
Private Member Functions | |
void | setSiteSuffix (const std::string &val) |
Private Attributes | |
std::string | _name |
const Site * | _site |
int | _station |
std::string | _nameWithoutSite |
std::string | _prefix |
std::string | _suffix |
std::string | _siteSuffix |
std::string | _longname |
const SampleTag * | _sampleTag |
int | _A2dChannel |
std::string | _units |
type_t | _type |
unsigned int | _length |
VariableConverter * | _converter |
std::list< Parameter * > | _parameters |
List of pointers to Parameters. | |
std::list< const Parameter * > | _constParameters |
List of const pointers to Parameters for providing via getParameters(). | |
float | _missingValue |
float | _minValue |
float | _maxValue |
float | _plotRange [2] |
bool | _dynamic |
Static Private Attributes | |
static XMLCh * | namespaceURI = 0 |
Class describing a sampled variable.
Variable::Variable | ( | ) |
Create a variable.
References _plotRange, and nidas::core::floatNAN.
Copy constructor.
References _converter, _plotRange, addParameter(), nidas::core::Parameter::clone(), nidas::core::VariableConverter::clone(), and nidas::core::getSample().
|
virtual |
References _converter, _parameters, and nidas::core::getSample().
Add a parameter to this Variable.
Variable will then own the pointer and will delete it in its destructor.
References _constParameters, and _parameters.
Referenced by fromDOMElement(), operator=(), and Variable().
A more loose check of the equivalence of two variables, This will also return a value of true if either Site is NULL.
References nidas::core::Site::_name, _name, _nameWithoutSite, getLength(), and getSite().
float * Variable::convert | ( | dsm_time_t | ttag, |
float * | values, | ||
int | nvalues = 0, | ||
float * | results = 0 ) |
Apply the conversions for this Variable to the floats pointed to by values
, putting the results in results
, up to nvalues
.
Any calibrations are looked up using time ttag
. The min/max value limits of a variable are applied also, so if a variable value is converted but lies outside the min/max range, the value is set to floatNAN.
If nvalues
is null, then multiple values will be converted up to the length of the Variable, otherwise only the number given in nvalues
. If results
is null, then the converted values will be written back into the array pointed to by values
. Both values
and results
must point to enough memory to hold nvalues
floats. Typically the results of the conversions are written over the values passed in, and values
points into the memory in a DSMSensor output sample. However, if a sensor needs custom handling of the results, then the inputs and outputs can be kept separate. For example, The TRH Wisard sensor can keep the Ifan value as it was but convert T and RH to floatNAN if the Ifan result is NAN, meaning Ifan was bad or out of range. It is safe to pass results
equal to values
, the effect is the same as calling convert() with results=null
.
Usually this conversion is the last step applied to the output sample of a sensor's process() method, and this method is called from the DSMSensor::applyConversions() method.
If this Variable has a Site (getSite() returns non-null) and the Site's getApplyVariableConversions() returns false, then no conversions are applied, not even the min/max limit filter. Otherwise the conversions are applied.
Originally, the getApplyVariableConversions() was called on DSMSensor, usually inside a sensor subclass process() method. However, that value is usually copied from the Site's applyCals attribute. So the value of the flag should be the same for both Site and DSMSensor, unless there are some uses out there which change the DSMSensor's value, such as in the sensor subclass itself. However, if a Sensor does not want to apply conversions, then it can just avoid calling any conversion methods.
The original code limit filtered values whether conversion was applied or not, and there was some inconsistency in the domain of the min/max values: Did they apply to values before or after conversion? The convention will be that min/max are in the converted space, so now no filtering happens based on min/max if conversions not applied first. It also makes sense that disabling conversions, presumably to see the more raw values, implies not limit filtering any values either. In practice this change should have little effect, since the 'applyCals' Site attribute is rarely enabled.
The return value points just past the last element in values
to be converted. Note that results
is not passed by reference, therefore if non-null it must be advanced after the call to convert().
References _site, nidas::core::floatNAN, getConverter(), getLength(), getMaxValue(), getMinValue(), getMissingValue(), and nidas::core::getSample().
Referenced by nidas::dynld::IEEE_Float::process(), and nidas::dynld::ModbusRTU::process().
nidas::util::InvalidParameterException |
Implements nidas::core::DOMable.
References _sampleTag, addParameter(), COUNTER, nidas::core::Parameter::createParameter(), nidas::core::VariableConverter::createVariableConverter(), nidas::core::Project::getInstance(), getName(), nidas::core::getSample(), getSampleTag(), getUnits(), setConverter(), setDynamic(), setLength(), setLongName(), setMaxValue(), setMinValue(), setMissingValue(), setPlotRange(), setPrefix(), setType(), setUnits(), and WLOG.
|
inline |
References _A2dChannel.
Referenced by parseAnalog().
|
inline |
References _converter.
|
inline |
References _converter.
Referenced by convert(), toDOMElement(), and nidas::dynld::isff::NCAR_TRH::validate().
How many values in this variable?
References _length.
Referenced by closeMatch(), convert(), nidas::core::NearestResampler::ctorCommon(), nidas::core::NearestResamplerAtRate::NearestResamplerAtRate(), operator<(), operator==(), and toDOMElement().
|
inline |
References _longname.
Referenced by SampleCounter::collectMetadata(), and toDOMElement().
|
inline |
|
inline |
|
inline |
References _missingValue.
Referenced by convert().
|
inline |
References _name.
Referenced by nidas::dynld::isff::Wind3D::checkSampleTags(), SampleCounter::collectMetadata(), nidas::core::NearestResamplerAtRate::connect(), nidas::core::SampleAverager::connect(), nidas::dynld::StatisticsCruncher::connect(), nidas::core::NearestResampler::connect(), nidas::dynld::StatisticsCruncher::createCombinations(), nidas::core::NearestResampler::ctorCommon(), nidas::core::DSMSensor::fromDOMElement(), fromDOMElement(), nidas::dynld::WxtSensor::init(), nidas::dynld::StatisticsCruncher::initStats(), PConfig::loadVariables(), parseOther(), PConfig::showAll(), stats_log_variable(), and toDOMElement().
References nidas::core::DOMable::namespaceURI.
Referenced by nidas::dynld::UDPSampleOutput::getProjectDOM(), nidas::core::Dataset::toDOMElement(), nidas::core::ProjectConfig::toDOMElement(), nidas::core::Dataset::toDOMParent(), nidas::core::Datasets::toDOMParent(), nidas::core::ProjectConfig::toDOMParent(), nidas::core::ProjectConfigs::toDOMParent(), nidas::core::DSMConfig::toDOMParent(), nidas::core::DSMSensor::toDOMParent(), nidas::core::Project::toDOMParent(), nidas::core::SampleTag::toDOMParent(), nidas::core::Site::toDOMParent(), nidas::core::ServerSocket::toDOMParent(), toDOMParent(), nidas::core::Datasets::writeXML(), and nidas::core::ProjectConfigs::writeXML().
|
inline |
Fetch a parameter by name.
Returns a NULL pointer if no such parameter exists.
References _constParameters, and nidas::core::getSample().
Get full list of parameters.
References _constParameters.
Referenced by nidas::dynld::raf::A2D_Serial::validate().
References _plotRange.
|
inline |
References _prefix.
Referenced by SampleCounter::collectMetadata().
float Variable::getSampleRate | ( | ) | const |
Convenience routine to get the SampleTag rate.
References _sampleTag.
Return the measurement site for this variable.
References _site.
Referenced by closeMatch(), nidas::core::NearestResampler::ctorCommon(), operator<(), operator==(), and setSampleTag().
|
inline |
Site suffix, which is added to the name.
References _siteSuffix.
|
inline |
Station number of this variable:
Variables can be grouped by a station number.
A measured variable is associated with a Site. A Site also has a non-negative station number. A Site may have an associated suffix, like ".bigtower".
By default, all DSMSensors at a site will be assigned the site's station number. To support the logical grouping of variables into stations, the station number of a DSMSensor can be set to a different value than the Site's number.
All variables sampled by a DSMSensor will get assigned its station number.
If the station number of a variable is 0, then the site suffix will be appended to the variable name.
Otherwise, if the station number of a variable is positive, the site suffix is not appended to its name. In this way we can have variables with a common name, like "RH.2m" at different sites, which will have different station numbers.
References _station.
Referenced by nidas::dynld::StatisticsCruncher::connect(), nidas::core::NearestResampler::ctorCommon(), DataPrep::run(), setSampleTag(), and setSite().
|
inline |
Variable suffix, which is added to the name.
The full variable name is created from prefix + suffix + siteSuffix. suffix and/or siteSuffix may be empty strings. The suffix commonly comes from the DSMSensor::getFullSuffix(), containing an optional sensor suffix and a height/depth string.
References _suffix.
|
inline |
References _units.
Referenced by SampleCounter::collectMetadata(), fromDOMElement(), and toDOMElement().
|
inline |
References _dynamic.
Referenced by toDOMElement().
References operator==().
References getLength(), getNameWithoutSite(), nidas::core::getSample(), and getSite().
Assignment.
References _A2dChannel, _converter, _dynamic, _length, _longname, _maxValue, _minValue, _missingValue, _name, _nameWithoutSite, _parameters, _plotRange, _prefix, _site, _siteSuffix, _station, _suffix, _type, _units, addParameter(), nidas::core::VariableConverter::clone(), and nidas::core::getSample().
Equivalence operator for Variable, checks equivalence of their length, the variables's names without any site suffix, and their sites.
References _name, _nameWithoutSite, _station, getLength(), and getSite().
Referenced by operator!=().
The A2D channel for this variable.
References _A2dChannel, and nidas::core::getSample().
|
inline |
Set the VariableConverter for this Variable.
Variable will own the pointer and will delete it.
References _converter, and nidas::core::getSample().
Referenced by fromDOMElement().
A dynamic variable is one that can come and go.
The dynamic attribute is typically used by a display application which will scan all the variables for a project and create a plot for each. If a variable is dynamic, then that application should wait to create a plot for the variable until data is received for it.
References _dynamic, and nidas::core::getSample().
Referenced by fromDOMElement().
References _length, and nidas::core::getSample().
Referenced by fromDOMElement().
Descriptive, long name, e.g.
"Ambient air temperature".
References _longname, and nidas::core::getSample().
Referenced by fromDOMElement().
References _maxValue, _plotRange, and nidas::core::getSample().
Referenced by fromDOMElement().
Set the minimum allowed value for this variable.
Variable values less than val will be set to NAN. Support for this check must be supported by each DSMSensor class.
References _minValue, _plotRange, and nidas::core::getSample().
Referenced by fromDOMElement().
References _missingValue, and nidas::core::getSample().
Referenced by fromDOMElement().
Set the full name.
This clears the suffix and site portions of the name. Once this is called, the suffix and siteSuffix fields are cleared.
References _name, _nameWithoutSite, _prefix, _siteSuffix, _suffix, and nidas::core::getSample().
Referenced by nidas::dynld::StatisticsCruncher::addVariable(), nidas::core::NearestResampler::ctorCommon(), nidas::dynld::StatisticsCruncher::initStats(), nidas::core::NearestResamplerAtRate::NearestResamplerAtRate(), nidas::dynld::StatisticsCruncher::setupCovariances(), nidas::dynld::StatisticsCruncher::setupFluxes(), nidas::dynld::StatisticsCruncher::setupMinMax(), nidas::dynld::StatisticsCruncher::setupPrunedTrivariances(), nidas::dynld::StatisticsCruncher::setupReducedFluxes(), nidas::dynld::StatisticsCruncher::setupReducedScalarFluxes(), and nidas::dynld::StatisticsCruncher::setupTrivariances().
References _plotRange, and nidas::core::getSample().
Referenced by fromDOMElement().
Set the name prefix.
The full variable name will be the concatenation of: prefix + suffix + site
References _name, _nameWithoutSite, _prefix, _siteSuffix, _suffix, and nidas::core::getSample().
Referenced by nidas::dynld::isff::WisardMote::createSampleTags(), and fromDOMElement().
Set the sample tag pointer.
Variable does not own the pointer. This also copies attributes from the sample, such as site and station if they have not been set on this Variable.
References _sampleTag, nidas::core::getSample(), getSite(), getStation(), setSite(), and setStation().
Set the Site where this variable was measured.
References _site, nidas::core::getSample(), getStation(), and setSiteSuffix().
Referenced by setSampleTag().
References _name, _prefix, _siteSuffix, _suffix, and nidas::core::getSample().
Referenced by setSite(), and setStation().
References _site, _station, nidas::core::getSample(), and setSiteSuffix().
Referenced by nidas::dynld::StatisticsCruncher::createCombinations(), nidas::dynld::StatisticsCruncher::initStats(), and setSampleTag().
References _name, _nameWithoutSite, _prefix, _siteSuffix, _suffix, and nidas::core::getSample().
The string discription of the units for this variable.
References _units, and nidas::core::getSample().
Referenced by nidas::core::NearestResampler::ctorCommon(), fromDOMElement(), nidas::dynld::StatisticsCruncher::initStats(), and nidas::core::NearestResamplerAtRate::NearestResamplerAtRate().
|
virtual |
xercesc::DOMException |
Reimplemented from nidas::core::DOMable.
References _plotRange, getConverter(), getLength(), getLongName(), getName(), nidas::core::getSample(), getUnits(), and isDynamic().
Referenced by toDOMParent().
|
virtual |
xercesc::DOMException |
Reimplemented from nidas::core::DOMable.
References nidas::core::DOMable::getNamespaceURI(), and toDOMElement().
Referenced by nidas::core::SampleTag::toDOMElement().
|
private |
Referenced by getA2dChannel(), operator=(), and setA2dChannel().
List of const pointers to Parameters for providing via getParameters().
Referenced by addParameter(), getParameter(), and getParameters().
|
private |
Referenced by getConverter(), getConverter(), operator=(), setConverter(), Variable(), and ~Variable().
|
private |
Referenced by isDynamic(), operator=(), and setDynamic().
Referenced by getLength(), operator=(), and setLength().
|
private |
Referenced by getLongName(), operator=(), and setLongName().
|
private |
Referenced by getMaxValue(), operator=(), and setMaxValue().
|
private |
Referenced by getMinValue(), operator=(), and setMinValue().
|
private |
Referenced by getMissingValue(), operator=(), and setMissingValue().
|
private |
Referenced by closeMatch(), getName(), operator=(), operator==(), setName(), setPrefix(), setSiteSuffix(), and setSuffix().
|
private |
Referenced by closeMatch(), getNameWithoutSite(), operator=(), operator==(), setName(), setPrefix(), and setSuffix().
|
private |
List of pointers to Parameters.
Referenced by addParameter(), operator=(), and ~Variable().
|
private |
Referenced by getPlotRange(), operator=(), setMaxValue(), setMinValue(), setPlotRange(), toDOMElement(), Variable(), and Variable().
|
private |
Referenced by getPrefix(), operator=(), setName(), setPrefix(), setSiteSuffix(), and setSuffix().
Referenced by fromDOMElement(), getSampleRate(), getSampleTag(), and setSampleTag().
Referenced by convert(), getSite(), operator=(), setSite(), and setStation().
|
private |
Referenced by getSiteSuffix(), operator=(), setName(), setPrefix(), setSiteSuffix(), and setSuffix().
|
private |
Referenced by getStation(), operator=(), operator==(), and setStation().
|
private |
Referenced by getSuffix(), operator=(), setName(), setPrefix(), setSiteSuffix(), and setSuffix().
|
private |
Referenced by getType(), operator=(), and setType().
|
private |
Referenced by getUnits(), operator=(), and setUnits().
|
staticprivateinherited |
Referenced by nidas::core::DOMable::getNamespaceURI().