Skip to content

Commit 95c9570

Browse files
emolterbsipocz
authored andcommitted
complying with template in pull request #2341
1 parent 1d2621d commit 95c9570

File tree

3 files changed

+66
-61
lines changed

3 files changed

+66
-61
lines changed

astroquery/solarsystem/pds/__init__.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,13 @@ class Conf(_config.ConfigNamespace):
1414
"""
1515

1616
# server settings
17-
pds_server = _config.ConfigItem(
17+
url = _config.ConfigItem(
1818
"https://pds-rings.seti.org/cgi-bin/tools/viewer3_xxx.pl?", "Ring Node"
1919
)
2020

2121
# implement later: other pds tools
2222

23-
timeout = _config.ConfigItem(30, "Time limit for connecting to PDS servers.")
24-
25-
# PDS settings - put hardcoded dictionaries of any kind here
26-
27-
planet_defaults = {
28-
"mars": {
29-
"ephem": "000 MAR097 + DE440",
30-
"moons": "402 Phobos, Deimos",
31-
"center_ansa": "Phobos Ring",
32-
"rings": "Phobos, Deimos",
33-
},
34-
"jupiter": {
35-
"ephem": "000 JUP365 + DE440",
36-
"moons": "516 All inner moons (J1-J5,J14-J16)",
37-
"center_ansa": "Main Ring",
38-
"rings": "Main & Gossamer",
39-
},
40-
"saturn": {
41-
"ephem": "000 SAT389 + SAT393 + SAT427 + DE440",
42-
"moons": "653 All inner moons (S1-S18,S32-S35,S49,S53)",
43-
"center_ansa": "A",
44-
"rings": "A,B,C,F,G,E",
45-
},
46-
"uranus": {
47-
"ephem": "000 URA111 + URA115 + DE440",
48-
"moons": "727 All inner moons (U1-U15,U25-U27)",
49-
"center_ansa": "Epsilon",
50-
"rings": "All rings",
51-
},
52-
"neptune": {
53-
"ephem": "000 NEP081 + NEP095 + DE440",
54-
"moons": "814 All inner moons (N1-N8,N14)",
55-
"center_ansa": "Adams Ring",
56-
"rings": "Galle, LeVerrier, Arago, Adams",
57-
},
58-
"pluto": {
59-
"ephem": "000 PLU058 + DE440",
60-
"moons": "905 All moons (P1-P5)",
61-
"center_ansa": "Hydra",
62-
"rings": "Styx, Nix, Kerberos, Hydra",
63-
},
64-
}
65-
66-
neptune_arcmodels = {
67-
1: "#1 (820.1194 deg/day)",
68-
2: "#2 (820.1118 deg/day)",
69-
3: "#3 (820.1121 deg/day)",
70-
}
23+
timeout = _config.ConfigItem(30, "Time limit for connecting to PDS servers (seconds).")
7124

7225

7326
conf = Conf()

astroquery/solarsystem/pds/core.py

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,51 @@
1919
# import configurable items declared in __init__.py, e.g. hardcoded dictionaries
2020
from . import conf
2121

22+
planet_defaults = {
23+
"mars": {
24+
"ephem": "000 MAR097 + DE440",
25+
"moons": "402 Phobos, Deimos",
26+
"center_ansa": "Phobos Ring",
27+
"rings": "Phobos, Deimos",
28+
},
29+
"jupiter": {
30+
"ephem": "000 JUP365 + DE440",
31+
"moons": "516 All inner moons (J1-J5,J14-J16)",
32+
"center_ansa": "Main Ring",
33+
"rings": "Main & Gossamer",
34+
},
35+
"saturn": {
36+
"ephem": "000 SAT389 + SAT393 + SAT427 + DE440",
37+
"moons": "653 All inner moons (S1-S18,S32-S35,S49,S53)",
38+
"center_ansa": "A",
39+
"rings": "A,B,C,F,G,E",
40+
},
41+
"uranus": {
42+
"ephem": "000 URA111 + URA115 + DE440",
43+
"moons": "727 All inner moons (U1-U15,U25-U27)",
44+
"center_ansa": "Epsilon",
45+
"rings": "All rings",
46+
},
47+
"neptune": {
48+
"ephem": "000 NEP081 + NEP095 + DE440",
49+
"moons": "814 All inner moons (N1-N8,N14)",
50+
"center_ansa": "Adams Ring",
51+
"rings": "Galle, LeVerrier, Arago, Adams",
52+
},
53+
"pluto": {
54+
"ephem": "000 PLU058 + DE440",
55+
"moons": "905 All moons (P1-P5)",
56+
"center_ansa": "Hydra",
57+
"rings": "Styx, Nix, Kerberos, Hydra",
58+
},
59+
}
60+
61+
neptune_arcmodels = {
62+
1: "#1 (820.1194 deg/day)",
63+
2: "#2 (820.1118 deg/day)",
64+
3: "#3 (820.1121 deg/day)",
65+
}
66+
2267

2368
@async_to_sync
2469
class RingNodeClass(BaseQuery):
@@ -27,14 +72,21 @@ class RingNodeClass(BaseQuery):
2772
<https://pds-rings.seti.org/tools/>
2873
"""
2974

