1515"""
1616
1717from __future__ import division
18+ from six import string_types ,PY2
1819from dateutil .parser import parse
1920from datetime import datetime
2021import numpy as np
@@ -118,7 +119,7 @@ def eci2ecef(eci, t):
118119 raise ImportError ('You need to install AstroPy' )
119120
120121 t = np .atleast_1d (t )
121- if isinstance (t [0 ],str ): #don't just ram in in case it's float
122+ if isinstance (t [0 ], string_types ): #don't just ram in in case it's float
122123 t = str2dt (t )
123124
124125 if isinstance (t [0 ], datetime ):
@@ -140,7 +141,8 @@ def eci2ecef(eci, t):
140141 ecef = np .empty_like (eci )
141142
142143 for i in range (N ):
143- ecef [i , :] = _rottrip (gst [i ]) @ eci [i , :]
144+ #ecef[i, :] = _rottrip(gst[i]) @ eci[i, :]
145+ ecef [i , :] = _rottrip (gst [i ]).dot (eci [i , :])
144146
145147 return ecef
146148
@@ -187,7 +189,7 @@ def ecef2eci(ecef, t):
187189 raise ImportError ('Please install AstroPy' )
188190
189191 t = np .atleast_1d (t )
190- if isinstance (t [0 ],str ): #don't just ram in in case it's float
192+ if isinstance (t [0 ], string_types ): #don't just ram in in case it's float
191193 t = str2dt (t )
192194
193195 if isinstance (t [0 ], datetime ):
@@ -208,7 +210,8 @@ def ecef2eci(ecef, t):
208210 """
209211 eci = np .empty_like (ecef )
210212 for i in range (N ):
211- eci [i , :] = _rottrip (gst [i ]).T @ ecef [i , :] # this one is transposed
213+ #eci[i, :] = _rottrip(gst[i]).T @ ecef[i, :] # this one is transposed
214+ eci [i , :] = _rottrip (gst [i ]).T .dot (ecef [i , :]) # this one is transposed
212215
213216 return eci
214217#%% to ENU
@@ -423,10 +426,10 @@ def str2dt(t):
423426 """
424427
425428 t = np .atleast_1d (t )
426- if isinstance (t [0 ],str ):
429+ if isinstance (t [0 ], string_types ):
427430 t = [parse (T ) for T in t ]
428431
429- assert isinstance (t [0 ],datetime ), 'did not convert {} to datetime' .format (type (t [0 ]))
432+ assert isinstance (t [0 ], datetime ), 'did not convert {} to datetime' .format (type (t [0 ]))
430433
431434 return t
432435#%% internal use
@@ -487,15 +490,20 @@ def _uvw2enu(u, v, w, lat0, lon0, deg):
487490
488491#%% azel radec
489492def azel2radec (az_deg , el_deg , lat_deg , lon_deg , t ):
493+ if PY2 :
494+ raise RuntimeError ('Python 2 is not supported for this AstroPy operation. It is time to upgrade to Python 3 (released 2008)' )
495+
490496 if Time is None :
491497 raise ImportError ('You need to install AstroPy' )
492498
493499
494500 t = str2dt (t )
495501
496502 obs = EarthLocation (lat = lat_deg * u .deg , lon = lon_deg * u .deg )
503+
497504 direc = AltAz (location = obs , obstime = Time (t ),
498505 az = az_deg * u .deg , alt = el_deg * u .deg )
506+
499507 sky = SkyCoord (direc .transform_to (ICRS ()))
500508
501509 return sky .ra .deg , sky .dec .deg
0 commit comments