From cc178b66371172063d0cea0844020f370f5ce8e8 Mon Sep 17 00:00:00 2001 From: Hacene SI HADJ MOHAND Date: Mon, 14 Dec 2020 13:42:41 +0100 Subject: [PATCH] process ok --- src/ExternLib/Tsyganenko96/GeopackWrapper.hh | 11 +++++++++++ src/ExternLib/Tsyganenko96/Shue98.hh | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/Tsyganenko96/Shue98Creator.hh | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/ExternLib/Tsyganenko96/Tsyganenko96.hh | 104 ++++++++------------------------------------------------------------------------------------------------ 4 files changed, 381 insertions(+), 96 deletions(-) create mode 100644 src/ExternLib/Tsyganenko96/Shue98.hh create mode 100644 src/ExternLib/Tsyganenko96/Shue98Creator.hh diff --git a/src/ExternLib/Tsyganenko96/GeopackWrapper.hh b/src/ExternLib/Tsyganenko96/GeopackWrapper.hh index 2365017..3c13d2f 100644 --- a/src/ExternLib/Tsyganenko96/GeopackWrapper.hh +++ b/src/ExternLib/Tsyganenko96/GeopackWrapper.hh @@ -35,6 +35,17 @@ namespace AMDA { return (ID_MGNP == 1); } + + static bool shue98(float Pdyn_i, float bzIMF_i, float sat_pos_X_GSM, float sat_pos_Y_GSM, float sat_pos_Z_GSM, + float &x_mgnp, float &y_mgnp, float &z_mgnp, float &DIST_MGNP, int &ID_MGNP) { + // We use dynamic pressure Pdyn + float vel_mgnp = -1.0; + + shuetal_mgnp_08_(&Pdyn_i, &vel_mgnp, &bzIMF_i, &sat_pos_X_GSM, &sat_pos_Y_GSM, &sat_pos_Z_GSM, + &x_mgnp, &y_mgnp, &z_mgnp, &DIST_MGNP, &ID_MGNP); + + return ID_MGNP != 0; + } static bool computeGeomagneticFieldInGSM(float sat_pos_X_GSM, float sat_pos_Y_GSM, float sat_pos_Z_GSM, float Pdyn, float Dst, float B_Y_GSM, float B_Z_GSM, diff --git a/src/ExternLib/Tsyganenko96/Shue98.hh b/src/ExternLib/Tsyganenko96/Shue98.hh new file mode 100644 index 0000000..136a21a --- /dev/null +++ b/src/ExternLib/Tsyganenko96/Shue98.hh @@ -0,0 +1,168 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * File: Shue98.hh + * Author: hacene + * + * Created on December 14, 2020, 11:42 AM + */ + +#ifndef SHUE98_HH +#define SHUE98_HH +#include "Parameter.hh" +#include "ParamData.hh" +#include "DataTypeMath.hh" +#include "Operation.hh" +#include "GeopackWrapper.hh" +#include "Tsyganenko96.hh" + +#include + +namespace AMDA { + namespace Parameters { + namespace Shue98 { + + template + class Shue98Base : public Tsyganenko96Base { + public: + + /** + * @brief Constructor. + * @details Create the ParamData type of the input ParamData. + */ + Shue98Base(Process& pProcess, ParamDataSpec >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE) + : Tsyganenko96Base(pProcess, paramImfInput, paramPswInput), + _paramInput(paramInput), + _paramOutput(new TOutputParamData), _inGSE(inGSE) { + _paramDataOutput = _paramOutput; + } + + virtual ~Shue98Base() { + } + + /** + * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo) + */ + + void write(ParamDataIndexInfo &pParamDataIndexInfo) { + for (unsigned int _index = pParamDataIndexInfo._startIndex; + _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; + ++_index) { + double crtTime = _paramInput.getTime(_index); + + float b_x_gse, b_y_gse, b_z_gse; + getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse); + + float p_sw; + getPswData(crtTime, p_sw); + if (isNAN(p_sw)) { + p_sw = DEFAULT_PSW; + } + + + std::vector inputElt = _paramInput.get(_index); + + time_t timestamp = crtTime; + struct tm *tmp; + tmp = gmtime(×tamp); + + std::vector ouputElt; + ouputElt.resize(3); + ouputElt << NotANumber(); + + //Init geopack with GSM frame + geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + //Compute magnetic field + float X_GSW, Y_GSW, Z_GSW; + float dst; + int pos_id; + bool computed = false; + computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm, sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM, + X_GSW, Y_GSW, Z_GSW, dst, pos_id); + if (computed) { + ouputElt[0] = B_X_RES; + ouputElt[1] = B_Y_RES; + ouputElt[2] = B_Z_RES; + } + + + _paramOutput->pushTime(crtTime); + pushData(ouputElt, dst, pos_id); + } + } + + void pushData(std::vector std::vectorouputElt, ElemType dst, int pos_id) = 0; + + protected: + ParamDataSpec >& _paramInput; + + TOutputParamData* _paramOutput; + + bool _inGSE; + }; + + template + class Shue98Dst : public Shue98Base { + + Shue98Dst(Process& pProcess, ParamDataSpec >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE) + : Shue98Base>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) { + + } + + virtual ~Shue98Dst() { + } + + pushData(std::vector/*ouputElt*/, ElemType dst, int /*pos_id*/) { + Shue98Base>::_paramOutput->getDataList().push_back(dst); + } + + }; + + template + class Shue98Pos_Id : public Shue98Base { + + Shue98Pos_Id(Process& pProcess, ParamDataSpec >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE) + : Shue98Base>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) { + + } + + virtual ~Shue98Pos_Id() { + } + + pushData(std::vector/*ouputElt*/, ElemType /*dst*/, int pos_id) { + Shue98Base>::_paramOutput->getDataList().push_back(pos_id); + } + + }; + + template + class Shue98Pos : public Shue98Base { + + Shue98Pos(Process& pProcess, ParamDataSpec >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE) + : Shue98Base>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) { + + } + + virtual ~Shue98Pos() { + } + + pushData(std::vector ouputElt, ElemType /*dst*/, int /*pos_id*/) { + Shue98Base>>::_paramOutput->getDataList().push_back(ouputElt); + } + + }; + + } + } + + + + + +#endif /* SHUE98_HH */ + diff --git a/src/ExternLib/Tsyganenko96/Shue98Creator.hh b/src/ExternLib/Tsyganenko96/Shue98Creator.hh new file mode 100644 index 0000000..4c727a2 --- /dev/null +++ b/src/ExternLib/Tsyganenko96/Shue98Creator.hh @@ -0,0 +1,194 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +/* + * File: TiltAngleCreator.hh + * Author: hacene + * + * Created on June 19, 2020, 10:34 AM + */ +#ifndef TILTANGLECREATOR_HH +#define TILTANGLECREATOR_HH + +#include "DicError.hh" +#include "AMDA_exception.hh" + +#include "ParamData.hh" +#include "VisitorOfParamData.hh" +#include "Shue98.hh" + +namespace AMDA { + namespace Parameters { + + class Shue98Creator : public VisitorOfParamData { + public: + + Shue98Creator(Process& pProcess, ParamData& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE, const std::string& processType) : + _process(pProcess), + _paramData(paramInput), + _paramImfInput(paramImfInput), + _paramPswInput(paramPswInput), + _inGSE(inGSE), + _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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator 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("Shue98Creator operation not supported")); + } + + /** + * @brief get the Tsyganenko96 parameterized operation. + */ + Operation * getOperation() const { + return _operation; + } + private: + + template + void createOperation() { + if (_type == "pos_id") + _operation = new Shue98::Shue98Pos_Id( _process, dynamic_cast >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE); + if (_type == "dst") + _operation = new Shue98::Shue98Dst( _process, dynamic_cast >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE); + if (_type == "pos") + _operation = new Shue98::Shue98Pos( _process, dynamic_cast >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE); + } + Process &_process; + ParamData &_paramData; + ParamData &_paramImfInput; + ParamData &_paramPswInput; + bool _inGSE; + std::string _type; + Operation* _operation; + }; + + } +} + +#endif /* TILTANGLECREATOR_HH */ diff --git a/src/ExternLib/Tsyganenko96/Tsyganenko96.hh b/src/ExternLib/Tsyganenko96/Tsyganenko96.hh index c2b18a5..d60048a 100644 --- a/src/ExternLib/Tsyganenko96/Tsyganenko96.hh +++ b/src/ExternLib/Tsyganenko96/Tsyganenko96.hh @@ -43,6 +43,13 @@ namespace AMDA { _paramPswInput(dynamic_cast&> (paramPswInput)), _paramDstInput(dynamic_cast&> (paramDstInput)) { } + + Tsyganenko96Base(Process& pProcess, ParamData& paramImfInput, ParamData& paramPswInput) + : Operation(pProcess), + _paramImfInput(dynamic_cast >&> (paramImfInput)), + _paramPswInput(dynamic_cast&> (paramPswInput)), + _paramDstInput(dynamic_cast&> (paramPswInput)){ + } virtual ~Tsyganenko96Base() { } @@ -264,102 +271,7 @@ namespace AMDA { bool _inGSE; }; - - - template - class Shue98Base: public Tsyganenko96Base { - public: - - /** - * @brief Constructor. - * @details Create the ParamData type of the input ParamData. - */ - Shue98Base(Process& pProcess, ParamDataSpec >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, ParamData& paramDstInput, bool inGSE) - : Shue98Base(pProcess, paramImfInput, paramPswInput, paramDstInput), - _paramInput(paramInput), - _paramOutput(new ParamDataSpec >), _inGSE(inGSE) { - _paramDataOutput = _paramOutput; - } - - virtual ~Shue98Base() { - } - - /** - * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo) - */ - - void write(ParamDataIndexInfo &pParamDataIndexInfo) { - for (unsigned int _index = pParamDataIndexInfo._startIndex; - _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess; - ++_index) { - double crtTime = _paramInput.getTime(_index); - - float b_x_gse, b_y_gse, b_z_gse; - getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse); - - float p_sw; - getPswData(crtTime, p_sw); - if (isNAN(p_sw)) { - p_sw = DEFAULT_PSW; - } - - - std::vector inputElt = _paramInput.get(_index); - - time_t timestamp = crtTime; - struct tm *tmp; - tmp = gmtime(×tamp); - - std::vector ouputElt; - ouputElt.resize(3); - ouputElt << NotANumber(); - - //Init geopack with GSM frame - geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); - - //Compute magnetic field - float X_GSW, Y_GSW, Z_GSW; - float dst; - int pos_id; - bool computed = false; - computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm ,sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM , - X_GSW, Y_GSW, Z_GSW, dst, pos_id); - if (computed) { - ouputElt[0] = B_X_RES; - ouputElt[1] = B_Y_RES; - ouputElt[2] = B_Z_RES; - } - - - _paramOutput->pushTime(crtTime); - pushData(ouputElt,dst, pos_id); - } - } - - void pushData(std::vector std::vectorouputElt, ElemType dst, int pos_id ) =0; - - protected: - ParamDataSpec >& _paramInput; - - ParamDataSpec >* _paramOutput; - - bool _inGSE; - }; - - template - class Shue98Dst : public Shue98Base{ - - }; - - template - class Shue98Pos_Id : public Shue98Base{ - - }; - - template - class Shue98Pos: public Shue98Base{ - - }; + template class DipoleBase : public Operation { -- libgit2 0.21.2