OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
orbit.h
Go to the documentation of this file.
1 /*
2  *----------------------------------------------------------------------
3  * @(#) orbit.h 1.03 5 May 95 <shc>
4  * Copyright (c) 1993, CSIRO Division of Oceanography.
5  *----------------------------------------------------------------------
6  *
7  * Various structures, constants and macros used in the orbit
8  * package routines.
9  *
10  * History:
11  * 1.0 18 Oct 93 <shc>
12  * Initial version.
13  *
14  * 1.01 12 Dec 94 <shc>
15  * Added errstr stuff for integration with Python
16  *
17  * 1.02 27 Jan 95 <shc>
18  * Added SGP4 stuff.
19  *
20  * 1.03 5 May 95 <shc>
21  * Added TLE_VALUES struct and prototypes for tle.c
22  *
23  * 1.04 24 Jan 96 <shc>
24  * Modified SGP4 struct so secular rates are more accessible,
25  * changed rates from rad/min to rad/sec for conformance with
26  * package standards.
27  *
28  *----------------------------------------------------------------------
29  */
30 
31 #ifndef __ORBIT__
32 #define __ORBIT__
33 
34 #include <stdint.h>
35 #include <math.h>
36 #include <time.h>
37 #ifndef NULL
38 #include <stdio.h>
39 #endif
40 
41 #include "earth.h"
42 #include "lunsol.h"
43 
44 #define DPI 3.14159265358979323846
45 #define D2PI 6.28318530717958647692
46 #define D3PI 9.42477796076937971538
47 
48 #define FP_ERRVAL -1.0e-20 /* Error value from f.p. routines */
49 
50 /* Degrees to radians */
51 #define DTOR(X) ((X) * DPI/180.0)
52 
53 /* Radians to degrees */
54 #define RTOD(X) ((X) * 180.0/DPI)
55 
56 /* Fold an angle to the range [0..2 Pi] radians */
57 #define AN2PI(X) fmod(fmod((X), D2PI) + D2PI, D2PI)
58 
59 /* Fold an angle to the range [-Pi .. Pi] radians */
60 #define ANPI(X) (fmod(fmod((X), D2PI) + D3PI, D2PI) - DPI)
61 
62 /* Fold an angle to the range [0..360] degrees */
63 #define AN360(X) fmod(fmod((X), 360.0) + 360.0, 360.0)
64 
65 /* Arc-seconds to radians */
66 #define ASTOR(X) ((X) * DPI/(180.0 * 3600.0))
67 
68 /* Arc-seconds per century to radians per day */
69 #define ASPCTORPD(X) ((X) * DPI/(180.0 * 3600.0 * 36525.0))
70 
71 /* Epoch(s) in my time scheme (JD % 2400000) */
72 #define J2000 (51545.0)
73 
74 /*
75  * Struct for defining the attitude (orientation) of a satellite
76  * or satellite scanner vector. Angles are in radians.
77  */
78 
79 struct ATTITUDE {
80  double pitch;
81  double roll;
82  double yaw;
83 };
84 
85 /*
86  * Structure used by the Brouwer routines. The first 6 structure
87  * members, which are set by the user, are Brouwer mean elements.
88  * The remaining elements are initialised by blinit() for subsequent use by
89  * blosc(). Of these, only "darp", "dran" and "dman", which are the time
90  * derivatives of "arp", "ran" and "man", are independently useful.
91  */
92 
93 struct BROUWER {
94  double sma, /* Semi-major axis (metres) */
95  ecc, /* Eccentricity */
96  inc, /* Inclination (radians) */
97  arp, /* Argument of perigee (radians) */
98  ran, /* Right ascension of the ascending node (radians) */
99  man; /* Mean anomaly (radians) */
100 
101  double darp, /* Secular rate of "arp" (radians/sec) */
102  dran, /* Secular rate of "ran" (radians/sec) */
103  dman; /* Secular rate of "man" (radians/sec) */
104 
105  /* You really don't want to know about these. */
106  double a20, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10,
109 };
110 
111 /*
112  * Structure for specifying geodetic coordinates (e.g. an observer's
113  * location).
114  */
115 
116 struct GEODETIC {
117  double lat; /* Geodetic latitude (radians) */
118  double lon; /* Longitude (radians) */
119  double height; /* Height above the geoid (metres) */
120 };
121 
122 /*
123  * Structure for transfer of Keplerian orbital elements.
124  */
125 
126 struct KEPLER {
127  double sma, /* Semi-major axis (metres) */
128  ecc, /* Eccentricity */
129  inc, /* Inclination (radians) */
130  arp, /* Argument of perigee (radians) */
131  ran, /* Right ascension of the ascending node (radians) */
132  man; /* Mean anomaly (radians) */
133 };
134 
135 /*
136  * Structure for specifying nutation angles (radians).
137  */
138 struct NUTATION {
139  double mood; /* Mean obliquity of date */
140  double nutlon; /* Nutation in longitude */
141  double nutobl; /* Nutation in obliquity */
142 };
143 
144 /*
145  * Structure for specifying precession angles (radians).
146  */
147 struct PRECESSION {
148  double zeta;
149  double z;
150  double theta;
151 };
152 
153 /*
154  * Structure for specifying right ascension and declination (radians).
155  */
156 struct RADEC {
157  double ra;
158  double dec;
159 };
160 
161 /*
162  * Structure used by the SGP4 routines. The first 7 members are the
163  * orbital elements at epoch + the drag coefficient. The remaining
164  * members are initialised by sgp4_init() for subsequent use by
165  * sgp4_pred().
166  */
167 
168 struct SGP4 {
169  double xno, /* Mean motion (radians/sec) */
170  eo, /* Eccentricity */
171  xincl, /* Inclination (radians) */
172  omegao, /* Argument of perigee (radians) */
173  xnodeo, /* Longitude of ascending node (radians) */
174  xmo, /* Mean anomaly (radians) */
175  bstar; /* Drag coefficient */
176 
177  double omgdot, /* Secular rate of omega (radians/sec) */
178  xnodot, /* Secular rate of xnode (radians/sec) */
179  xmdot; /* Secular rate of xm (radians/sec) */
180 
181  /* You probably don't want to know about these. */
182  int isimp;
183  double aodp, aycof, c1, c1sq, c4, c5, cosio, d2, d3, d4, delmo,
186 };
187 
188 /*
189  * Two-line-element values. The function tle_parse() can be used to
190  * read the values from an element set into this structure.
191  */
192 
193 struct TLE_VALUES {
194  int satellite_number; /* NORAD satellite number */
195  char designator[9]; /* International designator */
196  int year; /* Last two digits of year */
197  double dayofyr; /* Day of year (1 origin) */
198  double mmdt; /* First derivative of mean motion */
199  double mmdt2; /* Second derivative of mean motion */
200  double bstar; /* B* drag term */
203  double incl; /* Inclination (deg) */
204  double raan; /* Right ascension of asc node (deg) */
205  double ecc; /* Eccentricity */
206  double argp; /* Argument of perigee (deg) */
207  double manom; /* Mean anomaly (deg) */
208  double mmotion; /* Mean motion (revs/day) */
209  int revolution; /* Epoch orbit number */
210 };
211 
212 /*
213  * Structure for specifying topocentric coordinates.
214  */
215 
216 struct TOPOCENTRIC {
217  double az; /* Azimuth (radians) */
218  double el; /* Elevation (radians) */
219  double range; /* Range (metres) */
220 };
221 
222 
223 
224 /*
225  * Function prototypes.
226  */
227 
228 /* brouwer.c */
229 int blinit(struct BROUWER *bp, char **errstr);
230 int blosc(struct BROUWER *bp, double delt, struct KEPLER *kp,
231  char **errstr);
232 
233 /* ctogd.c */
234 void ctogd(double r[3], double gha, struct GEODETIC *geod,
235  double dgeod[3][3]);
236 
237 /* ctok.c */
238 int ctok(double r[6], struct KEPLER *keplr, char **errmsg);
239 
240 /* ctotc.c */
241 void ctotc(double r[3], struct GEODETIC *obs, double gha,
242  struct TOPOCENTRIC *top, double daer[3][3]);
243 
244 /* eanom.c */
245 double eanom(double manom, double ecc, char **errstr);
246 
247 /* efitoeci.c */
248 int efitoeci(double r[6], double gha, double rp[6]);
249 
250 /* efrtoeci.c */
251 int efrtoeci(double r[6], double gha, double rp[6]);
252 
253 /* ecitoefi.c */
254 int ecitoefi(double r[6], double gha, double rp[6]);
255 
256 /* ecitoefr.c */
257 int ecitoefr(double r[6], double gha, double rp[6]);
258 
259 /* gmha.c */
260 double gmha(double tjd);
261 double gmhadot(double tjd);
262 
263 /* julian.c */
264 void caldat(int32_t julian, int *year, int *month, int *day);
265 double itojul(int32_t date, int32_t time);
266 int32_t julday(int year, int month, int day);
267 void jultoi(double tjd, int32_t *date, int32_t *time);
268 void jultotm(double tjd, struct tm *time);
269 double tmtojul(struct tm *time);
270 
271 /* ktoc.c */
272 int ktoc(struct KEPLER *kp, double r[6], char **errstr);
273 
274 /* ktosgp4.c */
275 int ktosgp4(struct KEPLER *kepler, struct SGP4 *sgp4, char **errmsg);
276 
277 /* locate.c */
278 int locate(double r[6], struct ATTITUDE *sat,
279  struct ATTITUDE *scanner, double loc[3]);
280 
281 /* moonpos.c */
282 void moonpos(double tjd, double r[3]);
283 
284 /* nutate.c */
285 void nut_angles(double tjd, struct NUTATION *angles, struct NUTATION *rates);
286 void nut_matrix(double tjd, double a[3][3]);
287 
288 /* obliq.c */
289 void obliq(double tjd, double *mood, double *dmood);
290 
291 /* precess.c */
292 void pre_angles(double tjd0, double tjd1, struct PRECESSION *angles);
293 void pre_reduce(double tjd0, struct RADEC *rad0,
294  double tjd1, struct RADEC *rad1);
295 
296 /* rdtotc.c */
297 void rdtotc(struct RADEC *rad, struct GEODETIC *obs,
298  double gmha, struct TOPOCENTRIC *top);
299 
300 /* refract.c */
301 double refract(double alt, double temp, double pressure);
302 double unrefract(double alt, double temp, double pressure);
303 
304 /* sgp4.c */
305 int sgp4_init(struct SGP4 *sgp4, char **errstr);
306 int sgp4_pred(struct SGP4 *sgp4, double tsince, double rect[6],
307  char **errstr);
308 double sgp4_orbit(struct SGP4 *sgp4, struct TLE_VALUES *tv, double tsince);
309 int sgp4_tle(double *epoch, struct SGP4 *sgp4, char *line1,
310  char *line2, char **errstr);
311 
312 /* sunpos.c */
313 int sunpos(double tjd, double r[3], char **errstr);
314 
315 /* tconv.c */
316 double tconv(double tjd, char conv[], char **errstr);
317 int tcset(double x, char what[], char **errstr);
318 
319 /* tle.c */
320 int tle_parse(char *line1, char *line2, struct TLE_VALUES *tv,
321  char **errstr);
322 
323 #endif /* __ORBIT__ */
double dec
Definition: orbit.h:158
int r
Definition: decode_rs.h:73
double b15
Definition: orbit.h:107
int ecitoefi(double r[6], double gha, double rp[6])
double c5
Definition: orbit.h:183
int ecitoefr(double r[6], double gha, double rp[6])
int ktosgp4(struct KEPLER *kepler, struct SGP4 *sgp4, char **errmsg)
void moonpos(double tjd, double r[3])
double sidp
Definition: orbit.h:108
double range
Definition: orbit.h:219
int32_t day
double c4
Definition: orbit.h:183
int isimp
Definition: orbit.h:182
double b2
Definition: orbit.h:106
double t3cof
Definition: orbit.h:184
double b1
Definition: orbit.h:106
double mmdt
Definition: orbit.h:198
double height
Definition: orbit.h:119
double omgdot
Definition: orbit.h:177
void pre_angles(double tjd0, double tjd1, struct PRECESSION *angles)
double b14
Definition: orbit.h:107
double ran
Definition: orbit.h:131
int tcset(double x, char what[], char **errstr)
double pitch
Definition: orbit.h:80
double xhdot1
Definition: orbit.h:185
double theta
Definition: orbit.h:150
double aodp
Definition: orbit.h:183
double ecc
Definition: orbit.h:95
double eta2
Definition: orbit.h:107
double gmhadot(double tjd)
Definition: gmha.c:78
double eo
Definition: orbit.h:170
double b6
Definition: orbit.h:106
double b7
Definition: orbit.h:106
double mmdt2
Definition: orbit.h:199
double itojul(int32_t date, int32_t time)
Definition: time-utils.c:100
double xmcof
Definition: orbit.h:185
double roll
Definition: orbit.h:81
double b9
Definition: orbit.h:106
float tm[MODELMAX]
double sinmo
Definition: orbit.h:184
double incl
Definition: orbit.h:203
double d3
Definition: orbit.h:183
Definition: orbit.h:93
double delmo
Definition: orbit.h:183
double xincl
Definition: orbit.h:171
double sma
Definition: orbit.h:127
int sgp4_pred(struct SGP4 *sgp4, double tsince, double rect[6], char **errstr)
double t4cof
Definition: orbit.h:184
double dayofyr
Definition: orbit.h:197
void nut_angles(double tjd, struct NUTATION *angles, struct NUTATION *rates)
void ctotc(double r[3], struct GEODETIC *obs, double gha, struct TOPOCENTRIC *top, double daer[3][3])
double x3thm1
Definition: orbit.h:185
int satellite_number
Definition: orbit.h:194
double cosio
Definition: orbit.h:183
double nutobl
Definition: orbit.h:141
int32_t julday(int year, int month, int day)
Definition: julian.c:37
double xnodcf
Definition: orbit.h:185
int revolution
Definition: orbit.h:209
double gmha(double tjd)
Definition: gmha.c:61
double manom
Definition: orbit.h:207
int ctok(double r[6], struct KEPLER *keplr, char **errmsg)
double el
Definition: orbit.h:218
int sgp4_tle(double *epoch, struct SGP4 *sgp4, char *line1, char *line2, char **errstr)
double xnodp
Definition: orbit.h:185
int element_number
Definition: orbit.h:202
void ctogd(double r[3], double gha, struct GEODETIC *geod, double dgeod[3][3])
Definition: orbit.h:126
double sidph
Definition: orbit.h:108
double d4
Definition: orbit.h:183
double b10
Definition: orbit.h:106
double raan
Definition: orbit.h:204
double t5cof
Definition: orbit.h:184
char designator[9]
Definition: orbit.h:195
double dran
Definition: orbit.h:102
double arp
Definition: orbit.h:97
subroutine kepler(AM, E, EA, SE, CE)
Definition: kepler.f:2
double arp
Definition: orbit.h:130
double eanom(double manom, double ecc, char **errstr)
Definition: eanom.c:53
void jultoi(double tjd, int32_t *date, int32_t *time)
Definition: time-utils.c:134
double dman
Definition: orbit.h:103
double omgcof
Definition: orbit.h:184
double man
Definition: orbit.h:132
double eta
Definition: orbit.h:107
int blosc(struct BROUWER *bp, double delt, struct KEPLER *kp, char **errstr)
int ephem_type
Definition: orbit.h:201
void rdtotc(struct RADEC *rad, struct GEODETIC *obs, double gmha, struct TOPOCENTRIC *top)
int efitoeci(double r[6], double gha, double rp[6])
double az
Definition: orbit.h:217
double a20
Definition: orbit.h:106
double argp
Definition: orbit.h:206
double ran
Definition: orbit.h:98
double zeta
Definition: orbit.h:148
double eta
Definition: orbit.h:184
double xmdot
Definition: orbit.h:179
double mood
Definition: orbit.h:139
double aycof
Definition: orbit.h:183
double xno
Definition: orbit.h:169
double ecc
Definition: orbit.h:205
double lon
Definition: orbit.h:118
Definition: orbit.h:156
double b8
Definition: orbit.h:106
double xlcof
Definition: orbit.h:185
double theta
Definition: orbit.h:108
double nutlon
Definition: orbit.h:140
double sgp4_orbit(struct SGP4 *sgp4, struct TLE_VALUES *tv, double tsince)
double c1
Definition: orbit.h:183
double omegao
Definition: orbit.h:172
int locate(double r[6], struct ATTITUDE *sat, struct ATTITUDE *scanner, double loc[3])
double x1mth2
Definition: orbit.h:185
double edp2
Definition: orbit.h:107
double sinio
Definition: orbit.h:184
double inc
Definition: orbit.h:129
double b5
Definition: orbit.h:106
double yaw
Definition: orbit.h:82
double b12
Definition: orbit.h:107
double xmo
Definition: orbit.h:174
double tconv(double tjd, char conv[], char **errstr)
double man
Definition: orbit.h:99
double b3
Definition: orbit.h:106
subroutine pressure(uw, uo3, xps)
Definition: 6sm1.f:6248
data_t loc[NROOTS]
Definition: decode_rs.h:78
double ecc
Definition: orbit.h:128
Definition: orbit.h:168
double b11
Definition: orbit.h:107
double refract(double alt, double temp, double pressure)
double xnodeo
Definition: orbit.h:173
double inc
Definition: orbit.h:96
double darp
Definition: orbit.h:101
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start time
Definition: HISTORY.txt:248
double gmp2
Definition: orbit.h:108
double c1sq
Definition: orbit.h:183
double b4
Definition: orbit.h:106
int blinit(struct BROUWER *bp, char **errstr)
void obliq(double tjd, double *mood, double *dmood)
Definition: obliq.c:35
int bp[2]
void nut_matrix(double tjd, double a[3][3])
double eta6
Definition: orbit.h:108
double unrefract(double alt, double temp, double pressure)
double eta3
Definition: orbit.h:107
double x7thm1
Definition: orbit.h:185
double cidph
Definition: orbit.h:108
double xnodot
Definition: orbit.h:178
double z
Definition: orbit.h:149
void pre_reduce(double tjd0, struct RADEC *rad0, double tjd1, struct RADEC *rad1)
int year
Definition: orbit.h:196
integer function julian(DAY, MONTH, YEAR)
Definition: julian.f:2
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] angles
Definition: HISTORY.txt:366
double ra
Definition: orbit.h:157
double gm2
Definition: orbit.h:108
double sma
Definition: orbit.h:94
int tle_parse(char *line1, char *line2, struct TLE_VALUES *tv, char **errstr)
int efrtoeci(double r[6], double gha, double rp[6])
void jultotm(double tjd, struct tm *time)
Definition: time-utils.c:62
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
double theta2
Definition: orbit.h:108
double lat
Definition: orbit.h:117
int sunpos(double tjd, double r[3], char **errstr)
double bstar
Definition: orbit.h:175
double bstar
Definition: orbit.h:200
double tmtojul(struct tm *time)
Definition: time-utils.c:32
int sgp4_init(struct SGP4 *sgp4, char **errstr)
double d2
Definition: orbit.h:183
Definition: orbit.h:79
int ktoc(struct KEPLER *kp, double r[6], char **errstr)
double mmotion
Definition: orbit.h:208
double t2cof
Definition: orbit.h:184
double b13
Definition: orbit.h:107
void caldat(int32_t julian, int *year, int *month, int *day)
Definition: julian.c:75