Skip to content

Commit e086551

Browse files
committed
Tests are passing.
1 parent 80b562a commit e086551

File tree

2 files changed

+34
-66
lines changed

2 files changed

+34
-66
lines changed

astroquery/jplhorizons/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Conf(_config.ConfigNamespace):
5252
'illumination_flag': ('illumination_flag', '---'),
5353
'nearside_flag': ('nearside_flag', '---'),
5454
'R.A._(ICRF)': ('RA', 'deg'),
55-
'DEC__(ICRF)': ('DEC', 'deg'),
55+
'DEC_(ICRF)': ('DEC', 'deg'),
5656
'R.A.___(ICRF)': ('RA', 'deg'),
5757
'DEC____(ICRF)': ('DEC', 'deg'),
5858
'R.A._(ICRF/J2000.0)': ('RA', 'deg'),
@@ -84,7 +84,7 @@ class Conf(_config.ConfigNamespace):
8484
'X_(sat-prim)': ('sat_X', 'arcsec'),
8585
'Y_(sat-prim)': ('sat_Y', 'arcsec'),
8686
'SatPANG': ('sat_PANG', 'deg'),
87-
'L_Ap_Sid_Time': ('siderealtime', '---'),
87+
'L_Ap_Sid_Time': ('siderealtime', "hour"),
8888
'a-mass': ('airmass', '---'),
8989
'mag_ex': ('magextinct', 'mag'),
9090
'APmag': ('V', 'mag'),
@@ -145,7 +145,7 @@ class Conf(_config.ConfigNamespace):
145145
'N.Pole-DC': ('NPole_DEC', 'deg'),
146146
'GlxLon': ('GlxLon', 'deg'),
147147
'GlxLat': ('GlxLat', 'deg'),
148-
'L_Ap_SOL_Time': ('solartime', '---'),
148+
'L_Ap_SOL_Time': ('solartime', 'hour'),
149149
'399_ins_LT': ('earth_lighttime', 'minute'),
150150
'RA_3sigma': ('RA_3sigma', 'arcsec'),
151151
'DEC_3sigma': ('DEC_3sigma', 'arcsec'),
@@ -160,8 +160,8 @@ class Conf(_config.ConfigNamespace):
160160
'DOP_X_3sig': ('XBand_3sigma', 'Hz'),
161161
'RT_delay_3sig': ('DoppDelay_3sigma', 'second'),
162162
'Tru_Anom': ('true_anom', 'deg'),
163-
'r-L_Ap_Hour_Ang': ('hour_angle', '---'),
164-
'L_Ap_Hour_Ang': ('hour_angle', '---'),
163+
'r-L_Ap_Hour_Ang': ('hour_angle', 'hour'),
164+
'L_Ap_Hour_Ang': ('hour_angle', 'hour'),
165165
'phi': ('alpha_true', 'deg'),
166166
'PAB-LON': ('PABLon', 'deg'),
167167
'PAB-LAT': ('PABLat', 'deg'),

astroquery/jplhorizons/tests/test_jplhorizons_remote.py

Lines changed: 29 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@
1515

1616
@pytest.mark.remote_data
1717
class TestHorizonsClass:
18-
1918
def test_ephemerides_query(self):
2019
# check all values of Ceres for a given epoch
21-
# orbital uncertainty of Ceres is basically zero
22-
res = jplhorizons.Horizons(id='Ceres', location='I41',
23-
id_type='smallbody',
24-
epochs=2451544.5,
25-
quantities=",".join(str(q) for q in range(1, 49))
26-
).ephemerides()[0]
20+
quantities = ",".join(str(q) for q in range(1, 49))
21+
horizons = jplhorizons.Horizons(
22+
id="Ceres", location="I41", id_type="smallbody", epochs=2451544.5
23+
)
24+
res = horizons.ephemerides(quantities=quantities)
2725

