Commit 8269f84f20ccf8ef5d887259ecf7e63b646684e7

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

intermed

src/ExternLib/Tsyganenko96/ProcessShue98.cc 0 → 100644
@@ -0,0 +1,141 @@ @@ -0,0 +1,141 @@
  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: ProcessShue98.cc
  9 + * Author: hacene
  10 + *
  11 + * Created on December 14, 2020, 3:21 PM
  12 + */
  13 +#include <stdlib.h>
  14 +#include <string>
  15 +
  16 +#include <boost/lexical_cast.hpp>
  17 +
  18 +#include "DicError.hh"
  19 +#include "AMDA_exception.hh"
  20 +
  21 +#include "Operation.hh"
  22 +#include "ParameterManager.hh"
  23 +#include "ProcessShue98.hh"
  24 +#include "ParameterCreatorFromExpression.hh"
  25 +//#include "Shue98.hh"
  26 +
  27 +using namespace std;
  28 +using namespace boost;
  29 +using namespace log4cxx;
  30 +
  31 +namespace AMDA {
  32 + namespace Parameters {
  33 +
  34 +ProcessShue98::ProcessShue98(Parameter &parameter, bool inGSE, const std::string& processType) : SingleParamProcess_CRTP(parameter),
  35 + _inGSE(inGSE),_type(processType) {
  36 + }
  37 +
  38 +ProcessShue98::ProcessShue98(const ProcessShue98& pProcess,Parameter &parameter) :SingleParamProcess_CRTP(pProcess, parameter), _inGSE(pProcess._inGSE),
  39 + _type(pProcess._type) {
  40 + }
  41 +
  42 +ProcessShue98::~ProcessShue98() {
  43 + if (_inputImfParam != nullptr) {
  44 + _inputImfParam->closeConnection(this);
  45 + }
  46 + if (_inputPswParam != nullptr) {
  47 + _inputPswParam->closeConnection(this);
  48 + }
  49 +}
  50 +
  51 + void ProcessShue98::establishConnection() {
  52 + if (_attributList.size() != 2) {
  53 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessShue98::parse require 2 attributes'")));
  54 + }
  55 +
  56 + //Imf parameter
  57 + _inputImfParam = _parameter.getParameterManager().getParameter(_attributList[0]);
  58 + if (_inputImfParam == nullptr) {
  59 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessShue98::parse cannot retrieve imf param")));
  60 + }
  61 + _inputImfParam->openConnection(this);
  62 +
  63 + //Psw parameter
  64 + _inputPswParam = _parameter.getParameterManager().getParameter(_attributList[1]);
  65 + if (_inputPswParam == nullptr) {
  66 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_PROCESS_ERR) << AMDA::ex_msg(std::string("ProcessShue98::parse cannot retrieve psw param")));
  67 + }
  68 + _inputPswParam->openConnection(this);
  69 +
  70 +
  71 + SingleParamProcess::establishConnection();
  72 + }
  73 +
  74 +TimeStamp ProcessShue98::init() {
  75 +
  76 +TimeStamp time = _parameterInput->init( this, _timeIntervalList);
  77 +
  78 + _inputImfParam->init( this, _timeIntervalList);
  79 + ParamData* lImfParamInput = _inputImfParam->getParamData(this).get();
  80 +
  81 + _inputPswParam->init( this, _timeIntervalList);
  82 + ParamData* lPswParamInput = _inputPswParam->getParamData(this).get();
  83 +
  84 + _paramInput = _parameterInput->getParamData(this).get();
  85 +
  86 + Shue98Creator lCreator(*this, *_paramInput, *lImfParamInput, *lPswParamInput, _inGSE, _type);
  87 + _operation = lCreator.getOperation();
  88 + _paramData = ParamDataSPtr(_operation->getParamOutput());
  89 + _paramData->setMinSampling(_paramInput->getMinSampling());
  90 + return time;
  91 +
  92 + return time;
  93 + }
  94 +
  95 +unsigned int ProcessShue98::write() {
  96 + getImfData();
  97 + getPswData();
  98 + return SingleParamProcess::write();
  99 +}
  100 +
  101 +/*
  102 +void ProcessShue98::getImfData() {
  103 + try {
  104 + ParamDataIndexInfo lParamDataIndexInfo;
  105 + lParamDataIndexInfo = _inputImfParam->getAsync(this).get();
  106 + while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) {
  107 + reinterpret_cast<Shue98::Shue98Base*>(_operation)->pushImfData(lParamDataIndexInfo);
  108 + if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt)
  109 + break;
  110 + lParamDataIndexInfo = _inputImfParam->getAsync(this).get();
  111 + }
  112 + }catch (...) {
  113 + throw;
  114 + }
  115 +}
  116 +
  117 +
  118 +void ProcessShue98::getPswData() {
  119 + try {
  120 + ParamDataIndexInfo lParamDataIndexInfo;
  121 + lParamDataIndexInfo = _inputPswParam->getAsync(this).get();
  122 + while ((!lParamDataIndexInfo._noMoreTimeInt && !lParamDataIndexInfo._timeIntToProcessChanged) || (lParamDataIndexInfo._nbDataToProcess > 0)) {
  123 + reinterpret_cast<Shue98::Shue98Base*>(_operation)->pushPswData(lParamDataIndexInfo);
  124 + if (lParamDataIndexInfo._timeIntToProcessChanged || lParamDataIndexInfo._noMoreTimeInt)
  125 + break;
  126 + lParamDataIndexInfo = _inputPswParam->getAsync(this).get();
  127 + }
  128 + }catch (...) {
  129 + throw;
  130 + }
  131 +
  132 +}
  133 + * */
  134 +
  135 +ProcessShue98PosGSM::ProcessShue98PosGSM(Parameter &parameter) : ProcessShue98(parameter,false,"pos") {
  136 +}
  137 +
  138 +ProcessShue98PosGSE::ProcessShue98PosGSE(Parameter &parameter) : ProcessShue98(parameter,true,"pos") {
  139 +}
  140 + }
  141 +}
