Skip to content

Commit 5db2092

Browse files
committed
MAINT: skybox to use votable responses to workaround parsing non-ascii objectnames from responses
1 parent 731caee commit 5db2092

File tree

2 files changed

+32
-57
lines changed

2 files changed

+32
-57
lines changed

astroquery/imcce/__init__.py

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,30 @@ class Conf(_config.ConfigNamespace):
3131
# SkyBoT configuration
3232

3333
# dictionary for field name and unit conversions using 'output=all`
34-
field_names = {'Num': 'Number',
35-
'Name': 'Name',
36-
'RA(h)': 'RA',
37-
'DE(deg)': 'DEC',
38-
'Class': 'Type',
39-
'Mv': 'V',
40-
'Err(arcsec)': 'posunc',
41-
'd(arcsec)': 'centerdist',
42-
'dRA(arcsec/h)': 'RA_rate',
43-
'dDEC(arcsec/h)': 'DEC_rate',
44-
'Dg(ua)': 'geodist',
45-
'Dh(ua)': 'heliodist',
46-
'Phase(deg)': 'alpha',
47-
'SunElong(deg)': 'elong',
48-
'x(au)': 'x',
49-
'y(au)': 'y',
50-
'z(au)': 'z',
51-
'vx(au/d)': 'vx',
52-
'vy(au/d)': 'vy',
53-
'vz(au/d)': 'vz',
54-
'Ref. Epoch(JD)': 'epoch'}
55-
field_units = {'RA': u.deg, # after conversion to deg
56-
'DEC': u.deg, # after conversion to deg
57-
'V': u.mag,
58-
'posunc': u.arcsec,
59-
'centerdist': u.arcsec,
60-
'RA_rate': u.arcsec/u.hour,
61-
'DEC_rate': u.arcsec/u.hour,
62-
'geodist': u.au,
63-
'heliodist': u.au,
64-
'alpha': u.degree,
65-
'elong': u.degree,
66-
'x': u.au,
67-
'y': u.au,
68-
'z': u.au,
69-
'vx': u.au/u.day,
70-
'vy': u.au/u.day,
71-
'vz': u.au/u.day,
72-
'epoch': u.day}
34+
field_names = {'num': 'Number',
35+
'name': 'Name',
36+
'ra': 'RA',
37+
'de': 'DEC',
38+
'class': 'Type',
39+
'magV': 'V',
40+
'errpos': 'posunc',
41+
'angdist': 'centerdist',
42+
'dracosdec': 'RA_rate',
43+
'ddec': 'DEC_rate',
44+
'dgeo': 'geodist',
45+
'dhelio': 'heliodist',
46+
'phase': 'alpha',
47+
'solelong': 'elong',
48+
'px': 'x',
49+
'py': 'y',
50+
'pz': 'z',
51+
'vx': 'vx',
52+
'vy': 'vy',
53+
'vz': 'vz',
54+
'jdref': 'epoch',
55+
'_raj2000': '_raj2000',
56+
'_decj2000': '_decj2000',
57+
'externallink': 'externallink'}
7358

7459

7560
conf = Conf()

astroquery/imcce/core.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def cone_search_async(self,
599599
+ str(int(find_comets)),
600600
'-refsys': 'EQJ2000',
601601
'-output': 'all',
602-
'-mime': 'text'}
602+
'-mime': 'votable'}
603603

604604
# check for diagnostic flags
605605
if get_query_payload:
@@ -617,36 +617,26 @@ def cone_search_async(self,
617617

618618
def _parse_result(self, response, *, verbose=False):
619619
"""
620-
internal wrapper to parse queries
620+
internal wrapper to parse queries.
621621
"""
622622

623623
if self._get_raw_response:
624624
return response.text
625625

626-
# intercept error messages
627-
response_txt = response.text.split('\n')[2:-1]
628-
if len(response_txt) < 3 and len(response_txt[-1].split('|')) < 21:
629-
raise RuntimeError(response_txt[-1])
630-
631-
names = response_txt[0].replace('# ', '').strip().split(' | ')
632-
results = ascii.read(response_txt[1:], delimiter='|',
633-
names=names, fast_reader=False)
634-
results = QTable(results)
626+
results = QTable.read(BytesIO(response.content), format='votable')
635627

636628
# convert coordinates to degrees
637-
coo = SkyCoord(ra=results['RA(h)'], dec=results['DE(deg)'],
629+
coo = SkyCoord(ra=results['ra'], dec=results['de'],
638630
unit=(u.hourangle, u.deg), frame='icrs')
639-
results['RA(h)'] = coo.ra.deg
640-
results['DE(deg)'] = coo.dec.deg
631+
results['ra'] = coo.ra.deg
632+
results['ra'].unit = u.deg
633+
results['de'] = coo.dec.deg
634+
results['de'].unit = u.deg
641635

642636
colnames = results.columns[:]
643637
for fieldname in colnames:
644638
# apply field name change
645639
results.rename_column(fieldname, conf.field_names[fieldname])
646-
# apply unit, if available
647-
if conf.field_names[fieldname] in conf.field_units:
648-
results[conf.field_names[fieldname]].unit = conf.field_units[
649-
conf.field_names[fieldname]]
650640

651641
# convert object numbers to int
652642
# unnumbered asteroids return as non numeric values ('-')

0 commit comments

Comments
 (0)