@@ -12,26 +12,26 @@ |
||
12 | 12 | */ |
13 | 13 | class Predict_PassDetail |
14 | 14 | { |
15 | - public $time; /*!< time in "jul_utc" */ |
|
16 | - public $pos; /*!< Raw unprocessed position at time */ |
|
17 | - public $vel; /*!< Raw unprocessed velocity at time */ |
|
18 | - public $velo; |
|
19 | - public $az; |
|
20 | - public $el; |
|
21 | - public $range; |
|
22 | - public $range_rate; |
|
23 | - public $lat; |
|
24 | - public $lon; |
|
25 | - public $alt; |
|
26 | - public $ma; |
|
27 | - public $phase; |
|
28 | - public $footprint; |
|
29 | - public $vis; |
|
30 | - public $orbit; |
|
15 | + public $time; /*!< time in "jul_utc" */ |
|
16 | + public $pos; /*!< Raw unprocessed position at time */ |
|
17 | + public $vel; /*!< Raw unprocessed velocity at time */ |
|
18 | + public $velo; |
|
19 | + public $az; |
|
20 | + public $el; |
|
21 | + public $range; |
|
22 | + public $range_rate; |
|
23 | + public $lat; |
|
24 | + public $lon; |
|
25 | + public $alt; |
|
26 | + public $ma; |
|
27 | + public $phase; |
|
28 | + public $footprint; |
|
29 | + public $vis; |
|
30 | + public $orbit; |
|
31 | 31 | |
32 | - public function __construct() |
|
33 | - { |
|
34 | - $this->pos = new Predict_Vector(); |
|
35 | - $this->vel = new Predict_Vector(); |
|
36 | - } |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + $this->pos = new Predict_Vector(); |
|
35 | + $this->vel = new Predict_Vector(); |
|
36 | + } |
|
37 | 37 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | */ |
6 | 6 | class Predict_ObsSet |
7 | 7 | { |
8 | - public $az = 0.0; /*!< Azimuth [deg] */ |
|
9 | - public $el = 0.0; /*!< Elevation [deg] */ |
|
10 | - public $range = 0.0; /*!< Range [km] */ |
|
11 | - public $range_rate = 0.0; /*!< Velocity [km/sec] */ |
|
8 | + public $az = 0.0; /*!< Azimuth [deg] */ |
|
9 | + public $el = 0.0; /*!< Elevation [deg] */ |
|
10 | + public $range = 0.0; /*!< Range [km] */ |
|
11 | + public $range_rate = 0.0; /*!< Velocity [km/sec] */ |
|
12 | 12 | } |
@@ -12,221 +12,221 @@ |
||
12 | 12 | */ |
13 | 13 | class Predict_TLE |
14 | 14 | { |
15 | - public $header; /* Header line of TLE file */ |
|
16 | - public $line1; /* Line 1 of TLE */ |
|
17 | - public $line2; /* Line 2 of TLE */ |
|
18 | - public $epoch; /*!< Epoch Time in NORAD TLE format YYDDD.FFFFFFFF */ |
|
19 | - public $epoch_year; /*!< Epoch: year */ |
|
20 | - public $epoch_day; /*!< Epoch: day of year */ |
|
21 | - public $epoch_fod; /*!< Epoch: Fraction of day. */ |
|
22 | - public $xndt2o; /*!< 1. time derivative of mean motion */ |
|
23 | - public $xndd6o; /*!< 2. time derivative of mean motion */ |
|
24 | - public $bstar; /*!< Bstar drag coefficient. */ |
|
25 | - public $xincl; /*!< Inclination */ |
|
26 | - public $xnodeo; /*!< R.A.A.N. */ |
|
27 | - public $eo; /*!< Eccentricity */ |
|
28 | - public $omegao; /*!< argument of perigee */ |
|
29 | - public $xmo; /*!< mean anomaly */ |
|
30 | - public $xno; /*!< mean motion */ |
|
31 | - |
|
32 | - public $catnr; /*!< Catalogue Number. */ |
|
33 | - public $elset; /*!< Element Set number. */ |
|
34 | - public $revnum; /*!< Revolution Number at epoch. */ |
|
35 | - |
|
36 | - public $sat_name; /*!< Satellite name string. */ |
|
37 | - public $idesg; /*!< International Designator. */ |
|
38 | - public $status; /*!< Operational status. */ |
|
39 | - |
|
40 | - /* values needed for squint calculations */ |
|
41 | - public $xincl1; |
|
42 | - public $xnodeo1; |
|
43 | - public $omegao1; |
|
44 | - |
|
45 | - |
|
46 | - /* Converts the strings in a raw two-line element set */ |
|
47 | - /* to their intended numerical values. No processing */ |
|
48 | - /* of these values is done, e.g. from deg to rads etc. */ |
|
49 | - /* This is done in the select_ephemeris() function. */ |
|
50 | - public function __construct($header, $line1, $line2) |
|
51 | - { |
|
52 | - if (!$this->Good_Elements($line1, $line2)) { |
|
53 | - throw new Predict_Exception('Invalid TLE contents'); |
|
54 | - } |
|
55 | - |
|
56 | - $this->header = $header; |
|
57 | - $this->line1 = $line1; |
|
58 | - $this->line2 = $line2; |
|
59 | - |
|
60 | - /** Decode Card 1 **/ |
|
61 | - /* Satellite's catalogue number */ |
|
62 | - $this->catnr = (int) substr($line1, 2, 5); |
|
63 | - |
|
64 | - /* International Designator for satellite */ |
|
65 | - $this->idesg = substr($line1, 9, 8); |
|
66 | - |
|
67 | - /* Epoch time; this is the complete, unconverted epoch. */ |
|
68 | - /* Replace spaces with 0 before casting, as leading spaces are allowed */ |
|
69 | - $this->epoch = (float) str_replace(' ', '0', substr($line1, 18, 14)); |
|
70 | - |
|
71 | - /* Now, convert the epoch time into year, day |
|
15 | + public $header; /* Header line of TLE file */ |
|
16 | + public $line1; /* Line 1 of TLE */ |
|
17 | + public $line2; /* Line 2 of TLE */ |
|
18 | + public $epoch; /*!< Epoch Time in NORAD TLE format YYDDD.FFFFFFFF */ |
|
19 | + public $epoch_year; /*!< Epoch: year */ |
|
20 | + public $epoch_day; /*!< Epoch: day of year */ |
|
21 | + public $epoch_fod; /*!< Epoch: Fraction of day. */ |
|
22 | + public $xndt2o; /*!< 1. time derivative of mean motion */ |
|
23 | + public $xndd6o; /*!< 2. time derivative of mean motion */ |
|
24 | + public $bstar; /*!< Bstar drag coefficient. */ |
|
25 | + public $xincl; /*!< Inclination */ |
|
26 | + public $xnodeo; /*!< R.A.A.N. */ |
|
27 | + public $eo; /*!< Eccentricity */ |
|
28 | + public $omegao; /*!< argument of perigee */ |
|
29 | + public $xmo; /*!< mean anomaly */ |
|
30 | + public $xno; /*!< mean motion */ |
|
31 | + |
|
32 | + public $catnr; /*!< Catalogue Number. */ |
|
33 | + public $elset; /*!< Element Set number. */ |
|
34 | + public $revnum; /*!< Revolution Number at epoch. */ |
|
35 | + |
|
36 | + public $sat_name; /*!< Satellite name string. */ |
|
37 | + public $idesg; /*!< International Designator. */ |
|
38 | + public $status; /*!< Operational status. */ |
|
39 | + |
|
40 | + /* values needed for squint calculations */ |
|
41 | + public $xincl1; |
|
42 | + public $xnodeo1; |
|
43 | + public $omegao1; |
|
44 | + |
|
45 | + |
|
46 | + /* Converts the strings in a raw two-line element set */ |
|
47 | + /* to their intended numerical values. No processing */ |
|
48 | + /* of these values is done, e.g. from deg to rads etc. */ |
|
49 | + /* This is done in the select_ephemeris() function. */ |
|
50 | + public function __construct($header, $line1, $line2) |
|
51 | + { |
|
52 | + if (!$this->Good_Elements($line1, $line2)) { |
|
53 | + throw new Predict_Exception('Invalid TLE contents'); |
|
54 | + } |
|
55 | + |
|
56 | + $this->header = $header; |
|
57 | + $this->line1 = $line1; |
|
58 | + $this->line2 = $line2; |
|
59 | + |
|
60 | + /** Decode Card 1 **/ |
|
61 | + /* Satellite's catalogue number */ |
|
62 | + $this->catnr = (int) substr($line1, 2, 5); |
|
63 | + |
|
64 | + /* International Designator for satellite */ |
|
65 | + $this->idesg = substr($line1, 9, 8); |
|
66 | + |
|
67 | + /* Epoch time; this is the complete, unconverted epoch. */ |
|
68 | + /* Replace spaces with 0 before casting, as leading spaces are allowed */ |
|
69 | + $this->epoch = (float) str_replace(' ', '0', substr($line1, 18, 14)); |
|
70 | + |
|
71 | + /* Now, convert the epoch time into year, day |
|
72 | 72 | and fraction of day, according to: |
73 | 73 | |
74 | 74 | YYDDD.FFFFFFFF |
75 | 75 | */ |
76 | 76 | |
77 | - // Adjust for 2 digit year through 2056 |
|
78 | - $this->epoch_year = (int) substr($line1, 18, 2); |
|
79 | - if ($this->epoch_year > 56) { |
|
80 | - $this->epoch_year = $this->epoch_year + 1900; |
|
81 | - } else { |
|
82 | - $this->epoch_year = $this->epoch_year + 2000; |
|
83 | - } |
|
77 | + // Adjust for 2 digit year through 2056 |
|
78 | + $this->epoch_year = (int) substr($line1, 18, 2); |
|
79 | + if ($this->epoch_year > 56) { |
|
80 | + $this->epoch_year = $this->epoch_year + 1900; |
|
81 | + } else { |
|
82 | + $this->epoch_year = $this->epoch_year + 2000; |
|
83 | + } |
|
84 | 84 | |
85 | - /* Epoch day */ |
|
86 | - $this->epoch_day = (int) substr($line1, 20, 3); |
|
85 | + /* Epoch day */ |
|
86 | + $this->epoch_day = (int) substr($line1, 20, 3); |
|
87 | 87 | |
88 | - /* Epoch fraction of day */ |
|
89 | - $this->epoch_fod = (float) substr($line1, 23, 9); |
|
88 | + /* Epoch fraction of day */ |
|
89 | + $this->epoch_fod = (float) substr($line1, 23, 9); |
|
90 | 90 | |
91 | 91 | |
92 | - /* Satellite's First Time Derivative */ |
|
93 | - $this->xndt2o = (float) substr($line1, 33, 10); |
|
92 | + /* Satellite's First Time Derivative */ |
|
93 | + $this->xndt2o = (float) substr($line1, 33, 10); |
|
94 | 94 | |
95 | - /* Satellite's Second Time Derivative */ |
|
96 | - $this->xndd6o = (float) (substr($line1, 44, 1) . '.' . substr($line1, 45, 5) . 'E' . substr($line1, 50, 2)); |
|
95 | + /* Satellite's Second Time Derivative */ |
|
96 | + $this->xndd6o = (float) (substr($line1, 44, 1) . '.' . substr($line1, 45, 5) . 'E' . substr($line1, 50, 2)); |
|
97 | 97 | |
98 | - /* Satellite's bstar drag term |
|
98 | + /* Satellite's bstar drag term |
|
99 | 99 | FIXME: How about buff[0] ???? |
100 | 100 | */ |
101 | - $this->bstar = (float) (substr($line1, 53, 1) . '.' . substr($line1, 54, 5) . 'E' . substr($line1, 59, 2)); |
|
101 | + $this->bstar = (float) (substr($line1, 53, 1) . '.' . substr($line1, 54, 5) . 'E' . substr($line1, 59, 2)); |
|
102 | 102 | |
103 | - /* Element Number */ |
|
104 | - $this->elset = (int) substr($line1, 64, 4); |
|
103 | + /* Element Number */ |
|
104 | + $this->elset = (int) substr($line1, 64, 4); |
|
105 | 105 | |
106 | - /** Decode Card 2 **/ |
|
107 | - /* Satellite's Orbital Inclination (degrees) */ |
|
108 | - $this->xincl = (float) substr($line2, 8, 8); |
|
106 | + /** Decode Card 2 **/ |
|
107 | + /* Satellite's Orbital Inclination (degrees) */ |
|
108 | + $this->xincl = (float) substr($line2, 8, 8); |
|
109 | 109 | |
110 | - /* Satellite's RAAN (degrees) */ |
|
111 | - $this->xnodeo = (float) substr($line2, 17, 8); |
|
110 | + /* Satellite's RAAN (degrees) */ |
|
111 | + $this->xnodeo = (float) substr($line2, 17, 8); |
|
112 | 112 | |
113 | - /* Satellite's Orbital Eccentricity */ |
|
114 | - $this->eo = (float) ('.' . substr($line2, 26, 7)); |
|
113 | + /* Satellite's Orbital Eccentricity */ |
|
114 | + $this->eo = (float) ('.' . substr($line2, 26, 7)); |
|
115 | 115 | |
116 | - /* Satellite's Argument of Perigee (degrees) */ |
|
117 | - $this->omegao = (float) substr($line2, 34, 8); |
|
116 | + /* Satellite's Argument of Perigee (degrees) */ |
|
117 | + $this->omegao = (float) substr($line2, 34, 8); |
|
118 | 118 | |
119 | - /* Satellite's Mean Anomaly of Orbit (degrees) */ |
|
120 | - $this->xmo = (float) substr($line2, 43, 8); |
|
119 | + /* Satellite's Mean Anomaly of Orbit (degrees) */ |
|
120 | + $this->xmo = (float) substr($line2, 43, 8); |
|
121 | 121 | |
122 | - /* Satellite's Mean Motion (rev/day) */ |
|
123 | - $this->xno = (float) substr($line2, 52, 11); |
|
122 | + /* Satellite's Mean Motion (rev/day) */ |
|
123 | + $this->xno = (float) substr($line2, 52, 11); |
|
124 | 124 | |
125 | - /* Satellite's Revolution number at epoch */ |
|
126 | - $this->revnum = (float) substr($line2, 63, 5); |
|
127 | - } |
|
125 | + /* Satellite's Revolution number at epoch */ |
|
126 | + $this->revnum = (float) substr($line2, 63, 5); |
|
127 | + } |
|
128 | 128 | |
129 | - /* Calculates the checksum mod 10 of a line from a TLE set and */ |
|
130 | - /* returns true if it compares with checksum in column 68, else false.*/ |
|
131 | - /* tle_set is a character string holding the two lines read */ |
|
132 | - /* from a text file containing NASA format Keplerian elements. */ |
|
133 | - /* NOTE!!! The stuff about two lines is not quite true. |
|
129 | + /* Calculates the checksum mod 10 of a line from a TLE set and */ |
|
130 | + /* returns true if it compares with checksum in column 68, else false.*/ |
|
131 | + /* tle_set is a character string holding the two lines read */ |
|
132 | + /* from a text file containing NASA format Keplerian elements. */ |
|
133 | + /* NOTE!!! The stuff about two lines is not quite true. |
|
134 | 134 | The function assumes that tle_set[0] is the begining |
135 | 135 | of the line and that there are 68 elements - see the consumer |
136 | 136 | */ |
137 | - public function Checksum_Good($tle_set) |
|
138 | - { |
|
139 | - if (strlen($tle_set) < 69) { |
|
140 | - return false; |
|
141 | - } |
|
142 | - |
|
143 | - $checksum = 0; |
|
144 | - |
|
145 | - for ($i = 0; $i < 68; $i++) { |
|
146 | - if (($tle_set[$i] >= '0') && ($tle_set[$i] <= '9')) { |
|
147 | - $value = $tle_set[$i] - '0'; |
|
148 | - } else if ($tle_set[$i] == '-' ) { |
|
149 | - $value = 1; |
|
150 | - } else { |
|
151 | - $value = 0; |
|
152 | - } |
|
153 | - |
|
154 | - $checksum += $value; |
|
155 | - } |
|
156 | - |
|
157 | - $checksum %= 10; |
|
158 | - $check_digit = $tle_set[68] - '0'; |
|
159 | - |
|
160 | - return $checksum == $check_digit; |
|
161 | - } |
|
162 | - |
|
163 | - /* Carries out various checks on a TLE set to verify its validity */ |
|
164 | - /* $line1 is the first line of the TLE, $line2 is the second line */ |
|
165 | - /* from a text file containing NASA format Keplerian elements. */ |
|
166 | - public function Good_Elements($line1, $line2) |
|
167 | - { |
|
168 | - /* Verify checksum of both lines of a TLE set */ |
|
169 | - if (!$this->Checksum_Good($line1) || !$this->Checksum_Good($line2)) { |
|
170 | - return false; |
|
171 | - } |
|
172 | - |
|
173 | - /* Check the line number of each line */ |
|
174 | - if (($line1[0] != '1') || ($line2[0] != '2')) { |
|
175 | - return false; |
|
176 | - } |
|
177 | - |
|
178 | - /* Verify that Satellite Number is same in both lines */ |
|
179 | - if (strncmp($line1[2], $line2[2], 5) != 0) { |
|
180 | - return false; |
|
181 | - } |
|
182 | - |
|
183 | - /* Check that various elements are in the right place */ |
|
184 | - if (($line1[23] != '.') || |
|
185 | - ($line1[34] != '.') || |
|
186 | - ($line2[11] != '.') || |
|
187 | - ($line2[20] != '.') || |
|
188 | - ($line2[37] != '.') || |
|
189 | - ($line2[46] != '.') || |
|
190 | - ($line2[54] != '.') || |
|
191 | - (strncmp(substr($line1, 61), ' 0 ', 3) != 0)) { |
|
192 | - |
|
193 | - return false; |
|
194 | - } |
|
195 | - |
|
196 | - return true; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * A function to allow checksum creation of a line. This is driven by |
|
201 | - * the fact that some TLEs from SpaceTrack are missing checksum numbers. |
|
202 | - * You can use this to create a checksum for a line, but you should |
|
203 | - * probably have confidence that the TLE data itself is good. YMMV. |
|
204 | - * |
|
205 | - * @throws Predict_Exception if the line is not exactly 68 chars |
|
206 | - * @return string |
|
207 | - */ |
|
208 | - static public function createChecksum($line) |
|
209 | - { |
|
210 | - if (strlen($line) != 68) { |
|
211 | - throw Predict_Exception('Invalid line, needs to e 68 chars'); |
|
212 | - } |
|
213 | - |
|
214 | - $checksum = 0; |
|
215 | - |
|
216 | - for ($i = 0; $i < 68; $i++) { |
|
217 | - if (($line[$i] >= '0') && ($line[$i] <= '9')) { |
|
218 | - $value = (int) $line[$i]; |
|
219 | - } else if ($line[$i] == '-' ) { |
|
220 | - $value = 1; |
|
221 | - } else { |
|
222 | - $value = 0; |
|
223 | - } |
|
224 | - |
|
225 | - $checksum += $value; |
|
226 | - } |
|
227 | - |
|
228 | - $checksum %= 10; |
|
229 | - |
|
230 | - return $checksum; |
|
231 | - } |
|
137 | + public function Checksum_Good($tle_set) |
|
138 | + { |
|
139 | + if (strlen($tle_set) < 69) { |
|
140 | + return false; |
|
141 | + } |
|
142 | + |
|
143 | + $checksum = 0; |
|
144 | + |
|
145 | + for ($i = 0; $i < 68; $i++) { |
|
146 | + if (($tle_set[$i] >= '0') && ($tle_set[$i] <= '9')) { |
|
147 | + $value = $tle_set[$i] - '0'; |
|
148 | + } else if ($tle_set[$i] == '-' ) { |
|
149 | + $value = 1; |
|
150 | + } else { |
|
151 | + $value = 0; |
|
152 | + } |
|
153 | + |
|
154 | + $checksum += $value; |
|
155 | + } |
|
156 | + |
|
157 | + $checksum %= 10; |
|
158 | + $check_digit = $tle_set[68] - '0'; |
|
159 | + |
|
160 | + return $checksum == $check_digit; |
|
161 | + } |
|
162 | + |
|
163 | + /* Carries out various checks on a TLE set to verify its validity */ |
|
164 | + /* $line1 is the first line of the TLE, $line2 is the second line */ |
|
165 | + /* from a text file containing NASA format Keplerian elements. */ |
|
166 | + public function Good_Elements($line1, $line2) |
|
167 | + { |
|
168 | + /* Verify checksum of both lines of a TLE set */ |
|
169 | + if (!$this->Checksum_Good($line1) || !$this->Checksum_Good($line2)) { |
|
170 | + return false; |
|
171 | + } |
|
172 | + |
|
173 | + /* Check the line number of each line */ |
|
174 | + if (($line1[0] != '1') || ($line2[0] != '2')) { |
|
175 | + return false; |
|
176 | + } |
|
177 | + |
|
178 | + /* Verify that Satellite Number is same in both lines */ |
|
179 | + if (strncmp($line1[2], $line2[2], 5) != 0) { |
|
180 | + return false; |
|
181 | + } |
|
182 | + |
|
183 | + /* Check that various elements are in the right place */ |
|
184 | + if (($line1[23] != '.') || |
|
185 | + ($line1[34] != '.') || |
|
186 | + ($line2[11] != '.') || |
|
187 | + ($line2[20] != '.') || |
|
188 | + ($line2[37] != '.') || |
|
189 | + ($line2[46] != '.') || |
|
190 | + ($line2[54] != '.') || |
|
191 | + (strncmp(substr($line1, 61), ' 0 ', 3) != 0)) { |
|
192 | + |
|
193 | + return false; |
|
194 | + } |
|
195 | + |
|
196 | + return true; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * A function to allow checksum creation of a line. This is driven by |
|
201 | + * the fact that some TLEs from SpaceTrack are missing checksum numbers. |
|
202 | + * You can use this to create a checksum for a line, but you should |
|
203 | + * probably have confidence that the TLE data itself is good. YMMV. |
|
204 | + * |
|
205 | + * @throws Predict_Exception if the line is not exactly 68 chars |
|
206 | + * @return string |
|
207 | + */ |
|
208 | + static public function createChecksum($line) |
|
209 | + { |
|
210 | + if (strlen($line) != 68) { |
|
211 | + throw Predict_Exception('Invalid line, needs to e 68 chars'); |
|
212 | + } |
|
213 | + |
|
214 | + $checksum = 0; |
|
215 | + |
|
216 | + for ($i = 0; $i < 68; $i++) { |
|
217 | + if (($line[$i] >= '0') && ($line[$i] <= '9')) { |
|
218 | + $value = (int) $line[$i]; |
|
219 | + } else if ($line[$i] == '-' ) { |
|
220 | + $value = 1; |
|
221 | + } else { |
|
222 | + $value = 0; |
|
223 | + } |
|
224 | + |
|
225 | + $checksum += $value; |
|
226 | + } |
|
227 | + |
|
228 | + $checksum %= 10; |
|
229 | + |
|
230 | + return $checksum; |
|
231 | + } |
|
232 | 232 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | */ |
7 | 7 | class Predict_Geodetic |
8 | 8 | { |
9 | - public $lat; /*!< Lattitude [rad] */ |
|
10 | - public $lon; /*!< Longitude [rad] */ |
|
11 | - public $alt; /*!< Altitude [km] */ |
|
12 | - public $theta; |
|
9 | + public $lat; /*!< Lattitude [rad] */ |
|
10 | + public $lon; /*!< Longitude [rad] */ |
|
11 | + public $alt; /*!< Altitude [km] */ |
|
12 | + public $theta; |
|
13 | 13 | } |
@@ -8,32 +8,32 @@ |
||
8 | 8 | */ |
9 | 9 | class Predict_SGSDPStatic |
10 | 10 | { |
11 | - public $aodp; |
|
12 | - public $aycof; |
|
13 | - public $c1; |
|
14 | - public $c4; |
|
15 | - public $c5; |
|
16 | - public $cosio; |
|
17 | - public $d2; |
|
18 | - public $d3; |
|
19 | - public $d4; |
|
20 | - public $delmo; |
|
21 | - public $omgcof; |
|
22 | - public $eta; |
|
23 | - public $omgdot; |
|
24 | - public $sinio; |
|
25 | - public $xnodp; |
|
26 | - public $sinmo; |
|
27 | - public $t2cof; |
|
28 | - public $t3cof; |
|
29 | - public $t4cof; |
|
30 | - public $t5cof; |
|
31 | - public $x1mth2; |
|
32 | - public $x3thm1; |
|
33 | - public $x7thm1; |
|
34 | - public $xmcof; |
|
35 | - public $xmdot; |
|
36 | - public $xnodcf; |
|
37 | - public $xnodot; |
|
38 | - public $xlcof; |
|
11 | + public $aodp; |
|
12 | + public $aycof; |
|
13 | + public $c1; |
|
14 | + public $c4; |
|
15 | + public $c5; |
|
16 | + public $cosio; |
|
17 | + public $d2; |
|
18 | + public $d3; |
|
19 | + public $d4; |
|
20 | + public $delmo; |
|
21 | + public $omgcof; |
|
22 | + public $eta; |
|
23 | + public $omgdot; |
|
24 | + public $sinio; |
|
25 | + public $xnodp; |
|
26 | + public $sinmo; |
|
27 | + public $t2cof; |
|
28 | + public $t3cof; |
|
29 | + public $t4cof; |
|
30 | + public $t5cof; |
|
31 | + public $x1mth2; |
|
32 | + public $x3thm1; |
|
33 | + public $x7thm1; |
|
34 | + public $xmcof; |
|
35 | + public $xmdot; |
|
36 | + public $xnodcf; |
|
37 | + public $xnodot; |
|
38 | + public $xlcof; |
|
39 | 39 | } |
@@ -7,14 +7,14 @@ |
||
7 | 7 | */ |
8 | 8 | class Predict_QTH |
9 | 9 | { |
10 | - public $name; /*!< Name, eg. callsign. */ |
|
11 | - public $loc; /*!< Location, eg City, Country. */ |
|
12 | - public $desc; /*!< Short description. */ |
|
13 | - public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | - public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | - public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | - public $qra; /*!< QRA locator */ |
|
17 | - public $wx; /*!< Weather station code (4 chars). */ |
|
10 | + public $name; /*!< Name, eg. callsign. */ |
|
11 | + public $loc; /*!< Location, eg City, Country. */ |
|
12 | + public $desc; /*!< Short description. */ |
|
13 | + public $lat; /*!< Latitude in dec. deg. North. */ |
|
14 | + public $lon; /*!< Longitude in dec. deg. East. */ |
|
15 | + public $alt; /*!< Altitude above sea level in meters. */ |
|
16 | + public $qra; /*!< QRA locator */ |
|
17 | + public $wx; /*!< Weather station code (4 chars). */ |
|
18 | 18 | |
19 | - public $data; /*!< Raw data from cfg file. */ |
|
19 | + public $data; /*!< Raw data from cfg file. */ |
|
20 | 20 | } |
@@ -22,304 +22,304 @@ |
||
22 | 22 | */ |
23 | 23 | class Predict_Sat |
24 | 24 | { |
25 | - // Fifth root of a hundred, used for magnitude calculation |
|
26 | - const POGSONS_RATIO = 2.5118864315096; |
|
27 | - |
|
28 | - public $name = null; |
|
29 | - public $nickname = null; |
|
30 | - public $website = null; |
|
31 | - |
|
32 | - public $tle = null; /*!< Keplerian elements */ |
|
33 | - public $flags = 0; /*!< Flags for algo ctrl */ |
|
34 | - public $sgps = null; |
|
35 | - public $dps = null; |
|
36 | - public $deep_arg = null; |
|
37 | - public $pos = null; /*!< Raw position and range */ |
|
38 | - public $vel = null; /*!< Raw velocity */ |
|
39 | - |
|
40 | - /*** FIXME: REMOVE */ |
|
41 | - public $bearing = null; /*!< Az, El, range and vel */ |
|
42 | - public $astro = null; /*!< Ra and Decl */ |
|
43 | - /*** END */ |
|
44 | - |
|
45 | - /* time keeping fields */ |
|
46 | - public $jul_epoch = null; |
|
47 | - public $jul_utc = null; |
|
48 | - public $tsince = null; |
|
49 | - public $aos = null; /*!< Next AOS. */ |
|
50 | - public $los = null; /*!< Next LOS */ |
|
51 | - |
|
52 | - public $az = null; /*!< Azimuth [deg] */ |
|
53 | - public $el = null; /*!< Elevation [deg] */ |
|
54 | - public $range = null; /*!< Range [km] */ |
|
55 | - public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
56 | - public $ra = null; /*!< Right Ascension [deg] */ |
|
57 | - public $dec = null; /*!< Declination [deg] */ |
|
58 | - public $ssplat = null; /*!< SSP latitude [deg] */ |
|
59 | - public $ssplon = null; /*!< SSP longitude [deg] */ |
|
60 | - public $alt = null; /*!< altitude [km] */ |
|
61 | - public $velo = null; /*!< velocity [km/s] */ |
|
62 | - public $ma = null; /*!< mean anomaly */ |
|
63 | - public $footprint = null; /*!< footprint */ |
|
64 | - public $phase = null; /*!< orbit phase */ |
|
65 | - public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
66 | - public $orbit = null; /*!< orbit number */ |
|
67 | - public $otype = null; /*!< orbit type. */ |
|
68 | - |
|
69 | - public function __construct(Predict_TLE $tle) |
|
70 | - { |
|
71 | - $headerParts = explode(' ', $tle->header); |
|
72 | - $this->name = $headerParts[0]; |
|
73 | - $this->nickname = $this->name; |
|
74 | - $this->tle = $tle; |
|
75 | - $this->pos = new Predict_Vector(); |
|
76 | - $this->vel = new Predict_Vector(); |
|
77 | - $this->sgps = new Predict_SGSDPStatic(); |
|
78 | - $this->deep_arg = new Predict_DeepArg(); |
|
79 | - $this->dps = new Predict_DeepStatic(); |
|
80 | - |
|
81 | - $this->select_ephemeris(); |
|
82 | - $this->sat_data_init_sat($this); |
|
83 | - } |
|
84 | - |
|
85 | - /* Selects the apropriate ephemeris type to be used */ |
|
86 | - /* for predictions according to the data in the TLE */ |
|
87 | - /* It also processes values in the tle set so that */ |
|
88 | - /* they are apropriate for the sgp4/sdp4 routines */ |
|
89 | - public function select_ephemeris() |
|
90 | - { |
|
91 | - /* Preprocess tle set */ |
|
92 | - $this->tle->xnodeo *= Predict::de2ra; |
|
93 | - $this->tle->omegao *= Predict::de2ra; |
|
94 | - $this->tle->xmo *= Predict::de2ra; |
|
95 | - $this->tle->xincl *= Predict::de2ra; |
|
96 | - $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
97 | - |
|
98 | - /* store mean motion before conversion */ |
|
99 | - $this->meanmo = $this->tle->xno; |
|
100 | - $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
101 | - $this->tle->xndt2o *= $temp; |
|
102 | - $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
103 | - $this->tle->bstar /= Predict::ae; |
|
104 | - |
|
105 | - /* Period > 225 minutes is deep space */ |
|
106 | - $dd1 = Predict::xke / $this->tle->xno; |
|
107 | - $dd2 = Predict::tothrd; |
|
108 | - $a1 = pow($dd1, $dd2); |
|
109 | - $r1 = cos($this->tle->xincl); |
|
110 | - $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
111 | - $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
112 | - $del1 = $temp / ($a1 * $a1); |
|
113 | - $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
114 | - ($del1 * 1.654320987654321 + 1.0))); |
|
115 | - $delo = $temp / ($ao * $ao); |
|
116 | - $xnodp = $this->tle->xno / ($delo + 1.0); |
|
117 | - |
|
118 | - /* Select a deep-space/near-earth ephemeris */ |
|
119 | - if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
120 | - $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
121 | - } else { |
|
122 | - $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** Initialise satellite data. |
|
127 | - * @param sat The satellite to initialise. |
|
128 | - * @param qth Optional QTH info, use (0,0) if NULL. |
|
129 | - * |
|
130 | - * This function calculates the satellite data at t = 0, ie. epoch time |
|
131 | - * The function is called automatically by gtk_sat_data_read_sat. |
|
132 | - */ |
|
133 | - public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
134 | - { |
|
135 | - $obs_geodetic = new Predict_Geodetic(); |
|
136 | - $obs_set = new Predict_ObsSet(); |
|
137 | - $sat_geodetic = new Predict_Geodetic(); |
|
138 | - /* double jul_utc, age; */ |
|
139 | - |
|
140 | - $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
141 | - $sat->jul_epoch = $jul_utc; |
|
142 | - |
|
143 | - /* initialise observer location */ |
|
144 | - if ($qth != null) { |
|
145 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
146 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
147 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
148 | - $obs_geodetic->theta = 0; |
|
149 | - } |
|
150 | - else { |
|
151 | - $obs_geodetic->lon = 0.0; |
|
152 | - $obs_geodetic->lat = 0.0; |
|
153 | - $obs_geodetic->alt = 0.0; |
|
154 | - $obs_geodetic->theta = 0; |
|
155 | - } |
|
156 | - |
|
157 | - /* execute computations */ |
|
158 | - $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
159 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
160 | - $sdpsgp->SDP4($sat, 0.0); |
|
161 | - } else { |
|
162 | - $sdpsgp->SGP4($sat, 0.0); |
|
163 | - } |
|
164 | - |
|
165 | - /* scale position and velocity to km and km/sec */ |
|
166 | - Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
167 | - |
|
168 | - /* get the velocity of the satellite */ |
|
169 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
170 | - $sat->velo = $sat->vel->w; |
|
171 | - Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
172 | - Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
173 | - |
|
174 | - while ($sat_geodetic->lon < -Predict::pi) { |
|
175 | - $sat_geodetic->lon += Predict::twopi; |
|
176 | - } |
|
177 | - |
|
178 | - while ($sat_geodetic->lon > Predict::pi) { |
|
179 | - $sat_geodetic->lon -= Predict::twopi; |
|
180 | - } |
|
181 | - |
|
182 | - $sat->az = Predict_Math::Degrees($obs_set->az); |
|
183 | - $sat->el = Predict_Math::Degrees($obs_set->el); |
|
184 | - $sat->range = $obs_set->range; |
|
185 | - $sat->range_rate = $obs_set->range_rate; |
|
186 | - $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
187 | - $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
188 | - $sat->alt = $sat_geodetic->alt; |
|
189 | - $sat->ma = Predict_Math::Degrees($sat->phase); |
|
190 | - $sat->ma *= 256.0 / 360.0; |
|
191 | - $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
192 | - $age = 0.0; |
|
193 | - $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
194 | - $age * $sat->tle->bstar * Predict::ae) * $age + |
|
195 | - $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
196 | - |
|
197 | - /* orbit type */ |
|
198 | - $sat->otype = $sat->get_orbit_type($sat); |
|
199 | - } |
|
200 | - |
|
201 | - public function get_orbit_type(Predict_Sat $sat) |
|
202 | - { |
|
203 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
204 | - |
|
205 | - if ($this->geostationary($sat)) { |
|
206 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
207 | - } else if ($this->decayed($sat)) { |
|
208 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
209 | - } else { |
|
210 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
211 | - } |
|
212 | - |
|
213 | - return $orbit; |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** Determinte whether satellite is in geostationary orbit. |
|
218 | - * @author John A. Magliacane, KD2BD |
|
219 | - * @param sat Pointer to satellite data. |
|
220 | - * @return TRUE if the satellite appears to be in geostationary orbit, |
|
221 | - * FALSE otherwise. |
|
222 | - * |
|
223 | - * A satellite is in geostationary orbit if |
|
224 | - * |
|
225 | - * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
226 | - * |
|
227 | - * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
228 | - */ |
|
229 | - public function geostationary(Predict_Sat $sat) |
|
230 | - { |
|
231 | - if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
232 | - return true; |
|
233 | - } else { |
|
234 | - return false; |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** Determine whether satellite has decayed. |
|
240 | - * @author John A. Magliacane, KD2BD |
|
241 | - * @author Alexandru Csete, OZ9AEC |
|
242 | - * @param sat Pointer to satellite data. |
|
243 | - * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
244 | - * @bug Modified version of the predict code but it is not tested. |
|
245 | - * |
|
246 | - * A satellite is decayed if |
|
247 | - * |
|
248 | - * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
249 | - * |
|
250 | - */ |
|
251 | - public function decayed(Predict_Sat $sat) |
|
252 | - { |
|
253 | - /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
25 | + // Fifth root of a hundred, used for magnitude calculation |
|
26 | + const POGSONS_RATIO = 2.5118864315096; |
|
27 | + |
|
28 | + public $name = null; |
|
29 | + public $nickname = null; |
|
30 | + public $website = null; |
|
31 | + |
|
32 | + public $tle = null; /*!< Keplerian elements */ |
|
33 | + public $flags = 0; /*!< Flags for algo ctrl */ |
|
34 | + public $sgps = null; |
|
35 | + public $dps = null; |
|
36 | + public $deep_arg = null; |
|
37 | + public $pos = null; /*!< Raw position and range */ |
|
38 | + public $vel = null; /*!< Raw velocity */ |
|
39 | + |
|
40 | + /*** FIXME: REMOVE */ |
|
41 | + public $bearing = null; /*!< Az, El, range and vel */ |
|
42 | + public $astro = null; /*!< Ra and Decl */ |
|
43 | + /*** END */ |
|
44 | + |
|
45 | + /* time keeping fields */ |
|
46 | + public $jul_epoch = null; |
|
47 | + public $jul_utc = null; |
|
48 | + public $tsince = null; |
|
49 | + public $aos = null; /*!< Next AOS. */ |
|
50 | + public $los = null; /*!< Next LOS */ |
|
51 | + |
|
52 | + public $az = null; /*!< Azimuth [deg] */ |
|
53 | + public $el = null; /*!< Elevation [deg] */ |
|
54 | + public $range = null; /*!< Range [km] */ |
|
55 | + public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
56 | + public $ra = null; /*!< Right Ascension [deg] */ |
|
57 | + public $dec = null; /*!< Declination [deg] */ |
|
58 | + public $ssplat = null; /*!< SSP latitude [deg] */ |
|
59 | + public $ssplon = null; /*!< SSP longitude [deg] */ |
|
60 | + public $alt = null; /*!< altitude [km] */ |
|
61 | + public $velo = null; /*!< velocity [km/s] */ |
|
62 | + public $ma = null; /*!< mean anomaly */ |
|
63 | + public $footprint = null; /*!< footprint */ |
|
64 | + public $phase = null; /*!< orbit phase */ |
|
65 | + public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
66 | + public $orbit = null; /*!< orbit number */ |
|
67 | + public $otype = null; /*!< orbit type. */ |
|
68 | + |
|
69 | + public function __construct(Predict_TLE $tle) |
|
70 | + { |
|
71 | + $headerParts = explode(' ', $tle->header); |
|
72 | + $this->name = $headerParts[0]; |
|
73 | + $this->nickname = $this->name; |
|
74 | + $this->tle = $tle; |
|
75 | + $this->pos = new Predict_Vector(); |
|
76 | + $this->vel = new Predict_Vector(); |
|
77 | + $this->sgps = new Predict_SGSDPStatic(); |
|
78 | + $this->deep_arg = new Predict_DeepArg(); |
|
79 | + $this->dps = new Predict_DeepStatic(); |
|
80 | + |
|
81 | + $this->select_ephemeris(); |
|
82 | + $this->sat_data_init_sat($this); |
|
83 | + } |
|
84 | + |
|
85 | + /* Selects the apropriate ephemeris type to be used */ |
|
86 | + /* for predictions according to the data in the TLE */ |
|
87 | + /* It also processes values in the tle set so that */ |
|
88 | + /* they are apropriate for the sgp4/sdp4 routines */ |
|
89 | + public function select_ephemeris() |
|
90 | + { |
|
91 | + /* Preprocess tle set */ |
|
92 | + $this->tle->xnodeo *= Predict::de2ra; |
|
93 | + $this->tle->omegao *= Predict::de2ra; |
|
94 | + $this->tle->xmo *= Predict::de2ra; |
|
95 | + $this->tle->xincl *= Predict::de2ra; |
|
96 | + $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
97 | + |
|
98 | + /* store mean motion before conversion */ |
|
99 | + $this->meanmo = $this->tle->xno; |
|
100 | + $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
101 | + $this->tle->xndt2o *= $temp; |
|
102 | + $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
103 | + $this->tle->bstar /= Predict::ae; |
|
104 | + |
|
105 | + /* Period > 225 minutes is deep space */ |
|
106 | + $dd1 = Predict::xke / $this->tle->xno; |
|
107 | + $dd2 = Predict::tothrd; |
|
108 | + $a1 = pow($dd1, $dd2); |
|
109 | + $r1 = cos($this->tle->xincl); |
|
110 | + $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
111 | + $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
112 | + $del1 = $temp / ($a1 * $a1); |
|
113 | + $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
114 | + ($del1 * 1.654320987654321 + 1.0))); |
|
115 | + $delo = $temp / ($ao * $ao); |
|
116 | + $xnodp = $this->tle->xno / ($delo + 1.0); |
|
117 | + |
|
118 | + /* Select a deep-space/near-earth ephemeris */ |
|
119 | + if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
120 | + $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
121 | + } else { |
|
122 | + $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** Initialise satellite data. |
|
127 | + * @param sat The satellite to initialise. |
|
128 | + * @param qth Optional QTH info, use (0,0) if NULL. |
|
129 | + * |
|
130 | + * This function calculates the satellite data at t = 0, ie. epoch time |
|
131 | + * The function is called automatically by gtk_sat_data_read_sat. |
|
132 | + */ |
|
133 | + public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
134 | + { |
|
135 | + $obs_geodetic = new Predict_Geodetic(); |
|
136 | + $obs_set = new Predict_ObsSet(); |
|
137 | + $sat_geodetic = new Predict_Geodetic(); |
|
138 | + /* double jul_utc, age; */ |
|
139 | + |
|
140 | + $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
141 | + $sat->jul_epoch = $jul_utc; |
|
142 | + |
|
143 | + /* initialise observer location */ |
|
144 | + if ($qth != null) { |
|
145 | + $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
146 | + $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
147 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
148 | + $obs_geodetic->theta = 0; |
|
149 | + } |
|
150 | + else { |
|
151 | + $obs_geodetic->lon = 0.0; |
|
152 | + $obs_geodetic->lat = 0.0; |
|
153 | + $obs_geodetic->alt = 0.0; |
|
154 | + $obs_geodetic->theta = 0; |
|
155 | + } |
|
156 | + |
|
157 | + /* execute computations */ |
|
158 | + $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
159 | + if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
160 | + $sdpsgp->SDP4($sat, 0.0); |
|
161 | + } else { |
|
162 | + $sdpsgp->SGP4($sat, 0.0); |
|
163 | + } |
|
164 | + |
|
165 | + /* scale position and velocity to km and km/sec */ |
|
166 | + Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
167 | + |
|
168 | + /* get the velocity of the satellite */ |
|
169 | + $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
170 | + $sat->velo = $sat->vel->w; |
|
171 | + Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
172 | + Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
173 | + |
|
174 | + while ($sat_geodetic->lon < -Predict::pi) { |
|
175 | + $sat_geodetic->lon += Predict::twopi; |
|
176 | + } |
|
177 | + |
|
178 | + while ($sat_geodetic->lon > Predict::pi) { |
|
179 | + $sat_geodetic->lon -= Predict::twopi; |
|
180 | + } |
|
181 | + |
|
182 | + $sat->az = Predict_Math::Degrees($obs_set->az); |
|
183 | + $sat->el = Predict_Math::Degrees($obs_set->el); |
|
184 | + $sat->range = $obs_set->range; |
|
185 | + $sat->range_rate = $obs_set->range_rate; |
|
186 | + $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
187 | + $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
188 | + $sat->alt = $sat_geodetic->alt; |
|
189 | + $sat->ma = Predict_Math::Degrees($sat->phase); |
|
190 | + $sat->ma *= 256.0 / 360.0; |
|
191 | + $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
192 | + $age = 0.0; |
|
193 | + $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
194 | + $age * $sat->tle->bstar * Predict::ae) * $age + |
|
195 | + $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
196 | + |
|
197 | + /* orbit type */ |
|
198 | + $sat->otype = $sat->get_orbit_type($sat); |
|
199 | + } |
|
200 | + |
|
201 | + public function get_orbit_type(Predict_Sat $sat) |
|
202 | + { |
|
203 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
204 | + |
|
205 | + if ($this->geostationary($sat)) { |
|
206 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
207 | + } else if ($this->decayed($sat)) { |
|
208 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
209 | + } else { |
|
210 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
211 | + } |
|
212 | + |
|
213 | + return $orbit; |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** Determinte whether satellite is in geostationary orbit. |
|
218 | + * @author John A. Magliacane, KD2BD |
|
219 | + * @param sat Pointer to satellite data. |
|
220 | + * @return TRUE if the satellite appears to be in geostationary orbit, |
|
221 | + * FALSE otherwise. |
|
222 | + * |
|
223 | + * A satellite is in geostationary orbit if |
|
224 | + * |
|
225 | + * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
226 | + * |
|
227 | + * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
228 | + */ |
|
229 | + public function geostationary(Predict_Sat $sat) |
|
230 | + { |
|
231 | + if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
232 | + return true; |
|
233 | + } else { |
|
234 | + return false; |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** Determine whether satellite has decayed. |
|
240 | + * @author John A. Magliacane, KD2BD |
|
241 | + * @author Alexandru Csete, OZ9AEC |
|
242 | + * @param sat Pointer to satellite data. |
|
243 | + * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
244 | + * @bug Modified version of the predict code but it is not tested. |
|
245 | + * |
|
246 | + * A satellite is decayed if |
|
247 | + * |
|
248 | + * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
249 | + * |
|
250 | + */ |
|
251 | + public function decayed(Predict_Sat $sat) |
|
252 | + { |
|
253 | + /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
254 | 254 | value matches up with the value in predict 2.2.3 */ |
255 | - /*** FIXME decayed is treated as a static quantity. |
|
255 | + /*** FIXME decayed is treated as a static quantity. |
|
256 | 256 | It is time dependent. Also sat->jul_utc is often zero |
257 | 257 | when this function is called |
258 | 258 | ***/ |
259 | - if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
260 | - return true; |
|
261 | - } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
262 | - (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
263 | - return true; |
|
264 | - } else { |
|
265 | - return false; |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
271 | - * magnitudes are listed inside the function for now. |
|
272 | - * |
|
273 | - * @param float $time The daynum the satellite is calculated for |
|
274 | - * @param Predict_QTH $qth The observer location |
|
275 | - * |
|
276 | - * @return null on failure, float otherwise |
|
277 | - */ |
|
278 | - public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
279 | - { |
|
280 | - // Recorded intrinsic magnitudes and their respective |
|
281 | - // illumination and distance from heavens-above.com |
|
282 | - static $intrinsicMagnitudes = array( |
|
283 | - '25544' => array( |
|
284 | - 'mag' => -1.3, |
|
285 | - 'illum' => .5, |
|
286 | - 'distance' => 1000, |
|
287 | - ) |
|
288 | - ); |
|
289 | - |
|
290 | - // Return null if we don't have a record of the intrinsic mag |
|
291 | - if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
292 | - return null; |
|
293 | - } |
|
294 | - $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
295 | - |
|
296 | - // Convert the observer's geodetic info to radians and km so |
|
297 | - // we can compare vectors |
|
298 | - $observerGeo = new Predict_Geodetic(); |
|
299 | - $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
300 | - $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
301 | - $observerGeo->alt = $qth->alt * 1000; |
|
302 | - |
|
303 | - // Now determine the sun and observer positions |
|
304 | - $observerPos = new Predict_Vector(); |
|
305 | - $observerVel = new Predict_Vector(); |
|
306 | - $solarVector = new Predict_Vector(); |
|
307 | - Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
308 | - Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
309 | - |
|
310 | - // Determine the solar phase and and thus the percent illumination |
|
311 | - $observerSatPos = new Predict_Vector(); |
|
312 | - Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
313 | - $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
314 | - $illum = $phaseAngle / 180; |
|
315 | - |
|
316 | - $illuminationChange = $illum / $imag['illum']; |
|
317 | - $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
318 | - $changeInMagnitude = log( |
|
319 | - $illuminationChange * $inverseSquareOfDistanceChange, |
|
320 | - self::POGSONS_RATIO |
|
321 | - ); |
|
322 | - |
|
323 | - return $imag['mag'] - $changeInMagnitude; |
|
324 | - } |
|
259 | + if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
260 | + return true; |
|
261 | + } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
262 | + (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
263 | + return true; |
|
264 | + } else { |
|
265 | + return false; |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
271 | + * magnitudes are listed inside the function for now. |
|
272 | + * |
|
273 | + * @param float $time The daynum the satellite is calculated for |
|
274 | + * @param Predict_QTH $qth The observer location |
|
275 | + * |
|
276 | + * @return null on failure, float otherwise |
|
277 | + */ |
|
278 | + public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
279 | + { |
|
280 | + // Recorded intrinsic magnitudes and their respective |
|
281 | + // illumination and distance from heavens-above.com |
|
282 | + static $intrinsicMagnitudes = array( |
|
283 | + '25544' => array( |
|
284 | + 'mag' => -1.3, |
|
285 | + 'illum' => .5, |
|
286 | + 'distance' => 1000, |
|
287 | + ) |
|
288 | + ); |
|
289 | + |
|
290 | + // Return null if we don't have a record of the intrinsic mag |
|
291 | + if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
292 | + return null; |
|
293 | + } |
|
294 | + $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
295 | + |
|
296 | + // Convert the observer's geodetic info to radians and km so |
|
297 | + // we can compare vectors |
|
298 | + $observerGeo = new Predict_Geodetic(); |
|
299 | + $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
300 | + $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
301 | + $observerGeo->alt = $qth->alt * 1000; |
|
302 | + |
|
303 | + // Now determine the sun and observer positions |
|
304 | + $observerPos = new Predict_Vector(); |
|
305 | + $observerVel = new Predict_Vector(); |
|
306 | + $solarVector = new Predict_Vector(); |
|
307 | + Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
308 | + Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
309 | + |
|
310 | + // Determine the solar phase and and thus the percent illumination |
|
311 | + $observerSatPos = new Predict_Vector(); |
|
312 | + Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
313 | + $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
314 | + $illum = $phaseAngle / 180; |
|
315 | + |
|
316 | + $illuminationChange = $illum / $imag['illum']; |
|
317 | + $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
318 | + $changeInMagnitude = log( |
|
319 | + $illuminationChange * $inverseSquareOfDistanceChange, |
|
320 | + self::POGSONS_RATIO |
|
321 | + ); |
|
322 | + |
|
323 | + return $imag['mag'] - $changeInMagnitude; |
|
324 | + } |
|
325 | 325 | } |
@@ -6,8 +6,8 @@ |
||
6 | 6 | */ |
7 | 7 | class Predict_Vector |
8 | 8 | { |
9 | - public $x = 0; |
|
10 | - public $y = 0; |
|
11 | - public $z = 0; |
|
12 | - public $w = 0; |
|
9 | + public $x = 0; |
|
10 | + public $y = 0; |
|
11 | + public $z = 0; |
|
12 | + public $w = 0; |
|
13 | 13 | } |
@@ -30,194 +30,194 @@ |
||
30 | 30 | */ |
31 | 31 | class Predict_Time |
32 | 32 | { |
33 | - /* The function Julian_Date_of_Epoch returns the Julian Date of */ |
|
34 | - /* an epoch specified in the format used in the NORAD two-line */ |
|
35 | - /* element sets. It has been modified to support dates beyond */ |
|
36 | - /* the year 1999 assuming that two-digit years in the range 00-56 */ |
|
37 | - /* correspond to 2000-2056. Until the two-line element set format */ |
|
38 | - /* is changed, it is only valid for dates through 2056 December 31. */ |
|
39 | - public static function Julian_Date_of_Epoch($epoch) |
|
40 | - { |
|
41 | - $year = 0; |
|
42 | - |
|
43 | - /* Modification to support Y2K */ |
|
44 | - /* Valid 1957 through 2056 */ |
|
45 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
46 | - if ($year < 57) { |
|
47 | - $year = $year + 2000; |
|
48 | - } else { |
|
49 | - $year = $year + 1900; |
|
50 | - } |
|
51 | - /* End modification */ |
|
52 | - |
|
53 | - return self::Julian_Date_of_Year($year) + $day; |
|
54 | - } |
|
55 | - |
|
56 | - /* Equivalent to the C modf function */ |
|
57 | - public static function modf($x, &$ipart) { |
|
58 | - $ipart = (int)$x; |
|
59 | - return $x - $ipart; |
|
60 | - } |
|
61 | - |
|
62 | - /* The function Julian_Date_of_Year calculates the Julian Date */ |
|
63 | - /* of Day 0.0 of {year}. This function is used to calculate the */ |
|
64 | - /* Julian Date of any date by using Julian_Date_of_Year, DOY, */ |
|
65 | - /* and Fraction_of_Day. */ |
|
66 | - public static function Julian_Date_of_Year($year) |
|
67 | - { |
|
68 | - /* Astronomical Formulae for Calculators, Jean Meeus, */ |
|
69 | - /* pages 23-25. Calculate Julian Date of 0.0 Jan year */ |
|
70 | - $year = $year - 1; |
|
71 | - $i = (int) ($year / 100); |
|
72 | - $A = $i; |
|
73 | - $i = (int) ($A / 4); |
|
74 | - $B = (int) (2 - $A + $i); |
|
75 | - $i = (int) (365.25 * $year); |
|
76 | - $i += (int) (30.6001 * 14); |
|
77 | - $jdoy = $i + 1720994.5 + $B; |
|
78 | - |
|
79 | - return $jdoy; |
|
80 | - } |
|
81 | - |
|
82 | - /* The function ThetaG calculates the Greenwich Mean Sidereal Time */ |
|
83 | - /* for an epoch specified in the format used in the NORAD two-line */ |
|
84 | - /* element sets. It has now been adapted for dates beyond the year */ |
|
85 | - /* 1999, as described above. The function ThetaG_JD provides the */ |
|
86 | - /* same calculation except that it is based on an input in the */ |
|
87 | - /* form of a Julian Date. */ |
|
88 | - public static function ThetaG($epoch, Predict_DeepArg $deep_arg) |
|
89 | - { |
|
90 | - /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
91 | - // double year,day,UT,jd,TU,GMST,_ThetaG; |
|
92 | - |
|
93 | - /* Modification to support Y2K */ |
|
94 | - /* Valid 1957 through 2056 */ |
|
95 | - $year = 0; |
|
96 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
97 | - |
|
98 | - if ($year < 57) { |
|
99 | - $year += 2000; |
|
100 | - } else { |
|
101 | - $year += 1900; |
|
102 | - } |
|
103 | - /* End modification */ |
|
104 | - |
|
105 | - $UT = fmod($day, $day); |
|
106 | - $jd = self::Julian_Date_of_Year($year) + $day; |
|
107 | - $TU = ($jd - 2451545.0) / 36525; |
|
108 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
109 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
110 | - $deep_arg->ds50 = $jd - 2433281.5 + $UT; |
|
111 | - |
|
112 | - return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); |
|
113 | - } |
|
114 | - |
|
115 | - /* See the ThetaG doc block above */ |
|
116 | - public static function ThetaG_JD($jd) |
|
117 | - { |
|
118 | - /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
119 | - $UT = Predict_Math::Frac($jd + 0.5); |
|
120 | - $jd = $jd - $UT; |
|
121 | - $TU = ($jd - 2451545.0) / 36525; |
|
122 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
123 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
124 | - |
|
125 | - return Predict::twopi * $GMST / Predict::secday; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Read the system clock and return the current Julian day. From phpPredict |
|
130 | - * |
|
131 | - * @return float |
|
132 | - */ |
|
133 | - public static function get_current_daynum() { |
|
134 | - // Gets the current decimal day number from microtime |
|
135 | - |
|
136 | - list($usec, $sec) = explode(' ', microtime()); |
|
137 | - return self::unix2daynum($sec, $usec); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Converts a standard unix timestamp and optional |
|
142 | - * milliseconds to a daynum |
|
143 | - * |
|
144 | - * @param int $sec Seconds from the unix epoch |
|
145 | - * @param int $usec Optional milliseconds |
|
146 | - * |
|
147 | - * @return float |
|
148 | - */ |
|
149 | - public static function unix2daynum($sec, $usec = 0) |
|
150 | - { |
|
151 | - $time = ((($sec + $usec) / 86400.0) - 3651.0); |
|
152 | - return $time + 2444238.5; |
|
153 | - } |
|
154 | - |
|
155 | - /* The function Delta_ET has been added to allow calculations on */ |
|
156 | - /* the position of the sun. It provides the difference between UT */ |
|
157 | - /* (approximately the same as UTC) and ET (now referred to as TDT).*/ |
|
158 | - /* This function is based on a least squares fit of data from 1950 */ |
|
159 | - /* to 1991 and will need to be updated periodically. */ |
|
160 | - public static function Delta_ET($year) |
|
161 | - { |
|
162 | - /* Values determined using data from 1950-1991 in the 1990 |
|
33 | + /* The function Julian_Date_of_Epoch returns the Julian Date of */ |
|
34 | + /* an epoch specified in the format used in the NORAD two-line */ |
|
35 | + /* element sets. It has been modified to support dates beyond */ |
|
36 | + /* the year 1999 assuming that two-digit years in the range 00-56 */ |
|
37 | + /* correspond to 2000-2056. Until the two-line element set format */ |
|
38 | + /* is changed, it is only valid for dates through 2056 December 31. */ |
|
39 | + public static function Julian_Date_of_Epoch($epoch) |
|
40 | + { |
|
41 | + $year = 0; |
|
42 | + |
|
43 | + /* Modification to support Y2K */ |
|
44 | + /* Valid 1957 through 2056 */ |
|
45 | + $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
46 | + if ($year < 57) { |
|
47 | + $year = $year + 2000; |
|
48 | + } else { |
|
49 | + $year = $year + 1900; |
|
50 | + } |
|
51 | + /* End modification */ |
|
52 | + |
|
53 | + return self::Julian_Date_of_Year($year) + $day; |
|
54 | + } |
|
55 | + |
|
56 | + /* Equivalent to the C modf function */ |
|
57 | + public static function modf($x, &$ipart) { |
|
58 | + $ipart = (int)$x; |
|
59 | + return $x - $ipart; |
|
60 | + } |
|
61 | + |
|
62 | + /* The function Julian_Date_of_Year calculates the Julian Date */ |
|
63 | + /* of Day 0.0 of {year}. This function is used to calculate the */ |
|
64 | + /* Julian Date of any date by using Julian_Date_of_Year, DOY, */ |
|
65 | + /* and Fraction_of_Day. */ |
|
66 | + public static function Julian_Date_of_Year($year) |
|
67 | + { |
|
68 | + /* Astronomical Formulae for Calculators, Jean Meeus, */ |
|
69 | + /* pages 23-25. Calculate Julian Date of 0.0 Jan year */ |
|
70 | + $year = $year - 1; |
|
71 | + $i = (int) ($year / 100); |
|
72 | + $A = $i; |
|
73 | + $i = (int) ($A / 4); |
|
74 | + $B = (int) (2 - $A + $i); |
|
75 | + $i = (int) (365.25 * $year); |
|
76 | + $i += (int) (30.6001 * 14); |
|
77 | + $jdoy = $i + 1720994.5 + $B; |
|
78 | + |
|
79 | + return $jdoy; |
|
80 | + } |
|
81 | + |
|
82 | + /* The function ThetaG calculates the Greenwich Mean Sidereal Time */ |
|
83 | + /* for an epoch specified in the format used in the NORAD two-line */ |
|
84 | + /* element sets. It has now been adapted for dates beyond the year */ |
|
85 | + /* 1999, as described above. The function ThetaG_JD provides the */ |
|
86 | + /* same calculation except that it is based on an input in the */ |
|
87 | + /* form of a Julian Date. */ |
|
88 | + public static function ThetaG($epoch, Predict_DeepArg $deep_arg) |
|
89 | + { |
|
90 | + /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
91 | + // double year,day,UT,jd,TU,GMST,_ThetaG; |
|
92 | + |
|
93 | + /* Modification to support Y2K */ |
|
94 | + /* Valid 1957 through 2056 */ |
|
95 | + $year = 0; |
|
96 | + $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
97 | + |
|
98 | + if ($year < 57) { |
|
99 | + $year += 2000; |
|
100 | + } else { |
|
101 | + $year += 1900; |
|
102 | + } |
|
103 | + /* End modification */ |
|
104 | + |
|
105 | + $UT = fmod($day, $day); |
|
106 | + $jd = self::Julian_Date_of_Year($year) + $day; |
|
107 | + $TU = ($jd - 2451545.0) / 36525; |
|
108 | + $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
109 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
110 | + $deep_arg->ds50 = $jd - 2433281.5 + $UT; |
|
111 | + |
|
112 | + return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); |
|
113 | + } |
|
114 | + |
|
115 | + /* See the ThetaG doc block above */ |
|
116 | + public static function ThetaG_JD($jd) |
|
117 | + { |
|
118 | + /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
119 | + $UT = Predict_Math::Frac($jd + 0.5); |
|
120 | + $jd = $jd - $UT; |
|
121 | + $TU = ($jd - 2451545.0) / 36525; |
|
122 | + $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
123 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
124 | + |
|
125 | + return Predict::twopi * $GMST / Predict::secday; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Read the system clock and return the current Julian day. From phpPredict |
|
130 | + * |
|
131 | + * @return float |
|
132 | + */ |
|
133 | + public static function get_current_daynum() { |
|
134 | + // Gets the current decimal day number from microtime |
|
135 | + |
|
136 | + list($usec, $sec) = explode(' ', microtime()); |
|
137 | + return self::unix2daynum($sec, $usec); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Converts a standard unix timestamp and optional |
|
142 | + * milliseconds to a daynum |
|
143 | + * |
|
144 | + * @param int $sec Seconds from the unix epoch |
|
145 | + * @param int $usec Optional milliseconds |
|
146 | + * |
|
147 | + * @return float |
|
148 | + */ |
|
149 | + public static function unix2daynum($sec, $usec = 0) |
|
150 | + { |
|
151 | + $time = ((($sec + $usec) / 86400.0) - 3651.0); |
|
152 | + return $time + 2444238.5; |
|
153 | + } |
|
154 | + |
|
155 | + /* The function Delta_ET has been added to allow calculations on */ |
|
156 | + /* the position of the sun. It provides the difference between UT */ |
|
157 | + /* (approximately the same as UTC) and ET (now referred to as TDT).*/ |
|
158 | + /* This function is based on a least squares fit of data from 1950 */ |
|
159 | + /* to 1991 and will need to be updated periodically. */ |
|
160 | + public static function Delta_ET($year) |
|
161 | + { |
|
162 | + /* Values determined using data from 1950-1991 in the 1990 |
|
163 | 163 | Astronomical Almanac. See DELTA_ET.WQ1 for details. */ |
164 | 164 | |
165 | - $delta_et = 26.465 + 0.747622 * ($year - 1950) + |
|
166 | - 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); |
|
167 | - |
|
168 | - return $delta_et; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Converts a daynum to a unix timestamp. From phpPredict. |
|
173 | - * |
|
174 | - * @param float $dn Julian Daynum |
|
175 | - * |
|
176 | - * @return float |
|
177 | - */ |
|
178 | - public static function daynum2unix($dn) { |
|
179 | - // Converts a daynum to a UNIX timestamp |
|
180 | - |
|
181 | - return (86400.0 * ($dn - 2444238.5 + 3651.0)); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Converts a daynum to a readable time format. |
|
186 | - * |
|
187 | - * @param float $dn The julian date |
|
188 | - * @param string $zone The zone string, defaults to America/Los_Angeles |
|
189 | - * @param string $format The date() function's format string. Defaults to m-d-Y H:i:s |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') |
|
194 | - { |
|
195 | - $unix = self::daynum2unix($dn); |
|
196 | - $date = new DateTime("@" . round($unix)); |
|
197 | - $dateTimezone = new DateTimezone($zone); |
|
198 | - $date->setTimezone($dateTimezone); |
|
199 | - return $date->format($format); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Returns the unix timestamp of a TLE's epoch |
|
204 | - * |
|
205 | - * @param Predict_TLE $tle The TLE object |
|
206 | - * |
|
207 | - * @return int |
|
208 | - */ |
|
209 | - public static function getEpochTimeStamp(Predict_TLE $tle) |
|
210 | - { |
|
211 | - $year = $tle->epoch_year; |
|
212 | - $day = $tle->epoch_day; |
|
213 | - $sec = round(86400 * $tle->epoch_fod); |
|
214 | - |
|
215 | - $zone = new DateTimeZone('GMT'); |
|
216 | - $date = new DateTime(); |
|
217 | - $date->setTimezone($zone); |
|
218 | - $date->setDate($year, 1, 1); |
|
219 | - $date->setTime(0, 0, 0); |
|
220 | - |
|
221 | - return $date->format('U') + (86400 * $day) + $sec - 86400; |
|
222 | - } |
|
165 | + $delta_et = 26.465 + 0.747622 * ($year - 1950) + |
|
166 | + 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); |
|
167 | + |
|
168 | + return $delta_et; |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Converts a daynum to a unix timestamp. From phpPredict. |
|
173 | + * |
|
174 | + * @param float $dn Julian Daynum |
|
175 | + * |
|
176 | + * @return float |
|
177 | + */ |
|
178 | + public static function daynum2unix($dn) { |
|
179 | + // Converts a daynum to a UNIX timestamp |
|
180 | + |
|
181 | + return (86400.0 * ($dn - 2444238.5 + 3651.0)); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Converts a daynum to a readable time format. |
|
186 | + * |
|
187 | + * @param float $dn The julian date |
|
188 | + * @param string $zone The zone string, defaults to America/Los_Angeles |
|
189 | + * @param string $format The date() function's format string. Defaults to m-d-Y H:i:s |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') |
|
194 | + { |
|
195 | + $unix = self::daynum2unix($dn); |
|
196 | + $date = new DateTime("@" . round($unix)); |
|
197 | + $dateTimezone = new DateTimezone($zone); |
|
198 | + $date->setTimezone($dateTimezone); |
|
199 | + return $date->format($format); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * Returns the unix timestamp of a TLE's epoch |
|
204 | + * |
|
205 | + * @param Predict_TLE $tle The TLE object |
|
206 | + * |
|
207 | + * @return int |
|
208 | + */ |
|
209 | + public static function getEpochTimeStamp(Predict_TLE $tle) |
|
210 | + { |
|
211 | + $year = $tle->epoch_year; |
|
212 | + $day = $tle->epoch_day; |
|
213 | + $sec = round(86400 * $tle->epoch_fod); |
|
214 | + |
|
215 | + $zone = new DateTimeZone('GMT'); |
|
216 | + $date = new DateTime(); |
|
217 | + $date->setTimezone($zone); |
|
218 | + $date->setDate($year, 1, 1); |
|
219 | + $date->setTime(0, 0, 0); |
|
220 | + |
|
221 | + return $date->format('U') + (86400 * $day) + $sec - 86400; |
|
222 | + } |
|
223 | 223 | } |