Blame view

src/ExternLib/Cain/Cain.hh 5.06 KB
a1ab0552   Hacene SI HADJ MOHAND   plugin added
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * 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:   Cain.hh
 * Author: hacene
 *
 * Created on September 6, 2021, 11:41 AM
 */

#ifndef CAIN_HH
#define CAIN_HH


#include "Parameter.hh"
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "Operation.hh"
#include "SpiceKernelMgr.hh"
#include <vector>
#include <c++/4.8.2/bits/basic_string.h>
6ba9e9fd   Hacene SI HADJ MOHAND   connection ok
25
#include "cainWarpper.hh"
a1ab0552   Hacene SI HADJ MOHAND   plugin added
26

6ba9e9fd   Hacene SI HADJ MOHAND   connection ok
27
#define RM  3396.2  //RADIUS_MARS 
a1ab0552   Hacene SI HADJ MOHAND   plugin added
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51


namespace AMDA {
    namespace Parameters {
        namespace Cain {

            using namespace std;

            template<typename DataType, class TOutputParamData>
            class Cain : public Operation {
            public:

                Cain(Process& pProcess, ParamDataSpec<vector<DataType> >&paramInput) : Operation(pProcess),
                _paramInput(paramInput), _paramOutput(new TOutputParamData()) {
                    _paramDataOutput = _paramOutput;
                }

                virtual ~Cain() {
                }

                /**
                 * @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
                 */
                void write(ParamDataIndexInfo &pParamDataIndexInfo) {
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
52
53
54
55
                    double dlat, dlong, alt;
                    double B= 0.0;
                    double Bx = 0.0, By = 0.0, Bz = 0.0;
                    double Btt = 0.0, Bpp = 0.0, Brr = 0.0;
a1ab0552   Hacene SI HADJ MOHAND   plugin added
56
57
58
59
60
                    int ifail = -1;
                    for (unsigned int _index = pParamDataIndexInfo._startIndex;
                            _index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
                            ++_index) {
                        std::vector<DataType> xyz_MSO = _paramInput.getDataList()[_index];
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
61
62
63
64
65
66
                        dlat = (double) xyz_MSO[0];
                        dlong = (double) xyz_MSO[1];
                        alt = (double) xyz_MSO[2]*RM;
                        double crtTime = _paramInput.getTime(_index);                        
                        cainWarpper::getCain(
                                dlat, dlong,    alt,
6ba9e9fd   Hacene SI HADJ MOHAND   connection ok
67
68
69
                                Btt, Bpp, Brr,
                                Bx, By, Bz,
                                B, ifail);
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
70
                        std::vector<double> outputBrtp;
a1ab0552   Hacene SI HADJ MOHAND   plugin added
71
72
73
                        outputBrtp.resize(3);
                        outputBrtp[0] = Btt;
                        outputBrtp[1] = Bpp;
12661f64   Hacene SI HADJ MOHAND   correction index iau
74
                        outputBrtp[2] = Brr;
a1ab0552   Hacene SI HADJ MOHAND   plugin added
75

a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
76
                        vector<double>outputBxyz;
a1ab0552   Hacene SI HADJ MOHAND   plugin added
77
78
79
80
                        outputBxyz.resize(3);
                        outputBxyz[0] = Bx;
                        outputBxyz[1] = By;
                        outputBxyz[2] = Bz;
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
81
82
                        // writing data 
                        _paramOutput->pushTime(crtTime);
a1ab0552   Hacene SI HADJ MOHAND   plugin added
83
84
85
86
87
                        pushResult(outputBrtp, B, outputBxyz);

                    }
                }

a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
88
                virtual void pushResult(std::vector<double>& fieldSph, double& magnitude_, std::vector<double> &fieldCoor) = 0;
a1ab0552   Hacene SI HADJ MOHAND   plugin added
89
90
91
92
93
94
95
96
97
98
99
100
            protected:
                ParamDataSpec<std::vector<DataType> >& _paramInput;
                TOutputParamData* _paramOutput;
            };

        template<typename DataType, class TOutputParamData>
        class CainMag : public Cain<DataType, TOutputParamData >{
            public:
                CainMag(Process& pProcess, ParamDataSpec<vector<DataType> >& paramInput) :
                Cain<DataType, TOutputParamData>(pProcess, paramInput) {
                }
                
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
101
                void pushResult(std::vector<double>& /*fieldSph*/, double& magnitude_, std::vector<double>& /*fieldCoor*/){
a1ab0552   Hacene SI HADJ MOHAND   plugin added
102
103
104
                    Cain<DataType, TOutputParamData> ::_paramOutput->getDataList().push_back(magnitude_);
                }
        };
a3f0658d   Hacene SI HADJ MOHAND   lib ok validation ko
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
        
      template<typename DataType, class TOutputParamData>
        class CainCart : public Cain<DataType, TOutputParamData >{
            public:
                CainCart(Process& pProcess, ParamDataSpec<vector<DataType> >& paramInput) :
                Cain<DataType, TOutputParamData>(pProcess, paramInput) {
                }
                
                void pushResult(std::vector<double>& /*fieldSph*/, double& /*magnitude_*/, std::vector<double>& fieldCoor){
                    Cain<DataType, TOutputParamData> ::_paramOutput->getDataList().push_back(fieldCoor);
                }
        };
        
        template<typename DataType, class TOutputParamData>
        class CainSphr : public Cain<DataType, TOutputParamData >{
            public:
                CainSphr(Process& pProcess, ParamDataSpec<vector<DataType> >& paramInput) :
                Cain<DataType, TOutputParamData>(pProcess, paramInput) {
                }
                
                void pushResult(std::vector<double>& fieldSph, double& /*magnitude_*/, std::vector<double>& /*fieldCoor*/){
                    Cain<DataType, TOutputParamData> ::_paramOutput->getDataList().push_back(fieldSph);
                }
        };
        
a1ab0552   Hacene SI HADJ MOHAND   plugin added
130
131
132
133
134
        }
    }
}

#endif /* CAIN2003_HH */