Commit da72b553463fe11da81b3324907655cbfc451852

Authored by Hacene SI HADJ MOHAND
1 parent 371c3b86

calcul presque ok

src/ExternLib/Tsyganenko96/AMDAPlugin.cc
... ... @@ -40,5 +40,13 @@ extern "C" void registerPlugin(AMDA::Plugins::PluginManager & pm) {
40 40 ProcessFactory factProcessTiltAngle= boost::factory<ProcessTiltAngle*>();
41 41 ServicesServer::getInstance()->addProcessFactory("tilt_angle", factProcessTiltAngle);
42 42 ServicesServer::getInstance()->linkProcessWithPlugin("tilt_angle", pm.getCurrentPluginPath());
  43 +
  44 + ProcessFactory factProcessAttitudeGSE = boost::factory<ProcessAttitudeGSE*>();
  45 + ServicesServer::getInstance()->addProcessFactory("attitude_gse", factProcessAttitudeGSE);
  46 + ServicesServer::getInstance()->linkProcessWithPlugin("attitude_gse", pm.getCurrentPluginPath());
  47 +
  48 + ProcessFactory factProcessAttitudeGSM = boost::factory<ProcessAttitudeGSM*>();
  49 + ServicesServer::getInstance()->addProcessFactory("attitude_gsm", factProcessAttitudeGSM);
  50 + ServicesServer::getInstance()->linkProcessWithPlugin("attitude_gsm", pm.getCurrentPluginPath());
43 51  
44 52 }
... ...
src/ExternLib/Tsyganenko96/GeopackWrapper.hh
... ... @@ -144,11 +144,37 @@ namespace AMDA {
144 144 lat *= (180. / M_PI);
145 145 }
146 146  
147   - static void computeTiltAngle(int iyr, int iday, int ihour, int min, int isec, float & tiltAngle) {
148   - float v_default_x = -400.0;
  147 + static void computeTiltAngleAttitude(int iyr, int iday, int ihour, int min, int isec, float & tiltAngle,
  148 + std::vector<float> &attitudeGSE, std::vector<float> &attitudeGSM) {
  149 + float v_default_x = -400.0;
149 150 float v_default_y = 0.0;
150 151 float v_default_z = 0.0;
151   - recalc_08_modified_(&iyr, &iday, &ihour, &min, &isec, &v_default_x, &v_default_y, &v_default_z, & tiltAngle);
  152 + float XSM = 0.0;
  153 + float YSM = 0.0;
  154 + float ZSM = 1.0;
  155 + float XGSM = 0.0;
  156 + float YGSM =0.0;
  157 + float ZGSM = 0.0;
  158 + float XGSE = 0.0;
  159 + float YGSE =0.0;
  160 + float ZGSE = 0.0;
  161 +
  162 + int transformFlag =1;
  163 + recalc_08_(&iyr, &iday, &ihour, &min, &isec, &v_default_x, &v_default_y, &v_default_z);
  164 + smgsw_08_(&XSM, &YSM, &ZSM,&XGSM, &YGSM, &ZGSM,&transformFlag);
  165 + gswgse_08_(&XGSM, &YGSM, &ZGSM,&XGSE, &YGSE, &ZGSE, &transformFlag);
  166 +
  167 + // tilte angle
  168 + tiltAngle = std::atan(XGSE/std::sqrt(YGSE*YGSE+ZGSE*ZGSE));
  169 + //attitude in GSE
  170 + attitudeGSE[0] = XGSE;
  171 + attitudeGSE[1] = YGSE;
  172 + attitudeGSE[2] = ZGSE;
  173 + //attitude in GSM
  174 + attitudeGSM[0] = XGSM;
  175 + attitudeGSM[1] = YGSM;
  176 + attitudeGSM[2] = ZGSM;
  177 +
152 178 }
153 179  
154 180 };
... ...
src/ExternLib/Tsyganenko96/ProcessTiltAngle.cc
... ... @@ -22,6 +22,8 @@
22 22  
23 23 namespace AMDA {
24 24 namespace Parameters {
  25 +
  26 + // Tilte Angle
25 27  
26 28 ProcessTiltAngle::ProcessTiltAngle(Parameter &parameter) : SingleParamProcess_CRTP(parameter) {
27 29 }
... ... @@ -51,6 +53,68 @@ namespace AMDA {
51 53  
52 54 return time;
53 55 }
  56 + // Attitude GSE
  57 +
  58 + ProcessAttitudeGSE ::ProcessAttitudeGSE(Parameter &parameter) : SingleParamProcess_CRTP(parameter) {
  59 + }
  60 +
  61 + ProcessAttitudeGSE::ProcessAttitudeGSE(const ProcessAttitudeGSE& pProcess, Parameter &parameter) : SingleParamProcess_CRTP(pProcess, parameter) {
  62 + }
  63 +
  64 + ProcessAttitudeGSE::~ProcessAttitudeGSE() {
  65 + }
  66 +
  67 + TimeStamp ProcessAttitudeGSE::init() {
  68 +
  69 + TimeStamp time = _parameterInput->init(this, _timeIntervalList);
  70 +
  71 + Parameter::InfoList lInfoList = _parameterInput->getInfoList();
  72 + _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end());
  73 +
  74 + _paramInput = _parameterInput->getParamData(this).get();
  75 +
  76 + TiltAngleCreator lCreator(*this, *_paramInput, "gse");
  77 +
  78 + _operation = lCreator.getOperation();
  79 +
  80 + _paramData = ParamDataSPtr(_operation->getParamOutput());
  81 +
  82 + _paramData->setMinSampling(_paramInput->getMinSampling());
  83 +
  84 + return time;
  85 + }
  86 +
  87 + // Attitude GSM
  88 +
  89 + ProcessAttitudeGSM ::ProcessAttitudeGSM(Parameter &parameter) : SingleParamProcess_CRTP(parameter) {
  90 + }
  91 +
  92 + ProcessAttitudeGSM::ProcessAttitudeGSM(const ProcessAttitudeGSM& pProcess, Parameter &parameter) : SingleParamProcess_CRTP(pProcess, parameter) {
  93 + }
  94 +
  95 + ProcessAttitudeGSM::~ProcessAttitudeGSM() {
  96 + }
  97 +
  98 + TimeStamp ProcessAttitudeGSM::init() {
  99 +
  100 + TimeStamp time = _parameterInput->init(this, _timeIntervalList);
  101 +
  102 + Parameter::InfoList lInfoList = _parameterInput->getInfoList();
  103 + _parameter.getInfoList().insert(lInfoList.begin(), lInfoList.end());
  104 +
  105 + _paramInput = _parameterInput->getParamData(this).get();
  106 +
  107 + TiltAngleCreator lCreator(*this, *_paramInput, "gsm");
  108 +
  109 + _operation = lCreator.getOperation();
  110 +
  111 + _paramData = ParamDataSPtr(_operation->getParamOutput());
  112 +
  113 + _paramData->setMinSampling(_paramInput->getMinSampling());
  114 +
  115 + return time;
  116 + }
  117 +
54 118  
55 119 }
56 120 }
... ...
src/ExternLib/Tsyganenko96/ProcessTiltAngle.hh
... ... @@ -33,6 +33,33 @@ namespace AMDA {
33 33 private:
34 34  
35 35 };
  36 +
  37 + class ProcessAttitudeGSE : public SingleParamProcess_CRTP<ProcessAttitudeGSE> {
  38 + public:
  39 + ProcessAttitudeGSE (Parameter & parameter);
  40 + ProcessAttitudeGSE (const ProcessAttitudeGSE& pProcess, Parameter &pParameter);
  41 + virtual ~ProcessAttitudeGSE();
  42 +
  43 + /**
  44 + * @overload Process::init()
  45 + */
  46 + virtual TimeStamp init();
  47 + private:
  48 +
  49 + };
  50 +
  51 + class ProcessAttitudeGSM : public SingleParamProcess_CRTP<ProcessAttitudeGSM> {
  52 + public:
  53 + ProcessAttitudeGSM(Parameter & parameter);
  54 + ProcessAttitudeGSM(const ProcessAttitudeGSM& pProcess, Parameter &pParameter);
  55 + virtual ~ProcessAttitudeGSM();
  56 +
  57 + /**
  58 + * @overload Process::init()
  59 + */
  60 + virtual TimeStamp init();
  61 + private:
  62 + };
