Aether  0.0
Ionosphere-Thermosphere model
indices.h
1 // Copyright 2020, the Aether Development Team (see doc/dev_team.md for members)
2 // Full license can be found in License.md
3 
4 #ifndef INCLUDE_INDICES_H_
5 #define INCLUDE_INDICES_H_
6 
7 /**************************************************************
8  * \class Indices
9  *
10  * \brief A class for keeping track of indices (1d vectors w/time)
11 
12  This is a class that allows users to read in and keep track of
13  indices, such as IMF Bz, Kp, AE, F107, etc. These are often needed
14  to drive other sub models, such as EUVAC, MSIS, Weimer, etc. Basically,
15  the way you use this is to:
16  - read a file (custom for each type of file)
17  - get the proper index number
18  - call the set_index function with the time and values array
19  - call the appropriate get function with time to get index value at time
20 
21  * \author Aaron Ridley
22  *
23  * \date 2021/04/16
24  **************************************************************/
25 
26 #include <vector>
27 #include <string>
28 
32 
34 
36  int64_t nTimes;
37 
39  std::vector<double> times;
40 
42  int nVars;
43 
45  std::vector<std::string> var_names;
46 
48  std::vector<std::vector<float>> values;
49 
51  std::vector<float> missing_values;
52 
54  std::vector<int> index_id;
55 };
56 
57 /**************************************************************
58  \brief Print out information in the structure for debugging
59  \param contents structure containing the index file output
60  **/
61 void print_index_file_output_struct(index_file_output_struct contents);
62 
63 class Indices {
64 
65 // -----------------------------------------------------------------------
66 // Public functions and variables
67 // -----------------------------------------------------------------------
68 
69  public:
70 
71  /**************************************************************
72  \brief Initialize the class
73  \param args info about how user has configured things
74  **/
75  Indices(Inputs args);
76 
77  /**************************************************************
78  \brief get the daily f107 value at the given time
79  \param time time in seconds
80  **/
81  precision_t get_f107(double time);
82 
83  /**************************************************************
84  \brief get the 81-day average f107 at the given time
85  \param time time in seconds
86  **/
87  precision_t get_f107a(double time);
88 
89  /**************************************************************
90  \brief a series of functions that return the internal index number
91 
92  In order to keep track of which index is which, the class uses
93  constants. These functions return these constants. The user doesn't
94  really need to know about the constants, but they have to get the
95  constant (when reading the file, for example) and then provide that
96  to the set index function. Conversely, we could create a bunch of
97  set_ functions (such as the set_f107 function below). We figured
98  that this minor inconvience is easier than making a bunch of set_
99  functions.
100 
101  **/
102  int get_f107_index_id();
103  int get_f107a_index_id();
104  int get_imfbx_index_id();
105  int get_imfby_index_id();
106  int get_imfbz_index_id();
107  int get_swvx_index_id();
108  int get_swvy_index_id();
109  int get_swvz_index_id();
110  int get_swn_index_id();
111  int get_swt_index_id();
112  int get_ae_index_id();
113  int get_au_index_id();
114  int get_al_index_id();
115 
116  /**************************************************************
117  \brief This function sets the f107, does an 81 day ave, sets f107a too
118  \param f107_contents contents from the f107 file (time, f107, etc.)
119  **/
120  // This is the method for setting f107 specifically:
121  void set_f107(index_file_output_struct f107_contents);
122 
123  /**************************************************************
124  \brief set the index array into the indices class
125  \param index_id which index is being checked in (bx, by, kp, ae, etc)
126  \param time vector of time for each index value
127  \param values vector of values for each index value
128  \param missing value for missing data
129  **/
130  void set_index(int index_id,
131  std::vector<double> time,
132  std::vector<float> values,
133  precision_t missing);
134 
135 // -----------------------------------------------------------------------
136 // Private functions and variables
137 // -----------------------------------------------------------------------
138 
139 private:
140 
142  struct index_time_pair {
143 
145  int64_t nValues;
146 
148  std::vector<float> values;
149 
151  std::vector<double> times;
152 
154  std::string name;
155  };
156 
158  std::vector<index_time_pair> all_indices_arrays;
159 
161  const int iF107_ = 0;
162  const int iF107A_ = 1;
163  const int iIMFBX_ = 2;
164  const int iIMFBY_ = 3;
165  const int iIMFBZ_ = 4;
166  const int iSWVX_ = 5;
167  const int iSWVY_ = 6;
168  const int iSWVZ_ = 7;
169  const int iSWN_ = 8;
170  const int iSWT_ = 9;
171  const int iAE_ = 10;
172  const int iAL_ = 11;
173  const int iAU_ = 12;
175  int nIndices = 13;
176 
177  /**************************************************************
178  \brief The general function that returns the index value at the time
179  \param time the time in seconds that the index is requested at
180  \param the index to return (i.e., one of the constants defined above)
181  **/
182  precision_t get_index(double time, int index);
183 };
184 
185 
186 #endif // INCLUDE_INDICES_H_
index_file_output_struct::nVars
int nVars
number of variables read in:
Definition: indices.h:59
index_file_output_struct
Definition: indices.h:33
index_file_output_struct::values
std::vector< std::vector< float > > values
a 2d vector (vars vs times) of indices values:
Definition: indices.h:65
Inputs
Definition: inputs.h:10
index_file_output_struct::missing_values
std::vector< float > missing_values
a vector of missing values for each variable:
Definition: indices.h:68
index_file_output_struct::var_names
std::vector< std::string > var_names
variable names as a vector of strings:
Definition: indices.h:62
index_file_output_struct::times
std::vector< double > times
array of times that correspond to the values:
Definition: indices.h:56
index_file_output_struct::index_id
std::vector< int > index_id
The index_id returned by the call to get_XXX_index_id:
Definition: indices.h:71
index_file_output_struct::nTimes
int64_t nTimes
number of times read in:
Definition: indices.h:53
Indices
Definition: indices.h:63