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

Keep input coordinates and errors in table generated by Simbad.query_region #2047

Closed
samuelperezdi opened this issue Apr 22, 2021 · 4 comments
Labels

Comments

@samuelperezdi
Copy link

samuelperezdi commented Apr 22, 2021

Hello there! This situation is kinda related to #967. I was trying to perform a Simbad.query_region into a list of coordinates. I wanted to be able to keep the input related to each row (or the index) of the output, and it would be extremely helpful to have a error label too, in case of not finding an object with Simbad.

I found out that there is an alternative with typed_id, but this option seems to work only with query_objects. Would it be possible to consider these features for query_region? I think there could be an alternative too with XMatch.query, I partially reached my goal using XMatch directly with their web page.

@samuelperezdi samuelperezdi changed the title Keep input coordinates and errors in table generated by Simbad.region_query Keep input coordinates and errors in table generated by Simbad.query_region Apr 22, 2021
@keflavich
Copy link
Contributor

OK, so, the solution you mentioned is this: #496 (comment)

I don't think what you're asking for is possible, though - it would require an upstream change, I think. You basically want your search coordinates as a return column, right?

@aoberto any ideas?

@samuelperezdi
Copy link
Author

OK, so, the solution you mentioned is this: #496 (comment)

I don't think what you're asking for is possible, though - it would require an upstream change, I think. You basically want your search coordinates as a return column, right?

@aoberto any ideas?

Thank you for your comment, Adam. Yes, I basically want the search coordinates as a return column, even better if not found coordinates are returned as a row with an special label (or simply None).

@aoberto
Copy link
Contributor

aoberto commented Aug 1, 2021

Sorry, it does not look so simple to me.
Until now, there was no input given in the output for query by coordinates.

The difficulty I see here, it that coordinates are given through a SkyCoord object, so depending of the interpretation and the output format of the coordinates, it could be too risky to recognize exactly the given coordinates in the output comparing strings.

Beside of that, errors are raised when no object are found.
UserWarning: Warning: The script line number 3 raised an error (recorded in the errors attribute of the result table): '0:36:00 +9:12:00': No astronomical object found

From now, I just added a column named 'SCRIPT_NUMBER_ID' which is the number (from 1) of the corresponding query array position. You do not have to add this field manually, it will always be inside the output. So you can group by this number to get results query by query.

For instance :

    MAIN_ID           RA           DEC      RA_PREC DEC_PREC COO_ERR_MAJA ...    MAIN_ID_2    OTYPE     RA_d        DEC_d     SCRIPT_NUMBER_ID
                   "h:m:s"       "d:m:s"                         mas      ...                           deg          deg                      
--------------- ------------- ------------- ------- -------- ------------ ... --------------- ----- ------------ ------------ ----------------
        IC 2501 09 38 47.1807 -60 05 30.742      14       14        0.587 ...         IC 2501    PN 144.69658630 -60.09187281              1
 TYC 8941-569-1 09 38 30.2822 -60 05 17.630      14       14        0.021 ...  TYC 8941-569-1  Star 144.62617590 -60.08823059              1
TYC 9003-1531-1 13 33 42.9011 -65 59 11.359      14       14        0.028 ... TYC 9003-1531-1  Star 203.42875481 -65.98648878              2
      NGC  5189 13 33 32.8779 -65 58 27.038      14       14        0.025 ...       NGC  5189    PN 203.38699130 -65.97417749              2

Can you try it (do not forget to clean the cache), and tell me if it looks good to you or if some adjustments are needed.
After then, we could add it in the documentation.

@ManonMarchand
Copy link
Member

ManonMarchand commented Sep 8, 2023

It looks fixed to me. Doing the query from the examples

from astroquery.simbad import Simbad
import astropy.coordinates as coord
import astropy.units as u
result_table = Simbad.query_region(coord.SkyCoord(ra=[10, 11], dec=[10, 11],
                                   unit=(u.deg, u.deg), frame='fk5'),
                                   radius=0.1 * u.deg)

returns

<Table length=16>
        MAIN_ID                RA           DEC      RA_PREC DEC_PREC ... COO_ERR_ANGLE COO_QUAL COO_WAVELENGTH     COO_BIBCODE     SCRIPT_NUMBER_ID
                            "h:m:s"       "d:m:s"                     ...      deg                                                                  
         object              str13         str13      int16   int16   ...     int16       str1        str1             object            int32      
------------------------ ------------- ------------- ------- -------- ... ------------- -------- -------------- ------------------- ----------------
  GALEX J004011.0+095752 00 40 11.0357 +09 57 51.355      14       14 ...            90        A              O 2020yCat.1350....0G                1
   PLCKECC G118.25-52.70    00 39 55.5     +10 03 42       5        5 ...             0        E              m 2011A&A...536A...7P                1
         IRAS 00373+0947    00 39 55.6     +10 04 15       5        5 ...            67        E              F 1988NASAR1190....1B                1
         IRAS 00371+0946    00 39 43.1     +10 03 21       5        5 ...            67        E              F 1988NASAR1190....1B                1
SDSS J004014.26+095527.0  00 40 14.266  +09 55 27.02       7        7 ...             0        C              O 2020ApJS..250....8L                1
            LEDA 1387229    00 43 57.2     +10 58 54       5        5 ...             0        D              O 2003A&A...412...45P                2
            LEDA 1387610    00 43 50.3     +11 00 32       5        5 ...             0        D              O 2003A&A...412...45P                2
            LEDA 1386801    00 43 53.1     +10 56 59       5        5 ...             0        D              O 2003A&A...412...45P                2
            LEDA 1387466    00 43 41.3     +10 59 57       5        5 ...             0        D              O 2003A&A...412...45P                2
     NVSS J004350+110411    00 43 50.2     +11 04 11       5        5 ...             0        C              R 2015ApJ...801...26H                2
    87GB 004144.9+104343 00 44 20.7559 +11 00 10.703       8        8 ...            90        C              M 2017MNRAS.468..196T                2
SDSS J004340.18+105815.6 00 43 40.1850 +10 58 15.610      14       14 ...            90        A              O 2020yCat.1350....0G                2
  GALEX J004357.6+105446  00 43 57.698  +10 54 46.15       7        7 ...             0        D                2007ApJ...664...53A                2
SDSS J004422.75+110104.3  00 44 22.753  +11 01 04.34       7        7 ...             0        C              O 2017A&A...597A..79P                2
          TYC  607-628-1 00 44 05.6169 +11 05 41.196      14       14 ...            90        A              O 2020yCat.1350....0G                2
       Fermi bn170124528         00 44         +11.0       2        2 ...            90        E              G 2020ApJ...893...46V                2

Can we close? Don't hesitate to ask again if it did not solve the issue

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

No branches or pull requests

4 participants