0 \ No newline at end of file 142 \ No newline at end of file
src/ExternLib/Tsyganenko96/ProcessShue98.hh 0 → 100644
@@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
  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: ProcessShue98.hh
  9 + * Author: hacene
  10 + *
  11 + * Created on December 14, 2020, 9:15 PM
  12 + */
  13 +
  14 +#ifndef PROCESSSHUE98_HH
  15 +#define PROCESSSHUE98_HH
  16 +
  17 +
  18 +#include "SingleParamProcess.hh"
  19 +#include "ParamInfo.hh"
  20 +#include "Shue98Creator.hh"
  21 +
  22 +namespace AMDA {
  23 + namespace Parameters {
  24 +
  25 + class ProcessShue98 : public SingleParamProcess_CRTP<ProcessShue98> {
  26 + public:
  27 + ProcessShue98(Parameter & parameter, bool inGSE, const std::string& processType);
  28 + ProcessShue98(const ProcessShue98& pProcess, Parameter & parameter);
  29 + virtual ~ProcessShue98();
  30 +
  31 + /**
  32 + * @overload Process::establishConnection()
  33 + */
  34 + virtual void establishConnection();
  35 +
  36 + /**
  37 + * @overload Process::init()
  38 + */
  39 + virtual TimeStamp init();
  40 +
  41 + /**
  42 + * Write data in dataParam.
  43 + */
  44 + virtual unsigned int write();
  45 +
  46 + protected:
  47 + void getImfData();
  48 +
  49 + void getPswData();
  50 +
  51 + bool _inGSE;
  52 +
  53 + std::string _type;
  54 + private:
  55 + /**
  56 + * @brief params intput
  57 + */
  58 + ParameterSPtr _inputImfParam;
  59 +
  60 + ParameterSPtr _inputPswParam;
  61 +
  62 + };
  63 +
  64 + /**
  65 + * @class Shue98PosGSM
  66 + * @brief Process to Shue 98 position if GSM
  67 + */
  68 + class ProcessShue98PosGSM : public ProcessShue98 {
  69 + public:
  70 + /**
  71 + * @brief Constructor.
  72 + */
  73 + ProcessShue98PosGSM(Parameter &parameter);
  74 + };
  75 +
  76 + /**
  77 + * @class Shue98PosGSE
  78 + * @brief Process to Shue 98 position if GSE
  79 + */
  80 + class ProcessShue98PosGSE : public ProcessShue98 {
  81 + public:
  82 + /**
  83 + * @brief Constructor.
  84 + */
  85 + ProcessShue98PosGSE(Parameter &parameter);
  86 + };
  87 +
  88 + }
  89 +}
  90 +
  91 +#endif /* PROCESSSHUE98_HH */
  92 +
