From 603309fa4d44ca4534fe513b83387c970f85baab Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 11:54:25 +0100 Subject: [PATCH 1/7] doc: UCAC2 is now tagged as obsolete --- astroquery/vizier/tests/test_vizier_remote.py | 2 +- docs/vizier/vizier.rst | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/astroquery/vizier/tests/test_vizier_remote.py b/astroquery/vizier/tests/test_vizier_remote.py index f27d7fd52c..574cb3b005 100644 --- a/astroquery/vizier/tests/test_vizier_remote.py +++ b/astroquery/vizier/tests/test_vizier_remote.py @@ -146,7 +146,7 @@ def test_asu_tsv_return_type(self): result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"], return_type='asu-tsv', cache=False) assert isinstance(result, list) - assert len(result) == 3 + assert len(result) == 2 def test_query_constraints(self): vizier = Vizier(row_limit=3) diff --git a/docs/vizier/vizier.rst b/docs/vizier/vizier.rst index 08b9aa0a76..08e01b3ad5 100644 --- a/docs/vizier/vizier.rst +++ b/docs/vizier/vizier.rst @@ -255,11 +255,10 @@ dimension. ... width="30m", ... catalog=["NOMAD", "UCAC"]) >>> print(result) - TableList with 4 tables: + TableList with 3 tables: '0:I/297/out' with 19 column(s) and 50 row(s) - '1:I/289/out' with 13 column(s) and 50 row(s) - '2:I/322A/out' with 24 column(s) and 50 row(s) - '3:I/340/ucac5' with 20 column(s) and 50 row(s) + '1:I/322A/out' with 24 column(s) and 50 row(s) + '2:I/340/ucac5' with 20 column(s) and 50 row(s) One more thing to note in the above example is that the coordinates may be @@ -311,11 +310,10 @@ this Vizier instance: ... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS >>> result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"]) >>> print(result) - TableList with 4 tables: + TableList with 3 tables: '0:I/297/out' with 3 column(s) and 50 row(s) - '1:I/289/out' with 2 column(s) and 18 row(s) - '2:I/322A/out' with 3 column(s) and 10 row(s) - '3:I/340/ucac5' with 2 column(s) and 26 row(s) + '1:I/322A/out' with 3 column(s) and 10 row(s) + '2:I/340/ucac5' with 2 column(s) and 26 row(s) >>> print(result['I/322A/out']) _RAJ2000 _DEJ2000 Vmag deg deg mag From 86734778a2bebbd7e911bd1dabe7e86407af5698 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 11:59:27 +0100 Subject: [PATCH 2/7] fix: changes in trailing zeroes --- docs/vizier/vizier.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/vizier/vizier.rst b/docs/vizier/vizier.rst index 08e01b3ad5..9d7b2666c9 100644 --- a/docs/vizier/vizier.rst +++ b/docs/vizier/vizier.rst @@ -346,7 +346,7 @@ the ``"+"`` in front of ``"_r"``. ------ ---------- ---------- ---------------- ------ ... ---- ---- ---- ---- 0.134 299.590280 35.201599 19582166+3512057 6.872 ... 111 000 0 0 10.135 299.587491 35.203217 19582099+3512115 10.285 ... 111 c00 0 0 - 11.167 299.588599 35.198849 19582126+3511558 13.111 ... 002 00c 0 0 + 11.167 299.588599 35.198849 19582126+3511558 13.111 ... 2 00c 0 0 12.288 299.586356 35.200542 19582072+3512019 14.553 ... 111 ccc 0 0 17.691 299.586254 35.197994 19582070+3511527 16.413 ... 100 c00 0 0 @@ -392,9 +392,9 @@ index to the ``agn`` table (not the 0-based python convention). _q RAJ2000 DEJ2000 _2MASS Jmag ... Rflg Bflg Cflg Xflg Aflg deg deg mag ... --- ---------- ---------- ---------------- ------ ... ---- ---- ---- ---- ---- - 1 10.686015 41.269630 00424464+4116106 9.399 ... 020 020 0c0 2 0 + 1 10.686015 41.269630 00424464+4116106 9.399 ... 20 20 0c0 2 0 1 10.685657 41.269550 00424455+4116103 10.773 ... 200 200 c00 2 0 - 1 10.685837 41.270599 00424460+4116141 9.880 ... 020 020 0c0 2 0 + 1 10.685837 41.270599 00424460+4116141 9.880 ... 20 20 0c0 2 0 1 10.683263 41.267456 00424398+4116028 12.136 ... 200 100 c00 2 0 1 10.683465 41.269676 00424403+4116108 11.507 ... 200 100 c00 2 0 3 27.238636 5.906066 01485727+0554218 8.961 ... 112 111 000 0 0 From 187c39f9af362879d66291d61b91a526a2bb22f2 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 13:47:19 +0100 Subject: [PATCH 3/7] fix: data.data needed for comparison in masked array maybe a numpy 2.0 change? --- astroquery/vizier/tests/test_vizier_remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astroquery/vizier/tests/test_vizier_remote.py b/astroquery/vizier/tests/test_vizier_remote.py index 574cb3b005..db7a92d627 100644 --- a/astroquery/vizier/tests/test_vizier_remote.py +++ b/astroquery/vizier/tests/test_vizier_remote.py @@ -154,4 +154,4 @@ def test_query_constraints(self): # row_limit is taken in account assert len(result) == 3 # the criteria is respected - assert np.all(np.isclose(result["mB2"], 14.7, rtol=1e-09, atol=1e-09)) + assert np.all(np.isclose(result["mB2"].data.data, 14.7, rtol=1e-09, atol=1e-09)) From 1c03261fbe2c5383d1df73f5afc20cd2055eec6d Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 14:24:48 +0100 Subject: [PATCH 4/7] test: fix non-deterministic order in tests --- docs/vizier/vizier.rst | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/vizier/vizier.rst b/docs/vizier/vizier.rst index 9d7b2666c9..ef8037cf23 100644 --- a/docs/vizier/vizier.rst +++ b/docs/vizier/vizier.rst @@ -20,11 +20,12 @@ Table Discover If you want to search for a set of tables, e.g. based on author name or other keywords, the :meth:`~astroquery.vizier.VizierClass.find_catalogs` tool can be used: +.. order is not deterministic .. doctest-remote-data:: >>> from astroquery.vizier import Vizier - >>> catalog_list = Vizier.find_catalogs('hot jupiter exoplanet transit') - >>> for k, v in catalog_list.items(): + >>> catalog_list = Vizier().find_catalogs('hot jupiter exoplanet transit') + >>> for k, v in catalog_list.items(): # doctest: +IGNORE_OUTPUT ... print(k, ":", v.description) J/A+A/635/A205 : Ultra-hot Jupiter WASP-121b transits (Bourrier+, 2020) J/ApJ/788/39 : Hot Jupiter exoplanets host stars EW and abundances (Teske+, 2014) @@ -45,7 +46,7 @@ the complete contents of those catalogs: .. doctest-remote-data:: >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) - >>> print(catalogs) + >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) '1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s) @@ -65,7 +66,7 @@ way: .. doctest-remote-data:: >>> catalogs = Vizier.get_catalogs(catalog_list.values()) - >>> print(catalogs) + >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) '1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s) @@ -81,7 +82,7 @@ way: .. doctest-remote-data:: >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) - >>> print(catalogs) + >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) '1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s) @@ -101,7 +102,7 @@ complete catalog, you need to change that: >>> Vizier.ROW_LIMIT = -1 >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) - >>> print(catalogs) + >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 235 row(s) '1:J/A+A/635/A205/20140123' with 7 column(s) and 195 row(s) @@ -160,11 +161,11 @@ For instance to query Sirius across all catalogs: .. doctest-remote-data:: >>> from astroquery.vizier import Vizier - >>> vizier = Vizier() + >>> vizier = Vizier(row_limit=10) >>> result = vizier.query_object("sirius") >>> print(result) - TableList with 416 tables: - '0:METAobj' with 5 column(s) and 7 row(s) + TableList with ... tables: + '0:METAobj' with 5 column(s) and 7 row(s) '1:ReadMeObj' with 5 column(s) and 7 row(s) '2:I/34/greenw2a' with 16 column(s) and 1 row(s) ... @@ -298,23 +299,24 @@ on the Vizier class. >>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], ... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS -Note that whenever an unknown keyword is specified, a warning is emitted and +Note that whenever an unknown keyword is specified (here ``xry``) a warning is emitted and that keyword is discarded from further consideration. The behavior for searching with these keywords is the same as defined for the web interface (`for details see here`_). Now we call the different query methods on this Vizier instance: +.. output can be in any order here .. doctest-remote-data:: >>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], - ... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS + ... column_filters={"Vmag":">10"}, keywords=["optical"]) >>> result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"]) >>> print(result) TableList with 3 tables: '0:I/297/out' with 3 column(s) and 50 row(s) '1:I/322A/out' with 3 column(s) and 10 row(s) '2:I/340/ucac5' with 2 column(s) and 26 row(s) - >>> print(result['I/322A/out']) + >>> print(result['I/322A/out']) # doctest: +IGNORE_OUTPUT _RAJ2000 _DEJ2000 Vmag deg deg mag ------------- ------------- ------ From b8955d29e5d9bcc8b87ecfa058d9f181add63f27 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 14:25:31 +0100 Subject: [PATCH 5/7] fix: ucd keyword had a typo --- CHANGES.rst | 5 +++++ astroquery/vizier/core.py | 4 ++-- astroquery/vizier/tests/test_vizier_remote.py | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 15c4c47eb5..7d79215cd2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -149,6 +149,11 @@ skyview - Overlay arguments ``lut``, ``grid``, and ``gridlabel`` are removed, as they only apply to output types not returned by Astroquery [#2979] +vizier +^^^^^^ + +- Fixed search by UCD -- they were ignored. [#3147] + vsa ^^^ diff --git a/astroquery/vizier/core.py b/astroquery/vizier/core.py index fe0749ebee..ae44501774 100644 --- a/astroquery/vizier/core.py +++ b/astroquery/vizier/core.py @@ -78,7 +78,7 @@ def __init__(self, *, columns=["*"], column_filters={}, catalog=None, self.column_filters = column_filters self.catalog = catalog self._keywords = None - self.ucd = ucd + self._ucd = ucd if keywords: self.keywords = keywords self.TIMEOUT = timeout @@ -233,7 +233,7 @@ def find_catalogs(self, keywords, *, include_obsolete=False, verbose=False, data_payload["-obsolete"] = None if self.ucd != "": - data_payload["ucd"] = self.ucd + data_payload["-ucd"] = self.ucd params = "&".join([k if v is None else f"{k}={v}" for k, v in data_payload.items()]) diff --git a/astroquery/vizier/tests/test_vizier_remote.py b/astroquery/vizier/tests/test_vizier_remote.py index db7a92d627..66dd2a0f05 100644 --- a/astroquery/vizier/tests/test_vizier_remote.py +++ b/astroquery/vizier/tests/test_vizier_remote.py @@ -131,7 +131,6 @@ def test_findcatalog_maxcatalog(self): assert len(cats) >= 39 # as of 2024 def test_findcatalog_ucd(self): - # this fails for VizieR 7.33.3, should work in next releases vizier = Vizier() ucdresult = vizier(ucd='phys.albedo').find_catalogs('mars', max_catalogs=5000) result = vizier.find_catalogs('mars', max_catalogs=5000) From 32a651dc9c60a0f002e4f20321a297c17407f1a8 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Tue, 10 Dec 2024 16:18:00 +0100 Subject: [PATCH 6/7] fix: ignore units warnings --- docs/vizier/vizier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/vizier/vizier.rst b/docs/vizier/vizier.rst index ef8037cf23..9aa420c19a 100644 --- a/docs/vizier/vizier.rst +++ b/docs/vizier/vizier.rst @@ -162,7 +162,7 @@ For instance to query Sirius across all catalogs: >>> from astroquery.vizier import Vizier >>> vizier = Vizier(row_limit=10) - >>> result = vizier.query_object("sirius") + >>> result = vizier.query_object("sirius") # doctest: +IGNORE_WARNINGS >>> print(result) TableList with ... tables: '0:METAobj' with 5 column(s) and 7 row(s) From 4799e0ed9b5e16616d5d7b883409268a12c4cb35 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Thu, 12 Dec 2024 11:06:01 +0100 Subject: [PATCH 7/7] docs: switch to use a single instance of Vizier when possible --- docs/vizier/vizier.rst | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/vizier/vizier.rst b/docs/vizier/vizier.rst index 9aa420c19a..df3fe3c883 100644 --- a/docs/vizier/vizier.rst +++ b/docs/vizier/vizier.rst @@ -24,7 +24,8 @@ the :meth:`~astroquery.vizier.VizierClass.find_catalogs` tool can be used: .. doctest-remote-data:: >>> from astroquery.vizier import Vizier - >>> catalog_list = Vizier().find_catalogs('hot jupiter exoplanet transit') + >>> vizier = Vizier() # this instantiates Vizier with its default parameters + >>> catalog_list = vizier.find_catalogs('hot jupiter exoplanet transit') >>> for k, v in catalog_list.items(): # doctest: +IGNORE_OUTPUT ... print(k, ":", v.description) J/A+A/635/A205 : Ultra-hot Jupiter WASP-121b transits (Bourrier+, 2020) @@ -45,7 +46,7 @@ the complete contents of those catalogs: .. doctest-remote-data:: - >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) + >>> catalogs = vizier.get_catalogs(catalog_list.keys()) >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) @@ -65,7 +66,7 @@ way: .. doctest-remote-data:: - >>> catalogs = Vizier.get_catalogs(catalog_list.values()) + >>> catalogs = vizier.get_catalogs(catalog_list.values()) >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) @@ -81,7 +82,7 @@ way: .. doctest-remote-data:: - >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) + >>> catalogs = vizier.get_catalogs(catalog_list.keys()) >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s) @@ -100,8 +101,8 @@ complete catalog, you need to change that: .. doctest-remote-data:: - >>> Vizier.ROW_LIMIT = -1 - >>> catalogs = Vizier.get_catalogs(catalog_list.keys()) + >>> vizier.ROW_LIMIT = -1 + >>> catalogs = vizier.get_catalogs(catalog_list.keys()) >>> print(catalogs) # doctest: +IGNORE_OUTPUT TableList with 10 tables: '0:J/A+A/635/A205/20140119' with 7 column(s) and 235 row(s) @@ -114,7 +115,7 @@ complete catalog, you need to change that: '7:J/AJ/157/217/transits' with 8 column(s) and 236 row(s) '8:J/A+A/635/A122/table2' with 4 column(s) and 18 row(s) '9:J/A+A/635/A122/table3' with 4 column(s) and 17 row(s) - >>> Vizier.ROW_LIMIT = 50 + >>> vizier.ROW_LIMIT = 50 Get a catalog's associated metadata ----------------------------------- @@ -211,7 +212,8 @@ quasar 3C 273: >>> from astroquery.vizier import Vizier >>> from astropy.coordinates import Angle - >>> result = Vizier.query_region("3C 273", radius=Angle(0.1, "deg"), catalog='GSC') + >>> vizier = Vizier() + >>> result = vizier.query_region("3C 273", radius=Angle(0.1, "deg"), catalog='GSC') Note that the radius may also be specified as a string in the format expected by `~astropy.coordinates.Angle`. So the above query may also @@ -219,14 +221,14 @@ be written as: .. doctest-remote-data:: - >>> result = Vizier.query_region("3C 273", radius="0d6m0s", catalog='GSC') + >>> result = vizier.query_region("3C 273", radius="0d6m0s", catalog='GSC') Or using angular units and quantities from `astropy.units`: .. doctest-remote-data:: >>> import astropy.units as u - >>> result = Vizier.query_region("3C 273", radius=0.1*u.deg, catalog='GSC') + >>> result = vizier.query_region("3C 273", radius=0.1*u.deg, catalog='GSC') To see the result: @@ -250,7 +252,8 @@ dimension. >>> from astroquery.vizier import Vizier >>> import astropy.units as u >>> import astropy.coordinates as coord - >>> result = Vizier.query_region(coord.SkyCoord(ra=299.590, dec=35.201, + >>> vizier = Vizier() + >>> result = vizier.query_region(coord.SkyCoord(ra=299.590, dec=35.201, ... unit=(u.deg, u.deg), ... frame='icrs'), ... width="30m", @@ -279,7 +282,8 @@ constraints on the columns of the returned tables by mean of the ``column_filter >>> from astroquery.vizier import Vizier >>> import astropy.units as u >>> from astropy.coordinates import SkyCoord - >>> result = Vizier.query_region(SkyCoord.from_name('M81'), + >>> vizier = Vizier() + >>> result = vizier.query_region(SkyCoord.from_name('M81'), ... radius=10*u.arcmin, ... catalog='I/345/gaia2', ... column_filters={'Gmag': '<19'}) @@ -296,7 +300,7 @@ on the Vizier class. .. doctest-remote-data:: - >>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], + >>> vizier = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], ... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS Note that whenever an unknown keyword is specified (here ``xry``) a warning is emitted and @@ -308,9 +312,9 @@ this Vizier instance: .. output can be in any order here .. doctest-remote-data:: - >>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], + >>> vizier = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'], ... column_filters={"Vmag":">10"}, keywords=["optical"]) - >>> result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"]) + >>> result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"]) >>> print(result) TableList with 3 tables: '0:I/297/out' with 3 column(s) and 50 row(s) @@ -340,8 +344,8 @@ the ``"+"`` in front of ``"_r"``. .. doctest-remote-data:: - >>> v = Vizier(columns=["*", "+_r"], catalog="II/246") - >>> result = v.query_region("HD 226868", radius="20s") + >>> vizier = Vizier(columns=["*", "+_r"], catalog="II/246") + >>> result = vizier.query_region("HD 226868", radius="20s") >>> print(result[0]) _r RAJ2000 DEJ2000 _2MASS Jmag ... Bflg Cflg Xflg Aflg deg deg mag ...