36 63 }
37 64 }
38 65  
... ...
src/ExternLib/Tsyganenko96/TiltAngleCreator.hh
... ... @@ -162,14 +162,16 @@ namespace AMDA {
162 162 Operation * getOperation() const {
163 163 return _operation;
164 164 }
165   -
166   -
167 165 private:
168 166  
169 167 template <typename Type>
170 168 void createOperation() {
171 169 if (_type == "tilt")
172 170 _operation = new Tsyganenko96::DipoleTiltAngle<Type>(_process, dynamic_cast<ParamDataSpec<Type> &> (_paramData));
  171 + if (_type == "gse")
  172 + _operation = new Tsyganenko96::DipoleAtitudeGSE<Type>(_process, dynamic_cast<ParamDataSpec<Type> &> (_paramData));
  173 + if (_type == "gsm")
  174 + _operation = new Tsyganenko96::DipoleAtitudeGSM<Type>(_process, dynamic_cast<ParamDataSpec<Type> &> (_paramData));
173 175 }
174 176 Process &_process;
175 177 ParamData &_paramData;
... ... @@ -181,4 +183,3 @@ namespace AMDA {
181 183 }
182 184  
183 185 #endif /* TILTANGLECREATOR_HH */
184   -
... ...
src/ExternLib/Tsyganenko96/Tsyganenko96.hh
... ... @@ -265,31 +265,69 @@ namespace AMDA {
265 265 bool _inGSE;
266 266 };
267 267  
268   - template<typename DataType>
  268 + template<typename ElemType, class TOutputParamData>
269 269 class DipoleBase : public Operation {
270 270 public:
271 271  
272   - DipoleBase(Process& pProcess, ParamDataSpec<DataType>& paramInput) : Operation(pProcess),
  272 + DipoleBase(Process& pProcess, ParamDataSpec<ElemType>& paramInput) : Operation(pProcess),
273 273 _paramInput(paramInput),
274   - _paramOutput(new ParamDataSpec<DataType>) {
  274 + _paramOutput(new TOutputParamData) {
275 275 _paramDataOutput = _paramOutput;
276 276 }
277 277  
278 278 virtual ~DipoleBase() {
279 279 }
280 280  
  281 + void write(ParamDataIndexInfo &pParamDataIndexInfo) {
  282 + for (unsigned int _index = pParamDataIndexInfo._startIndex;
  283 + _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
  284 + ++_index) {
  285 + double crtTime = _paramInput.getTime(_index);
  286 + time_t timestamp = crtTime;
  287 + struct tm *tmp;
  288 + tmp = gmtime(&timestamp);
  289 + float tiltAngle;
  290 + std::vector<float> attitudeGSE;
  291 + attitudeGSE.resize(3);
  292 + std::vector<float> attitudeGSM;
  293 + attitudeGSM.resize(3);
  294 + geopack::GeopackWrapper::computeTiltAngleAttitude(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec,
  295 + tiltAngle,
  296 + attitudeGSE,
  297 + attitudeGSM);
  298 + ElemType tiltAngle_res = (ElemType) tiltAngle;
  299 + std::vector<ElemType> attitudeGSE_res;
  300 + attitudeGSE_res.resize(3);
  301 + attitudeGSE_res[0] = (ElemType) attitudeGSE[0];
  302 + attitudeGSE_res[1] = (ElemType) attitudeGSE[1];
  303 + attitudeGSE_res[2] = (ElemType) attitudeGSE[2];
  304 +
  305 + std::vector<ElemType> attitudeGSM_res;
  306 + attitudeGSM_res.resize(3);
  307 + attitudeGSM_res[0] = (ElemType) attitudeGSM[0];
  308 + attitudeGSM_res[1] = (ElemType) attitudeGSM[1];
  309 + attitudeGSM_res[2] = (ElemType) attitudeGSM[2];
  310 +
  311 + attitudeGSM_res.resize(3);
  312 + _paramOutput->pushTime(crtTime);
  313 + pushData(tiltAngle_res, attitudeGSE_res, attitudeGSM_res);
  314 + }
  315 + };
  316 + virtual void pushData(ElemType tilt, std::vector<ElemType> attitudeGSE, std::vector<ElemType> attitudeGSM) = 0;
  317 +
  318 +
281 319 protected:
282 320 /**
283 321 * @brief Input paramter data.
284 322 */
285   - ParamDataSpec<DataType>& _paramInput;
  323 + ParamDataSpec<ElemType>& _paramInput;
286 324  
287   - ParamDataSpec<DataType>* _paramOutput;
  325 + TOutputParamData* _paramOutput;
288 326  
289 327 };
290 328  
291 329 template <typename ElemType>
292   - class DipoleTiltAngle : public DipoleBase<ElemType> {
  330 + class DipoleTiltAngle : public DipoleBase<ElemType, ParamDataSpec<ElemType>> {
293 331 public:
294 332  
295 333 /**
... ... @@ -297,27 +335,55 @@ namespace AMDA {
297 335 * @details Create the ParamData type of the input ParamData.
298 336 */
299 337 DipoleTiltAngle(Process& pProcess, ParamDataSpec<ElemType >& paramInput)
300   - : DipoleBase<ElemType>(pProcess, paramInput) {
  338 + : DipoleBase<ElemType , ParamDataSpec<ElemType> >(pProcess, paramInput) {
301 339 }
302 340  
303 341 virtual ~DipoleTiltAngle() {
304 342 }
305 343  
306   - void write(ParamDataIndexInfo &pParamDataIndexInfo) {
307   - for (unsigned int _index = pParamDataIndexInfo._startIndex;
308   - _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
309   - ++_index) {
310   - double crtTime = DipoleBase<ElemType>::_paramInput.getTime(_index);
311   - time_t timestamp = crtTime;
312   - struct tm *tmp;
313   - tmp = gmtime(&timestamp);
314   - float tiltAngle_res;
315   - geopack::GeopackWrapper::computeTiltAngle(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, tiltAngle_res);
  344 + void pushData(ElemType tilt, std::vector<ElemType> /*attitudeGSE*/, std::vector<ElemType> /*attitudeGSM*/) {
  345 + DipoleBase<ElemType, ParamDataSpec<ElemType>>::_paramOutput->getDataList().push_back(tilt * 180.0 / (atan(1)*4));
  346 + }
  347 + };
  348 +
  349 + template <typename ElemType>
  350 + class DipoleAtitudeGSM : public DipoleBase<ElemType, ParamDataSpec<std::vector<ElemType>>> {
  351 + public:
316 352  
317   - DipoleBase<ElemType>::_paramOutput->pushTime(crtTime);
318   - DipoleBase<ElemType>::_paramOutput->getDataList().push_back(tiltAngle_res*180.0/(atan(1)*4));
319   - }
320   - };
  353 + /**
  354 + * @brief Constructor.
  355 + * @details Create the ParamData type of the input ParamData.
  356 + */
  357 + DipoleAtitudeGSM(Process& pProcess, ParamDataSpec<ElemType >& paramInput)
  358 + : DipoleBase<ElemType, ParamDataSpec<std::vector<ElemType>>>(pProcess, paramInput) {
  359 + }
  360 +
  361 + virtual ~DipoleAtitudeGSM() {
  362 + }
  363 +
  364 + void pushData(ElemType /*tilt*/, std::vector<ElemType> /*attitudeGSE*/, std::vector<ElemType> attitudeGSM) {
  365 + DipoleBase<ElemType, ParamDataSpec<std::vector<ElemType>>>::_paramOutput->getDataList().push_back(attitudeGSM);
  366 + }
  367 + };
  368 +
  369 + template <typename ElemType>
  370 + class DipoleAtitudeGSE : public DipoleBase<ElemType, ParamDataSpec<std::vector<ElemType>>> {
  371 + public:
  372 +
  373 + /**
  374 + * @brief Constructor.
  375 + * @details Create the ParamData type of the input ParamData.
  376 + */
  377 + DipoleAtitudeGSE(Process& pProcess, ParamDataSpec<ElemType >& paramInput)
  378 + : DipoleBase<ElemType, ParamDataSpec<std::vector<ElemType>>>(pProcess, paramInput) {
  379 + }
  380 +
  381 + virtual ~DipoleAtitudeGSE() {
  382 + }
  383 +
  384 + void pushData(ElemType /*tilt*/, std::vector<ElemType> attitudeGSE, std::vector<ElemType> /*attitudeGSM*/) {
  385 + DipoleBase<ElemType , ParamDataSpec<std::vector<ElemType>>>::_paramOutput->getDataList().push_back(attitudeGSE);
  386 + }
321 387 };
322 388  
323 389 } /* namespace Tsyganenko96 */
... ...