@@ -54,25 +54,7 @@ def eci2ecef_astropy(x, y, z, t: datetime) -> tuple:
54
54
"""
55
55
eci2ecef using Astropy
56
56
57
- Parameters
58
- ----------
59
- x : float
60
- ECI x-location [meters]
61
- y : float
62
- ECI y-location [meters]
63
- z : float
64
- ECI z-location [meters]
65
- t : datetime.datetime
66
- time of obsevation (UTC)
67
-
68
- Results
69
- -------
70
- x_ecef : float
71
- x ECEF coordinate
72
- y_ecef : float
73
- y ECEF coordinate
74
- z_ecef : float
75
- z ECEF coordinate
57
+ see eci2ecef() for description
76
58
"""
77
59
78
60
gcrs = GCRS (CartesianRepresentation (x * u .m , y * u .m , z * u .m ), obstime = t )
@@ -89,27 +71,7 @@ def eci2ecef_numpy(x, y, z, t: datetime) -> tuple:
89
71
"""
90
72
eci2ecef using Numpy
91
73
92
- less accurate than astropy, but may be good enough.
93
-
94
- Parameters
95
- ----------
96
- x : float
97
- ECI x-location [meters]
98
- y : float
99
- ECI y-location [meters]
100
- z : float
101
- ECI z-location [meters]
102
- t : datetime.datetime
103
- time of obsevation (UTC)
104
-
105
- Results
106
- -------
107
- x_ecef : float
108
- x ECEF coordinate
109
- y_ecef : float
110
- y ECEF coordinate
111
- z_ecef : float
112
- z ECEF coordinate
74
+ see eci2ecef() for description
113
75
"""
114
76
115
77
x = numpy .atleast_1d (x )
@@ -165,33 +127,50 @@ def ecef2eci(x, y, z, time: datetime) -> tuple:
165
127
"""
166
128
167
129
try :
168
- itrs = ITRS (CartesianRepresentation (x * u .m , y * u .m , z * u .m ), obstime = time )
169
- gcrs = itrs .transform_to (GCRS (obstime = time ))
170
- eci = EarthLocation (* gcrs .cartesian .xyz )
171
-
172
- x_eci = eci .x .value
173
- y_eci = eci .y .value
174
- z_eci = eci .z .value
130
+ return ecef2eci_astropy (x , y , z , time )
175
131
except NameError :
176
- x = numpy .atleast_1d (x )
177
- y = numpy .atleast_1d (y )
178
- z = numpy .atleast_1d (z )
179
- gst = numpy .atleast_1d (greenwichsrt (juliandate (time )))
180
- assert x .shape == y .shape == z .shape
181
- assert x .size == gst .size
182
-
183
- ecef = numpy .column_stack ((x .ravel (), y .ravel (), z .ravel ()))
184
- eci = numpy .empty ((x .size , 3 ))
185
- for i in range (x .size ):
186
- eci [i , :] = R3 (gst [i ]).T @ ecef [i , :]
187
-
188
- x_eci = eci [:, 0 ].reshape (x .shape )
189
- y_eci = eci [:, 1 ].reshape (y .shape )
190
- z_eci = eci [:, 2 ].reshape (z .shape )
132
+ return ecef2eci_numpy (x , y , z , time )
133
+
134
+
135
+ def ecef2eci_astropy (x , y , z , t : datetime ) -> tuple :
136
+ """ecef2eci using Astropy
137
+ see ecef2eci() for description
138
+ """
139
+ itrs = ITRS (CartesianRepresentation (x * u .m , y * u .m , z * u .m ), obstime = t )
140
+ gcrs = itrs .transform_to (GCRS (obstime = t ))
141
+ eci = EarthLocation (* gcrs .cartesian .xyz )
142
+
143
+ x_eci = eci .x .value
144
+ y_eci = eci .y .value
145
+ z_eci = eci .z .value
191
146
192
147
return x_eci , y_eci , z_eci
193
148
194
149
150
+ def ecef2eci_numpy (x , y , z , t : datetime ) -> tuple :
151
+ """ecef2eci using Numpy
152
+ see ecef2eci() for description
153
+ """
154
+
155
+ x = numpy .atleast_1d (x )
156
+ y = numpy .atleast_1d (y )
157
+ z = numpy .atleast_1d (z )
158
+ gst = numpy .atleast_1d (greenwichsrt (juliandate (t )))
159
+ assert x .shape == y .shape == z .shape
160
+ assert x .size == gst .size
161
+
162
+ ecef = numpy .column_stack ((x .ravel (), y .ravel (), z .ravel ()))
163
+ eci = numpy .empty ((x .size , 3 ))
164
+ for i in range (x .size ):
165
+ eci [i , :] = R3 (gst [i ]).T @ ecef [i , :]
166
+
167
+ x_eci = eci [:, 0 ].reshape (x .shape )
168
+ y_eci = eci [:, 1 ].reshape (y .shape )
169
+ z_eci = eci [:, 2 ].reshape (z .shape )
170
+
171
+ return x_eci .squeeze ()[()], y_eci .squeeze ()[()], z_eci .squeeze ()[()]
172
+
173
+
195
174
def R3 (x : float ):
196
175
"""Rotation matrix for ECI"""
197
176
return numpy .array (
0 commit comments