CINXE.COM
A new access to SIMBAD TAP in astroquery
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>A new access to SIMBAD TAP in astroquery</title> <meta name="keywords" content="CDS, astronomy data center, centre de donnees astronomiques, astronomy, astronomie, Strasbourg,python, tap, simbad, astroquery" /> <meta name="cds:date" content="2024-12-01T05:04:01+0100" data-pagefind-meta="date[content]" data-pagefind-sort="desc" /> <meta name="cds:tag" content="python" data-pagefind-filter="tag[content]" data-pagefind-meta="tags[content]" /> <meta name="cds:tag" content="tap" data-pagefind-filter="tag[content]" data-pagefind-meta="tags[content]" /> <meta name="cds:tag" content="simbad" data-pagefind-filter="tag[content]" data-pagefind-meta="tags[content]" /> <meta name="cds:tag" content="astroquery" data-pagefind-filter="tag[content]" data-pagefind-meta="tags[content]" /> <meta name="cds:service" content="simbad" data-pagefind-filter="service[content]" data-pagefind-meta="services[content]" /><meta name="cds:section" content="news" data-pagefind-filter="section[content]" data-pagefind-meta="section[content]" /> <link rel="canonical" href="https://cds.unistra.fr/fr/news/2024/04/05-access-simbad-tap-from-astroquery/" /> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:image" content="https://cds.unistra.fr/img/misc/cds.png"> <meta name="twitter:title" content="A new access to SIMBAD TAP in astroquery"> <meta name="twitter:description" content="The latest version of the python library astroquery (v0.4.7) ships a new access to SIMBAD TAP. The detailed documentation is on astroquery's page, but here is a quick preview of some of the new functionalities:"> <link rel="alternate" hreflang="fr" href="https://cds.unistra.fr/fr/news/2024/04/05-access-simbad-tap-from-astroquery/" /> <link rel="alternate" hreflang="en" href="https://cds.unistra.fr/news/2024/04/05-access-simbad-tap-from-astroquery/" /> <link rel="alternate" hreflang="x-default" href="https://cds.unistra.fr/news/2024/04/05-access-simbad-tap-from-astroquery/" /> <!-- Include the CSS stylesheet for the CDS navbar and footer: --> <link href="/cds-navbar-resources/css/cdsnavbar.min.css" rel="stylesheet"> <!-- Include OpenSearch engines for CDS services: --> <link title="SIMBAD" rel="search" type="application/opensearchdescription+xml" href="/cds-navbar-resources/opensearch/simbad.xml"> <link title="VizieR" rel="search" type="application/opensearchdescription+xml" href="/cds-navbar-resources/opensearch/vizier.xml"> <link title="Aladin" rel="search" type="application/opensearchdescription+xml" href="/cds-navbar-resources/opensearch/aladin.xml"> <link title="XMatch" rel="search" type="application/opensearchdescription+xml" href="/cds-navbar-resources/opensearch/xmatch.xml"> <link rel="stylesheet" href="https://cds.unistra.fr/css/cds.min.css"> <link rel="preload" fetchpriority="high" as="image" href="https://cds.unistra.fr/img/title/fond_HD74319.webp" type="image/webp"> <link rel="apple-touch-icon" sizes="180x180" href="https://cds.unistra.fr/favicon/apple-touch-icon.png?v=2022"> <link rel="icon" type="image/png" sizes="32x32" href="https://cds.unistra.fr/favicon/favicon-32x32.png?v=2022"> <link rel="icon" type="image/png" sizes="16x16" href="https://cds.unistra.fr/favicon/favicon-16x16.png?v=2022"> <link rel="manifest" href="https://cds.unistra.fr/favicon/site.webmanifest?v=2022"> <link rel="mask-icon" href="https://cds.unistra.fr/favicon/safari-pinned-tab.svg?v=2022" color="#2d89ef"> <link rel="shortcut icon" href="https://cds.unistra.fr/favicon.ico?v=2022"> <meta name="apple-mobile-web-app-title" content="CDS Website"> <meta name="application-name" content="CDS Website"> <meta name="msapplication-TileColor" content="#2d89ef"> <meta name="theme-color" content="#ffffff"> </head> <body> <div class="void-wrapper for-menu" data-pagefind-ignore> <!-- -- ####################################################################### -- # # -- # CDS TOP NAVIGATION BAR # -- # # -- ####################################################################### --> <nav class="cds-menu for-cds" role="menubar" aria-label="CDS services navigation" data-pagefind-ignore> <!-- HEADER: CDS WEBSITE LINK --> <header><a href="https://cds.unistra.fr" role="menuitem" aria-label="CDS website"></a></header> <!-- MENU CONTENT --> <ul role="menu" aria-label="CDS services"> <!-- List of all services (collapsed on very small screens) --> <li class="is-collapsed-when-very-small" role="none"> <!-- Trigger for showing the menu on very small screens --> <span class="menu-trigger for-all-services" tabindex="0" onclick="void(0)" role="menuitem" aria-label="List CDS services and more" aria-haspopup="true" aria-expanded="false"><span>Services</span></span> <!-- CDS main services --> <ul role="menu" aria-label="CDS main services"> <li role="none"><a class="portal" href="http://cdsportal.u-strasbg.fr" role="menuitem" aria-label="CDS Portal"><span></span></a></li> <li role="none"><a class="simbad" href="http://simbad.cds.unistra.fr/simbad" role="menuitem" aria-label="Simbad"><span></span></a></li> <li role="none"><a class="vizier" href="https://vizier.cds.unistra.fr/viz-bin/VizieR" role="menuitem" aria-label="VizieR"><span></span></a></li> <li role="none"><a class="aladin" href="http://aladin.cds.unistra.fr/aladin.gml" role="menuitem" aria-label="Aladin"><span></span></a></li> <li role="none"><a class="xmatch" href="http://cdsxmatch.u-strasbg.fr" role="menuitem" aria-label="X-Match"><span></span></a></li> <!-- SUB-MENU: Other CDS services --> <li role="none"> <!-- Trigger for showing the sub-menu --> <a class="menu-trigger for-other-services" tabindex="0" onclick="void(0)" role="menuitem" aria-label="Other resources" aria-haspopup="true">Others</a> <!-- Sub-menu itself --> <ul role="menu" aria-label="Other resources"> <li role="none"><a href="https://cds.unistra.fr/cgi-bin/Sesame" role="menuitem" aria-label="Sesame name resolver">Sesame name resolver</a></li> <li role="none"><a href="https://cds.unistra.fr/cgi-bin/Dic-Simbad" role="menuitem" aria-label="Dictionary of nomenclature">Dictionary of nomenclature</a></li> <li role="separator" class="divider" aria-hidden="true"></li> <!-- Link: email CDS-Question--> <li role="none"><a href="mailto:cds-question@unistra.fr" tabindex="0" role="menuitem" aria-label="Contact us">Contact us</a></li> </ul> </li> </ul> </li> <!-- Link: CDS help resources --> <li role="none"><a class="help" href="https://cds.unistra.fr/help" role="menuitem" aria-label="Help resources"><span>Help</span></a></li> </ul> </nav> <div class="cdsPageTitle"><h1></h1></div> </div> <header data-pagefind-body> <input type="checkbox" id="mainMenuOpener"> <label for="mainMenuOpener"><span></span></label> <nav class="sitenavbar" aria-label="CDS Website navigation" data-pagefind-ignore> <ul> <li class="home-shortcut" title="Page principale"><a href="https://cds.unistra.fr/fr/"></a></li> <li class="parent"> <a href="https://cds.unistra.fr/fr/about">脌 propos</a> <ul> <li><a href="https://cds.unistra.fr/fr/about/cds">CDS</a></li> <li><a href="https://cds.unistra.fr/fr/about/cts">CoreTrustSeal</a></li> <li><a href="https://cds.unistra.fr/fr/about/partners">Partenaires</a></li> <li><a href="https://cds.unistra.fr/fr/about/projects">Projets</a></li> <li><a href="https://cds.unistra.fr/fr/about/staff">Personnel</a></li> <li><a href="https://cds.unistra.fr/fr/about/contact">Contact</a></li> </ul> </li> <li> <a href="https://cds.unistra.fr/fr/data-publication">Publication de donn茅es</a> </li> <li class="parent"> <a href="https://cds.unistra.fr/fr/data-access">Acc猫s aux donn茅es</a> <ul> <li><a href="https://cds.unistra.fr/fr/data-access/services">Services</a></li> <li><a href="https://cds.unistra.fr/fr/data-access/tools">Outils</a></li> </ul> </li> <li class="parent"> <a class="active" href="https://cds.unistra.fr/fr/news">Actualit茅s</a> <ul> <li><a class="active" href="https://cds.unistra.fr/fr/news">Actualit茅s</a></li> <li><a href="https://cds.unistra.fr/fr/blog">Blog</a></li> <li><a href="https://cds.unistra.fr/fr/events">脡v茅nements</a></li> </ul> </li> <li class="parent"> <a href="https://cds.unistra.fr/fr/help">Aide</a> <ul> <li><a href="https://cds.unistra.fr/fr/help/acknowledgement">Citation</a></li> <li><a href="https://cds.unistra.fr/fr/help/documentation">Documentation des services</a></li> <li><a href="https://cds.unistra.fr/fr/help/tutorials">Tutoriels</a></li> <li><a href="https://cds.unistra.fr/fr/help/faq">FAQ</a></li> <li><a href="https://cds.unistra.fr/fr/help/communication">Communication</a></li> <li><a class="internal" href="http://cloud-wiki.u-strasbg.fr/twiki/bin/view/">Wiki (interne)</a></li> </ul> </li> <li class="search-trigger" title="Rechercher dans les pages du CDS"></li> </ul> </nav> <div class="translations" role="menu" aria-label="Language selector" data-pagefind-ignore> <span class="active" tabindex="0" role="menuitem" aria-label="Current language isFran莽ais" aria-haspopup="true">Fran莽ais</span> <ul role="menu"> <li aria-hidden="true"><a href="https://cds.unistra.fr/news/2024/04/05-access-simbad-tap-from-astroquery/" role="menuitem" aria-label="Switch toEnglish">English</a></li> </ul> </div> <h1 aria-label="Page title"> A new access to SIMBAD TAP in astroquery </h1> </header> <div class="search-container" data-pagefind-ignore> <div class="modal-background"></div> <div class="search-form"> <input type="text" placeholder="Mots 脿 chercher..." /> </div> <div class="search-result hidden"> <div class="message">D茅sol茅 ! Aucune page trouv茅e avec les mots <code class="terms"></code></div> <div class="filters"></div> <ul class="results"></ul> </div> </div> <div class=" main-wrapper" > <main data-pagefind-body> <div class="pageDates"> <strong>Cr茅ation:</strong> <span title="April 05, 2024 - 10:32 UTC">April 05, 2024 - 12:32 CEST</span> <br/> <strong>Modification:</strong> <span title="December 01, 2024 - 04:04 UTC">December 01, 2024 - 05:04 CET</span> </div> <p>The latest version of the python library <a href="https://astroquery.readthedocs.io/en/latest/"target="_blank" rel="noopener">astroquery</a> (v0.4.7) ships a new access to SIMBAD TAP.</p> <p>The detailed documentation is on <a href="https://astroquery.readthedocs.io/en/latest/simbad/simbad.html#query-tap"target="_blank" rel="noopener">astroquery's page</a>, but here is a quick preview of some of the new functionalities:</p> <h2 id="simple-simbad-tap-access">Simple SIMBAD TAP access <a href="#simple-simbad-tap-access" class="quick-link" title="Quick link on this section."></a></h2><p>You can now call <code>query_tap</code> directly. Let's, for example, look for stars in 5 degrees around M13 where SIMBAD references a flux in the U band:</p> <div class="highlight"><pre tabindex="0" style=";-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#008000;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">astroquery.simbad</span> <span style="color:#008000;font-weight:bold">import</span> Simbad </span></span><span style="display:flex;"><span><span style="color:#008000;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">astropy.coordinates</span> <span style="color:#008000;font-weight:bold">import</span> SkyCoord </span></span><span style="display:flex;"><span><span style="color:#408080;font-style:italic"># first, we call sesame to find M13 coordinates</span> </span></span><span style="display:flex;"><span>m13 <span style="color:#666">=</span> SkyCoord<span style="color:#666">.</span>from_name(<span style="color:#ba2121">"M13"</span>) </span></span><span style="display:flex;"><span><span style="color:#408080;font-style:italic"># then we create an ADQL query</span> </span></span><span style="display:flex;"><span>adql <span style="color:#666">=</span> <span style="color:#ba2121">rf</span><span style="color:#ba2121">"""SELECT main_id, otype, flux, filter, bibcode AS flux_reference </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">-- join the tables "basic" and "flux" </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">FROM flux JOIN basic ON oidref = oid </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">-- take the filter 'U' </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">WHERE filter = 'U' </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">-- select any object which main type descends from Star </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">AND otype = 'Star..' </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">-- and add the coordinates condition </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">AND CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', </span><span style="color:#b68;font-weight:bold">{</span>m13<span style="color:#666">.</span>ra<span style="color:#666">.</span>deg<span style="color:#b68;font-weight:bold">}</span><span style="color:#ba2121">, </span><span style="color:#b68;font-weight:bold">{</span>m13<span style="color:#666">.</span>dec<span style="color:#666">.</span>deg<span style="color:#b68;font-weight:bold">}</span><span style="color:#ba2121">, 5)) = 1 </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">"""</span> </span></span><span style="display:flex;"><span>Simbad<span style="color:#666">.</span>query_tap(adql) </span></span></code></pre></div><pre tabindex="0"><code><Table length=58> main_id otype flux filter flux_reference object object float32 object object ----------------------- ------ ------- ------ ------------------- HD 151428 ** 7.85 U 1986A&AS...65..405O LSPM J1639+4124E PM* 16.13 U 2005MNRAS.358..333G GD 358 WD* 12.511 U 2013AJ....146..131L UCAC4 625-052116 * 18.075 U 2013AJ....146..131L UCAC4 613-056337 * 15.186 U 2013AJ....146..131L * nu.02 CrB PM* 8.8 U 2002yCat.2237....0D ... ... ... ... ... 2MASS J16342453+4059547 PM* 15.11 U 2005MNRAS.358..333G 2MASS J16382119+4122543 PM* 15.05 U 2005MNRAS.358..333G TYC 3066-2095-1 * 13.43 U 2005MNRAS.358..333G TYC 3074-1095-1 * 13.22 U 2005MNRAS.358..333G V* HZ Her LXB 11.9 U 2007A&A...469..807L PG 1636+351 WD* 13.585 U 2013AJ....146..131L </code></pre><h2 id="mix-your-own-tables-in-the-query">Mix your own tables in the query <a href="#mix-your-own-tables-in-the-query" class="quick-link" title="Quick link on this section."></a></h2><p>This new method also provides an easy way to join your own table(s) with Simbad tables within an ADQL query (this is like the <code>upload table</code> functionality on the SIMBAD TAP webpage):</p> <div class="highlight"><pre tabindex="0" style=";-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#008000;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">astroquery.simbad</span> <span style="color:#008000;font-weight:bold">import</span> Simbad </span></span><span style="display:flex;"><span><span style="color:#008000;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">astropy.table</span> <span style="color:#008000;font-weight:bold">import</span> Table </span></span><span style="display:flex;"><span>list_of_objects <span style="color:#666">=</span> Table([[<span style="color:#ba2121">"M1"</span>, <span style="color:#ba2121">"M2"</span>, <span style="color:#ba2121">"M3"</span>]], names<span style="color:#666">=</span>[<span style="color:#ba2121">"messier_id"</span>]) </span></span><span style="display:flex;"><span>adql <span style="color:#666">=</span> <span style="color:#ba2121">"""SELECT main_id, messier_id, ra, dec, otype FROM basic </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">JOIN messiers </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">ON basic.main_id = messiers.messier_id </span></span></span><span style="display:flex;"><span><span style="color:#ba2121">"""</span> </span></span><span style="display:flex;"><span>Simbad<span style="color:#666">.</span>query_tap(adql, messiers<span style="color:#666">=</span>list_of_objects) </span></span></code></pre></div><pre tabindex="0"><code><Table length=3> main_id messier_id ra dec otype deg deg object object float64 float64 object ------- ---------- ------------------ ------------------- ------ M 1 M1 83.6287 22.0147 SNR M 2 M2 323.36258333333336 -0.8232499999999998 GlC M 3 M3 205.5484166666666 28.37727777777778 GlC </code></pre><p>Note that we created an astropy Table from scratch so that the example would be self-contained, but you can also do this with a table read from any file format that astropy understands.</p> <p>If you have any feedback, don't hesitate to contact us!</p> <div class="paginate" data-pagefind-ignore><a class="prev-page" href="https://cds.unistra.fr/fr/news/2024/06/20-service-outage/"><i class="icon-arrow-right"></i> <small>Service outage</small></a><a class="top-page" href="https://cds.unistra.fr/fr/news/">Sommaire</a><a class="next-page" href="https://cds.unistra.fr/fr/news/2024/03/28-easter-egg-hunt/"><small>Easter Egg Hunt</small> <i class="icon-arrow-left"></i></a> </div> </main> </div> <div class="void-wrapper for-footer" data-pagefind-ignore> <!-- -- ####################################################################### -- # # -- # CDS FOOTER # -- # # -- ####################################################################### --> <footer class="cds-footer for-cds" data-pagefind-ignore> <div class="cds"> <!-- CDS Logo and link --> <a class="cds logo" href="https://cds.unistra.fr" title="CDS - Centre de Donn茅es astronomiques de Strasbourg" target="_blank"></a> <!-- Social networks links --> <div class="socials"> <a class="email" title="Send an email to the CDS team." href="mailto:cds-question@unistra.fr?Subject=CDS"></a> <a class="rss" title="RSS Feed of the CDS news" href="https://cds.unistra.fr/news/rss.php" target="_blank" rel="noopener noreferrer"></a> <a class="facebook" title="CDS' Facebook page." href="https://www.facebook.com/CDSportal/" target="_blank" rel="noopener noreferrer"></a> <a class="youtube" title="CDS' Youtube channel." href="https://www.youtube.com/@CDSportal" target="_blank" rel="noopener noreferrer"></a> <a class="github" title="CDS' GitHub page." href="https://github.com/cds-astro" target="_blank" rel="noopener noreferrer"></a> </div> </div> <div class="service"> <div class="content"> <a class="logo affiliation cnrs" href="https://www.cnrs.fr/en" title="CNRS - Centre National de la Recherche Scientifique" target="_blank"></a><a class="logo affiliation unistra" href="https://www.unistra.fr/" title="Unistra - Universit茅 de Strasbourg" target="_blank"></a><a class="logo affiliation obas" href="https://astro.unistra.fr" title="Observatoire astronomique de Strasbourg" target="_blank"></a> </div> </div> <div class="legal-links"> <a href="https://cds.unistra.fr/about/contact/">Contact</a> - <a href="https://cds.unistra.fr/legals/">Legals</a> </div> </footer> </div> <script type="text/javascript" src="https://cds.unistra.fr/js/cds-general.min.js"></script> </body> </html>