Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMatch Failure #3191

Open
SpacialTree opened this issue Jan 28, 2025 · 2 comments
Open

XMatch Failure #3191

SpacialTree opened this issue Jan 28, 2025 · 2 comments

Comments

@SpacialTree
Copy link

I tried running the following code to query XMatch:

from astroquery.xmatch import XMatch
from astropy.coordinates import SkyCoord
import regions

coord_BC2 = SkyCoord(3.0970501246, 0.3112008170, unit=(u.deg, u.deg), frame='galactic')
reg_alt = regions.CircleSkyRegion(center=coord_BC2, radius=0.5*u.arcmin)

tbl = XMatch.query(cat1='II/316/gps6', cat2='II/293/glimpse', area=reg_alt, max_distance=1*u.arcsec)

But it failed with this error:

HTTPError: 400 Client Error: Mauvaise Requête for url: http://cdsxmatch.u-strasbg.fr/xmatch/api/v1/sync

The above exception was the direct cause of the following exception:

InvalidQueryError                         Traceback (most recent call last)
Cell In[72], line 4
      1 coord_BC2 = SkyCoord(3.0970501246, 0.3112008170, unit=(u.deg, u.deg), frame='galactic')
      2 reg_alt = regions.CircleSkyRegion(center=coord_BC2, radius=0.5*u.arcmin)
----> 4 tbl = XMatch.query(cat1='II/316/gps6', cat2='II/293/glimpse', area=reg_alt, max_distance=1*u.arcsec)#, get_query_payload=True)

File /red/adamginsburg/repos/astroquery/astroquery/xmatch/core.py:76, in XMatchClass.query(self, cat1, cat2, max_distance, colRA1, colDec1, colRA2, colDec2, area, cache, get_query_payload, **kwargs)
     27 def query(self, cat1, cat2, max_distance, *,
     28           colRA1=None, colDec1=None, colRA2=None, colDec2=None,
     29           area='allsky', cache=True, get_query_payload=False, **kwargs):
...
	at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2486)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:844)

When I set get_query_payload=True, this is what I got:

({'request': 'xmatch',
  'distMaxArcsec': 1.0,
  'RESPONSEFORMAT': 'votable',
  'cat1': 'II/316/gps6',
  'cat2': 'II/293/glimpse',
  'area': 'cone',
  'coneRA': 267.90564932389594,
  'coneDec': -26.122240043829727,
  'coneRadiusDeg': 0.008333333333333333},
 {})

When I checked the webform payload on the http://cdsxmatch.u-strasbg.fr/ website, this is what the payload was:

PHASE: RUN
sessionId: 38859BA25E0BCDF6BF90A88DAB4D12CA
cat1: II/316/gps6
cat2: II/293/glimpse
typeCat1: vizier
typeCat2: vizier
xmatchMethod: fixedRadius
radius: 1
unit: arcsec
area: cone
areaCenter: 267.905 -26.1222
areaRadius: 0.008
areaRadiusUnit: deg

It looks like there is a difference, maybe there is something weird going on.

@ManonMarchand
Copy link
Member

ManonMarchand commented Jan 29, 2025

Hi,

I tried to reproduce, and the error message says:

Traceback (most recent call last):
  File "/home/manon.marchand/Documents/cds-astro-github/astroquery/astroquery/xmatch/core.py", line 115, in query_async
    response.raise_for_status()
  File "/home/manon.marchand/.conda/envs/astroquery-dev/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Mauvaise Requête for url: http://cdsxmatch.u-strasbg.fr/xmatch/api/v1/sync

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/manon.marchand/Documents/cds-astro-github/astroquery/astroquery/xmatch/core.py", line 76, in query
    response = self.query_async(cat1, cat2, max_distance, colRA1=colRA1, colDec1=colDec1,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/manon.marchand/Documents/cds-astro-github/astroquery/astroquery/xmatch/core.py", line 119, in query_async
    raise InvalidQueryError(error_reason) from err
astroquery.exceptions.InvalidQueryError: Message: Catalogue must be a URL or simbad or vizier:tabName
                 Trace:
java.lang.Exception: Catalogue must be a URL or simbad or vizier:tabName
        at cds.xmatch.servlet.SyncXMatch.getXMatchDataSet(SyncXMatch.java:390)
        at cds.xmatch.servlet.SyncXMatch.exec(SyncXMatch.java:654)
        at cds.xmatch.servlet.SyncXMatch.doPost(SyncXMatch.java:476)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2486)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:844)

Where the important line is: Message: Catalogue must be a URL or simbad or vizier:tabName

It works if you switch your line to:

tbl = XMatch.query(cat1='vizier:II/316/gps6', cat2='vizier:II/293/glimpse', area=reg_alt, max_distance=1*u.arcsec)

Maybe we should make this more visible in the documentation?

EDIT: just had a look at the documentation and I'm laughing so hard, there is nothing in there, we seriously have an issue. I'm super sorry and have no idea how you found the method to restrict the cross match inside a cone. Adding this to my to do list for ~ March, or I'm happy to help anyone wanting to contribute.

@keflavich
Copy link
Contributor

Ahhh, I see.

Yes, definitely need to fix the documentation!

Also, can we fix the error message? The part you found:
astroquery.exceptions.InvalidQueryError: Message: Catalogue must be a URL or simbad or vizier:tabName
is buried under 25 lines of java junk. Probably a way to do this is validate the tables before submitting the request and raise the invalidqueryerror before raise_for_status()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants