0
Solucionado

TableParseError when querying ESASky through astroquery

Alvaro Ribas hace 5 años actualizado hace 5 años 8

I am having issues querying ESASky through astroquery. When following the examples here, running the following three lines yieldsa Table Parse Error (below). 

>>> from astroquery.esasky import ESASky
>>> import astropy.units as u
>>> result = ESASky.query_region_catalogs("M51", 10 * u.arcmin, "integral")


This seems to happens with different catalogs. Has anyone encountered this issue before?

Thanks a lot!


------------

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in _parse_xml_table(self, response)
861 vo_table = votable.parse(tf, pedantic=False)
--> 862 first_table = vo_table.get_first_table()
863 table = first_table.to_table(use_names_over_ids=True)

~/opt/anaconda3/lib/python3.7/site-packages/astropy/io/votable/tree.py in get_first_table(self)
3492 return table
-> 3493 raise IndexError("No table found in VOTABLE file.")
3494

IndexError: No table found in VOTABLE file.

During handling of the above exception, another exception occurred:

TableParseError Traceback (most recent call last)
in
1 from astroquery.esasky import ESASky
2 import astropy.units as u
----> 3 result = ESASky.query_region_catalogs("M51", 10 * u.arcmin, "integral")

~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in query_region_catalogs(self, position, radius, catalogs, row_limit, get_query_payload, cache)
303 coordinates, sanitized_radius,
304 sanitized_row_limit,
--> 305 get_query_payload, cache)
306
307 if (get_query_payload):

~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in _store_query_result_catalogs(self, query_result, catalogs, coordinates, radius, row_limit, get_query_payload, cache)
767 catalog_table = self._query_region_catalog(coordinates, radius,
768 catalog, row_limit,
--> 769 get_query_payload, cache)
770 if (len(catalog_table) > 0):
771 query_result[catalog.upper()] = catalog_table

~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in _query_region_catalog(self, coordinates, radius, catalog_name, row_limit, get_query_payload, cache)
688 if (get_query_payload):
689 return request_payload
--> 690 return self._get_and_parse_from_tap(request_payload, cache)
691
692 def _build_observation_query(self, coordinates, radius, json):

~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in _get_and_parse_from_tap(self, request_payload, cache)
843 def _get_and_parse_from_tap(self, request_payload, cache):
844 response = self._send_get_request("/tap/sync", request_payload, cache)
--> 845 return self._parse_xml_table(response)
846
847 def _send_get_request(self, url_extension, request_payload, cache):

~/opt/anaconda3/lib/python3.7/site-packages/astroquery/esasky/core.py in _parse_xml_table(self, response)
867 self.table_parse_error = ex
868 raise TableParseError(
--> 869 "Failed to parse ESASky VOTABLE result! The raw response can be "
870 "found in self.response, and the error in "
871 "self.table_parse_error.")

TableParseError: Failed to parse ESASky VOTABLE result! The raw response can be found in self.response, and the error in self.table_parse_error.
BIEN, ESTOY SATISFECHO.
Puntuación de satisfacción por Alvaro Ribas hace 5 años
+1

Dear Alvaro,

The issue has now been fixed in the ESASky astroquery module. If you update astroquery you should find the module working correctly now. 

Many thanks for reporting this to us!

Best regards,

Debbie, on behalf of the ESASky team

Thanks Debbie! I will try it and let you know if I run into any issues.

Best,

Álvaro

The second way isn't through astroquery, but it is within a jupyter notebook and using our ESASky Jupyter Widget called pyESASky.  We have an example notebook on how to download data from pyESASky here:


https://github.com/esdc-esac-esa-int/pyesasky/blob/master/samples/What_can_you_do_with_pyESASky.ipynb


Installation instructions etc can be found here:

https://www.cosmos.esa.int/web/esdc/pyesasky

and https://github.com/esdc-esac-esa-int/pyesasky/blob/master/README.md

We've an example in Binder (Cluster Analysis notebook): 

https://gke.mybinder.org/v2/gh/esdc-esac-esa-int/notebooks/master/


And we've a video here:

I hope one of these options is good for you. Let us know how you go and if you need any help installing pyESASky!

Best regards,

Debbie, on behalf of the ESASky team

Thanks a lot! The TAP+ method works fine for he purpose I had in mind.

Best,

Álvaro

Hi Alvaro,

There are two ways I can think to do this. Firstly, you can use the astroquery TAP+ module and call the ESASky TAP: 

https://astroquery.readthedocs.io/en/latest/utils/tap.html

You select the table you're interested in, then perform a cone search using ADQL.

Here's some example jupyter notebook code:

# Calling the ESASky TAP and printing the available tables
from astroquery.utils.tap.core import TapPlus
esasky = TapPlus(url="http://sky.esa.int/esasky-tap/tap")
tables = esasky.load_tables(only_names=True)
for table in (tables):
      print(table.get_qualified_name())
# Inspect the columns of the 2MASS Catalogue
esasky = TapPlus(url="http://sky.esa.int/esasky-tap/tap")
tmass = esasky.load_table('public.t_tmass_original_valid_fdw')
for column in (tmass.columns):
    print(column.name)
# Perform a cone search on 2MASS around the coordinates for M51 with a radius of 10 arcminutes:
esasky = TapPlus(url="http://sky.esa.int/esasky-tap/tap")

job = esasky.launch_job("SELECT * FROM public.t_tmass_original_valid_fdw \
WHERE 1=CONTAINS( \
  POINT('ICRS', ra, dec), \
  CIRCLE('ICRS', 202.469575, +47.195258, 0.166667))", "tmass_M51.vot")
print(job)
job.get_results()

If you know TOPCAT, you can also inspect the ESASky TAP and try some ADQL code. Open Topcat -> VO -> Table Access Protocol (TAP) Query -> In keyword type 'ESASky' , click 'Find Service' -> Click 'use service' button. 

En revisión

Dear Alvaro,

Many thanks for letting us know. We'll look into it and get back to you asap!

Best regards,


Debbie, on behalf of the ESASky team.

Dear Debbie,

Thanks a lot for your reply. I was wondering if you know if there has been any progress on this. Absolutely no hurries, I am just checking because I need a few of the catalogs under ESASky and it would be very convenient to access them through astroquery, but I can look for other options if you think it would take some time to fix.

Thanks again!

Álvaro