src/ExternLib/Tsyganenko96/Shue98.hh deleted
@@ -1,168 +0,0 @@ @@ -1,168 +0,0 @@
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
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 18
19 #include "ParamData.hh" 19 #include "ParamData.hh"
20 #include "VisitorOfParamData.hh" 20 #include "VisitorOfParamData.hh"
21 -#include "Shue98.hh" 21 +#include "Tsyganenko96.hh"
22 22
23 namespace AMDA { 23 namespace AMDA {
24 namespace Parameters { 24 namespace Parameters {
@@ -32,7 +32,7 @@ namespace AMDA { @@ -32,7 +32,7 @@ namespace AMDA {
32 _paramImfInput(paramImfInput), 32 _paramImfInput(paramImfInput),
33 _paramPswInput(paramPswInput), 33 _paramPswInput(paramPswInput),
34 _inGSE(inGSE), 34 _inGSE(inGSE),
35 - _type(processType){ 35 + _type(processType) {
36 _paramData.accept(*this); 36 _paramData.accept(*this);
37 } 37 }
38 38
@@ -40,126 +40,126 @@ namespace AMDA { @@ -40,126 +40,126 @@ namespace AMDA {
40 * @overload VisitorOfParamData::visit(ParamDataScalaireShort *) 40 * @overload VisitorOfParamData::visit(ParamDataScalaireShort *)
41 */ 41 */
42 void visit(ParamDataScalaireShort *) { 42 void visit(ParamDataScalaireShort *) {
43 - createOperation<short>(); 43 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
44 } 44 }
45 45
46 /** 46 /**
47 * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *) 47 * @overload VisitorOfParamData::visit(ParamDataScalaireFloat *)
48 */ 48 */
49 void visit(ParamDataScalaireFloat *) { 49 void visit(ParamDataScalaireFloat *) {
50 - createOperation<float>(); 50 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
51 } 51 }
52 52
53 /** 53 /**
54 * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *) 54 * @overload VisitorOfParamData::visit(ParamDataScalaireDouble *)
55 */ 55 */
56 void visit(ParamDataScalaireDouble *) { 56 void visit(ParamDataScalaireDouble *) {
57 - createOperation<double>(); 57 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
58 } 58 }
59 59
60 /** 60 /**
61 * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *) 61 * @overload VisitorOfParamData::visit(ParamDataScalaireLongDouble *)
62 */ 62 */
63 void visit(ParamDataScalaireLongDouble *) { 63 void visit(ParamDataScalaireLongDouble *) {
64 - createOperation<long double>(); 64 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
65 } 65 }
66 66
67 /** 67 /**
68 * @overload VisitorOfParamData::visit(ParamDataScalaireInt *) 68 * @overload VisitorOfParamData::visit(ParamDataScalaireInt *)
69 */ 69 */
70 void visit(ParamDataScalaireInt *) { 70 void visit(ParamDataScalaireInt *) {
71 - createOperation<int>(); 71 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
72 } 72 }
73 73
74 /** 74 /**
75 * @overload VisitorOfParamData::visit(ParamDataLogicalData *) 75 * @overload VisitorOfParamData::visit(ParamDataLogicalData *)
76 */ 76 */
77 void visit(ParamDataLogicalData *) { 77 void visit(ParamDataLogicalData *) {
78 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 78 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
79 } 79 }
80 80
81 /** 81 /**
82 * @overload VisitorOfParamData::visit(ParamDataTab1DShort *) 82 * @overload VisitorOfParamData::visit(ParamDataTab1DShort *)
83 */ 83 */
84 void visit(ParamDataTab1DShort *) { 84 void visit(ParamDataTab1DShort *) {
85 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 85 + createOperation<short>();
86 } 86 }
87 87
88 /** 88 /**
89 * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *) 89 * @overload VisitorOfParamData::visit(ParamDataTab1DFloat *)
90 */ 90 */
91 void visit(ParamDataTab1DFloat *) { 91 void visit(ParamDataTab1DFloat *) {
92 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 92 + createOperation<float>();
93 } 93 }
94 94
95 /** 95 /**
96 * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *) 96 * @overload VisitorOfParamData::visit(ParamDataTab1DDouble *)
97 */ 97 */
98 void visit(ParamDataTab1DDouble *) { 98 void visit(ParamDataTab1DDouble *) {
99 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 99 + createOperation<double>();
100 } 100 }
101 101
102 /** 102 /**
103 * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *) 103 * @overload VisitorOfParamData::visit(ParamDataTab1DLongDouble *)
104 */ 104 */
105 void visit(ParamDataTab1DLongDouble *) { 105 void visit(ParamDataTab1DLongDouble *) {
106 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 106 + createOperation<long double>();
107 } 107 }
108 108
109 /** 109 /**
110 * @overload VisitorOfParamData::visit(ParamDataTab1DInt *) 110 * @overload VisitorOfParamData::visit(ParamDataTab1DInt *)
111 */ 111 */
112 void visit(ParamDataTab1DInt *) { 112 void visit(ParamDataTab1DInt *) {
113 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 113 + createOperation<int>();
114 } 114 }
115 115
116 /** 116 /**
117 * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *) 117 * @overload VisitorOfParamData::visit(ParamDataTab1DLogicalData *)
118 */ 118 */
119 void visit(ParamDataTab1DLogicalData *) { 119 void visit(ParamDataTab1DLogicalData *) {
120 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 120 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
121 } 121 }
122 122
123 /** 123 /**
124 * @overload VisitorOfParamData::visit(ParamDataTab2DShort *) 124 * @overload VisitorOfParamData::visit(ParamDataTab2DShort *)
125 */ 125 */
126 void visit(ParamDataTab2DShort *) { 126 void visit(ParamDataTab2DShort *) {
127 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 127 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
128 } 128 }
129 129
130 /** 130 /**
131 * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *) 131 * @overload VisitorOfParamData::visit(ParamDataTab2DFloat *)
132 */ 132 */
133 void visit(ParamDataTab2DFloat *) { 133 void visit(ParamDataTab2DFloat *) {
134 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 134 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
135 } 135 }
136 136
137 /** 137 /**
138 * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *) 138 * @overload VisitorOfParamData::visit(ParamDataTab2DDouble *)
139 */ 139 */
140 void visit(ParamDataTab2DDouble *) { 140 void visit(ParamDataTab2DDouble *) {
141 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 141 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
142 } 142 }
143 143
144 /** 144 /**
145 * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *) 145 * @overload VisitorOfParamData::visit(ParamDataTab2DLongDouble *)
146 */ 146 */
147 void visit(ParamDataTab2DLongDouble *) { 147 void visit(ParamDataTab2DLongDouble *) {
148 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 148 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
149 } 149 }
150 150
151 /** 151 /**
152 * @overload VisitorOfParamData::visit(ParamDataTab2DInt *) 152 * @overload VisitorOfParamData::visit(ParamDataTab2DInt *)
153 */ 153 */
154 void visit(ParamDataTab2DInt *) { 154 void visit(ParamDataTab2DInt *) {
155 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 155 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
156 } 156 }
157 157
158 /** 158 /**
159 * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *) 159 * @overload VisitorOfParamData::visit(ParamDataTab2DLogicalData *)
160 */ 160 */
161 void visit(ParamDataTab2DLogicalData *) { 161 void visit(ParamDataTab2DLogicalData *) {
162 - BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Shue98Creator operation not supported")); 162 + BOOST_THROW_EXCEPTION(AMDA::AMDA_exception() << AMDA::errno_code(AMDA_ERROR_UNKNOWN) << AMDA::ex_msg("Tsyganenko96Creator operation not supported"));
163 } 163 }
164 164
165 /** 165 /**
@@ -172,12 +172,8 @@ namespace AMDA { @@ -172,12 +172,8 @@ namespace AMDA {
172 172
173 template <typename Type> 173 template <typename Type>
174 void createOperation() { 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") 175 if (_type == "pos")
180 - _operation = new Shue98::Shue98Pos<Type>( _process, dynamic_cast<ParamDataSpec<std::vector<Type> >&>(_paramData), _paramImfInput, _paramPswInput, _inGSE); 176 + _operation = new Tsyganenko96::Shue98Pos<Type>(_process, dynamic_cast<ParamDataSpec<std::vector<Type> >&> (_paramData), _paramImfInput, _paramPswInput, _inGSE);
181 } 177 }
182 Process &_process; 178 Process &_process;
183 ParamData &_paramData; 179 ParamData &_paramData;
src/ExternLib/Tsyganenko96/Tsyganenko96.hh
@@ -258,7 +258,6 @@ namespace AMDA { @@ -258,7 +258,6 @@ namespace AMDA {
258 ouputElt[2] = B_Z_RES; 258 ouputElt[2] = B_Z_RES;
259 } 259 }
260 } 260 }
261 -  
262 _paramOutput->pushTime(crtTime); 261 _paramOutput->pushTime(crtTime);
263 _paramOutput->getDataList().push_back(ouputElt); 262 _paramOutput->getDataList().push_back(ouputElt);
264 } 263 }
@@ -394,6 +393,119 @@ namespace AMDA { @@ -394,6 +393,119 @@ namespace AMDA {
394 } 393 }
395 }; 394 };
396 395
  396 + template <typename ElemType, typename TOutputParamData>
  397 + class Shue98Base : public Tsyganenko96Base{
  398 + public:
  399 +
  400 + /**
  401 + * @brief Constructor.
  402 + * @details Create the ParamData type of the input ParamData.
  403 + */
  404 + Shue98Base(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
  405 + : Tsyganenko96Base(pProcess, paramImfInput, paramPswInput),
  406 + _paramInput(paramInput),
  407 + _paramOutput(new TOutputParamData), _inGSE(inGSE) {
  408 + _paramDataOutput = _paramOutput;
  409 + }
  410 +
  411 + virtual ~Shue98Base() {
  412 + }
  413 +
  414 + /**
  415 + * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
  416 + */
  417 +
  418 + void write(ParamDataIndexInfo &pParamDataIndexInfo) {
  419 +
  420 +
  421 + for (unsigned int _index = pParamDataIndexInfo._startIndex;
  422 + _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
  423 + ++_index) {
  424 + double crtTime = _paramInput.getTime(_index);
  425 +
  426 + float b_x_gse, b_y_gse, b_z_gse;
  427 + getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse);
  428 +
  429 + float p_sw;
  430 + getPswData(crtTime, p_sw);
  431 + if (isNAN(p_sw)) {
  432 + p_sw = DEFAULT_PSW;
  433 + }
  434 +
  435 +
  436 + std::vector<ElemType> inputElt = _paramInput.get(_index);
  437 +
  438 + time_t timestamp = crtTime;
  439 + struct tm *tmp;
  440 + tmp = gmtime(&timestamp);
  441 +
  442 + std::vector<ElemType> ouputElt;
  443 + ouputElt.resize(3);
  444 + ouputElt << NotANumber();
  445 +
  446 + //Init geopack with GSM frame
  447 + geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
  448 +
  449 + //Compute shue 98
  450 + // inout intialisation
  451 +
  452 + int transform_flag = -1;
  453 +
  454 + float sat_pos_X_GSE = inputElt[0];
  455 + float sat_pos_Y_GSE = inputElt[1];
  456 + float sat_pos_Z_GSE = inputElt[2];
  457 + float sat_pos_X_GSM = 0.;
  458 + float sat_pos_Y_GSM = 0.;
  459 + float sat_pos_Z_GSM = 0.;
  460 +
  461 + gswgse_08_(&sat_pos_X_GSM, &sat_pos_Y_GSM, &sat_pos_Z_GSM,
  462 + &sat_pos_X_GSE, &sat_pos_Y_GSE, &sat_pos_Z_GSE, &transform_flag);
  463 +
  464 + //Compute Imf B field in GSM frame
  465 + float b_x_gsm, b_y_gsm, b_z_gsm;
  466 + if (!isNAN(b_x_gse) && !isNAN(b_y_gse) && !isNAN(b_z_gse)) {
  467 + gswgse_08_(&b_x_gsm, &b_y_gsm, &b_z_gsm,
  468 + &b_x_gse, &b_y_gse, &b_z_gse, &transform_flag);
  469 + } else {
  470 + b_x_gsm = DEFAULT_IMF_GSM_X;
  471 + b_y_gsm = DEFAULT_IMF_GSM_Y;
  472 + b_z_gsm = DEFAULT_IMF_GSM_Z;
  473 + }
  474 +
  475 + float X_GSW, Y_GSW, Z_GSW;
  476 + float dst;
  477 + int pos_id;
  478 + bool computed = false;
  479 + computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm, sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM,
  480 + X_GSW, Y_GSW, Z_GSW, dst, pos_id);
  481 + if (computed) {
  482 + ouputElt[0] = X_GSW ;
  483 + ouputElt[1] = Y_GSW;
  484 + ouputElt[2] = Z_GSW;
  485 + }
  486 + _paramOutput->pushTime(crtTime);
  487 + pushData(ouputElt, dst, pos_id);
  488 + }
  489 + };
  490 +
  491 + virtual void pushData(std::vector<ElemType> ouputElt, ElemType dst) = 0;
  492 +
  493 + protected :
  494 + ParamDataSpec<std::vector<ElemType> >& _paramInput;
  495 +
  496 + TOutputParamData* _paramOutput;
  497 +
  498 + bool _inGSE;
  499 + };
  500 +
  501 + template <typename ElemType>
  502 + class Shue98Pos:public Shue98Base<ElemType, ParamDataSpec<std::vector<ElemType>>>{
  503 + Shue98Pos(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE):
  504 + Shue98Base<ElemType, ParamDataSpec<std::vector<ElemType>>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE){
  505 +
  506 + }
  507 + };
  508 +
397 } /* namespace Tsyganenko96 */ 509 } /* namespace Tsyganenko96 */
398 } /* namespace Parameters */ 510 } /* namespace Parameters */
399 } /* namespace AMDA */ 511 } /* namespace AMDA */