19
19
# import configurable items declared in __init__.py, e.g. hardcoded dictionaries
20
20
from . import conf
21
21
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
+
22
67
23
68
@async_to_sync
24
69
class RingNodeClass (BaseQuery ):
@@ -27,14 +72,21 @@ class RingNodeClass(BaseQuery):
27
72
<https://pds-rings.seti.org/tools/>
28
73
"""
29
74
30
- def __init__ (self , timeout = None ):
75
+ def __init__ (self , url = '' , timeout = None ):
31
76
'''
32
77
Instantiate Planetary Ring Node query
33
78
'''
34
79
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
38
90
39
91
def __str__ (self ):
40
92
@@ -134,13 +186,13 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
134
186
request_payload = dict (
135
187
[
136
188
("abbrev" , planet [:3 ]),
137
- ("ephem" , self . planet_defaults [planet ]["ephem" ]),
189
+ ("ephem" , planet_defaults [planet ]["ephem" ]),
138
190
("time" , epoch .utc .iso [:16 ]),
139
191
("fov" , 10 ), # next few are figure options, can be hardcoded and ignored
140
192
("fov_unit" , planet .capitalize () + " radii" ),
141
193
("center" , "body" ),
142
194
("center_body" , planet .capitalize ()),
143
- ("center_ansa" , self . planet_defaults [planet ]["center_ansa" ]),
195
+ ("center_ansa" , planet_defaults [planet ]["center_ansa" ]),
144
196
("center_ew" , "east" ),
145
197
("center_ra" , "" ),
146
198
("center_ra_type" , "hours" ),
@@ -152,9 +204,9 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
152
204
("longitude" , longitude ),
153
205
("lon_dir" , "east" ),
154
206
("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 )]),
158
210
("extra_ra" , "" ), # figure options below this line, can all be hardcoded and ignored
159
211
("extra_ra_type" , "hours" ),
160
212
("extra_dec" , "" ),
@@ -178,7 +230,7 @@ def ephemeris_async(self, planet, *, epoch=None, location=None, neptune_arcmodel
178
230
179
231
# query and parse
180
232
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
182
234
)
183
235
184
236
return response
@@ -202,7 +254,7 @@ def _parse_result(self, response, verbose=None):
202
254
self .last_response = response
203
255
try :
204
256
self ._last_query .remove_cache_file (self .cache_location )
205
- except ( FileNotFoundError , AttributeError ) :
257
+ except FileNotFoundError :
206
258
# this is allowed: if `cache` was set to False, this
207
259
# won't be needed
208
260
pass
0 commit comments