FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Aether/include/indices.h at develop · AetherModel/Aether · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
AetherModel
/
Aether
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
25
Code
Issues
21
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Aether
/
include
/
indices.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
257 lines (204 loc) · 8.53 KB
Breadcrumbs
Aether
/
include
/
indices.h
Copy path
File metadata and controls
257 lines (204 loc) · 8.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
//
Copyright 2020, the Aether Development Team (see doc/dev_team.md for members)
//
Full license can be found in License.md
#
ifndef
INCLUDE_INDICES_H_
#
define
INCLUDE_INDICES_H_
/*
*************************************************************
* \class Indices
*
* \brief A class for keeping track of indices (1d vectors w/time)
This is a class that allows users to read in and keep track of
indices, such as IMF Bz, Kp, AE, F107, etc. These are often needed
to drive other sub models, such as EUVAC, MSIS, Weimer, etc. Basically,
the way you use this is to:
- read a file (custom for each type of file)
- get the proper index number
- call the set_index function with the time and values array
- call the appropriate get function with time to get index value at time
* \author Aaron Ridley
*
* \date 2021/04/16
*************************************************************
*/
#
include
<
vector
>
#
include
<
string
>
//
/ A structure that is made available to the user to allow the
//
/ general reading of a file, since the information that is needed
//
/ from the file could all be contained within this structure
struct
index_file_output_struct
{
//
/ number of times read in:
int64_t
nTimes;
//
/ array of times that correspond to the values:
std::vector<
double
> times;
//
/ number of variables read in:
int
nVars;
//
/ variable names as a vector of strings:
std::vector<std::string> var_names;
//
/ a 2d vector (vars vs times) of indices values:
std::vector<std::vector<
float
>> values;
//
/ a vector of missing values for each variable:
std::vector<
float
> missing_values;
//
/ The index_id returned by the call to get_XXX_index_id:
std::vector<
int
> index_id;
};
/*
*************************************************************
\brief Print out information in the structure for debugging
\param contents structure containing the index file output
*
*/
void
print_index_file_output_struct
(index_file_output_struct contents);
class
Indices
{
//
-----------------------------------------------------------------------
//
Public functions and variables
//
-----------------------------------------------------------------------
public:
/*
*************************************************************
\brief Initialize the class
*
*/
Indices
();
/*
*************************************************************
\brief get the daily f107 value at the given time
\param time time in seconds
*
*/
precision_t
get_f107
(
double
time);
/*
*************************************************************
\brief get the 81-day average f107 at the given time
\param time time in seconds
*
*/
precision_t
get_f107a
(
double
time);
/*
*************************************************************
\brief a series of functions that return the internal index number
In order to keep track of which index is which, the class uses
constants. These functions return these constants. The user doesn't
really need to know about the constants, but they have to get the
constant (when reading the file, for example) and then provide that
to the set index function. Conversely, we could create a bunch of
set_ functions (such as the set_f107 function below). We figured
that this minor inconvience is easier than making a bunch of set_
functions.
*
*/
int
get_f107_index_id
();
int
get_f107a_index_id
();
int
get_imfbx_index_id
();
int
get_imfby_index_id
();
int
get_imfbz_index_id
();
int
get_swvx_index_id
();
int
get_swvy_index_id
();
int
get_swvz_index_id
();
int
get_swn_index_id
();
int
get_swt_index_id
();
int
get_ae_index_id
();
int
get_au_index_id
();
int
get_al_index_id
();
json
get_all_indices
(
double
time);
bool
restart_file
(std::string dir,
bool
DoRead,
double
time);
/*
*************************************************************
\brief Return the indices index of the variable name
\param name the name of the variable to find the index for
*
*/
int
lookup_index_id
(std::string name);
/*
*************************************************************
\brief This function sets the f107, does an 81 day ave, sets f107a too
\param f107_contents contents from the f107 file (time, f107, etc.)
*
*/
//
This is the method for setting f107 specifically:
void
set_f107
(index_file_output_struct f107_contents);
/*
*************************************************************
\brief set the index array into the indices class
\param index_id which index is being checked in (bx, by, kp, ae, etc)
\param time vector of time for each index value
\param values vector of values for each index value
\param missing value for missing data
*
*/
bool
set_index
(
int
index_id,
std::vector<
double
> time,
std::vector<
float
> values,
precision_t
missing);
/*
*************************************************************
\brief set the index array into the indices class
\param index_name which index is being checked in (bx, by, kp, ae, etc)
\param time vector of time for each index value
\param values vector of values for each index value
\param missing value for missing data
*
*/
bool
set_index
(std::string index_name,
std::vector<
double
> timearray,
std::vector<
float
> indexarray,
precision_t
missing);
/*
*************************************************************
\brief Perturbs the indices requested by user input
*
*/
bool
perturb
();
/*
*************************************************************
\brief Perturbs the specific indices based on the user input
\param iIndex which index to perturb
\param seed random seed for perturbations
\param style characteristics of the perturbations (+/*, mean/std, const)
\param DoReport output information if true
*
*/
void
perturb_index
(
int
iIndex,
int
seed, json style,
bool
DoReport);
/*
*************************************************************
\brief Re-Perturbs the specific indices based on old values and the new value
\param iIndex which index to perturb
\param unperturbedValue unperturbed value (value read in at start))
\param perturbedValue value that the code has now
\param newValue value that the restart index file contains
*
*/
void
reperturb_index
(
int
iIndex,
precision_t
unperturbedValue,
precision_t
perturbedValue,
precision_t
newValue);
/*
*************************************************************
\brief The general function that returns the index value at the time
\param time the time in seconds that the index is requested at
\param the index to return (i.e., one of the constants defined above)
*
*/
precision_t
get_index
(
double
time,
int
index,
bool
useNonperturbed =
false
);
/*
*************************************************************
* \brief Get the name of the indices at the specified index
* \param iIndex which index to get name
* \return The string of name if the function succeeds, empty string if iIndex is out of range
*
*/
std::string
get_name
(
int
iIndex);
/*
*************************************************************
\brief Return the number of the indices vector
*
*/
int
all_indices_array_size
();
//
-----------------------------------------------------------------------
//
Private functions and variables
//
-----------------------------------------------------------------------
private:
//
/ structure containing information about the specific index:
struct
index_time_pair
{
//
/ the number of values in the vectors:
int64_t
nValues;
//
/ a vector of values for the index:
std::vector<
precision_t
> values;
std::vector<
precision_t
> originals;
//
/ a vector of times for the values:
std::vector<
double
> times;
//
/ the name of the index as a string:
std::string name;
bool
didPerturb;
bool
isAddPerturb;
bool
isConstantPerturb;
};
//
/ the vector that contains all of the indices vectors:
std::vector<index_time_pair> all_indices_arrays;
//
/ constants for keeping track of indices:
const
int
iF107_ =
0
;
const
int
iF107A_ =
1
;
const
int
iIMFBX_ =
2
;
const
int
iIMFBY_ =
3
;
const
int
iIMFBZ_ =
4
;
const
int
iSWVX_ =
5
;
const
int
iSWVY_ =
6
;
const
int
iSWVZ_ =
7
;
const
int
iSWN_ =
8
;
const
int
iSWT_ =
9
;
const
int
iAE_ =
10
;
const
int
iAL_ =
11
;
const
int
iAU_ =
12
;
//
/ number of indices that system is capable of keeping track of:
int
nIndices =
13
;
//
/ this will let us go back and forth between names and ids:
json indices_lookup;
};
#
endif
//
INCLUDE_INDICES_H_
Back
|
FazBrowse Home
|
New Git URL