Shue98.hh
5.85 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* 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: Shue98.hh
* Author: hacene
*
* Created on December 14, 2020, 11:42 AM
*/
#ifndef SHUE98_HH
#define SHUE98_HH
#include "Parameter.hh"
#include "ParamData.hh"
#include "DataTypeMath.hh"
#include "Operation.hh"
#include "GeopackWrapper.hh"
#include "Tsyganenko96.hh"
#include <iterator>
namespace AMDA {
namespace Parameters {
namespace Shue98 {
template <typename ElemType, typename TOutputParamData>
class Shue98Base : public Tsyganenko96Base {
public:
/**
* @brief Constructor.
* @details Create the ParamData type of the input ParamData.
*/
Shue98Base(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
: Tsyganenko96Base(pProcess, paramImfInput, paramPswInput),
_paramInput(paramInput),
_paramOutput(new TOutputParamData), _inGSE(inGSE) {
_paramDataOutput = _paramOutput;
}
virtual ~Shue98Base() {
}
/**
* @overload Operation::write(ParamDataIndexInfo &pParamDataIndexInfo)
*/
void write(ParamDataIndexInfo &pParamDataIndexInfo) {
for (unsigned int _index = pParamDataIndexInfo._startIndex;
_index < pParamDataIndexInfo._startIndex + pParamDataIndexInfo._nbDataToProcess;
++_index) {
double crtTime = _paramInput.getTime(_index);
float b_x_gse, b_y_gse, b_z_gse;
getImfData(crtTime, b_x_gse, b_y_gse, b_z_gse);
float p_sw;
getPswData(crtTime, p_sw);
if (isNAN(p_sw)) {
p_sw = DEFAULT_PSW;
}
std::vector<ElemType> inputElt = _paramInput.get(_index);
time_t timestamp = crtTime;
struct tm *tmp;
tmp = gmtime(×tamp);
std::vector<ElemType> ouputElt;
ouputElt.resize(3);
ouputElt << NotANumber();
//Init geopack with GSM frame
geopack::GeopackWrapper::initInGSM(1900 + tmp->tm_year, 1 + tmp->tm_yday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
//Compute magnetic field
float X_GSW, Y_GSW, Z_GSW;
float dst;
int pos_id;
bool computed = false;
computed = geopack::GeopackWrapper::shue98(p_sw, b_z_gsm, sat_pos_X_GSM, sat_pos_Y_GSM, sat_pos_Z_GSM,
X_GSW, Y_GSW, Z_GSW, dst, pos_id);
if (computed) {
ouputElt[0] = B_X_RES;
ouputElt[1] = B_Y_RES;
ouputElt[2] = B_Z_RES;
}
_paramOutput->pushTime(crtTime);
pushData(ouputElt, dst, pos_id);
}
}
void pushData(std::vector<ElemType> std::vector<ElemType>ouputElt, ElemType dst, int pos_id) = 0;
protected:
ParamDataSpec<std::vector<ElemType> >& _paramInput;
TOutputParamData* _paramOutput;
bool _inGSE;
};
template <typename ElemType>
class Shue98Dst : public Shue98Base {
Shue98Dst(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
: Shue98Base<ElemType, ParamDataSpec<ElemType>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
}
virtual ~Shue98Dst() {
}
pushData(std::vector<ElemType>/*ouputElt*/, ElemType dst, int /*pos_id*/) {
Shue98Base<ElemType,ParamDataSpec<ElemType>>::_paramOutput->getDataList().push_back(dst);
}
};
template <typename ElemType>
class Shue98Pos_Id : public Shue98Base {
Shue98Pos_Id(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
: Shue98Base<ElemType, ParamDataSpec<int>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
}
virtual ~Shue98Pos_Id() {
}
pushData(std::vector<ElemType>/*ouputElt*/, ElemType /*dst*/, int pos_id) {
Shue98Base<ElemType, ParamDataSpec<int>>::_paramOutput->getDataList().push_back(pos_id);
}
};
template <typename ElemType>
class Shue98Pos : public Shue98Base {
Shue98Pos(Process& pProcess, ParamDataSpec<std::vector<ElemType> >& paramInput, ParamData& paramImfInput, ParamData& paramPswInput, bool inGSE)
: Shue98Base<ElemType,ParamDataSpec<std::vector<ElemType>>>(pProcess, paramInput, paramImfInput, paramPswInput, inGSE) {
}
virtual ~Shue98Pos() {
}
pushData(std::vector<ElemType> ouputElt, ElemType /*dst*/, int /*pos_id*/) {
Shue98Base<ElemType, ParamDataSpec<std::vector<ElemType>>>::_paramOutput->getDataList().push_back(ouputElt);
}
};
}
}
#endif /* SHUE98_HH */