Skip to content

Commit 550bd95

Browse files
Edward Molterbsipocz
authored andcommitted
fixing oldest dependencies table read duplicate column error
1 parent 3c92254 commit 550bd95

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

astroquery/solarsystem/pds/core.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# 1. standard library imports
2-
32
import re
4-
import warnings
53

64
# 2. third party imports
75
from astropy.time import Time
86
from astropy import table
9-
from astropy.io import ascii
107
import astropy.units as u
118
from astropy.coordinates import EarthLocation, Angle
129
from bs4 import BeautifulSoup
@@ -282,14 +279,15 @@ def _parse_result(self, response, verbose=None):
282279

283280
# minor body table part 2
284281
elif group.startswith("Sub-"):
285-
group = "\n".join(group.split("\n")[1:]) # fixing two-row header
286-
group = "NAIF" + group[4:]
282+
283+
group = "\n".join(group.split("\n")[2:]) # removing two-row header entirely
287284
bodytable2_names = ("NAIF ID", "Body", "sub_obs_lon", "sub_obs_lat", "sub_sun_lon", "sub_sun_lat", "phase", "distance")
288285
bodytable2_units = [None, None, u.deg, u.deg, u.deg, u.deg, u.deg, u.km * 1e6]
289286
bodytable2 = table.QTable.read(group, format="ascii.fixed_width",
290287
col_starts=(0, 4, 18, 28, 37, 49, 57, 71),
291288
col_ends=(4, 18, 28, 37, 49, 57, 71, 90),
292-
names=bodytable2_names)
289+
names=bodytable2_names,
290+
data_start=0)
293291
# units=(bodytable_units)) # this much cleaner way of adding units is supported in later versions but not in 3.7
294292
for name, unit in zip(bodytable2_names, bodytable2_units):
295293
bodytable2[name].unit = unit
@@ -370,11 +368,14 @@ def _parse_result(self, response, verbose=None):
370368
peri = float(re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()"))
371369
elif "F Ring ascending node" in l[0]:
372370
ascn = float(l[1].strip(", \n"))
371+
ringtable_names = ("ring", "pericenter", "ascending node")
372+
ringtable_units = [None, u.deg, u.deg]
373373
ringtable = table.QTable(
374374
[["F"], [peri], [ascn]],
375-
names=("ring", "pericenter", "ascending node"),
376-
units=(None, u.deg, u.deg),
377-
)
375+
names=ringtable_names)
376+
# units=(ringtable_units) # this much cleaner way of adding units is supported in later versions but not in 3.7
377+
for name, unit in zip(ringtable_names, ringtable_units):
378+
ringtable[name].unit = unit
378379

379380
# Neptune ring arcs data
380381
elif group.startswith("Courage"):
@@ -387,11 +388,14 @@ def _parse_result(self, response, verbose=None):
387388
for s in re.sub("[a-zA-Z]+", "", l[1]).strip(", \n()").split()
388389
]
389390
if i == 0:
391+
ringtable_names = ("ring", "min_angle", "max_angle")
392+
ringtable_units = [None, u.deg, u.deg]
390393
ringtable = table.QTable(
391394
[[ring], [min_angle], [max_angle]],
392-
names=("ring", "min_angle", "max_angle"),
393-
units=(None, u.deg, u.deg),
394-
)
395+
names=ringtable_names)
396+
for name, unit in zip(ringtable_names, ringtable_units):
397+
ringtable[name].unit = unit
398+
# units=(ringtable_units) # this much cleaner way of adding units is supported in later versions but not in 3.7
395399
else:
396400
ringtable.add_row([ring, min_angle*u.deg, max_angle*u.deg])
397401

astroquery/solarsystem/pds/tests/test_pds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_parse_result(patch_request):
4848
# need _last_query to be defined
4949
q._last_query = AstroQuery('GET', 'http://dummy')
5050
with pytest.raises(ValueError):
51-
res = q.ephemeris('dummy-planet-name')
51+
q.ephemeris('dummy-planet-name')
5252

5353

5454
def test_ephemeris_query_Uranus(patch_request):

0 commit comments

Comments
 (0)