Cain.hh
5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
130
131
132
133
134
135
/*
* 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>
#include "cainWarpper.hh"
#define RM 3396.2 //RADIUS_MARS
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> >¶mInput) : Operation(pProcess),
_paramInput(paramInput), _paramOutput(new TOutputParamData()) {
_paramDataOutput = _paramOutput;
}
virtual ~Cain() {
}
/**
* @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
*/
void write(ParamDataIndexInfo &pParamDataIndexInfo) {
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;
int ifail = -1;
for (unsigned int _index = pParamDataIndexInfo._startIndex;
_index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
++_index) {
std::vector<DataType> xyz_MSO = _paramInput.getDataList()[_index];
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,
Btt, Bpp, Brr,
Bx, By, Bz,
B, ifail);
std::vector<double> outputBrtp;
outputBrtp.resize(3);
outputBrtp[0] = Btt;
outputBrtp[1] = Bpp;
outputBrtp[2] = Brr;
vector<double>outputBxyz;
outputBxyz.resize(3);
outputBxyz[0] = Bx;
outputBxyz[1] = By;
outputBxyz[2] = Bz;
// writing data
_paramOutput->pushTime(crtTime);
pushResult(outputBrtp, B, outputBxyz);
}
}
virtual void pushResult(std::vector<double>& fieldSph, double& magnitude_, std::vector<double> &fieldCoor) = 0;
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) {
}
void pushResult(std::vector<double>& /*fieldSph*/, double& magnitude_, std::vector<double>& /*fieldCoor*/){
Cain<DataType, TOutputParamData> ::_paramOutput->getDataList().push_back(magnitude_);
}
};
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);
}
};
}
}
}
#endif /* CAIN2003_HH */