Skip to content

Commit 72a34be

Browse files
emolterbsipocz
authored andcommitted
added offline test
1 parent d4b1f02 commit 72a34be

File tree

6 files changed

+447
-160
lines changed

6 files changed

+447
-160
lines changed

astroquery/solarsystem/pds/core.py

Lines changed: 51 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, planet=None, obs_time=None):
3737
3838
Parameters
3939
----------
40-
40+
4141
"""
4242

4343
super().__init__()
@@ -53,7 +53,7 @@ def __str__(self):
5353
>>> print(nodeobj) # doctest: +SKIP
5454
PDSRingNode instance
5555
"""
56-
return 'PDSRingNode instance'
56+
return "PDSRingNode instance"
5757

5858
# --- pretty stuff above this line, get it working below this line ---
5959

@@ -76,8 +76,8 @@ def ephemeris_async(
7676
----------
7777
self : RingNodeClass instance
7878
planet : str, required. one of Mars, Jupiter, Saturn, Uranus, Neptune, or Pluto
79-
obs_time : astropy.Time object, or str in format YYYY-MM-DD hh:mm, optional.
80-
If str is provided then UTC is assumed. If no obs_time is provided,
79+
obs_time : astropy.Time object, or str in format YYYY-MM-DD hh:mm, optional.
80+
If str is provided then UTC is assumed. If no obs_time is provided,
8181
the current time is used.
8282
location : array-like, or `~astropy.coordinates.EarthLocation`, optional
8383
Observer's location as a
@@ -141,7 +141,7 @@ def ephemeris_async(
141141
)
142142
elif type(obs_time) == Time:
143143
try:
144-
obs_time = obs_time.utc.to_value('iso', subfmt = 'date_hm')
144+
obs_time = obs_time.utc.to_value("iso", subfmt="date_hm")
145145
except Exception as e:
146146
raise ValueError(
147147
"illegal value for 'obs_time' parameter. could not parse astropy.time.core.Time object into format 'yyyy-mm-dd hh:mm' (UTC)"
@@ -154,25 +154,27 @@ def ephemeris_async(
154154
else:
155155
viewpoint = "latlon"
156156
if type(location) != EarthLocation:
157-
if hasattr(location, '__iter__'):
157+
if hasattr(location, "__iter__"):
158158
if len(location) != 3:
159159
raise ValueError(
160160
"location arrays require three values:"
161-
" longitude, latitude, and altitude")
161+
" longitude, latitude, and altitude"
162+
)
162163
else:
163164
raise TypeError(
164-
"location must be array-like or astropy EarthLocation")
165-
165+
"location must be array-like or astropy EarthLocation"
166+
)
167+
166168
if isinstance(location, EarthLocation):
167169
loc = location.geodetic
168170
longitude = loc[0].deg
169171
latitude = loc[1].deg
170172
altitude = loc[2].to(u.m).value
171-
elif hasattr(location, '__iter__'):
172-
longitude = Angle(location[0]).deg
173-
latitude = Angle(location[1]).deg
174-
altitude = u.Quantity(location[2]).to('m').value
175-
173+
elif hasattr(location, "__iter__"):
174+
latitude = Angle(location[0]).deg
175+
longitude = Angle(location[1]).deg
176+
altitude = u.Quantity(location[2]).to("m").value
177+
176178
if int(neptune_arcmodel) not in [1, 2, 3]:
177179
raise ValueError(
178180
f"Illegal Neptune arc model {neptune_arcmodel}. must be one of 1, 2, or 3 (see https://pds-rings.seti.org/tools/viewer3_nep.shtml for details)"
@@ -183,12 +185,9 @@ def ephemeris_async(
183185
# thankfully, adding extra planet-specific keywords here does not break query for other planets
184186
request_payload = OrderedDict(
185187
[
186-
("abbrev", planet[:3]),
187-
(
188-
"ephem",
189-
conf.planet_defaults[planet]["ephem"],
190-
), # change hardcoding for other planets
191-
("time", obs_time), #UTC. this should be enforced when checking inputs
188+
("abbrev", planet.lower()[:3]),
189+
("ephem", conf.planet_defaults[planet]["ephem"],),
190+
("time", obs_time), # UTC. this should be enforced when checking inputs
192191
(
193192
"fov",
194193
10,
@@ -297,17 +296,10 @@ def _parse_ringnode(self, src):
297296
"dRA",
298297
"dDec",
299298
),
300-
)
301-
units_list = [None,
302-
None,
303-
None,
304-
None,
305-
u.deg,
306-
u.deg,
307-
u.arcsec,
308-
u.arcsec]
309-
bodytable = table.QTable(bodytable, units = units_list)
310-
#for i in range(len(bodytable.colnames)):
299+
)
300+
units_list = [None, None, None, None, u.deg, u.deg, u.arcsec, u.arcsec]
301+
bodytable = table.QTable(bodytable, units=units_list)
302+
# for i in range(len(bodytable.colnames)):
311303
# bodytable[bodytable.colnames[i]].unit = units_list[i]
312304
# minor body table part 2
313305
elif group.startswith("Sub-"):
@@ -327,18 +319,11 @@ def _parse_ringnode(self, src):
327319
"sub_sun_lat",
328320
"phase",
329321
"distance",
330-
))
331-
units_list=[
332-
None,
333-
None,
334-
u.deg,
335-
u.deg,
336-
u.deg,
337-
u.deg,
338-
u.deg,
339-
u.km * 1e6]
340-
bodytable2 = table.QTable(bodytable2, units = units_list)
341-
#for i in range(len(bodytable2.colnames)):
322+
),
323+
)
324+
units_list = [None, None, u.deg, u.deg, u.deg, u.deg, u.deg, u.km * 1e6]
325+
bodytable2 = table.QTable(bodytable2, units=units_list)
326+
# for i in range(len(bodytable2.colnames)):
342327
# bodytable2[bodytable2.colnames[i]].unit = units_list[i]
343328

