Skip to content

Commit 77cb4f1

Browse files
committed
imports
1 parent f6169ed commit 77cb4f1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

pymap3d/__init__.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from __future__ import division
1818
from dateutil.parser import parse
1919
from datetime import datetime
20-
from numpy import (sin, cos, tan, sqrt, radians, arctan2, hypot, degrees, mod,
21-
atleast_2d, atleast_1d, empty_like, array, column_stack)
20+
import numpy as np
21+
from numpy import sin, cos, tan, sqrt, radians, arctan2, hypot, degrees, mod
2222
try:
2323
from astropy.time import Time
2424
from astropy import units as u
@@ -91,7 +91,7 @@ def eci2ecef(eci, t):
9191
if Time is None:
9292
raise ImportError('You need to install AstroPy')
9393

94-
t = atleast_1d(t)
94+
t = np.atleast_1d(t)
9595
if isinstance(t[0],str): #don't just ram in in case it's float
9696
t = str2dt(t)
9797

@@ -104,14 +104,14 @@ def eci2ecef(eci, t):
104104

105105
assert isinstance(gst[0], float) # must be in radians!
106106

107-
eci = atleast_2d(eci)
107+
eci = np.atleast_2d(eci)
108108
N, trip = eci.shape
109109
if eci.ndim > 2 or trip != 3:
110110
raise TypeError('eci triplets must be shape (N,3)')
111111
"""ported from:
112112
https://github.com/dinkelk/astrodynamics/blob/master/rot3.m
113113
"""
114-
ecef = empty_like(eci)
114+
ecef = np.empty_like(eci)
115115

116116
for i in range(N):
117117
ecef[i, :] = _rottrip(gst[i]) @ eci[i, :]
@@ -143,7 +143,7 @@ def ned2ecef(n, e, d, lat0, lon0, h0, ell=EarthEllipsoid(), deg=True):
143143
#%% to ECI
144144
def aer2eci(az, el, srange, lat0, lon0, h0, t, ell=EarthEllipsoid(), deg=True):
145145
x, y, z = aer2ecef(az, el, srange, lat0, lon0, h0, ell, deg)
146-
return ecef2eci(column_stack((x, y, z)), t)
146+
return ecef2eci(np.column_stack((x, y, z)), t)
147147

148148

149149
def ecef2eci(ecef, t):
@@ -154,7 +154,7 @@ def ecef2eci(ecef, t):
154154
if Time is None:
155155
raise ImportError('Please install AstroPy')
156156

157-
t = atleast_1d(t)
157+
t = np.atleast_1d(t)
158158
if isinstance(t[0],str): #don't just ram in in case it's float
159159
t = str2dt(t)
160160

@@ -167,14 +167,14 @@ def ecef2eci(ecef, t):
167167

168168
assert isinstance(gst[0], float) # must be in radians!
169169

170-
ecef = atleast_2d(ecef)
170+
ecef = np.atleast_2d(ecef)
171171
N, trip = ecef.shape
172172
if ecef.ndim > 2 or trip != 3:
173173
raise TypeError('ecef triplets must be shape (N,3)')
174174
"""ported from:
175175
https://github.com/dinkelk/astrodynamics/blob/master/rot3.m
176176
"""
177-
eci = empty_like(ecef)
177+
eci = np.empty_like(ecef)
178178
for i in range(N):
179179
eci[i, :] = _rottrip(gst[i]).T @ ecef[i, :] # this one is transposed
180180

@@ -382,7 +382,7 @@ def str2dt(t):
382382
output: datetime
383383
"""
384384

385-
t = atleast_1d(t)
385+
t = np.atleast_1d(t)
386386
if isinstance(t[0],str):
387387
t = [parse(T) for T in t]
388388

@@ -416,9 +416,9 @@ def _rottrip(ang):
416416
"""ported from:
417417
https://github.com/dinkelk/astrodynamics/blob/master/rot3.m
418418
"""
419-
return array([[cos(ang), sin(ang), 0],
420-
[-sin(ang), cos(ang), 0],
421-
[0, 0, 1]])
419+
return np.array([[cos(ang), sin(ang), 0],
420+
[-sin(ang), cos(ang), 0],
421+
[0, 0, 1]])
422422

423423

424424
def _enu2uvw(east, north, up, lat0, lon0, deg=True):
@@ -465,8 +465,10 @@ def radec2azel(ra_deg, dec_deg, lat_deg, lon_deg, t):
465465
raise ImportError('You need to install AstroPy')
466466
#%% input trapping
467467
t = str2dt(t)
468-
lat_deg = atleast_1d(lat_deg); lon_deg = atleast_1d(lon_deg)
469-
ra_deg = atleast_1d(ra_deg); dec_deg = atleast_1d(dec_deg)
468+
lat_deg = np.atleast_1d(lat_deg)
469+
lon_deg = np.atleast_1d(lon_deg)
470+
ra_deg = np.atleast_1d(ra_deg)
471+
dec_deg = np.atleast_1d(dec_deg)
470472

471473
assert lat_deg.size == 1 & lon_deg.size == 1, 'radec2azel is designed for one observer and one or more points (ra,dec).'
472474
assert ra_deg.shape == dec_deg.shape, 'ra and dec must be the same shape ndarray'

0 commit comments

Comments
 (0)