@@ -1072,8 +1072,8 @@ def to_hrz(self, observer, jD):
10721072 """
10731073 Get local horizontal coordinates from equatorial/celestial coordinates.
10741074
1075- Param: observer - Object of type hrz_posn representing the object 's
1076- position in the sky .
1075+ Param: observer - Object of type geo_posn representing the observers 's
1076+ location on the Earth .
10771077 Param: jD - UTC Julian day (float).
10781078
10791079 Returns object of type hrz_posn representing local position.
@@ -2114,15 +2114,19 @@ def get_ecl_from_rect(rect):
21142114 """
21152115 Get ecliptical coordinates from rectangular coordinates.
21162116
2117- Param: rect - Object of type rect_posn representing position.
2117+ Param: rect - Object of type rect_posn representing position in AU .
21182118
21192119 Returns object of type ecl_posn representing ecliptical position.
21202120 """
21212121
2122- _posn = ecl_posn ()
2123- _posn .lng = 1 * rect .lng
2124- _posn .lat = 1 * rect .lat
2125- return _posn
2122+ x = rect .X
2123+ y = rect .Y
2124+ z = rect .Z
2125+
2126+ sc = GeocentricTrueEcliptic (CartesianRepresentation (x * astrounits .au , y * astrounits .au , z * astrounits .au ),
2127+ equinox = 'J2000' )
2128+
2129+ return ecl_posn .from_astropy (sc )
21262130
21272131
21282132def get_equ_from_ecl (target , jD ):
@@ -2327,9 +2331,11 @@ def get_apparent_posn(mean_position, jD, proper_motion = None):
23272331
23282332 if proper_motion is None :
23292333 proper_motion = [mean_position .pm_ra , mean_position .pm_dec ]
2330- if proper_motion [0 ] is None or proper_motion [1 ] is None :
2331- proper_motion = _DEFAULT_PROPER_MOTION
2332-
2334+ if proper_motion [0 ] is None :
2335+ proper_motion = (_DEFAULT_PROPER_MOTION [0 ], proper_motion [1 ])
2336+ if proper_motion [1 ] is None :
2337+ proper_motion = (proper_motion [0 ], _DEFAULT_PROPER_MOTION [1 ])
2338+
23332339 t = AstroTime (jD , format = 'jd' , scale = 'utc' )
23342340 sc = mean_position .astropy
23352341 if sc is None :
@@ -3085,7 +3091,7 @@ def tt_to_tai(ttJD):
30853091 Returns: The TAI JD value (float).
30863092 """
30873093
3088- t = AstroTime (taiJD , format = 'jd' , scale = 'tt' )
3094+ t = AstroTime (ttJD , format = 'jd' , scale = 'tt' )
30893095 return t .tai .jd
30903096
30913097
@@ -3394,7 +3400,7 @@ def get_rect_from_equ(posn):
33943400
33953401 Param: posn - Object of type equ_posn giving position.
33963402
3397- Returns: Object of type rect_posn giving rectangular coordinates (normallized to 1).
3403+ Returns: Object of type rect_posn giving rectangular coordinates (normalized to 1).
33983404 """
33993405
34003406 sc = SkyCoord (posn .ra * astrounits .deg , posn .dec * astrounits .deg ,
@@ -3432,7 +3438,7 @@ def get_geo_from_rect(posn):
34323438 Adapoted from "Satellite Orbits", Montenbruck and Gill 2005, 5.85 - 5.88.
34333439 Also see gpstk ECEF::asGeodetic() method.
34343440
3435- Param: posn - object of type rect_posn giving position.
3441+ Param: posn - object of type rect_posn giving position in m .
34363442
34373443 Returns: object of type geo_posn giving geographical coordinates.
34383444 """
@@ -3450,7 +3456,7 @@ def get_rect_from_geo(posn):
34503456
34513457 Param: posn - object of type geo_posn giving geographical coordinates.
34523458
3453- Returns: object of type rect_posn giving ECEF position.
3459+ Returns: object of type rect_posn giving ECEF position in m .
34543460 """
34553461
34563462 el = EarthLocation .from_geodetic (posn .lng * astrounits .deg , posn .lat * astrounits .deg ,
@@ -3541,50 +3547,50 @@ def resolve_name(name):
35413547 """
35423548
35433549 try :
3544- result = urlopen ('https://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oxp/SNV?%s' % quote_plus (name ))
3545- tree = ElementTree .fromstring (result .read ())
3546- target = tree .find ('Target' )
3547- service = target .find ('Resolver' )
3548- ra = service .find ('jradeg' )
3549- dec = service .find ('jdedeg' )
3550- try :
3551- pm = service .find ('pm' )
3552- except Exception as e :
3553- pm = None
3554- try :
3555- plx = service .find ('plx' )
3556- except Exception as e :
3557- plx = None
3558-
3559- service = service .attrib ['name' ].split ('=' , 1 )[1 ]
3560- ra = float (ra .text )
3561- dec = float (dec .text )
3562- coordsys = 'J2000'
3563- if pm is not None :
3564- pmRA = float (pm .find ('pmRA' ).text )
3565- pmDec = float (pm .find ('pmDE' ).text )
3566- else :
3567- pmRA = None
3568- pmDec = None
3569- if plx is not None :
3570- dist = float (plx .find ('v' ).text )
3571- else :
3572- dist = None
3573-
3574- if pmRA is not None :
3575- pmRA = pmRA * math .cos (dec * math .pi / 180 )* astrounits .mas / astrounits .yr
3576- if pmDec is not None :
3577- pmDec = pmDec * astrounits .mas / astrounits .yr
3578- if dist is not None :
3579- dist = dist * astrounits .pc
3580-
3581- sc = SkyCoord (ra * astrounits .deg , dec * astrounits .deg ,
3582- pm_ra_cosdec = pmRA , pm_dec = pmDec ,
3583- distance = dist ,
3584- frame = 'icrs' )
3585- _posn = equ_posn .from_astropy (sc )
3586- _posn .resolved_by = service
3587-
3550+ with urlopen ('https://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oxp/SNV?%s' % quote_plus (name )) as result :
3551+ tree = ElementTree .fromstring (result .read ())
3552+ target = tree .find ('Target' )
3553+ service = target .find ('Resolver' )
3554+ ra = service .find ('jradeg' )
3555+ dec = service .find ('jdedeg' )
3556+ try :
3557+ pm = service .find ('pm' )
3558+ except Exception as e :
3559+ pm = None
3560+ try :
3561+ plx = service .find ('plx' )
3562+ except Exception as e :
3563+ plx = None
3564+
3565+ service = service .attrib ['name' ].split ('=' , 1 )[1 ]
3566+ ra = float (ra .text )
3567+ dec = float (dec .text )
3568+ coordsys = 'J2000'
3569+ if pm is not None :
3570+ pmRA = float (pm .find ('pmRA' ).text )
3571+ pmDec = float (pm .find ('pmDE' ).text )
3572+ else :
3573+ pmRA = None
3574+ pmDec = None
3575+ if plx is not None :
3576+ dist = float (plx .find ('v' ).text )
3577+ else :
3578+ dist = None
3579+
3580+ if pmRA is not None :
3581+ pmRA = pmRA * math .cos (dec * math .pi / 180 )* astrounits .mas / astrounits .yr
3582+ if pmDec is not None :
3583+ pmDec = pmDec * astrounits .mas / astrounits .yr
3584+ if dist is not None :
3585+ dist = dist * astrounits .pc
3586+
3587+ sc = SkyCoord (ra * astrounits .deg , dec * astrounits .deg ,
3588+ pm_ra_cosdec = pmRA , pm_dec = pmDec ,
3589+ distance = dist ,
3590+ frame = 'icrs' )
3591+ _posn = equ_posn .from_astropy (sc )
3592+ _posn .resolved_by = service
3593+
35883594 except (IOError , AttributeError , ValueError , RuntimeError ) as e :
35893595 raise RuntimeError (f"Failed to resolve source '{ name } '" )
35903596
0 commit comments