Skip to content

Commit 033da27

Browse files
committed
improve parsing of NRAO votables
1 parent e3b69e7 commit 033da27

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

astroquery/nrao/core.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,8 @@ def query_region_async(self, coordinates, radius=1 * u.deg,
244244
def _parse_result(self, response, verbose=False):
245245
if not verbose:
246246
commons.suppress_vo_warnings()
247-
# fix to replace non standard datatype 'integer' in returned VOTable
248-
# with 'int' to make it parsable by astropy.io.votable
249-
integer_re = re.compile(r'datatype="integer"')
250-
content = response.text
251-
new_content = integer_re.sub(r'datatype="int"', content)
247+
248+
new_content = response.text
252249

253250
# these are pretty bad hacks, but also needed...
254251
days_re = re.compile(r'unit="days" datatype="double"')
@@ -257,10 +254,17 @@ def _parse_result(self, response, verbose=False):
257254
degrees_re = re.compile(r'unit="degrees" datatype="double"')
258255
new_content = degrees_re.sub(r'unit="degrees" datatype="char" '
259256
'arraysize="*"', new_content)
257+
telconfig_re = re.compile(r'datatype="char" name="Telescope:config"')
258+
new_content = telconfig_re.sub(r'datatype="char"'
259+
'name="Telescope:config"'
260+
' arraysize="*"', new_content)
261+
262+
datatype_mapping = {'integer':'long'}
260263

261264
try:
262265
tf = six.BytesIO(new_content.encode())
263-
first_table = votable.parse(tf, pedantic=False).get_first_table()
266+
first_table = votable.parse(tf, pedantic=False,
267+
datatype_mapping=datatype_mapping).get_first_table()
264268
try:
265269
table = first_table.to_table(use_names_over_ids=True)
266270
except TypeError:

0 commit comments

Comments
 (0)