30-
def __init__(self, timeout=None):
75+
def __init__(self, url='', timeout=None):
3176
'''
3277
Instantiate Planetary Ring Node query
3378
'''
3479
super().__init__()
35-
self.url = conf.pds_server
36-
self.timeout = conf.timeout
37-
self.planet_defaults = conf.planet_defaults
80+
self.url = url
81+
self.timeout = timeout
82+
83+
@property
84+
def _url(self):
85+
return self.url or conf.url
86+
87+
@property
88+
def _timeout(self):
89+
return conf.timeout if self.timeout is None else self.timeout
3890

3991
def __str__(self):
4092

@@ -134,13 +186,13 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
134186
request_payload = dict(
135187
[
136188
("abbrev", planet[:3]),
137-
("ephem", self.planet_defaults[planet]["ephem"]),
189+
("ephem", planet_defaults[planet]["ephem"]),
138190
("time", epoch.utc.iso[:16]),
139191
("fov", 10), # next few are figure options, can be hardcoded and ignored
140192
("fov_unit", planet.capitalize() + " radii"),
141193
("center", "body"),
142194
("center_body", planet.capitalize()),
143-
("center_ansa", self.planet_defaults[planet]["center_ansa"]),
195+
("center_ansa", planet_defaults[planet]["center_ansa"]),
144196
("center_ew", "east"),
145197
("center_ra", ""),
146198
("center_ra_type", "hours"),
@@ -152,9 +204,9 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
152204
("longitude", longitude),
153205
("lon_dir", "east"),
154206
("altitude", altitude),
155-
("moons", self.planet_defaults[planet]["moons"]),
156-
("rings", self.planet_defaults[planet]["rings"]),
157-
("arcmodel", conf.neptune_arcmodels[int(neptune_arcmodel)]),
207+
("moons", planet_defaults[planet]["moons"]),
208+
("rings", planet_defaults[planet]["rings"]),
209+
("arcmodel", neptune_arcmodels[int(neptune_arcmodel)]),
158210
("extra_ra", ""), # figure options below this line, can all be hardcoded and ignored
159211
("extra_ra_type", "hours"),
160212
("extra_dec", ""),
@@ -178,7 +230,7 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
178230

179231
# query and parse
180232
response = self._request(
181-
"GET", self.url, params=request_payload, timeout=self.timeout, cache=cache
233+
"GET", self._url, params=request_payload, timeout=self._timeout, cache=cache
182234
)
183235

184236
return response
@@ -202,7 +254,7 @@ def _parse_result(self, response, verbose=None):
202254
self.last_response = response
203255
try:
204256
self._last_query.remove_cache_file(self.cache_location)
205-
except (FileNotFoundError, AttributeError):
257+
except FileNotFoundError:
206258
# this is allowed: if `cache` was set to False, this
207259
# won't be needed
208260
pass

docs/solarsystem/pds/pds.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ephemerides of the rings and small moons around Uranus as viewed from ALMA:
4646
4747
>>> bodytable, ringtable = RingNode.ephemeris(planet='Venus',
4848
... epoch='2024-05-08 22:39',
49-
... location = (-67.755 * u.deg, -23.029 * u.deg, 5000 * u.m)) # doctest: +IGNORE_EXCEPTION_DETAIL
49+
... location = (-67.755 * u.deg, -23.029 * u.deg, 5000 * u.m))
5050
Traceback (most recent call last):
5151
...
5252
ValueError: illegal value for 'planet' parameter (must be 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', or 'Pluto')

0 commit comments

Comments
 (0)