astrobase.services.simbad module

This queries the SIMBAD database using their TAP interface. The main use for this is to serve as a reverse name resolver (i.e. get all object names using a narrow cone-search).

For a more general and useful interface to SIMBAD, see the astroquery package by A. Ginsburg, B. Sipocz, et al.:

http://astroquery.readthedocs.io

astrobase.services.simbad.tap_query(querystr, simbad_mirror='simbad', returnformat='csv', forcefetch=False, cachedir='~/.astrobase/simbad-cache', verbose=True, timeout=10.0, refresh=2.0, maxtimeout=90.0, maxtries=3, complete_query_later=False, jitter=5.0)[source]

This queries the SIMBAD TAP service using the ADQL query string provided.

Parameters:
  • querystr (str) – This is the ADQL query string. See: http://www.ivoa.net/documents/ADQL/2.0 for the specification.
  • simbad_mirror (str) – This is the key used to select a SIMBAD mirror from the SIMBAD_URLS dict above. If set, the specified mirror will be used. If None, a random mirror chosen from that dict will be used.
  • returnformat ({'csv','votable','json'}) – The returned file format to request from the GAIA catalog service.
  • forcefetch (bool) – If this is True, the query will be retried even if cached results for it exist.
  • cachedir (str) – This points to the directory where results will be downloaded.
  • verbose (bool) – If True, will indicate progress and warn of any issues.
  • timeout (float) – This sets the amount of time in seconds to wait for the service to respond to our initial request.
  • refresh (float) – This sets the amount of time in seconds to wait before checking if the result file is available. If the results file isn’t available after refresh seconds have elapsed, the function will wait for refresh seconds continuously, until maxtimeout is reached or the results file becomes available.
  • maxtimeout (float) – The maximum amount of time in seconds to wait for a result to become available after submitting our query request.
  • maxtries (int) – The maximum number of tries (across all mirrors tried) to make to either submit the request or download the results, before giving up.
  • complete_query_later (bool) – If set to True, a submitted query that does not return a result before maxtimeout has passed will be cancelled but its input request parameters and the result URL provided by the service will be saved. If this function is then called later with these same input request parameters, it will check if the query finally finished and a result is available. If so, will download the results instead of submitting a new query. If it’s not done yet, will start waiting for results again. To force launch a new query with the same request parameters, set the forcefetch kwarg to True.
  • jitter (float) – This is used to control the scale of the random wait in seconds before starting the query. Useful in parallelized situations.
Returns:

This returns a dict of the following form:

{'params':dict of the input params used for the query,
 'provenance':'cache' or 'new download',
 'result':path to the file on disk with the downloaded data table}

Return type:

dict

astrobase.services.simbad.objectnames_conesearch(racenter, declcenter, searchradiusarcsec, simbad_mirror='simbad', returnformat='csv', forcefetch=False, cachedir='~/.astrobase/simbad-cache', verbose=True, timeout=10.0, refresh=2.0, maxtimeout=90.0, maxtries=1, complete_query_later=True)[source]

This queries the SIMBAD TAP service for a list of object names near the coords. This is effectively a “reverse” name resolver (i.e. this does the opposite of SESAME).

Parameters:
  • racenter,declcenter (float) – The cone-search center coordinates in decimal degrees
  • searchradiusarcsec (float) – The radius in arcseconds to search around the center coordinates.
  • simbad_mirror (str) – This is the key used to select a SIMBAD mirror from the SIMBAD_URLS dict above. If set, the specified mirror will be used. If None, a random mirror chosen from that dict will be used.
  • returnformat ({'csv','votable','json'}) – The returned file format to request from the GAIA catalog service.
  • forcefetch (bool) – If this is True, the query will be retried even if cached results for it exist.
  • cachedir (str) – This points to the directory where results will be downloaded.
  • verbose (bool) – If True, will indicate progress and warn of any issues.
  • timeout (float) – This sets the amount of time in seconds to wait for the service to respond to our initial request.
  • refresh (float) – This sets the amount of time in seconds to wait before checking if the result file is available. If the results file isn’t available after refresh seconds have elapsed, the function will wait for refresh seconds continuously, until maxtimeout is reached or the results file becomes available.
  • maxtimeout (float) – The maximum amount of time in seconds to wait for a result to become available after submitting our query request.
  • maxtries (int) – The maximum number of tries (across all mirrors tried) to make to either submit the request or download the results, before giving up.
  • complete_query_later (bool) – If set to True, a submitted query that does not return a result before maxtimeout has passed will be cancelled but its input request parameters and the result URL provided by the service will be saved. If this function is then called later with these same input request parameters, it will check if the query finally finished and a result is available. If so, will download the results instead of submitting a new query. If it’s not done yet, will start waiting for results again. To force launch a new query with the same request parameters, set the forcefetch kwarg to True.
Returns:

This returns a dict of the following form:

{'params':dict of the input params used for the query,
 'provenance':'cache' or 'new download',
 'result':path to the file on disk with the downloaded data table}

Return type:

dict