From 377d2481baca6bfff5fdbaa5b234dfc8d63a2ff5 Mon Sep 17 00:00:00 2001 From: Hacene SI HADJ MOHAND Date: Mon, 22 Jun 2020 16:41:11 +0200 Subject: [PATCH] tilt ok --- src/ExternLib/Tsyganenko96/AMDAPlugin.cc | 1 + src/ExternLib/Tsyganenko96/GeopackWrapper.hh | 4 ++-- src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc | 59 +++++++++++++++++++++++++++++++++++++---------------------- src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh | 26 ++++++++++++++++++-------- src/ExternLib/Tsyganenko96/TiltAngleCreator.hh | 314 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------- src/ExternLib/Tsyganenko96/Tsyganenko96.hh | 46 ++++++++++++++++++++++++++++++++-------------- 6 files changed, 249 insertions(+), 201 deletions(-) diff --git a/src/ExternLib/Tsyganenko96/AMDAPlugin.cc b/src/ExternLib/Tsyganenko96/AMDAPlugin.cc index d7724bf..a91de5d 100644 --- a/src/ExternLib/Tsyganenko96/AMDAPlugin.cc +++ b/src/ExternLib/Tsyganenko96/AMDAPlugin.cc @@ -40,4 +40,5 @@ extern "C" void registerPlugin(AMDA::Plugins::PluginManager & pm) { ProcessFactory factProcessTiltAngle= boost::factory(); ServicesServer::getInstance()->addProcessFactory("tilt_angle", factProcessTiltAngle); ServicesServer::getInstance()->linkProcessWithPlugin("tilt_angle", pm.getCurrentPluginPath()); + } diff --git a/src/ExternLib/Tsyganenko96/GeopackWrapper.hh b/src/ExternLib/Tsyganenko96/GeopackWrapper.hh index 5809c91..a841d7b 100644 --- a/src/ExternLib/Tsyganenko96/GeopackWrapper.hh +++ b/src/ExternLib/Tsyganenko96/GeopackWrapper.hh @@ -144,11 +144,11 @@ namespace AMDA { lat *= (180. / M_PI); } - static void computeTiltAngle(int iyr, int iday, int ihour, int min, int isec, float * tiltAngle) { + static void computeTiltAngle(int iyr, int iday, int ihour, int min, int isec, float & tiltAngle) { float v_default_x = -400.0; float v_default_y = 0.0; float v_default_z = 0.0; - recalc_08_modified_(&iyr, &iday, &ihour, &min, &isec, &v_default_x, &v_default_y, &v_default_z, tiltAngle); + recalc_08_modified_(&iyr, &iday, &ihour, &min, &isec, &v_default_x, &v_default_y, &v_default_z, & tiltAngle); } }; diff --git a/src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc b/src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc index 36a2fd2..a761ac8 100644 --- a/src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc +++ b/src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc @@ -10,32 +10,47 @@ * * Created on June 19, 2020, 10:32 AM */ +#include +#include +#include "Operation.hh" +#include "ParameterManager.hh" + +#include "ParameterCreatorFromExpression.hh" #include "ProcessTiltAngle.hh" +#include "TiltAngleCreator.hh" -ProcessTiltAngle::ProcessTiltAngle(Parameter ¶meter) : SingleParamProcess_CRTP(parameter) { -} +namespace AMDA { + namespace Parameters { -ProcessTiltAngle::ProcessTiltAngle(const ProcessTiltAngle& pProcess, Parameter ¶meter) : SingleParamProcess_CRTP(pProcess, parameter) { -} + ProcessTiltAngle::ProcessTiltAngle(Parameter ¶meter) : SingleParamProcess_CRTP(parameter) { + } -TimeStamp ProcessTiltAngle::init() { - - TimeStamp time = _parameterInput->init(this, _timeIntervalList); - - _paramInput = _parameterInput->getParamData(this).get(); - - TiltAngleCreator lCreator(*this, *paramInput, "tilt"); - - _operation = lCreator.getOperation(); - - _paramData = ParamDataSPtr(_operation->getParamOutput()); - - _paramData->setMinSampling(_paramInput->getMinSampling()); - - return time; -} + ProcessTiltAngle::ProcessTiltAngle(const ProcessTiltAngle& pProcess, Parameter ¶meter) : SingleParamProcess_CRTP(pProcess, parameter) { + } -ProcessTiltAngle::~ProcessTiltAngle() { -} + ProcessTiltAngle::~ProcessTiltAngle() { + } + + TimeStamp ProcessTiltAngle::init() { + + TimeStamp time = _parameterInput->init(this, _timeIntervalList); + Parameter::InfoList lInfoList = _parameterInput->getInfoList(); + _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end()); + + _paramInput = _parameterInput->getParamData(this).get(); + + TiltAngleCreator lCreator(*this, *_paramInput, "tilt"); + + _operation = lCreator.getOperation(); + + _paramData = ParamDataSPtr(_operation->getParamOutput()); + + _paramData->setMinSampling(_paramInput->getMinSampling()); + + return time; + } + + } +} diff --git a/src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh b/src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh index 883d412..f842e86 100644 --- a/src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh +++ b/src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh @@ -17,14 +17,24 @@ #include "ParamInfo.hh" #include "TiltAngleCreator.hh" -class ProcessTiltAngle { -public: - ProcessTiltAngle(); - ProcessTiltAngle(const ProcessTiltAngle& orig); - virtual ~ProcessTiltAngle(); -private: - -}; +namespace AMDA { + namespace Parameters { + + class ProcessTiltAngle : public SingleParamProcess_CRTP { + public: + ProcessTiltAngle(Parameter & parameter); + ProcessTiltAngle(const ProcessTiltAngle& pProcess, Parameter &pParameter); + virtual ~ProcessTiltAngle(); + + /** + * @overload Process::init() + */ + virtual TimeStamp init(); + private: + + }; + } +} #endif /* PROCESSTILTANGLE_HH */ diff --git a/src/ExternLib/Tsyganenko96/TiltAngleCreator.hh b/src/ExternLib/Tsyganenko96/TiltAngleCreator.hh index 83222e8..6449c39 100644 --- a/src/ExternLib/Tsyganenko96/TiltAngleCreator.hh +++ b/src/ExternLib/Tsyganenko96/TiltAngleCreator.hh @@ -20,161 +20,165 @@ #include "VisitorOfParamData.hh" #include "Tsyganenko96.hh" -class TiltAngleCreator : public VisitorOfParamData { -public: - - ProcessTiltAngleCreator(Process& pProcess, ParamData& paramInput, std::string processType) : _process(pProcess), _paramData(paramInput), _type(processType) { - _paramData.accept(*this); - } - virtual ~ProcessTiltAngleCreator(); - - /** - * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) - */ - void visit(ParamDataScalaireShort *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) - */ - void visit(ParamDataScalaireFloat *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) - */ - void visit(ParamDataScalaireDouble *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) - */ - void visit(ParamDataScalaireLongDouble *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) - */ - void visit(ParamDataScalaireInt *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataLogicalData *) - */ - void visit(ParamDataLogicalData *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) - */ - void visit(ParamDataTab1DShort *) { - createOperation(); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) - */ - void visit(ParamDataTab1DFloat *) { - createOperation(); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) - */ - void visit(ParamDataTab1DDouble *) { - createOperation(); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) - */ - void visit(ParamDataTab1DLongDouble *) { - createOperation(); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) - */ - void visit(ParamDataTab1DInt *) { - createOperation(); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) - */ - void visit(ParamDataTab1DLogicalData *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) - */ - void visit(ParamDataTab2DShort *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) - */ - void visit(ParamDataTab2DFloat *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) - */ - void visit(ParamDataTab2DDouble *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) - */ - void visit(ParamDataTab2DLongDouble *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) - */ - void visit(ParamDataTab2DInt *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) - */ - void visit(ParamDataTab2DLogicalData *) { - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); - } - - /** - * @brief get the Tsyganenko96 parameterized operation. - */ - Operation * getOperation() const { - return _operation; - } - - -private: - - template - void createOperation() { - if (_type == "tilte") - _operation = new DipoleTiltAngle::DipoleTiltAngle(_process, dynamic_cast > &> (_paramData), _paramImfInput); - } - Process &_process; - ParamData &_paramData; - ParamData &_paramImfInput; - std::string _type; - Operation* _operation; -}; +namespace AMDA { + namespace Parameters { + + class TiltAngleCreator : public VisitorOfParamData { + public: + + TiltAngleCreator(Process& pProcess, ParamData& paramInput, const std::string& processType) : _process(pProcess), _paramData(paramInput), _type(processType) { + _paramData.accept(*this); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) + */ + void visit(ParamDataScalaireShort *) { + createOperation(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) + */ + void visit(ParamDataScalaireFloat *) { + createOperation(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) + */ + void visit(ParamDataScalaireDouble *) { + createOperation(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) + */ + void visit(ParamDataScalaireLongDouble *) { + createOperation(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) + */ + void visit(ParamDataScalaireInt *) { + createOperation(); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataLogicalData *) + */ + void visit(ParamDataLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) + */ + void visit(ParamDataTab1DShort *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) + */ + void visit(ParamDataTab1DFloat *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) + */ + void visit(ParamDataTab1DDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) + */ + void visit(ParamDataTab1DLongDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) + */ + void visit(ParamDataTab1DInt *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) + */ + void visit(ParamDataTab1DLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) + */ + void visit(ParamDataTab2DShort *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) + */ + void visit(ParamDataTab2DFloat *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) + */ + void visit(ParamDataTab2DDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) + */ + void visit(ParamDataTab2DLongDouble *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) + */ + void visit(ParamDataTab2DInt *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) + */ + void visit(ParamDataTab2DLogicalData *) { + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported")); + } + + /** + * @brief get the Tsyganenko96 parameterized operation. + */ + Operation * getOperation() const { + return _operation; + } + + + private: + + template + void createOperation() { + if (_type == "tilt") + _operation = new Tsyganenko96::DipoleTiltAngle(_process, dynamic_cast &> (_paramData)); + } + Process &_process; + ParamData &_paramData; + std::string _type; + Operation* _operation; + }; + + } +} #endif /* TILTANGLECREATOR_HH */ diff --git a/src/ExternLib/Tsyganenko96/Tsyganenko96.hh b/src/ExternLib/Tsyganenko96/Tsyganenko96.hh index c24589b..5a4401d 100644 --- a/src/ExternLib/Tsyganenko96/Tsyganenko96.hh +++ b/src/ExternLib/Tsyganenko96/Tsyganenko96.hh @@ -33,10 +33,6 @@ namespace AMDA { #define DEFAULT_IMF_GSM_Z -3. #define DEFAULT_DST -10. #define DEFAULT_PSW 3. - - class DipoleBase : public Operation{ - A completer - }; class Tsyganenko96Base : public Operation { public: @@ -269,35 +265,57 @@ namespace AMDA { bool _inGSE; }; + template + class DipoleBase : public Operation { + public: + + DipoleBase(Process& pProcess, ParamDataSpec& paramInput) : Operation(pProcess), + _paramInput(paramInput), + _paramOutput(new ParamDataSpec) { + _paramDataOutput = _paramOutput; + } + + virtual ~DipoleBase() { + } + + protected: + /** + * @brief Input paramter data. + */ + ParamDataSpec& _paramInput; + + ParamDataSpec* _paramOutput; + + }; + template - class DipoleTiltAngle : public DipoleBase { + class DipoleTiltAngle : public DipoleBase { public: /** * @brief Constructor. * @details Create the ParamData type of the input ParamData. */ - DipoleTiltAngle(Process& pProcess, ParamDataSpec >& paramInput) - : Tsyganenko96Base(pProcess, paramImfInput, paramPswInput, paramDstInput), - _paramInput(paramInput), - _paramOutput(new ParamDataSpec) { - _paramDataOutput = _paramOutput; + DipoleTiltAngle(Process& pProcess, ParamDataSpec& paramInput) + : DipoleBase(pProcess, paramInput) { + } + virtual ~DipoleTiltAngle() { } void write(ParamDataIndexInfo &pParamDataIndexInfo) { for (unsigned int _index = pParamDataIndexInfo._startIndex; _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; ++_index) { - double crtTime = _paramInput.getTime(_index); + double crtTime = DipoleBase::_paramInput.getTime(_index); time_t timestamp = crtTime; struct tm *tmp; tmp = gmtime(×tamp); float tiltAngle_res; - geopack::GeopackWrapper::recalc_08_modified_(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tiltAngle_res); + geopack::GeopackWrapper::computeTiltAngle(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tiltAngle_res); - _paramOutput->pushTime(crtTime); - paramOutput->getDataList(tiltAngle_res); + DipoleBase::_paramOutput->pushTime(crtTime); + DipoleBase::_paramOutput->getDataList().push_back(tiltAngle_res*180.0/(atan(1)*4)); } }; }; -- libgit2 0.21.2