1 | /* -----------------------------------------------------------------------------
|
---|
2 | *
|
---|
3 | * Function : djul
|
---|
4 | *
|
---|
5 | * Purpose : computes the modified julian date (mjd) from
|
---|
6 | * year, month and day
|
---|
7 | *
|
---|
8 | * Author : Z. Lukes
|
---|
9 | *
|
---|
10 | * Created : 13-OCT-2001
|
---|
11 | *
|
---|
12 | * Changes :
|
---|
13 | *
|
---|
14 | * ---------------------------------------------------------------------------*/
|
---|
15 |
|
---|
16 | #include <math.h>
|
---|
17 |
|
---|
18 | double djul(long jj, long mm, double tt) {
|
---|
19 | long ii, kk;
|
---|
20 | double djul ;
|
---|
21 |
|
---|
22 | if( mm <= 2 ) {
|
---|
23 | jj = jj - 1;
|
---|
24 | mm = mm + 12;
|
---|
25 | }
|
---|
26 |
|
---|
27 | ii = jj/100;
|
---|
28 | kk = 2 - ii + ii/4;
|
---|
29 | djul = (365.25*jj - fmod( 365.25*jj, 1.0 )) - 679006.0;
|
---|
30 | djul = djul + floor( 30.6001*(mm + 1) ) + tt + kk;
|
---|
31 | return djul;
|
---|
32 | }
|
---|
33 |
|
---|
34 | /* -----------------------------------------------------------------------------
|
---|
35 | *
|
---|
36 | * Function : gpjd
|
---|
37 | *
|
---|
38 | * Purpose : computes the modified julian date (mjd) from
|
---|
39 | * gpsweek number and number of seconds past last
|
---|
40 | * saturday/sunday midnight
|
---|
41 | *
|
---|
42 | * Author : Z. Lukes
|
---|
43 | *
|
---|
44 | * Created : 13-OCT-2001
|
---|
45 | *
|
---|
46 | * Changes :
|
---|
47 | *
|
---|
48 | * ---------------------------------------------------------------------------*/
|
---|
49 |
|
---|
50 | double gpjd(double second, int nweek) {
|
---|
51 | double deltat;
|
---|
52 |
|
---|
53 | // days since starting epoch of gps weeks (sunday 06-jan-80)
|
---|
54 |
|
---|
55 | deltat = nweek*7.0 + second/86400.0 ;
|
---|
56 |
|
---|
57 | // mod. julian date
|
---|
58 |
|
---|
59 | return( 44244.0 + deltat) ;
|
---|
60 | }
|
---|
61 |
|
---|
62 | /* -----------------------------------------------------------------------------
|
---|
63 | *
|
---|
64 | * Function : jdgp
|
---|
65 | *
|
---|
66 | * Purpose : compute number of seconds past midnight of last
|
---|
67 | * saturday/sunday and gps week number of current
|
---|
68 | * date given in modified julian date
|
---|
69 | *
|
---|
70 | * Author : Z. Lukes
|
---|
71 | *
|
---|
72 | * Created : 13-OCT-2001
|
---|
73 | *
|
---|
74 | * Changes :
|
---|
75 | *
|
---|
76 | * ---------------------------------------------------------------------------*/
|
---|
77 |
|
---|
78 | void jdgp(double tjul, double & second, long & nweek) {
|
---|
79 | double deltat;
|
---|
80 |
|
---|
81 | deltat = tjul - 44244.0 ;
|
---|
82 |
|
---|
83 | // current gps week
|
---|
84 |
|
---|
85 | nweek = (long) floor(deltat/7.0);
|
---|
86 |
|
---|
87 | // seconds past midnight of last weekend
|
---|
88 |
|
---|
89 | second = (deltat - (nweek)*7.0)*86400.0;
|
---|
90 |
|
---|
91 | }
|
---|
92 |
|
---|
93 | /* -----------------------------------------------------------------------------
|
---|
94 | *
|
---|
95 | * Function : djul
|
---|
96 | *
|
---|
97 | * Purpose : compute year,month,day of month from
|
---|
98 | * modified julian date (mjd=jul. date-2400000.5)
|
---|
99 | *
|
---|
100 | * Author : Z. Lukes
|
---|
101 | *
|
---|
102 | * Created : 13-OCT-2001
|
---|
103 | *
|
---|
104 | * Changes :
|
---|
105 | *
|
---|
106 | * ---------------------------------------------------------------------------*/
|
---|
107 |
|
---|
108 | void jmt(double djul, long& jj, long& mm, double& dd) {
|
---|
109 | long ih, ih1, ih2 ;
|
---|
110 | double t1, t2, t3, t4;
|
---|
111 |
|
---|
112 | t1 = 1.0 + djul - fmod( djul, 1.0 ) + 2400000.0;
|
---|
113 | t4 = fmod( djul, 1.0 );
|
---|
114 | ih = long( (t1 - 1867216.25)/36524.25 );
|
---|
115 | t2 = t1 + 1 + ih - ih/4;
|
---|
116 | t3 = t2 - 1720995.0;
|
---|
117 | ih1 = long( (t3 - 122.1)/365.25 );
|
---|
118 | t1 = 365.25*ih1 - fmod( 365.25*ih1, 1.0 );
|
---|
119 | ih2 = long( (t3 - t1)/30.6001 );
|
---|
120 | dd = t3 - t1 - (int)( 30.6001*ih2 ) + t4;
|
---|
121 | mm = ih2 - 1;
|
---|
122 |
|
---|
123 | if ( ih2 > 13 ) mm = ih2 - 13;
|
---|
124 |
|
---|
125 | jj = ih1;
|
---|
126 |
|
---|
127 | if ( mm <= 2 ) jj = jj + 1;
|
---|
128 |
|
---|
129 | }
|
---|