2826
# Retrieved 2023 Aug 01:
2927
values = {
28+
"targetname": "1 Ceres (A801 AA)",
29+
"H": 3.33,
30+
"G": 0.120,
31+
"datetime_jd": 2451544.5,
3032
"datetime_str": "2000-Jan-01 00:00:00.000",
3133
"solar_presence": "*",
3234
"lunar_presence": "",
33-
"RA": Angle("12 34 48.58", unit="hr"),
34-
"DEC": Angle("+09 05 51.3", unit="deg"),
35-
"RA_app": Angle("12 34 47.66", unit="hr"),
36-
"DEC_app": Angle("+09 05 53.0", unit="deg"),
35+
"RA": 188.70240 * u.deg,
36+
"DEC": 9.09758 * u.deg,
37+
"RA_app": 188.69858 * u.deg,
38+
"DEC_app": 9.09806 * u.deg,
3739
"RA_rate": 35.17815 * u.arcsec / u.hr,
3840
"DEC_rate": -2.74237 * u.arcsec / u.hr,
3941
"AZ": 325.548736 * u.deg,
@@ -43,7 +45,7 @@ def test_ephemerides_query(self):
4345
"sat_X": -304791.02 * u.arcsec,
4446
"sat_Y": 115814.995 * u.arcsec,
4547
"sat_PANG": 277.607 * u.deg,
46-
"siderealtime": "22 52 25.4117",
48+
"siderealtime": 22.8737254836 * u.hr,
4749
"airmass": 999,
4850
"magextinct": np.ma.masked,
4951
"V": 8.259 * u.mag,
@@ -87,7 +89,7 @@ def test_ephemerides_query(self):
8789
"NPole_DEC": 66.76033 * u.deg,
8890
"GlxLon": 289.863376 * u.deg,
8991
"GlxLat": 71.544870 * u.deg,
90-
"solartime": "16 09 31.6338",
92+
"solartime": 16.1587871790 * u.hour,
9193
"earth_lighttime": 0.000354 * u.minute,
9294
"RA_3sigma": 0.000 * u.arcsec,
9395
"DEC_3sigma": 0.000 * u.arcsec,
@@ -102,74 +104,40 @@ def test_ephemerides_query(self):
102104
"XBand_3sigma": 0.00 * u.Hz,
103105
"DoppDelay_3sigma": 0.000001 * u.s,
104106
"true_anom": 7.1181 * u.deg,
105-
"hour_angle": "10 17 37.752",
107+
"hour_angle": 10.293820034 * u.hour,
106108
"alpha_true": 22.5691 * u.deg,
107109
"PABLon": 172.8355 * u.deg,
108110
"PABLat": 11.3478 * u.deg,
109111
"App_Lon_Sun": 309.1603680 * u.deg,
110-
"RA_ICRF_app": Angle("12 34 48.57", unit=u.hr),
111-
"DEC_ICRF_app": Angle("+09 05 46.6", unit=u.deg),
112+
"RA_ICRF_app": 188.70238 * u.deg,
113+
"DEC_ICRF_app": 9.09628 * u.deg,
112114
"RA_ICRF_rate": 35.17809 * u.arcsec / u.hour,
113115
"DEC_ICRF_rate": -2.74321 * u.arcsec / u.hour,
114116
"Sky_motion": 0.5880814 * u.arcsec / u.minute,
115117
"Sky_mot_PA": 94.457576 * u.deg,
116118
"RelVel-ANG": -53.53947 * u.deg,
117-
"Lun_Sky_Brt": np.masked,
118-
"sky_SNR": np.masked,
119+
"Lun_Sky_Brt": np.ma.masked,
120+
"sky_SNR": np.ma.masked,
119121
}
120122

121123
# the ephemeris changes with Ceres's and the planets' orbital elements,
122-
# which can be updated at any time, so only check for 1% tolerance, this
123-
# is enough to verify that columns are not being confused, and that
124+
# which can be updated at any time, so only check for 0.1% tolerance, this
125+
# is enough to verify that most columns are not being confused, and that
124126
# units are correct
125127

126128
for column, value in values.items():
127-
if u.isinstance(value, (u.Quantity, u.Angle)):
128-
assert u.isclose(res[column], value, rtol=0.001)
129+
if isinstance(value, (u.Quantity, Angle)):
130+
# A few columns have varied a lot more than the others
131+
if column in ["H", "G", "V", "surfbright"]:
132+
rtol = 0.1
133+
else:
134+
rtol = 0.001
135+
assert u.isclose(res[column], value, rtol=rtol)
129136
elif value is np.ma.masked:
130137
assert is_masked(res[column])
131138
else:
132139
assert res[column] == value
133140

134-
# assert res['targetname'] == "1 Ceres (A801 AA)"
135-
# assert res['datetime_str'] == "2000-Jan-01 00:00:00.000"
136-
# assert res['solar_presence'] == ""
137-
# assert res['lunar_presence'] == ""
138-
# assert res['elongFlag'] == '/L'
139-
# assert res['airmass'] == 999
140-
141-
# assert is_masked(res['AZ'])
142-
# assert is_masked(res['EL'])
143-
# assert is_masked(res['magextinct'])
144-
145-
# assert_quantity_allclose(
146-
# [2451544.5,
147-
# 3.33, .120,
148-
# 188.7028, 9.09829, 34.40955, -2.68359,
149-
# 96.17083,
150-
# 161.3828, 10.4528, 2.551099027865, 0.1744491,
151-
# 2.26315121010004, -21.9390512, 18.82205467,
152-
# 95.3996, 22.5698, 292.551,
153-
# 296.85,
154-
# 184.3426241, 11.7996517, 289.864335,
155-
# 71.545654,
156-
# 0.0, 0.0],
157-
# [res['datetime_jd'],
158-
# res['H'], res['G'],
159-
# res['RA'], res['DEC'], res['RA_rate'], res['DEC_rate'],
160-
# res['illumination'],
161-
# res['EclLon'], res['EclLat'], res['r'], res['r_rate'],
162-
# res['delta'], res['delta_rate'], res['lighttime'],
163-
# res['elong'], res['alpha'], res['sunTargetPA'],
164-
# res['velocityPA'],
165-
# res['ObsEclLon'], res['ObsEclLat'], res['GlxLon'],
166-
# res['GlxLat'],
167-
# res['RA_3sigma'], res['DEC_3sigma']], rtol=1e-3)
168-
169-
# # V and surfbright tend to vary a lot more than the others. Give them a
170-
# # more generous test:
171-
# assert_quantity_allclose([8.239, 6.779], [res['V'], res['surfbright']], rtol=0.1)
172-
173141
def test_ephemerides_query_two(self):
174142
# check comet ephemerides using options
175143
obj = jplhorizons.Horizons(id='Halley', id_type='comet_name',

0 commit comments

Comments
 (0)