344329
# ring plane data
@@ -359,15 +344,15 @@ def _parse_ringnode(self, src):
359344
}
360345

361346
elif "Ring plane opening angle" in l[0]:
362-
systemtable["opening_angle"] = float(
363-
re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()")
364-
) * u.deg
347+
systemtable["opening_angle"] = (
348+
float(re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()")) * u.deg
349+
)
365350
elif "Ring center phase angle" in l[0]:
366351
systemtable["phase_angle"] = float(l[1].strip(", \n")) * u.deg
367352
elif "Sub-solar longitude" in l[0]:
368-
systemtable["sub_sun_lon"] = float(
369-
re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()")
370-
) * u.deg
353+
systemtable["sub_sun_lon"] = (
354+
float(re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()")) * u.deg
355+
)
371356
elif "Sub-observer longitude" in l[0]:
372357
systemtable["sub_obs_lon"] = float(l[1].strip(", \n")) * u.deg
373358
else:
@@ -379,10 +364,10 @@ def _parse_ringnode(self, src):
379364
for line in lines:
380365
l = line.split(":")
381366
if "Sun-planet distance (AU)" in l[0]:
382-
#systemtable["d_sun_AU"] = float(l[1].strip(", \n"))
367+
# systemtable["d_sun_AU"] = float(l[1].strip(", \n"))
383368
pass
384369
elif "Observer-planet distance (AU)" in l[0]:
385-
#systemtable["d_obs_AU"] = float(l[1].strip(", \n"))
370+
# systemtable["d_obs_AU"] = float(l[1].strip(", \n"))
386371
pass
387372
elif "Sun-planet distance (km)" in l[0]:
388373
systemtable["d_sun"] = (
@@ -405,11 +390,12 @@ def _parse_ringnode(self, src):
405390
format="fixed_width",
406391
col_starts=(5, 18, 29),
407392
col_ends=(18, 29, 36),
408-
names=("ring", "pericenter", "ascending node"))
409-
410-
units_list=[None, u.deg, u.deg]
411-
ringtable = table.QTable(ringtable, units = units_list)
412-
393+
names=("ring", "pericenter", "ascending node"),
394+
)
395+
396+
units_list = [None, u.deg, u.deg]
397+
ringtable = table.QTable(ringtable, units=units_list)
398+
413399
# Saturn F-ring data
414400
elif group.startswith("F Ring"):
415401
lines = group.split("\n")
@@ -422,7 +408,7 @@ def _parse_ringnode(self, src):
422408
ringtable = table.Table(
423409
[["F"], [peri], [ascn]],
424410
names=("ring", "pericenter", "ascending node"),
425-
units=(None, u.deg, u.deg)
411+
units=(None, u.deg, u.deg),
426412
)
427413

428414
# Neptune ring arcs data
@@ -439,24 +425,23 @@ def _parse_ringnode(self, src):
439425
ringtable = table.Table(
440426
[[ring], [min_angle], [max_angle]],
441427
names=("ring", "min_angle", "max_angle"),
442-
units=(None, u.deg, u.deg)
428+
units=(None, u.deg, u.deg),
443429
)
444430
else:
445431
ringtable.add_row([ring, min_angle, max_angle])
446432

447433
else:
448434
pass
449435

450-
#
451-
## do some cleanup from the parsing job
452-
#
436+
# do some cleanup from the parsing job
453437
ringtable.add_index("ring")
454-
455-
bodytable = table.join(bodytable, bodytable2) # concatenate minor body table
438+
439+
bodytable = table.join(bodytable, bodytable2) # concatenate minor body table
456440
bodytable.add_index("Body")
457-
458-
systemtable["obs_time"] = Time(obs_time, format = 'iso', scale = 'utc') # add obs time to systemtable
459-
441+
442+
systemtable["obs_time"] = Time(
443+
obs_time, format="iso", scale="utc"
444+
) # add obs time to systemtable
460445

461446
return systemtable, bodytable, ringtable
462447

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
<title>Uranus Viewer 3.0 Results</title>
4+
<body style="font-family:arial; font-size:medium">
5+
<h1>Uranus Viewer 3.0 Results</h1>
6+
<p>
7+
<pre>
8+
Input Parameters
9+
----------------
10+
11+
Observation time: 2022-05-03 00:00
12+
Ephemeris: URA111 + URA115 + DE440
13+
Field of view: 10 (Uranus radii)
14+
Diagram center: Uranus
15+
Viewpoint: Lat = 10 (deg)
16+
Lon = -120.355 (deg east)
17+
Alt = 1000 (m)
18+
Moon selection: All inner moons (U1-U15,U25-U27)
19+
Ring selection: Nine major rings
20+
Standard stars: No
21+
Additional star: No
22+
Other bodies: None
23+
Title:
24+
Moon labels: Small (6 points)
25+
Moon enlargement: 0 (points)
26+
Blank disks: No
27+
Pericenter markers: None
28+
Marker size: 4 (points)
29+
Prime meridians: Yes
30+
31+
32+
Field of View Description (J2000)
33+
---------------------------------
34+
35+
Body RA Dec RA (deg) Dec (deg) dRA (") dDec (")
36+
799 Uranus 2h 48m 02.3164s 15d 48m 04.141s 42.009651 15.801150 0.000 0.000
37+
701 Ariel 2h 48m 02.6985s 15d 48m 14.802s 42.011244 15.804112 5.515 10.661
38+
702 Umbriel 2h 48m 03.0454s 15d 48m 16.080s 42.012689 15.804467 10.522 11.939
39+
703 Titania 2h 48m 02.9240s 15d 47m 36.893s 42.012184 15.793581 8.771 -27.248
40+
704 Oberon 2h 48m 04.1962s 15d 47m 42.409s 42.017484 15.795114 27.133 -21.732
41+
705 Miranda 2h 48m 02.7625s 15d 48m 07.862s 42.011510 15.802184 6.439 3.722
42+
706 Cordelia 2h 48m 02.2509s 15d 48m 07.282s 42.009379 15.802023 -0.944 3.141
43+
707 Ophelia 2h 48m 02.2438s 15d 48m 00.861s 42.009349 15.800239 -1.047 -3.280
44+
708 Bianca 2h 48m 02.0990s 15d 48m 05.324s 42.008746 15.801479 -3.137 1.183
45+
709 Cressida 2h 48m 02.3358s 15d 48m 00.038s 42.009732 15.800011 0.280 -4.102
46+
710 Desdemona 2h 48m 02.4006s 15d 48m 08.008s 42.010003 15.802224 1.217 3.867
47+
711 Juliet 2h 48m 02.1052s 15d 48m 06.438s 42.008772 15.801788 -3.047 2.298
48+
712 Portia 2h 48m 02.3709s 15d 48m 08.408s 42.009879 15.802336 0.787 4.267
49+
713 Rosalind 2h 48m 02.5516s 15d 48m 06.258s 42.010632 15.801738 3.395 2.117
50+
714 Belinda 2h 48m 02.4108s 15d 47m 59.372s 42.010045 15.799825 1.363 -4.769
51+
715 Puck 2h 48m 02.1358s 15d 48m 09.016s 42.008899 15.802505 -2.605 4.876
52+
725 Perdita 2h 48m 02.3249s 15d 48m 09.230s 42.009687 15.802564 0.124 5.089
53+
726 Mab 2h 48m 02.6883s 15d 48m 04.764s 42.011201 15.801323 5.368 0.623
54+
727 Cupid 2h 48m 02.5963s 15d 48m 04.777s 42.010818 15.801327 4.040 0.636
55+
56+
Sub-Observer Sub-Solar
57+
Body Lon(degE) Lat(deg) Lon(degE) Lat(deg) Phase(deg) Distance(10^6 km)
58+
799 Uranus 24.025 56.016 24.014 56.122 0.10924 3098.568884
59+
701 Ariel 124.977 56.141 124.967 56.249 0.10934 3098.505814
60+
702 Umbriel 139.323 56.082 139.313 56.190 0.10941 3098.454209
61+
703 Titania 251.999 56.036 251.987 56.141 0.10931 3098.498297
62+
704 Oberon 216.747 55.830 216.739 55.936 0.10959 3098.307219
63+
705 Miranda 151.067 54.505 151.037 54.611 0.10934 3098.502972
64+
706 Cordelia 308.108 56.084 308.095 56.194 0.10923 3098.576275
65+
707 Ophelia 89.619 56.085 89.605 56.188 0.10922 3098.581622
66+
708 Bianca 334.349 55.945 334.331 56.053 0.10919 3098.599901
67+
709 Cressida 280.863 56.045 280.852 56.149 0.10923 3098.568767
68+
710 Desdemona 145.642 55.889 145.633 55.998 0.10926 3098.554071
69+
711 Juliet 45.698 55.990 45.681 56.098 0.10920 3098.598161
70+
712 Portia 105.643 55.932 105.633 56.041 0.10926 3098.557986
71+
713 Rosalind 147.213 55.738 147.207 55.846 0.10929 3098.533106
72+
714 Belinda 223.015 56.048 223.006 56.152 0.10925 3098.558348
73+
715 Puck 55.434 56.246 55.421 56.355 0.10921 3098.591319
74+
725 Perdita 163.507 55.992 163.496 56.101 0.10925 3098.564229
75+
726 Mab 223.976 55.906 223.969 56.013 0.10932 3098.514000
76+
727 Cupid 246.256 55.885 246.250 55.992 0.10930 3098.527432
77+
78+
Ring Pericenter Ascending Node (deg, from ring plane ascending node)
79+
Six 58.012 283.243
80+
Five 300.684 245.829
81+
Four 128.182 177.661
82+
Alpha 13.729 62.922
83+
Beta 231.051 353.609
84+
Eta 0.000 0.000
85+
Gamma 200.019 0.000
86+
Delta 0.000 0.000
87+
Epsilon 13.383 0.000
88+
89+
Ring sub-solar latitude (deg): -56.12233 (-56.13586 to -56.10881)
90+
Ring plane opening angle (deg): -56.01577 (lit)
91+
Ring center phase angle (deg): 0.10924
92+
Sub-solar longitude (deg): 354.11072 from ring plane ascending node
93+
Sub-observer longitude (deg): 354.12204
94+
95+
Sun-planet distance (AU): 19.70547
96+
Observer-planet distance (AU): 20.71265
97+
Sun-planet distance (km): 2947.896667 x 10^6
98+
Observer-planet distance (km): 3098.568884 x 10^6
99+
Light travel time (sec): 10335.713263
100+
101+
</pre>
102+
<hr><b>Preview:</b><p>
103+
<a href="/work/viewer3_ura_24390.pdf"><image src="/work/viewer3_ura_24390tn.jpg"/></a><br>
104+
Click
105+
<a href="/work/viewer3_ura_24390.pdf">here</a>
106+
to download diagram (PDF, 21116 bytes).<p>
107+
Click
108+
<a href="/work/viewer3_ura_24390.jpg">here</a>
109+
to download diagram (JPEG format, 185169 bytes).<p>
110+
Click
111+
<a href="/work/viewer3_ura_24390.ps">here</a>
112+
to download diagram (PostScript format, 62562 bytes).
113+
<hr>
114+
<a href="/tools/viewer3_ura.shtml">Uranus Viewer Form</a> |
115+
<a href="/tools/index.html">RMS Node Tools</a> |
116+
<a href="/">Ring-Moon Systems Home</a>
117+
</body>
118+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
4+
def get_package_data():
5+
paths = [os.path.join("data", "*.html")] # etc, add other extensions
6+
7+
return {"astroquery.solarsystem.pds.tests": paths}

0 commit comments

Comments
 (0)