Skip to content

Commit c8f7b4c

Browse files
emolterbsipocz
authored andcommitted
added test for Pluto, wrote an rst file
1 parent 2dfa100 commit c8f7b4c

File tree

5 files changed

+349
-555
lines changed

5 files changed

+349
-555
lines changed

astroquery/solarsystem/pds/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ def ephemeris_async(
144144
elif type(obs_time) == str:
145145
try:
146146
Time.strptime(obs_time, "%Y-%m-%d %H:%M").jd
147-
except Exception as e:
147+
except Exception as ex:
148148
raise ValueError(
149149
"illegal value for 'obs_time' parameter. string must have format 'yyyy-mm-dd hh:mm'"
150150
)
151151
elif type(obs_time) == Time:
152152
try:
153153
obs_time = obs_time.utc.to_value("iso", subfmt="date_hm")
154-
except Exception as e:
154+
except Exception as ex:
155155
raise ValueError(
156156
"illegal value for 'obs_time' parameter. could not parse astropy.time.core.Time object into format 'yyyy-mm-dd hh:mm' (UTC)"
157157
)
@@ -444,7 +444,8 @@ def _parse_ringnode(self, src):
444444
pass
445445

446446
# do some cleanup from the parsing job
447-
ringtable.add_index("ring")
447+
if ringtable is not None:
448+
ringtable.add_index("ring")
448449

449450
bodytable = table.join(bodytable, bodytable2) # concatenate minor body table
450451
bodytable.add_index("Body")
@@ -474,7 +475,7 @@ def _parse_result(self, response, verbose=None):
474475
self.last_response = response
475476
try:
476477
systemtable, bodytable, ringtable = self._parse_ringnode(response.text)
477-
except Exception as e:
478+
except Exception as ex:
478479
try:
479480
self._last_query.remove_cache_file(self.cache_location)
480481
except OSError:
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
<title>Pluto Viewer 3.0 Results</title>
4+
<body style="font-family:arial; font-size:medium">
5+
<h1>Pluto Viewer 3.0 Results</h1>
6+
<p>
7+
<pre>
8+
Input Parameters
9+
----------------
10+
11+
Observation time: 2021-10-07 07:25
12+
Ephemeris: PLU058 + DE440
13+
Field of view: 10 (Pluto-Charon separations (19,571 km))
14+
Diagram center: Pluto
15+
Viewpoint: Earth's center
16+
Moon selection: All moons (P1-P5)
17+
Ring selection: None
18+
Standard stars: No
19+
Additional star: No
20+
Other bodies: None
21+
Title:
22+
Moon labels: Small (6 points)
23+
Moon enlargement: 0 (points)
24+
Blank disks: No
25+
Prime meridians: Yes
26+
27+
28+
Field of View Description (J2000)
29+
---------------------------------
30+
31+
Body RA Dec RA (deg) Dec (deg) dRA (") dDec (")
32+
999 Pluto 19h 44m 51.0347s -22d 56m 05.931s 296.212645 -22.934981 0.000 0.000
33+
901 Charon 19h 44m 51.0870s -22d 56m 05.830s 296.212862 -22.934953 0.722 0.101
34+
902 Nix 19h 44m 50.9270s -22d 56m 04.738s 296.212196 -22.934650 -1.488 1.192
35+
903 Hydra 19h 44m 51.0560s -22d 56m 08.227s 296.212733 -22.935619 0.294 -2.297
36+
904 Kerberos 19h 44m 50.9309s -22d 56m 07.195s 296.212212 -22.935332 -1.434 -1.264
37+
905 Styx 19h 44m 50.9944s -22d 56m 07.189s 296.212477 -22.935330 -0.557 -1.259
38+
39+
Sub-Observer Sub-Solar
40+
Body Lon(degW) Lat(deg) Lon(degW) Lat(deg) Phase(deg) Distance(10^6 km)
41+
999 Pluto 45.545 56.505 47.823 57.577 1.64048 5114.486814
42+
901 Charon 225.545 56.505 227.823 57.578 1.64048 5114.479237
43+
902 Nix 283.749 -41.845 285.264 -43.043 1.64048 5114.482774
44+
903 Hydra 7.786 -11.624 6.718 -12.887 1.64047 5114.516518
45+
904 Kerberos 12.108 56.881 14.388 57.967 1.64047 5114.516443
46+
905 Styx 350.443 56.472 352.720 57.544 1.64047 5114.509238
47+
48+
Ring sub-solar latitude (deg): 57.57737 ( 57.56961 to 57.58512)
49+
Ring plane opening angle (deg): 56.50534 (lit)
50+
Ring center phase angle (deg): 1.64048
51+
Sub-solar longitude (deg): 116.55873 from ring plane ascending node
52+
Sub-observer longitude (deg): 118.83690
53+
54+
Sun-planet distance (AU): 34.37680
55+
Observer-planet distance (AU): 34.18823
56+
Sun-planet distance (km): 5142.695995 x 10^6
57+
Observer-planet distance (km): 5114.486814 x 10^6
58+
Light travel time (sec): 17060.091666
59+
60+
</pre>
61+
<hr><b>Preview:</b><p>
62+
<a href="/work/viewer3_plu_42191.pdf"><image src="/work/viewer3_plu_42191tn.jpg"/></a><br>
63+
Click
64+
<a href="/work/viewer3_plu_42191.pdf">here</a>
65+
to download diagram (PDF, 11875 bytes).<p>
66+
Click
67+
<a href="/work/viewer3_plu_42191.jpg">here</a>
68+
to download diagram (JPEG format, 122052 bytes).<p>
69+
Click
70+
<a href="/work/viewer3_plu_42191.ps">here</a>
71+
to download diagram (PostScript format, 23630 bytes).
72+
<hr>
73+
<a href="/tools/viewer3_plu.shtml">Pluto Viewer Form</a> |
74+
<a href="/tools/index.html">RMS Node Tools</a> |
75+
<a href="/">Ring-Moon Systems Home</a>
76+
</body>
77+
</html>

astroquery/solarsystem/pds/tests/test_ringnode.py

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
from astroquery.utils.mocks import MockResponse
1010
from ... import pds
1111

12+
# files in data/ for different planets
13+
DATA_FILES = {'Uranus': 'uranus_ephemeris.html',
14+
'Pluto': 'pluto_ephemeris.html',
15+
}
16+
1217

1318
def data_path(filename):
1419
data_dir = os.path.join(os.path.dirname(__file__), "data")
@@ -18,7 +23,8 @@ def data_path(filename):
1823
# monkeypatch replacement request function
1924
def nonremote_request(self, request_type, url, **kwargs):
2025

21-
with open(data_path("uranus_ephemeris.html"), "rb") as f:
26+
planet_name = kwargs['params']['center_body']
27+
with open(data_path(DATA_FILES[planet_name.capitalize()]), "rb") as f:
2228
response = MockResponse(content=f.read(), url=url)
2329

2430
return response
@@ -36,7 +42,7 @@ def patch_request(request):
3642

3743
# --------------------------------- actual test functions
3844

39-
def test_ephemeris_query(patch_request):
45+
def test_ephemeris_query_Uranus(patch_request):
4046

4147
systemtable, bodytable, ringtable = pds.RingNode().ephemeris(
4248
planet="Uranus",
@@ -110,6 +116,79 @@ def test_ephemeris_query(patch_request):
110116
assert np.isclose(beta["ascending node"].to(u.deg).value, 353.6, rtol=1e-2)
111117

112118

119+
def test_ephemeris_query_Pluto(patch_request):
120+
121+
systemtable, bodytable, ringtable = pds.RingNode().ephemeris(
122+
planet="Pluto",
123+
obs_time="2021-10-07 07:25",
124+
)
125+
print(systemtable)
126+
print(bodytable[bodytable.loc_indices["Styx"]])
127+
# check system table
128+
assert_quantity_allclose(
129+
[
130+
57.57737,
131+
57.56961,
132+
57.56961,
133+
56.50534,
134+
1.64048,
135+
116.55873,
136+
118.8369,
137+
5142696000,
138+
5114486810,
139+
17060.091666,
140+
],
141+
[
142+
systemtable["sub_sun_lat"].to(u.deg).value,
143+
systemtable["sub_sun_lat_min"].to(u.deg).value,
144+
systemtable["sub_sun_lat_max"].to(u.deg).value,
145+
systemtable["opening_angle"].to(u.deg).value,
146+
systemtable["phase_angle"].to(u.deg).value,
147+
systemtable["sub_sun_lon"].to(u.deg).value,
148+
systemtable["sub_obs_lon"].to(u.deg).value,
149+
systemtable["d_sun"].to(u.km).value,
150+
systemtable["d_obs"].to(u.km).value,
151+
systemtable["light_time"].to(u.second).value,
152+
],
153+
rtol=1e-2,
154+
)
155+
156+
# check a moon in body table
157+
styx = bodytable[bodytable.loc_indices["Styx"]]
158+
assert styx["NAIF ID"] == 905
159+
assert styx["Body"] == "Styx"
160+
assert_quantity_allclose(
161+
[
162+
296.212477,
163+
-22.93533,
164+
-0.557,
165+
-1.259,
166+
350.443,
167+
56.472,
168+
352.72,
169+
57.544,
170+
1.64047,
171+
5114.509238,
172+
],
173+
[
174+
styx["RA (deg)"].to(u.deg).value,
175+
styx["Dec (deg)"].to(u.deg).value,
176+
styx["dRA"].to(u.arcsec).value,
177+
styx["dDec"].to(u.arcsec).value,
178+
styx["sub_obs_lon"].to(u.deg).value,
179+
styx["sub_obs_lat"].to(u.deg).value,
180+
styx["sub_sun_lon"].to(u.deg).value,
181+
styx["sub_sun_lat"].to(u.deg).value,
182+
styx["phase"].to(u.deg).value,
183+
styx["distance"].to(u.km * 1e6).value,
184+
],
185+
rtol=1e-2,
186+
)
187+
188+
# check ringtable is None
189+
assert ringtable is None
190+
191+
113192
def test_ephemeris_query_payload():
114193
res = pds.RingNode().ephemeris(
115194
planet="Neptune",
@@ -141,7 +220,7 @@ def test_ephemeris_query_payload():
141220
(
142221
"observatory",
143222
"Earth's center",
144-
),
223+
),
145224
("latitude", 10),
146225
("longitude", -120.355),
147226
("lon_dir", "east"),

0 commit comments

Comments
 (0)