astropy / astroquery

Functions and classes to access online data resources. Maintainers: @keflavich and @bsipocz and @ceb8
http://astroquery.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
695 stars 396 forks source link

Querying for all objects between 25-30pc using Simbad.query_criteria #925

Closed baddison2005 closed 7 years ago

baddison2005 commented 7 years ago

Hi,

I'm not quite sure how to retrieve all objects that reside between 25-30pc (parallax of greater than 33.3mas and less than 40.0mas) using astroquery.

On the Simbad website query page under search expression, I can enter plx > 33.3 & plx < 40.0 and retrieve the desired results. However, I can't seem to do this using astroquery. I don't know the correct syntax for doing such a search. I've read the astroquery docs but did not find what I was looking for. Here's what I have tried.

from astroquery.simbad import Simbad

Simbad.ROW_LIMIT = -1 # now any query fetches all the rows.
customSimbad = Simbad()
customSimbad.add_votable_fields('parallax', 'plx')
simbad_result = customSimbad.query_criteria('plx > 33.3 & plx < 40.0')

error message:
/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/astroquery/simbad/core.py:136: UserWarning: Warning: The script line number 3 raised an error (recorded in the `errors` attribute of the result table): Identifier not found in the database : NAME sample
  (error.line, error.msg))

I've also tried:

`simbad_result = customSimbad.query_criteria(plx > 33.3 & plx < 40.0)`
`simbad_result = customSimbad.query_criteria(plx > 33.3)`
Both queries resulted in errors. However, the following worked and got me results for objects at 33.3mas.
`simbad_result = customSimbad.query_criteria(plx = 33.3)`
simbad_result
Out[31]: 
<Table masked=True length=8>
        MAIN_ID               RA      ...     PLX_BIBCODE     PLX_VALUE_2
                           h:m:s    ...                         mas    
         object             str13     ...        object         float64  
----------------------- ------------- ... ------------------- -----------
              LHS  3089   15 35 05.15 ... 2014ApJ...784..156D      33.300
             NLTT  5383   01 37 07.17 ... 2014ApJ...784..156D      33.300
               G  46-26   09 11 13.13 ... 2014ApJ...784..156D      33.300
              HD 161897 17 41 06.6994 ... 2007A&A...474..653V      33.300
             NLTT 13711   04 41 46.92 ... 2014ApJ...784..156D      33.300
            BD-12  6102 21 49 45.9347 ... 2007A&A...474..653V      33.300
2MASS J03504003+3005394   03 50 40.03 ... 2014ApJ...784..156D      33.300
            LP   80-126 01 58 29.8130 ... 1995GCTP..C......0V      33.300

If someone could please help that would be greatly appreciated. My current workaround is to download as a .csv file the results from the Simbad query page and read those into Python using pyexcel.

Cheers, Brett

keflavich commented 7 years ago

I can't reproduce your error. If I try your exact example:

from astroquery.simbad import Simbad

Simbad.ROW_LIMIT = -1 # now any query fetches all the rows.
customSimbad = Simbad()
customSimbad.add_votable_fields('parallax', 'plx')
simbad_result = customSimbad.query_criteria('plx > 33.3 & plx < 40.0')

The result seems fine:

In [12]: len(simbad_result)
Out[12]: 1190

In [13]: simbad_result
Out[13]:
<Table masked=True length=1190>
        MAIN_ID               RA           DEC      RA_PREC DEC_PREC COO_ERR_MAJA COO_ERR_MINA ... PLX_VALUE PLX_PREC PLX_ERROR  PLX_QUAL     PLX_BIBCODE     PLX_VALUE_2
                           "h:m:s"       "d:m:s"                         mas          mas      ...    mas                mas                                      mas
         object             str13         str13      int16   int16     float32      float32    ...  float64   int16    float32     str1          object         float64
----------------------- ------------- ------------- ------- -------- ------------ ------------ ... --------- -------- ---------- -------- ------------------- -----------
              HD 224660 23 59 47.7872 +06 39 50.959       9        9       15.320        7.480 ...    39.860        2       1.46        A 2007A&A...474..653V      39.860
