Commit cc178b66371172063d0cea0844020f370f5ce8e8

Authored by Hacene SI HADJ MOHAND
1 parent f4ecc923
Exists in 8045_8044

process ok

src/ExternLib/Tsyganenko96/GeopackWrapper.hh
... ... @@ -35,6 +35,17 @@ namespace AMDA {
35 35  
36 36 return (ID_MGNP == 1);
37 37 }
  38 +
  39 + static bool shue98(float Pdyn_i, float bzIMF_i, float sat_pos_X_GSM, float sat_pos_Y_GSM, float sat_pos_Z_GSM,
  40 + float &x_mgnp, float &y_mgnp, float &z_mgnp, float &DIST_MGNP, int &ID_MGNP) {
  41 + // We use dynamic pressure Pdyn
  42 + float vel_mgnp = -1.0;
  43 +
  44 + shuetal_mgnp_08_(&Pdyn_i, &vel_mgnp, &bzIMF_i, &sat_pos_X_GSM, &sat_pos_Y_GSM, &sat_pos_Z_GSM,
  45 + &x_mgnp, &y_mgnp, &z_mgnp, &DIST_MGNP, &ID_MGNP);
  46 +
  47 + return ID_MGNP != 0;
  48 + }
38 49  
39 50 static bool computeGeomagneticFieldInGSM(float sat_pos_X_GSM, float sat_pos_Y_GSM, float sat_pos_Z_GSM,
40 51 float Pdyn, float Dst, float B_Y_GSM, float B_Z_GSM,
... ...
src/ExternLib/Tsyganenko96/Shue98.hh 0 → 100644
... ... @@ -0,0 +1,168 @@
  1 +/*
  2 + * To change this license header, choose License Headers in Project Properties.
  3 + * To change this template file, choose Tools | Templates
  4 + * and open the template in the editor.
  5 + */
  6 +
  7 +/*
  8 + * File: Shue98.hh
  9 + * Author: hacene
  10 + *
  11 + * Created on December 14, 2020, 11:42 AM
  12 + */
  13 +
  14 +#ifndef SHUE98_HH
  15 +#define SHUE98_HH
  16 +#include "Parameter.hh"
  17 +#include "ParamData.hh"
  18 +#include "DataTypeMath.hh"
  19 +#include "Operation.hh"
  20 +#include "GeopackWrapper.hh"
  21 +#include "Tsyganenko96.hh"
  22 +
  23 +#include <iterator>
  24 +
  25 +namespace AMDA {
  26 + namespace Parameters {
  27 + namespace Shue98 {
  28 +
  29 + template <typename ElemType, typename TOutputParamData>
  30 + class Shue98Base : public Tsyganenko96Base {
  31 + public:
  32 +
  33 + /**
  34 + * @brief Constructor.
  35 + * @details Create the ParamData type of the input ParamData.
  36 + */
  37 + Shue98Base(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
  38 + : Tsyganenko96Base(pProcess, paramImfInput, paramPswInput),
  39 + _paramInput(paramInput),
  40 + _paramOutput(new TOutputParamData), _inGSE(inGSE) {
  41 + _paramDataOutput = _paramOutput;
  42 + }
  43 +
  44 + virtual ~Shue98Base() {
  45 + }
  46 +
  47 + /**
  48 + * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
  49 + */
  50 +
  51 + void write(ParamDataIndexInfo &pParamDataIndexInfo) {
  52 + for (unsigned int _index = pParamDataIndexInfo._startIndex;
  53 + _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
  54 + ++_index) {
  55 + double crtTime = _paramInput.getTime(_index);
  56 +
  57 + float b_x_gse, b_y_gse, b_z_gse;
  58 + getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse);
  59 +
  60 + float p_sw;
  61 + getPswData(crtTime, p_sw);
  62 + if (isNAN(p_sw)) {
  63 + p_sw = DEFAULT_PSW;
  64 + }
  65 +
  66 +
  67 + std::vector<ElemType> inputElt = _paramInput.get(_index);
  68 +
  69 + time_t timestamp = crtTime;
  70 + struct tm *tmp;
  71 + tmp = gmtime(&timestamp);
  72 +
  73 + std::vector<ElemType> ouputElt;
  74 + ouputElt.resize(3);
  75 + ouputElt << NotANumber();
  76 +
  77 + //Init geopack with GSM frame
  78 + geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  79 +
  80 + //Compute magnetic field
  81 + float X_GSW, Y_GSW, Z_GSW;
  82 + float dst;
  83 + int pos_id;
  84 + bool computed = false;
  85 + computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm, sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM,
  86 + X_GSW, Y_GSW, Z_GSW, dst, pos_id);
  87 + if (computed) {
  88 + ouputElt[0] = B_X_RES;
  89 + ouputElt[1] = B_Y_RES;
  90 + ouputElt[2] = B_Z_RES;
  91 + }
  92 +
  93 +
  94 + _paramOutput->pushTime(crtTime);
  95 + pushData(ouputElt, dst, pos_id);
  96 + }
  97 + }
  98 +
  99 + void pushData(std::vector<ElemType> std::vector<ElemType>ouputElt, ElemType dst, int pos_id) = 0;
  100 +
  101 + protected:
  102 + ParamDataSpec<std::vector<ElemType> >& _paramInput;
  103 +
  104 + TOutputParamData* _paramOutput;
  105 +
  106 + bool _inGSE;
  107 + };
  108 +
  109 + template <typename ElemType>
  110 + class Shue98Dst : public Shue98Base {
  111 +
  112 + Shue98Dst(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
  113 + : Shue98Base<ElemType, ParamDataSpec<ElemType>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
  114 +
  115 + }
  116 +
  117 + virtual ~Shue98Dst() {
  118 + }
  119 +
  120 + pushData(std::vector<ElemType>/*ouputElt*/, ElemType dst, int /*pos_id*/) {
  121 + Shue98Base<ElemType,ParamDataSpec<ElemType>>::_paramOutput->getDataList().push_back(dst);
  122 + }
  123 +
  124 + };
  125 +
  126 + template <typename ElemType>
  127 + class Shue98Pos_Id : public Shue98Base {
  128 +
  129 + Shue98Pos_Id(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
  130 + : Shue98Base<ElemType, ParamDataSpec<int>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
  131 +
  132 + }
  133 +
  134 + virtual ~Shue98Pos_Id() {
  135 + }
  136 +
  137 + pushData(std::vector<ElemType>/*ouputElt*/, ElemType /*dst*/, int pos_id) {
  138 + Shue98Base<ElemType, ParamDataSpec<int>>::_paramOutput->getDataList().push_back(pos_id);
  139 + }
  140 +
  141 + };
  142 +
  143 + template <typename ElemType>
  144 + class Shue98Pos : public Shue98Base {
  145 +
  146 + Shue98Pos(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
  147 + : Shue98Base<ElemType,ParamDataSpec<std::vector<ElemType>>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
  148 +
  149 + }
  150 +
  151 + virtual ~Shue98Pos() {
  152 + }
  153 +
  154 + pushData(std::vector<ElemType> ouputElt, ElemType /*dst*/, int /*pos_id*/) {
  155 + Shue98Base<ElemType, ParamDataSpec<std::vector<ElemType>>>::_paramOutput->getDataList().push_back(ouputElt);
  156 + }
  157 +
  158 + };
  159 +
  160 + }
  161 + }
  162 +
  163 +
  164 +
  165 +
  166 +
  167 +#endif /* SHUE98_HH */
  168 +
... ...
src/ExternLib/Tsyganenko96/Shue98Creator.hh 0 → 100644
... ... @@ -0,0 +1,194 @@
  1 +/*
  2 + * To change this license header, choose License Headers in Project Properties.
  3 + * To change this template file, choose Tools | Templates
  4 + * and open the template in the editor.
  5 + */
  6 +
  7 +/*
  8 + * File: TiltAngleCreator.hh
  9 + * Author: hacene
  10 + *
  11 + * Created on June 19, 2020, 10:34 AM
  12 + */
  13 +#ifndef TILTANGLECREATOR_HH
  14 +#define TILTANGLECREATOR_HH
  15 +
  16 +#include "DicError.hh"
  17 +#include "AMDA_exception.hh"
  18 +
  19 +#include "ParamData.hh"
  20 +#include "VisitorOfParamData.hh"
  21 +#include "Shue98.hh"
  22 +
  23 +namespace AMDA {
  24 + namespace Parameters {
  25 +
  26 + class Shue98Creator : public VisitorOfParamData {
  27 + public:
  28 +
  29 + Shue98Creator(Process& pProcess, ParamData& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE, const std::string& processType) :
  30 + _process(pProcess),
  31 + _paramData(paramInput),
  32 + _paramImfInput(paramImfInput),
  33 + _paramPswInput(paramPswInput),
  34 + _inGSE(inGSE),
  35 + _type(processType){
  36 + _paramData.accept(*this);
  37 + }
  38 +
  39 + /**
  40 + * @overload VisitorOfParamData::visit(ParamDataScalaireShort *)
  41 + */
  42 + void visit(ParamDataScalaireShort *) {
  43 + createOperation<short>();
  44 + }
  45 +
  46 + /**
  47 + * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *)
  48 + */
  49 + void visit(ParamDataScalaireFloat *) {
  50 + createOperation<float>();
  51 + }
  52 +
  53 + /**
  54 + * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *)
  55 + */
  56 + void visit(ParamDataScalaireDouble *) {
  57 + createOperation<double>();
  58 + }
  59 +
  60 + /**
  61 + * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *)
  62 + */
  63 + void visit(ParamDataScalaireLongDouble *) {
  64 + createOperation<long double>();
  65 + }
  66 +
  67 + /**
  68 + * @overload VisitorOfParamData::visit(ParamDataScalaireInt *)
  69 + */
  70 + void visit(ParamDataScalaireInt *) {
  71 + createOperation<int>();
  72 + }
  73 +
  74 + /**
  75 + * @overload VisitorOfParamData::visit(ParamDataLogicalData *)
  76 + */
  77 + void visit(ParamDataLogicalData *) {
  78 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  79 + }
  80 +
  81 + /**
  82 + * @overload VisitorOfParamData::visit(ParamDataTab1DShort *)
  83 + */
  84 + void visit(ParamDataTab1DShort *) {
  85 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  86 + }
  87 +
  88 + /**
  89 + * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *)
  90 + */
  91 + void visit(ParamDataTab1DFloat *) {
  92 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  93 + }
  94 +
  95 + /**
  96 + * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *)
  97 + */
  98 + void visit(ParamDataTab1DDouble *) {
  99 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  100 + }
  101 +
  102 + /**
  103 + * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *)
  104 + */
  105 + void visit(ParamDataTab1DLongDouble *) {
  106 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  107 + }
  108 +
  109 + /**
  110 + * @overload VisitorOfParamData::visit(ParamDataTab1DInt *)
  111 + */
  112 + void visit(ParamDataTab1DInt *) {
  113 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  114 + }
  115 +
  116 + /**
  117 + * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *)
  118 + */
  119 + void visit(ParamDataTab1DLogicalData *) {
  120 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  121 + }
  122 +
  123 + /**
  124 + * @overload VisitorOfParamData::visit(ParamDataTab2DShort *)
  125 + */
  126 + void visit(ParamDataTab2DShort *) {
  127 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  128 + }
  129 +
  130 + /**
  131 + * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *)
  132 + */
  133 + void visit(ParamDataTab2DFloat *) {
  134 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  135 + }
  136 +
  137 + /**
  138 + * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *)
  139 + */
  140 + void visit(ParamDataTab2DDouble *) {
  141 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  142 + }
  143 +
  144 + /**
  145 + * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *)
  146 + */
  147 + void visit(ParamDataTab2DLongDouble *) {
  148 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  149 + }
  150 +
  151 + /**
  152 + * @overload VisitorOfParamData::visit(ParamDataTab2DInt *)
  153 + */
  154 + void visit(ParamDataTab2DInt *) {
  155 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  156 + }
  157 +
  158 + /**
  159 + * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *)
  160 + */
  161 + void visit(ParamDataTab2DLogicalData *) {
  162 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported"));
  163 + }
  164 +
  165 + /**
  166 + * @brief get the Tsyganenko96 parameterized operation.
  167 + */
  168 + Operation * getOperation() const {
  169 + return _operation;
  170 + }
  171 + private:
  172 +
  173 + template <typename Type>
  174 + void createOperation() {
  175 + if (_type == "pos_id")
  176 + _operation = new Shue98::Shue98Pos_Id<Type>( _process, dynamic_cast<ParamDataSpec<std::vector<Type> >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE);
  177 + if (_type == "dst")
  178 + _operation = new Shue98::Shue98Dst<Type>( _process, dynamic_cast<ParamDataSpec<std::vector<Type> >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE);
  179 + if (_type == "pos")
  180 + _operation = new Shue98::Shue98Pos<Type>( _process, dynamic_cast<ParamDataSpec<std::vector<Type> >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE);
  181 + }
  182 + Process &_process;
  183 + ParamData &_paramData;
  184 + ParamData &_paramImfInput;
  185 + ParamData &_paramPswInput;
  186 + bool _inGSE;
  187 + std::string _type;
  188 + Operation* _operation;
  189 + };
  190 +
  191 + }
  192 +}
  193 +
  194 +#endif /* TILTANGLECREATOR_HH */
... ...
src/ExternLib/Tsyganenko96/Tsyganenko96.hh
... ... @@ -43,6 +43,13 @@ namespace AMDA {
43 43 _paramPswInput(dynamic_cast<ParamDataSpec<float>&> (paramPswInput)),
44 44 _paramDstInput(dynamic_cast<ParamDataSpec<float>&> (paramDstInput)) {
45 45 }
  46 +
  47 + Tsyganenko96Base(Process& pProcess, ParamData& paramImfInput, ParamData& paramPswInput)
  48 + : Operation(pProcess),
  49 + _paramImfInput(dynamic_cast<ParamDataSpec<std::vector<float> >&> (paramImfInput)),
  50 + _paramPswInput(dynamic_cast<ParamDataSpec<float>&> (paramPswInput)),
  51 + _paramDstInput(dynamic_cast<ParamDataSpec<float>&> (paramPswInput)){
  52 + }
46 53  
47 54 virtual ~Tsyganenko96Base() {
48 55 }
... ... @@ -264,102 +271,7 @@ namespace AMDA {
264 271  
265 272 bool _inGSE;
266 273 };
267   -
268   -
269   - template <typename ElemType>
270   - class Shue98Base: public Tsyganenko96Base {
271   - public:
272   -
273   - /**
274   - * @brief Constructor.
275   - * @details Create the ParamData type of the input ParamData.
276   - */
277   - Shue98Base(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, ParamData& paramDstInput, bool inGSE)
278   - : Shue98Base(pProcess, paramImfInput, paramPswInput, paramDstInput),
279   - _paramInput(paramInput),
280   - _paramOutput(new ParamDataSpec<std::vector<ElemType> >), _inGSE(inGSE) {
281   - _paramDataOutput = _paramOutput;
282   - }
283   -
284   - virtual ~Shue98Base() {
285   - }
286   -
287   - /**
288   - * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
289   - */
290   -
291   - void write(ParamDataIndexInfo &pParamDataIndexInfo) {
292   - for (unsigned int _index = pParamDataIndexInfo._startIndex;
293   - _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
294   - ++_index) {
295   - double crtTime = _paramInput.getTime(_index);
296   -
297   - float b_x_gse, b_y_gse, b_z_gse;
298   - getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse);
299   -
300   - float p_sw;
301   - getPswData(crtTime, p_sw);
302   - if (isNAN(p_sw)) {
303   - p_sw = DEFAULT_PSW;
304   - }
305   -
306   -
307   - std::vector<ElemType> inputElt = _paramInput.get(_index);
308   -
309   - time_t timestamp = crtTime;
310   - struct tm *tmp;
311   - tmp = gmtime(&timestamp);
312   -
313   - std::vector<ElemType> ouputElt;
314   - ouputElt.resize(3);
315   - ouputElt << NotANumber();
316   -
317   - //Init geopack with GSM frame
318   - geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
319   -
320   - //Compute magnetic field
321   - float X_GSW, Y_GSW, Z_GSW;
322   - float dst;
323   - int pos_id;
324   - bool computed = false;
325   - computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm ,sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM ,
326   - X_GSW, Y_GSW, Z_GSW, dst, pos_id);
327   - if (computed) {
328   - ouputElt[0] = B_X_RES;
329   - ouputElt[1] = B_Y_RES;
330   - ouputElt[2] = B_Z_RES;
331   - }
332   -
333   -
334   - _paramOutput->pushTime(crtTime);
335   - pushData(ouputElt,dst, pos_id);
336   - }
337   - }
338   -
339   - void pushData(std::vector<ElemType> std::vector<ElemType>ouputElt, ElemType dst, int pos_id ) =0;
340   -
341   - protected:
342   - ParamDataSpec<std::vector<ElemType> >& _paramInput;
343   -
344   - ParamDataSpec<std::vector<ElemType> >* _paramOutput;
345   -
346   - bool _inGSE;
347   - };
348   -
349   - template <typename ElemType>
350   - class Shue98Dst : public Shue98Base{
351   -
352   - };
353   -
354   - template <typename ElemType>
355   - class Shue98Pos_Id : public Shue98Base{
356   -
357   - };
358   -
359   - template <typename ElemType>
360   - class Shue98Pos: public Shue98Base{
361   -
362   - };
  274 +
363 275  
364 276 template<typename ElemType, class TOutputParamData>
365 277 class DipoleBase : public Operation {
... ...