🛰️航天仿真算法库 SpaceAST
0.0.1
载入中...
搜索中...
未找到
DTM_12.h
1
#ifndef SWIG
2
#ifndef _DTM_12_h_
3
#define _DTM_12_h_
4
/* ----------------------------------------------------------------
5
*
6
* DTM_12.h
7
*
8
* this file contains routines for the dtm-2012 atmospheric model
9
*
10
* (w) 719-573-2600, email dvallado@agi.com
11
*
12
* *****************************************************************
13
*
14
* current :
15
* 30 sep 15 david vallado
16
* fix jd, jdfrac
17
* changes :
18
* 3 nov 14 david vallado
19
* update to msvs2013 c++
20
* 6 aug 13 david vallado
21
* conversion to c ++
22
* 10 may 13 sean bruinsma
23
* original baseline
24
* ***************************************************************** */
25
26
#include <math.h>
27
#if defined(_WIN32)
28
#include <io.h>
29
#endif
30
#include <stdio.h>
31
#include <stdlib.h>
32
#include <string.h>
33
#include "AstGlobal.h"
34
35
// cdav increment all by one to start at 1 instead of 0
36
// create a struct for the numebrs since they don't seem to work as globals in c++
37
typedef
struct
dtmindextype
38
{
39
static
const
int
Nb_lat = 7;
40
static
const
int
Nb_flux = 13;
41
static
const
int
Nb_kp = 16;
42
static
const
int
Nb_SLat = 3;
43
static
const
int
Nb_SASLat = 3;
44
static
const
int
Nb_NSLat = 4;
45
static
const
int
Nb_SANSLat = 4;
46
static
const
int
Nb_DiAn = 13;
47
static
const
int
Nb_SDiAn = 13;
48
static
const
int
Nb_TDi = 3;
49
static
const
int
Nb_AMg = 10;
50
static
const
int
Nb_Lon = 11;
// old 11
51
static
const
int
Nb_dPhas = 5;
52
}
dtmindextype
;
53
54
static
const
int
Nb_lat = 7;
55
static
const
int
Nb_flux = 13;
56
static
const
int
Nb_kp = 16;
57
static
const
int
Nb_SLat = 3;
58
static
const
int
Nb_SASLat = 3;
59
static
const
int
Nb_NSLat = 4;
60
static
const
int
Nb_SANSLat = 4;
61
static
const
int
Nb_DiAn = 13;
62
static
const
int
Nb_SDiAn = 13;
63
static
const
int
Nb_TDi = 3;
64
static
const
int
Nb_AMg = 10;
65
static
const
int
Nb_Lon = 11;
// only difference
66
static
const
int
Nb_dPhas = 5;
67
68
69
// double DTM_12_T_one; // SUM(T_x * T_dx) except T_dPhas
70
// double DTM_12_T_lat[Nb_lat]; // in latitude
71
// double DTM_12_T_flux[Nb_flux]; // in flux
72
// double DTM_12_T_kp[Nb_kp]; // in kp
73
// double DTM_12_T_SLat[Nb_SLat]; // annual & symetric in latitude
74
// double DTM_12_T_SASLat[Nb_SASLat]; // semi-annual & symetric in latitude
75
// double DTM_12_T_NSLat[Nb_NSLat]; // annual & non-symetric in latitude
76
// double DTM_12_T_SANSLat[Nb_SANSLat]; // semi-annual non-symetric in latitude
77
// double DTM_12_T_DiAn[Nb_DiAn]; // diurnal (& annual coupled)
78
// double DTM_12_T_SDiAn[Nb_SDiAn]; // semi-diurnal (& annual coupled)
79
// double DTM_12_T_TDi[Nb_TDi]; // ter-diurnal
80
// double DTM_12_T_AMg[Nb_AMg]; // activity (Magnetic)
81
// double DTM_12_T_Lon[Nb_Lon]; // in longitude
82
// double DTM_12_T_dPhas[Nb_dPhas]; // derivative of phases of the annual and semi-annual terms
83
84
typedef
struct
DTM_12type
85
{
86
double
T_one, T_lat[Nb_lat], T_flux[Nb_flux], T_kp[Nb_kp], T_SLat[Nb_SLat], T_SASLat[Nb_SASLat],
87
T_NSLat[Nb_NSLat], T_SANSLat[Nb_SANSLat], T_DiAn[Nb_DiAn], T_SDiAn[Nb_SDiAn], T_TDi[Nb_TDi],
88
T_AMg[Nb_AMg], T_Lon[Nb_Lon], T_dPhas[Nb_dPhas];
89
}
DTM_12type
;
90
91
// double ddtm_12_T_one; // SUM(T_x * T_dx) except T_dPhas
92
// double ddtm_12_T_lat[Nb_lat]; // in latitude
93
// double ddtm_12_T_flux[Nb_flux]; // in flux
94
// double ddtm_12_T_kp[Nb_kp]; // in kp
95
// double ddtm_12_T_SLat[Nb_SLat]; // annual & symetric in latitude
96
// double ddtm_12_T_SASLat[Nb_SASLat]; // semi-annual & symetric in latitude
97
// double ddtm_12_T_NSLat[Nb_NSLat]; // annual & non-symetric in latitude
98
// double ddtm_12_T_SANSLat[Nb_SANSLat]; // semi-annual non-symetric in latitude
99
// double ddtm_12_T_DiAn[Nb_DiAn]; // diurnal (& annual coupled)
100
// double ddtm_12_T_SDiAn[Nb_SDiAn]; // semi-diurnal (& annual coupled)
101
// double ddtm_12_T_TDi[Nb_TDi]; // ter-diurnal
102
// double ddtm_12_T_AMg[Nb_AMg]; // activity (Magnetic)
103
// double ddtm_12_T_Lon[Nb_Lon]; // in longitude
104
// double ddtm_12_T_dPhas[Nb_dPhas]; // derivative of phases of the annual and semi-annual terms
105
106
typedef
struct
ddtm_12type
107
{
108
double
T_one, T_lat[Nb_lat], T_flux[Nb_flux], T_kp[Nb_kp], T_SLat[Nb_SLat], T_SASLat[Nb_SASLat],
109
T_NSLat[Nb_NSLat], T_SANSLat[Nb_SANSLat], T_DiAn[Nb_DiAn], T_SDiAn[Nb_SDiAn], T_TDi[Nb_TDi],
110
T_AMg[Nb_AMg], T_Lon[Nb_Lon], T_dPhas[Nb_dPhas];
111
}
ddtm_12type
;
112
113
//.. Common Blocks ..
114
typedef
struct
plgdtmtype
115
{
116
double
p10, p20, p30, p40, p50, p60, p11, p21, p31, p41, p51, p22, p32, p42, p52,
117
p62, p33, p10mg, p20mg, p40mg;
118
}
plgdtmtype
;
119
120
typedef
struct
constype
121
{
122
double
deupi, cdr, sard;
123
}
constype
;
124
125
typedef
struct
datmotype
126
{
127
int
npara, itype, ilin;
128
}
datmotype
;
129
130
typedef
struct
eclipttype
131
{
132
double
cecl, secl, c2ecl, s2ecl, c3ecl, s3ecl, p10ecl, p20ecl, p30ecl,
133
p40ecl, p50ecl, p11ecl, p21ecl, p31ecl, p41ecl, p51ecl, p22ecl,
134
p32ecl, p42ecl, p52ecl, p33ecl;
135
}
eclipttype
;
136
137
typedef
struct
hlocaltype
138
{
139
double
hl0, ch, sh, c2h, s2h, c3h, s3h;
140
}
hlocaltype
;
141
142
typedef
struct
pardtmtype
143
{
144
DTM_12type
tt, h, he, ox, az2, o2, az, t0, tp;
145
ddtm_12type
dtt, dh, dhe, dox, daz2, do2, daz, dt0, dtp;
146
}
pardtmtype
;
147
148
149
// additional type definitions
150
//
151
//Custom type definitions
152
//These types contain all the data which is read directly from input files
153
// cdav don't need todaytype as the dtm_daterecordtype does this?
154
//typedef struct todaytype
155
//{
156
// int day, month, year, hour, minute, type_flag;
157
// double second;
158
//} todaytype;
159
160
//>@brief Structure to store data from solar flux "f" file
161
typedef
struct
f_structtype
162
{
163
int
year;
//< Year
164
int
month;
//< Month
165
int
day;
//< Day
166
double
f;
//< F from file
167
double
fbar;
//< FBAR from file
168
}
f_structtype
;
169
170
//>@brief Structure to store data from geomagnetic "a" file
171
// increment by 1 to have the same indices the same between languages
172
typedef
struct
a_structtype
173
{
174
int
year;
//< Year
175
int
month;
//< Month
176
int
day;
//< Day
177
int
dayofyear;
//< Day of year (1-366)
178
int
mean_am;
//< Mean value of a_m
179
int
am[9];
//< The eight a_m values in each line of the file
180
}
a_structtype
;
181
182
//> @brief Structure to hold the date input by the user
183
//>This type allows the user to enter either a MJD2000 date or a day/month/year hh:mm:sec
184
//>date, without the need of passing a large number of parameters.
185
//>The user must set a type_flag and the required variables
186
//>Unused variables do not need to be initialized
187
typedef
struct
dtm_daterectype
188
{
189
int
type_flag;
//<1 for MJD2000 date, 2 for calendar date
190
double
mjd2000;
//< Date in MJD2000
191
int
day;
//< Day
192
int
month;
//< Month
193
int
year;
//< Year
194
int
hour;
//< Hour
195
int
minute;
//< Minute
196
double
second;
//< Seconds
197
}
dtm_daterectype
;
198
199
// store the uncertainty parameters
200
typedef
struct
dtm_unctype
201
{
202
double
nomgrid[25][19], kp_scale[25][19], alt_scale[25][19];
203
}
dtm_unctype
;
204
205
206
#pragma once
207
208
// version : 2012
209
// #define pi 3.14159265358979323846
210
211
namespace
DTM_12 {
212
213
// public ref class DTM_12Cl
214
// {
215
216
// make sure they are all visible
217
// public:
218
219
// ---------------- routines ----------------
220
AST_WEATHER_API
221
void
dtm2012
222
(
223
plgdtmtype
& plgdtm,
hlocaltype
& hlocal,
eclipttype
& eclipt,
datmotype
& datmo,
constype
& cons,
pardtmtype
& pardtm,
224
double
day,
double
f[3],
double
fbar[3],
double
akp[5],
double
hellp,
double
hl,
double
latgd,
double
lon,
225
double
& tz,
double
& tinf,
double
& tp120,
double
& ro,
double
d[7],
double
& wmm
226
);
227
228
229
AST_WEATHER_API
230
void
density_uncertainty
231
(
232
double
nomgrid[25][19],
double
alt_scale[25][19],
double
kp_scale[25][19],
233
double
hellp,
double
latgd,
double
lst,
double
flux,
double
kp,
234
double
& unc
235
);
236
237
AST_WEATHER_API
238
void
gldtm_XX
239
(
240
plgdtmtype
& plgdtm,
hlocaltype
& hlocal,
datmotype
& datmo,
241
double
f[3],
double
fbar[3],
double
akp[5],
double
day,
DTM_12type
& DTM_12,
ddtm_12type
& ddtm_12,
242
double
& gdel,
double
ff0,
double
lon
243
);
244
245
246
// additional routines used by DTM
247
248
double
a2K
249
(
250
double
a
251
);
252
253
double
local_solar_time
254
(
255
double
longitude,
int
hour,
int
minute,
double
sec
256
);
257
258
int
leap_day
259
(
260
int
year
261
);
262
263
double
linear_interpolation
264
(
265
double
x1,
double
y1,
double
x2,
double
y2,
double
x
266
);
267
268
double
hms2hr
269
(
270
int
hr,
int
mins,
double
sec
271
);
272
273
int
day_of_year
274
(
275
int
day,
int
month,
int
year
276
);
277
278
bool
mdyhms_ok
279
(
280
int
day,
int
month,
int
year,
int
hour,
int
minute,
281
double
second
282
);
283
284
void
DJ2000
285
(
286
double
MJDay,
int
& year,
int
& mon,
int
& day,
int
& hr,
int
& minute,
double
& sec
287
);
288
289
void
JD2000
290
(
291
double
& MJDay,
int
year,
int
month,
int
day,
int
hr,
int
minute,
double
sec
292
);
293
294
void
fatal_error
295
(
296
int
code
297
);
298
299
void
warning
300
(
301
int
code
302
);
303
304
void
process_input_date
305
(
306
dtm_daterectype
& in_date
307
);
308
309
310
AST_WEATHER_API
311
void
InitSPW
312
(
313
char
path_to_a_file[100],
char
path_to_f_file[100],
int
& number_of_lines_in_a_file,
314
int
& number_of_lines_in_f_file,
a_structtype
a_indexes[3000],
f_structtype
f_indexes[3000]
315
);
316
317
318
AST_WEATHER_API
319
void
DTMInit
320
(
321
char
PATH_TO_DEN_UNC_1[100],
char
PATH_TO_DEN_UNC_2[100],
char
PATH_TO_DEN_UNC_3[100],
322
char
PATH_TO_DTM2012_IN_FILE[100],
char
PATH_TO_DTM2012_OUT_FILE[100],
int
IVERIF,
323
double
nomgrid[25][19],
double
kp_scale[25][19],
double
alt_scale[25][19],
324
pardtmtype
& pardtm
325
);
326
327
AST_WEATHER_API
328
void
dtm_wrapper
329
(
330
dtm_daterectype
& in_date,
double
lon,
int
number_of_lines_in_a_file,
int
number_of_lines_in_f_file,
331
a_structtype
a_indexes[3000],
f_structtype
f_indexes[3000],
332
double
f[3],
double
fbar[3],
double
akp[5],
double
& dayofyear,
double
& hl
333
);
334
335
336
// }; // class
337
338
};
// namespace
339
340
#endif
341
#endif
DTM_12type
定义
DTM_12.h:85
a_structtype
定义
DTM_12.h:173
constype
定义
DTM_12.h:121
datmotype
定义
DTM_12.h:126
ddtm_12type
定义
DTM_12.h:107
dtm_daterectype
定义
DTM_12.h:188
dtm_unctype
定义
DTM_12.h:201
dtmindextype
定义
DTM_12.h:38
eclipttype
定义
DTM_12.h:131
f_structtype
定义
DTM_12.h:162
hlocaltype
定义
DTM_12.h:138
pardtmtype
定义
DTM_12.h:143
plgdtmtype
定义
DTM_12.h:115
src
AstWeather
Atmosphere
DTM_12
DTM_12.h
制作者
1.12.0