USNO-B1.0 0703-00025105  02 19 28.075  -19 38 41.63       7        7       70.000       70.000 ...    37.200        1  4.0999999        D 2013AJ....146..161M      37.200
              HD  46090 06 31 21.4899 +02 54 40.666       9        9        4.930        4.310 ...    36.000        2 0.61000001        A 2007A&A...474..653V      36.000
              V* AN CrB 15 35 30.1596 +36 12 34.621       9        9        7.030        6.150 ...    33.490        2 0.82999998        A 2007A&A...474..653V      33.490
            BD-11  4672 18 33 28.8327 -11 38 09.731       9        9       15.040       11.170 ...    36.650        2       1.73        A 2007A&A...474..653V      36.650
             LP  619-49   14 12 11.02   -00 35 04.5       6        6      130.000       70.000 ...    39.700        1  3.9000001        D 1991NSC3..C......0G      39.700
             HIP  43650 08 53 29.2396 -48 24 19.992       9        9       79.540       69.480 ...    36.400        2  8.7700005        A 2007A&A...474..653V      36.400
               G 165-43   14 02 44.17   +30 07 46.2       6        6      260.000       70.000 ...    35.100        2        3.0          2014ApJ...784..156D      35.100
             HD 219175B 23 14 07.6183 -08 55 52.779       9        9       52.460       37.220 ...    39.320        2       5.46        A 2007A&A...474..653V      39.320
             LP  261-75   09 51 04.60   +35 58 09.8       6        6       70.000       60.000 ...    33.600        2        1.9          2014ApJ...784..156D      33.600
               G 250-14 06 41 49.0278 +68 46 39.478       8        8       13.000       12.000 ...    39.700        2        1.6          2014ApJ...784..156D      39.700
               G 206-37 18 39 59.9015 +33 24 54.306       8        8       16.000       16.000 ...    39.400        1  8.1000004        D 1995GCTP..C......0V      39.400
              HD 117099 13 27 27.1710 +35 43 34.226       9        9        7.290        4.400 ...    36.840        2 0.91000003        A 2007A&A...474..653V      36.840
            LP  102-243   17 45 48.01   +58 53 19.0       6        6       60.000       60.000 ...    35.600        2        6.5          2014ApJ...784..156D      35.600
             LP  299-15   03 05 07.87   +27 42 27.8       6        6       70.000       60.000 ...    38.800        2  4.1999998          2014ApJ...784..156D      38.800
                    ...           ...           ...     ...      ...          ...          ... ...       ...      ...        ...      ...                 ...         ...
              Ross  406  05 29 52.691  +32 04 52.48       7        7       70.000       60.000 ...    34.100        1        5.0        D 1991NSC3..C......0G      34.100
                LAWD 39   11 56 43.87   +18 22 19.6       6        6      130.000       90.000 ...    33.500        1        3.5        D 1995GCTP..C......0V      33.500
               G  85-38   05 01 53.21   +23 57 12.0       6        6      120.000       80.000 ...    38.100        2        1.3          2014ApJ...784..156D      38.100
             L  951-6 A 04 32 56.2462 +00 06 15.976       8        8       20.000       17.000 ...    38.200        2        3.8          2014ApJ...784..156D      38.200
             NLTT 14111 04 53 04.7312 +22 14 06.619       9        9       18.160       12.980 ...    37.680        2       1.29        A 2007A&A...474..653V      37.680
2MASS J06405810+4944304   06 40 58.10   +49 44 30.4       6        6       60.000       60.000 ...    34.400        2        3.5          2014ApJ...784..156D      34.400
              HD 218209 23 05 06.0916 +68 25 01.429       9        9        4.210        3.780 ...    33.850        2 0.38999999        A 2007A&A...474..653V      33.850
                * p Vel 10 37 18.1399 -48 13 32.234       9        9        3.070        2.550 ...    37.260        2 0.36000001        A 2007A&A...474..653V      37.260
            BD-08  2813 09 59 11.3592 -09 11 00.315       9        9       16.430       16.380 ...    33.600        2       2.24        A 2007A&A...474..653V      33.600
              *   9 Aur 05 06 40.6296 +51 35 51.802       9        9        3.430        2.370 ...    38.040        2       0.34        A 2007A&A...474..653V      38.040
       UCAC4 655-037703 05 43 56.2179 +40 51 06.972       8        8       15.000       14.000 ...    37.800        2        1.3          2014ApJ...784..156D      37.800
              Wolf 1438 12 13 20.4619 +16 41 39.676       9        9       40.520       17.250 ...    35.660        2       3.48        A 2007A&A...474..653V      35.660
              LHS  1977   08 04 20.22   +15 01 44.7       6        6      110.000       60.000 ...    39.700        2        3.2          2014ApJ...784..156D      39.700
           BD+39  1978C 07 37 26.5146 +38 52 28.213       9        9      200.500      128.000 ...    33.630        2  20.309999        A 2007A&A...474..653V      33.630
               HR  3028 07 51 05.7108 +54 07 45.270       9        9        3.950        3.070 ...    33.780        2 0.38999999        A 2007A&A...474..653V      33.780
               GJ  3195   03 04 43.35   +61 44 09.7       6        6       60.000       60.000 ...    36.200        1  7.1999998        D 1991NSC3..C......0G      36.200
baddison2005 commented 7 years ago

That's strange that it's working for you but not me. I'm using Python 3.6.1. Also I'm entering these commands using the Python console (IPython 6.1.0). I've ensured all my Python packages are up to date by running the sudo pip freeze --local | grep -v '^-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U command.

keflavich commented 7 years ago

I see the problem. You need to update to the development version of astroquery. This is Issue #891, which was fixed by #892.

baddison2005 commented 7 years ago

I can now confirm that it works by installing the development version of astroquery via: sudo -H pip install https://github.com/astropy/astroquery/archive/master.zip

FYI, I also needed to install pytest for astroquery to work using the development version.

Thanks for your help.

Cheers, Brett

bsipocz commented 7 years ago

@baddison2005 - I'm glad to see that your issue is solved. Could you just confirm, you couldn't install the dev version without pytest, or you just needed it to run the tests?

baddison2005 commented 7 years ago

I could install the dev versions without pytest but I could not import the package without pytest (importing astroquery without pytest package installed results in an error).

Cheers, Brett

Dr. Brett C. Addison Postdoc Mississippi State University Ph.D. Astronomy/Astrophysics University of New South Wales baddison2005@gmail.com

On Mon, Jun 12, 2017 at 6:02 AM, Brigitta Sipocz notifications@github.com wrote:

@baddison2005 https://github.com/baddison2005 - I'm glad to see that your issue is solved. Could you just confirm, you couldn't install the dev version without pytest, or you just needed it to run the tests?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/astropy/astroquery/issues/925#issuecomment-307758203, or mute the thread https://github.com/notifications/unsubscribe-auth/ANg7JpwQVmZvao_HZLZiRDJ6poJJThoIks5sDRqygaJpZM4N1xRO .

bsipocz commented 7 years ago

@keflavich - Should we formally require pytest in astroquery's setup.py, or shall we just go with the assumption that it is taken care of the astropy install (assuming one uses astropy 2.0+)?

keflavich commented 7 years ago

Yes, I guess so.