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

Unfriendly Simbad.query_criteria functionality #2041

Closed
DinoBektesevic opened this issue Apr 14, 2021 · 4 comments · Fixed by #2954
Closed

Unfriendly Simbad.query_criteria functionality #2041

DinoBektesevic opened this issue Apr 14, 2021 · 4 comments · Fixed by #2954

Comments

@DinoBektesevic
Copy link
Contributor

I either can't figure out how to, or the functionality for it isn't there but using Simbad.query_criteria wants me to pass full strings of my queries and will not accept SkyCoords. Currently the documentation shows these two usage cases:

result = Simbad.query_criteria('region(box, GAL, 0 +0, 3d 1d)', otype='SNR')
...
script = '(region(box, GAL, 0 +0, 0.5d 0.5d) | region(box, GAL, 43.3 -0.2, 0.25d 0.25d))'
result = Simbad.query_criteria(script, otype='SNR')

Could it be possible to add some friendliness to how this is scripted for some of the easier criterion operators such as region? For example:

result = Simbad.query_criteria(SkyCoord, criterion="region", shape="circle", radius=Unit)

Or something similar?

@bsipocz
Copy link
Member

bsipocz commented Apr 14, 2021

My thinking would be to provide a way to add criteria to the usual API methods, e.g.

query_region(coord, criteria={'otype': 'STAR',})

to query for stars, rather than forcing you to use query_criteria, and define regions by hand, etc. At the end of the day, we query the same API so this will all boil down to creating payload within astroquery.

@bsipocz bsipocz added the simbad label Apr 21, 2021
@ManonMarchand
Copy link
Member

ManonMarchand commented Jan 8, 2024

Hi there,

I'm working on query criteria now and would like to pick your minds.

I like a lot brigitta's idea but what about different operators than =? (ADQL has =, !=, <>, <, >, <=, >=, BETWEN, IN, LIKE, IS NULL, IS NOT NULL, EXISTS') And what about other logical operators than AND (namely OR and NOT are also possible there)?

I was thinking to introduce a Criteria dataclass (or named tuples I don't know what is more in astroquery's philosophy). Maybe something along:

from dataclasses import dataclass
from typing import Any

@dataclass
class Criteria:
    column: str
    operator: str
    value: Any
    logic = 'AND'

Criteria('ra', '<=', '10')
Criteria(column='ra', operator='<=', value='10', logic='AND')

Then it would be called like this :

query_region(coord, Criteria('otype', '!=', 'Cl*'))

(where the signature of query_region would be query_region(coord, **criteria))

Would that be more friendly?

@bsipocz
Copy link
Member

bsipocz commented Jan 8, 2024

I like a lot brigitta's idea but what about different operators than =? (ADQL has =, !=, <>, <, >, <=, >=, BETWEN, IN, LIKE, IS NULL, IS NOT NULL, EXISTS') And what about other logical operators than AND (namely OR and NOT are also possible there)?

I wonder how much of this scenario gets resolved with #2856 getting merged, practically asking users to write ADQL queries for the more complicated ones.

@ManonMarchand
Copy link
Member

ManonMarchand commented Jan 8, 2024

I think it's a bit different from adding the possibility to do tap. It'd be a way to do moderately intricate queries (a few joins / criteria only) for the non adql-proficient users

A kind of replacement for the current query_criteria that is bound to disapear (could be deprecated for a few more years but sim-script is not maintained upstream so the current bugs and missing features will stay as they are)

The idea is to add this feature when doing the rewrite of #1468

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

Successfully merging a pull request may close this issue.

3 participants