//---------------------------------------- void CBratAlgoFilterLanczos::SetParamValues(CVectorBratAlgorithmParam& args) { CheckInputParams(args); // Set variable m_varValue = args.at(CBratAlgoFilterLanczos::m_VAR_PARAM_INDEX).GetValueAsDouble(); int32_t valueInt32; // Set data window size (once) if (CTools::IsDefaultValue(m_dataWindowLength)) { this->CheckConstantParam(CBratAlgoFilterLanczos::m_WINDOW_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLanczos::m_WINDOW_PARAM_INDEX).GetValueAsInt(); if (valueInt32 <= 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window size parameter (%d) is not greater than 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLanczos::m_WINDOW_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_dataWindowLength = valueInt32; if (CTools::IsDefaultValue(valueInt32)) { m_dataWindowLength = 3; } if (CTools::IsEven(m_dataWindowLength)) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window size parameter (%d) is not an odd number." "You have to adjust the '%s' parameter.", this->GetName().c_str(), m_dataWindowLength, this->GetParamName(CBratAlgoFilterLanczos::m_WINDOW_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_dataWindowWidth = m_dataWindowLength; m_dataWindowHeight = m_dataWindowLength; } // Set valid points limit (once) if (CTools::IsDefaultValue(m_validPts)) { this->CheckConstantParam(CBratAlgoFilterLanczos::m_VALID_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLanczos::m_VALID_PARAM_INDEX).GetValueAsInt(); if (valueInt32 <= 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the '%s' parameter (%d) is less than or equal to 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), this->GetParamName(CBratAlgoFilterLanczos::m_VALID_PARAM_INDEX).c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLanczos::m_VALID_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_validPts = valueInt32; if (CTools::IsDefaultValue(valueInt32)) { m_validPts = GetDataWindowSize()/2; } if (GetDataWindowSize() < m_validPts) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window size %d (%dx%d) is less than the minimum number of valid points parameter (%d). " "You have to adjust either the '%s' parameter or the '%s' parameter.", this->GetName().c_str(), GetDataWindowSize(), m_dataWindowLength, m_dataWindowLength, m_validPts, this->GetParamName(CBratAlgoFilterLanczos::m_WINDOW_PARAM_INDEX).c_str(), this->GetParamName(CBratAlgoFilterLanczos::m_VALID_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } } // Set cut-off period (once) if (CTools::IsDefaultValue(m_cutOffPeriod)) { this->CheckConstantParam(CBratAlgoFilterLanczos::m_CUTOFF_PERIOD_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLanczos::m_CUTOFF_PERIOD_PARAM_INDEX).GetValueAsInt(); if (valueInt32 < 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the '%s' parameter (%d) is strictly less than 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), this->GetParamName(CBratAlgoFilterLanczos::m_CUTOFF_PERIOD_PARAM_INDEX).c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLanczos::m_CUTOFF_PERIOD_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_cutOffPeriod = valueInt32; if (CTools::IsDefaultValue(valueInt32)) { this->GetParamDefValue(CBratAlgoFilterLanczos::m_CUTOFF_PERIOD_PARAM_INDEX, m_cutOffPeriod); } m_cutOffFrequency = 1.0/static_cast<double>(m_cutOffPeriod); } // Set extrapolate flag (once) if (CTools::IsDefaultValue(m_extrapolate)) { SetParamValueExtrapolate(args, CBratAlgoFilterLanczos::m_EXTRAPOLATE_PARAM_INDEX); } }
//---------------------------------------- void CBratAlgoFilterLoess2D::SetParamValues(CVectorBratAlgorithmParam& args) { CheckInputParams(args); // Set variable m_varValue = args.at(CBratAlgoFilterLoess2D::m_VAR_PARAM_INDEX).GetValueAsDouble(); int32_t valueInt32; // Set data window width (once) if (isDefaultValue(m_dataWindowWidth)) { this->CheckConstantParam(CBratAlgoFilterLoess2D::m_WINDOW_WIDTH_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLoess2D::m_WINDOW_WIDTH_PARAM_INDEX).GetValueAsInt(); if (valueInt32 <= 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window width parameter (%d) is not greater than 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_WIDTH_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_dataWindowWidth = valueInt32; if (isDefaultValue(valueInt32)) { m_dataWindowWidth = 3; } if (CTools::IsEven(m_dataWindowWidth)) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window width parameter (%d) is not an odd number." "You have to adjust the '%s' parameter.", this->GetName().c_str(), m_dataWindowWidth, this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_WIDTH_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } } // Set data window height (once) if (isDefaultValue(m_dataWindowHeight)) { this->CheckConstantParam(CBratAlgoFilterLoess2D::m_WINDOW_HEIGHT_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLoess2D::m_WINDOW_HEIGHT_PARAM_INDEX).GetValueAsInt(); if (valueInt32 <= 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window height parameter (%d) is not greater than 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_HEIGHT_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_dataWindowHeight = valueInt32; if (isDefaultValue(valueInt32)) { m_dataWindowHeight = 3; } if (CTools::IsEven(m_dataWindowHeight)) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window height parameter (%d) is not an odd number." "You have to adjust the '%s' parameter.", this->GetName().c_str(), m_dataWindowHeight, this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_HEIGHT_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } } // Set valid points limit (once) if (isDefaultValue(m_validPts)) { this->CheckConstantParam(CBratAlgoFilterLoess2D::m_VALID_PARAM_INDEX); valueInt32 = args.at(CBratAlgoFilterLoess2D::m_VALID_PARAM_INDEX).GetValueAsInt(); if (valueInt32 <= 0) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the '%s' parameter (%d) is less than or equal to 0. " "You have to adjust the '%s' parameter.", this->GetName().c_str(), this->GetParamName(CBratAlgoFilterLoess2D::m_VALID_PARAM_INDEX).c_str(), valueInt32, this->GetParamName(CBratAlgoFilterLoess2D::m_VALID_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } m_validPts = valueInt32; if (isDefaultValue(valueInt32)) { m_validPts = GetDataWindowSize()/2; } if (GetDataWindowSize() < m_validPts) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window size parameter (%dx%d=%d ) is less than the minimum number of valid points parameter (%d). " "You have to adjust either the '%s' or '%s' parameters or the '%s' parameter.", this->GetName().c_str(), m_dataWindowWidth, m_dataWindowHeight, GetDataWindowSize(), m_validPts, this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_WIDTH_PARAM_INDEX).c_str(), this->GetParamName(CBratAlgoFilterLoess2D::m_WINDOW_HEIGHT_PARAM_INDEX).c_str(), this->GetParamName(CBratAlgoFilterLoess2D::m_VALID_PARAM_INDEX).c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } } // Set extrapolate flag (once) if (isDefaultValue(m_extrapolate)) { SetParamValueExtrapolate(args, CBratAlgoFilterLoess2D::m_EXTRAPOLATE_PARAM_INDEX); } }