CadcClass

class astroquery.cadc.CadcClass(url=None, tap_plus_handler=None, verbose=None)[source]

Bases: astroquery.query.BaseQuery

Class for accessing CADC data. Typical usage:

result = Cadc.query_region(‘08h45m07.5s +54d18m00s’, collection=’CFHT’)

… do something with result (optional) such as filter as in example below

urls = Cadc.get_data_urls(result[result[‘target_name’]==’Nr3491_1’])

… access data

Other ways to query the CADC data storage:

  • target name:

    Cadc.query_region(SkyCoord.from_name(‘M31’))

  • target name in the metadata:

    Cadc.query_name(‘M31-A-6’) # queries as a like ‘%lower(name)%’

  • TAP query on the CADC metadata (CAOM2 format -

    http://www.opencadc.org/caom2/) Cadc.get_tables() # list the tables Cadc.get_table(table_name) # list table schema Cadc.query

Initialize Cadc object

Parameters
urlstr, optional, default ‘None;

a url to use instead of the default

tap_plus_handlerdeprecated
verbosedeprecated
Returns
Cadc object

Attributes Summary

CADCDATALINK_SERVICE_URI

CADCLOGIN_SERVICE_URI

CADCTAP_SERVICE_URI

CADC_REGISTRY_URL

TIMEOUT

cadctap

data_link_url

Methods Summary

create(*args, **kwargs)

Queries the service and returns a table object.

create_async(query[, maxrec, uploads])

Creates a TAP job to execute and returns it to the caller.

exec_sync(query[, maxrec, uploads, output_file])

Run a query and return the results or save them in a output_file

get_collections()

Query CADC for all the hosted collections

get_data_urls(query_result[, …])

Function to map the results of a CADC query into URLs to corresponding data that can be later downloaded.

get_table(table[, verbose])

Gets the specified table

get_tables([only_names, verbose])

Gets all public tables

list_async_jobs([verbose])

Returns all the asynchronous jobs

list_jobs(*args, **kwargs)

Queries the service and returns a table object.

load_async_job(jobid[, verbose])

Loads an asynchronous job

load_job(*args, **kwargs)

Queries the service and returns a table object.

login([user, password, certificate_file])

Login, set varibles to use for logging in

logout([verbose])

Logout

query_name(*args, **kwargs)

Queries the service and returns a table object.

query_name_async(name)

Query CADC metadata for a name and return the corresponding metadata in

query_region(*args, **kwargs)

Queries the service and returns a table object.

query_region_async(coordinates[, radius, …])

Queries the CADC for a region around the specified coordinates.

run_query(query, operation[, output_file, …])

Deprecated since version 0.4.0.

Attributes Documentation

CADCLOGIN_SERVICE_URI = 'ivo://cadc.nrc.ca/gms'
CADCTAP_SERVICE_URI = 'ivo://cadc.nrc.ca/tap'
CADC_REGISTRY_URL = 'http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/reg/resource-caps'
TIMEOUT = 30
cadctap

Methods Documentation

create(*args, **kwargs)

Queries the service and returns a table object.

Creates a TAP job to execute and returns it to the caller. The caller then can start the execution and monitor the job. Typical (no error handling) sequence of events:

job = create_async(query) job = job.run().wait() job.raise_if_error() result = job.fetch_result() job.delete() # optional

See pyvo.dal.tap for details about the AsyncTAPJob

Parameters
querystr, mandatory

SQL to execute

maxrecint

the maximum records to return. defaults to the service default

uploads:

Temporary tables to upload and run with the queries

output_file: str or file handler:

File to save the results to

Returns
tableA Table object.

Notes

Support for other output formats (tsv, csv) to be added as soon as they are available in pyvo.

create_async(query, maxrec=None, uploads=None)[source]

Creates a TAP job to execute and returns it to the caller. The caller then can start the execution and monitor the job. Typical (no error handling) sequence of events:

job = create_async(query) job = job.run().wait() job.raise_if_error() result = job.fetch_result() job.delete() # optional

See pyvo.dal.tap for details about the AsyncTAPJob

Parameters
querystr, mandatory

SQL to execute

maxrecint

the maximum records to return. defaults to the service default

uploads:

Temporary tables to upload and run with the queries

output_file: str or file handler:

File to save the results to

Returns
AsyncTAPJob

the query instance

Notes

Support for other output formats (tsv, csv) to be added as soon as they are available in pyvo.

exec_sync(query, maxrec=None, uploads=None, output_file=None)[source]

Run a query and return the results or save them in a output_file

Parameters
querystr, mandatory

SQL to execute

maxrecint

the maximum records to return. defaults to the service default

uploads:

Temporary tables to upload and run with the queries

output_file: str or file handler:

File to save the results to

Returns
Results of running the query in (for now) votable format

Notes

Support for other output formats (tsv, csv) to be added as soon as they are available in pyvo.

get_collections()[source]

Query CADC for all the hosted collections

Returns
A dictionary of collections hosted at the CADC where the key is the
collection and value represents details of that collection.
get_data_urls(query_result, include_auxiliaries=False)[source]

Function to map the results of a CADC query into URLs to corresponding data that can be later downloaded.

The function uses the IVOA DataLink Service (http://www.ivoa.net/documents/DataLink/) implemented at the CADC. It works directly with the results produced by query_region and query_name but in principle it can work with other query results produced with the Cadc query as long as the results contain the ‘publisherID’ column. This column is part of the ‘caom2.Plane’ table.

Parameters
query_resultA Table object

Result returned by query_region or query_name. In general, the result of any CADC TAP query that contains the ‘publisherID’ column can be use here.

include_auxiliariesboolean

True to return URLs to auxiliary files such as previews, False otherwise

Returns
A list of URLs to data.
get_table(table, verbose=None)[source]

Gets the specified table

Parameters
tablestr, mandatory

full qualified table name (i.e. schema name + table name)

verbosedeprecated
Returns
A table object
get_tables(only_names=False, verbose=None)[source]

Gets all public tables

Parameters
only_namesbool, optional, default False

True to load table names only

verbosedeprecated
Returns
A list of table objects
list_async_jobs(verbose=None)[source]

Returns all the asynchronous jobs

Parameters
verbosedeprecated
Returns
A list of Job objects
list_jobs(*args, **kwargs)

Queries the service and returns a table object.

Returns all the asynchronous jobs

Parameters
verbosedeprecated
Returns
tableA Table object.
load_async_job(jobid, verbose=None)[source]

Loads an asynchronous job

Parameters
jobidstr, mandatory

job identifier

verbosedeprecated
Returns
A Job object
load_job(*args, **kwargs)

Queries the service and returns a table object.

Loads an asynchronous job

Parameters
jobidstr, mandatory

job identifier

verbosedeprecated
Returns
tableA Table object.
login(user=None, password=None, certificate_file=None)[source]

Login, set varibles to use for logging in

Parameters
userstr, required if certificate is None

username to login with

passwordstr, required if user is set

password to login with

certificatestr, required if user is None

path to certificate to use with logging in

Notes

This will soon be deprecated as it does not make sense to login with certificates.

logout(verbose=None)[source]

Logout

Parameters
verbosedeprecated

Notes

This method will soon be deprecated as it doesn’t make sense to login and logout with certificates.

query_name(*args, **kwargs)

Queries the service and returns a table object.

Query CADC metadata for a name and return the corresponding metadata in

the CAOM2 format (http://www.opencadc.org/caom2/).

Parameters
name: str

name of object to query for

Returns
tableA Table object.
query_name_async(name)[source]
Query CADC metadata for a name and return the corresponding metadata in

the CAOM2 format (http://www.opencadc.org/caom2/).

Parameters
name: str

name of object to query for

Returns
responseTable

Results of the query in a tabular format.

query_region(*args, **kwargs)

Queries the service and returns a table object.

Queries the CADC for a region around the specified coordinates.

Parameters
coordinatesstr or astropy.coordinates.

coordinates around which to query

radiusstr or astropy.units.Quantity.

the radius of the cone search

collection: Name of the CADC collection to query, optional
get_query_payloadbool, optional

Just return the dict of HTTP request parameters.

Returns
tableA Table object.
query_region_async(coordinates, radius=0.016666666666667, collection=None, get_query_payload=False)[source]

Queries the CADC for a region around the specified coordinates.

Parameters
coordinatesstr or astropy.coordinates.

coordinates around which to query

radiusstr or astropy.units.Quantity.

the radius of the cone search

collection: Name of the CADC collection to query, optional
get_query_payloadbool, optional

Just return the dict of HTTP request parameters.

Returns
responserequests.Response

The HTTP response returned from the service. All async methods should return the raw HTTP response.

run_query(query, operation, output_file=None, output_format='votable', verbose=None, background=False, upload_resource=None, upload_table_name=None)[source]

Deprecated since version 0.4.0: Use exec_sync or create_async instead

Runs a query

Parameters
querystr, mandatory

query to be executed

operationstr, mandatory,

‘sync’ or ‘async’ to run a synchronous or asynchronous job

output_filestr, optional, default None

file name where the results are saved if dumpToFile is True. If this parameter is not provided, the jobid is used instead

output_formatstr, optional, default ‘votable’

results format, ‘csv’, ‘tsv’ and ‘votable’

verbosedeprecated
save_to_filebool, optional, default ‘False’

if True, the results are saved in a file instead of using memory

backgroundbool, optional, default ‘False’

when the job is executed in asynchronous mode, this flag specifies whether the execution will wait until results are available

upload_resource: str, optional, default None

resource to be uploaded to UPLOAD_SCHEMA

upload_table_name: str, required if uploadResource is provided,

default None resource temporary table name associated to the uploaded resource

Returns
A Job object