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

Add a method to access a vizier catalog's metadata information #2878

Merged
merged 6 commits into from
Dec 7, 2023

Conversation

ManonMarchand
Copy link
Member

@ManonMarchand ManonMarchand commented Nov 13, 2023

Hello astroquery,

What the PR does

This PR adds a method to astroquery.vizier.VizierClass to retrieve metadata information for a given catalog. This should solve these issues :

>>> from astroquery.vizier import Vizier
>>> Vizier(catalog="VII/74A").get_catalog_metadata()["origin_article"]
<MaskedColumn name='origin_article' dtype='object' description='A bibliographic reference from which the present resource is derived or extracted.' length=1>
1966ApJS...14....1A
>>> from astroquery.vizier import Vizier
>>> Vizier(catalog="VII/74A").get_catalog_metadata()
<Table length=1>
          title            authors                                                                    description                                                                      origin_article   ...       created             updated       waveband other_identifier
          object            object                                                                       object                                                                            object       ...        object              object        object       object     
-------------------------- -------- ----------------------------------------------------------------------------------------------------------------------------------------------- ------------------- ... ------------------- ------------------- -------- ----------------
Atlas of Peculiar Galaxies Arp H.C. This electronic version of Arp's 1966 "Atlas of Peculiar Galaxies" contains only its Table 2 published in the Astrophysical Journal Supplement. 1966ApJS...14....1A ... 1999-01-18T06:16:30 2021-10-21T00:00:00  optical                 
>>> from astroquery.vizier import Vizier
>>> Vizier(catalog="VII/74A").get_catalog_metadata()["description"]
<MaskedColumn name='description' dtype='object' description='An account of the nature of the resource.' length=1>
This electronic version of Arp's 1966 "Atlas of Peculiar Galaxies" contains only its Table 2 published in the Astrophysical Journal Supplement.

How it's done

It's a TAP query sent to the ivoa registry with pyvo. The output is an astropy table.

Edit: This is in a draft state cause @gilleslandais will do a first review

@ManonMarchand ManonMarchand marked this pull request as draft November 21, 2023 17:31
@gilleslandais
Copy link

Thank you for the update !

I propose minor changes in sematic (to be more close from VizieR) :

description -> abstract
other_identifier -> doi

Update sql:

SELECT TOP 1 res_title as title,
               creator_seq as authors,
                res_description as abstract,
                source_value as origin_article,
                reference_url as webpage,
                created, updated,
                waveband,
                alt_identifier as doi
                FROM rr.resource NATURAL LEFT OUTER JOIN rr.capability
                NATURAL LEFT OUTER JOIN rr.interface
                NATURAL LEFT OUTER JOIN rr.alt_identifier
                WHERE ivoid = 'ivo://cds.vizier/{catalog.lower()}'"""

and add a test on alt_identifier to select only alternate identifier prefixed with "doi:" (cf VOResource 1.2, 2.2.5 Alternate Identifiers)

metadata = registry.regtap.RegistryQuery(registry.regtap.REGISTRY_BASEURL, query)
if get_query_payload:
     return metadata
# remove alternate identifier which is not a DOI
if t["doi"][0].find("doi:") < 0: 
     t["doi"][0] = ""

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (8c15f2f) 66.52% compared to head (0a342d3) 66.53%.
Report is 7 commits behind head on main.

Files Patch % Lines
astroquery/vizier/core.py 78.57% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2878      +/-   ##
==========================================
+ Coverage   66.52%   66.53%   +0.01%     
==========================================
  Files         235      235              
  Lines       18101    18114      +13     
==========================================
+ Hits        12041    12052      +11     
- Misses       6060     6062       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 5, 2023

Gilles remarks are now implemented.

This made me realize that the doctests were skipped for vizier.core so I included them back with the tiny fixes needed to make them pass. I skipped the output in the example on Kang W51 because it's always changing.

I think it's ready for review

@ManonMarchand ManonMarchand marked this pull request as ready for review December 5, 2023 13:34
@bsipocz bsipocz added this to the v0.4.7 milestone Dec 7, 2023
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good, pending a very minor docstring formatting issue. I'll go ahead and commit that directly and go ahead with the merge.

Also, I noticed that there is a new failure with the remote tests which is apparently unrelated and is due to changes in astropy, so will open a PR with the fix.

astroquery/vizier/core.py Outdated Show resolved Hide resolved
astroquery/vizier/core.py Outdated Show resolved Hide resolved
@bsipocz bsipocz merged commit 885734b into astropy:main Dec 7, 2023
@bsipocz
Copy link
Member

bsipocz commented Dec 7, 2023

Thank you @ManonMarchand!

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

Successfully merging this pull request may close these issues.

3 participants