AlmaClass

class astroquery.alma.AlmaClass[source]

Bases: astroquery.query.QueryWithLogin

Attributes Summary

TIMEOUT
USERNAME
archive_url
cycle0_table Return a table of Cycle 0 Project IDs and associated UIDs.

Methods Summary

download_and_extract_files(urls[, delete, …]) Given a list of tarball URLs:
download_files(files[, savedir, cache, …]) Given a list of file URLs, download them
get_cycle0_uid_contents(uid) List the file contents of a UID from Cycle 0.
get_files_from_tarballs(downloaded_files[, …]) Given a list of successfully downloaded tarballs, extract files with names matching a specified regular expression.
help([cache]) Return the valid query parameters
login([username, store_password, …]) Login to the ALMA Science Portal.
query(*args, **kwargs) Queries the service and returns a table object.
query_async(payload[, cache, public, …]) Perform a generic query with user-specified payload
query_object(*args, **kwargs) Queries the service and returns a table object.
query_object_async(object_name[, cache, …]) Query the archive with a source name
query_region(*args, **kwargs) Queries the service and returns a table object.
query_region_async(coordinate, radius[, …]) Query the ALMA archive with a source name and radius
retrieve_data_from_uid(uids[, cache]) Stage & Download ALMA data.
stage_data(uids) Stage ALMA data
validate_query(payload[, cache]) Use the ALMA query validator service to check whether the keywords are valid

Attributes Documentation

TIMEOUT = 60
USERNAME = ''
archive_url = 'http://almascience.org'
cycle0_table

Return a table of Cycle 0 Project IDs and associated UIDs.

The table is distributed with astroquery and was provided by Felix Stoehr.

Methods Documentation

download_and_extract_files(urls, delete=True, regex='.*\\.fits$', include_asdm=False, path='cache_path', verbose=True)[source]

Given a list of tarball URLs:

  1. Download the tarball
  2. Extract all FITS files (or whatever matches the regex)
  3. Delete the downloaded tarball

See Alma.get_files_from_tarballs for details

Parameters:
urls : str or list

A single URL or a list of URLs

include_asdm : bool

Only affects cycle 1+ data. If set, the ASDM files will be downloaded in addition to the script and log files. By default, though, this file will be downloaded and deleted without extracting any information: you must change the regex if you want to extract data from an ASDM tarball

download_files(files, savedir=None, cache=True, continuation=True)[source]

Given a list of file URLs, download them

Note: Given a list with repeated URLs, each will only be downloaded once, so the return may have a different length than the input list

get_cycle0_uid_contents(uid)[source]

List the file contents of a UID from Cycle 0. Will raise an error if the UID is from cycle 1+, since those data have been released in a different and more consistent format. See http://almascience.org/documents-and-tools/cycle-2/ALMAQA2Productsv1.01.pdf for details.

get_files_from_tarballs(downloaded_files, regex='.*\\.fits$', path='cache_path', verbose=True)[source]

Given a list of successfully downloaded tarballs, extract files with names matching a specified regular expression. The default is to extract all FITS files

Parameters:
downloaded_files : list

A list of downloaded files. These should be paths on your local machine.

regex : str

A valid regular expression

path : ‘cache_path’ or str

If ‘cache_path’, will use the astroquery.Alma cache directory (Alma.cache_location), otherwise will use the specified path. Note that the subdirectory structure of the tarball will be maintained.

Returns:
filelist : list

A list of the extracted file locations on disk

help(cache=True)[source]

Return the valid query parameters

login(username=None, store_password=False, reenter_password=False)

Login to the ALMA Science Portal.

Parameters:
username : str, optional

Username to the ALMA Science Portal. If not given, it should be specified in the config file.

store_password : bool, optional

Stores the password securely in your keyring. Default is False.

reenter_password : bool, optional

Asks for the password even if it is already stored in the keyring. This is the way to overwrite an already stored passwork on the keyring. Default is False.

query(*args, **kwargs)

Queries the service and returns a table object.

Perform a generic query with user-specified payload

Parameters:
payload : dict

A dictionary of payload keywords that are accepted by the ALMA archive system. You can look these up by examining the forms at http://almascience.org/aq or using the help method

cache : bool

Cache the query? (note: HTML queries cannot be cached using the standard caching mechanism because the URLs are different each time

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

Returns:
table : A Table object.
query_async(payload, cache=True, public=True, science=True, max_retries=5, get_html_version=False, get_query_payload=False, **kwargs)[source]

Perform a generic query with user-specified payload

Parameters:
payload : dict

A dictionary of payload keywords that are accepted by the ALMA archive system. You can look these up by examining the forms at http://almascience.org/aq or using the help method

cache : bool

Cache the query? (note: HTML queries cannot be cached using the standard caching mechanism because the URLs are different each time

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

query_object(*args, **kwargs)

Queries the service and returns a table object.

Query the archive with a source name

Parameters:
object_name : str

The object name. Will be parsed by SESAME on the ALMA servers.

cache : bool

Cache the query?

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

payload : dict

Dictionary of additional keywords. See help.

kwargs : dict

Passed to query_async

Returns:
table : A Table object.
query_object_async(object_name, cache=True, public=True, science=True, payload=None, **kwargs)[source]

Query the archive with a source name

Parameters:
object_name : str

The object name. Will be parsed by SESAME on the ALMA servers.

cache : bool

Cache the query?

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

payload : dict

Dictionary of additional keywords. See help.

kwargs : dict

Passed to query_async

query_region(*args, **kwargs)

Queries the service and returns a table object.

Query the ALMA archive with a source name and radius

Parameters:
coordinates : str / astropy.coordinates

the identifier or coordinates around which to query.

radius : str / Quantity, optional

the radius of the region

cache : bool

Cache the query?

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

payload : dict

Dictionary of additional keywords. See help.

kwargs : dict

Passed to query_async

Returns:
table : A Table object.
query_region_async(coordinate, radius, cache=True, public=True, science=True, payload=None, **kwargs)[source]

Query the ALMA archive with a source name and radius

Parameters:
coordinates : str / astropy.coordinates

the identifier or coordinates around which to query.

radius : str / Quantity, optional

the radius of the region

cache : bool

Cache the query?

public : bool

Return only publicly available datasets?

science : bool

Return only data marked as “science” in the archive?

payload : dict

Dictionary of additional keywords. See help.

kwargs : dict

Passed to query_async

retrieve_data_from_uid(uids, cache=True)[source]

Stage & Download ALMA data. Will print out the expected file size before attempting the download.

Parameters:
uids : list or str

A list of valid UIDs or a single UID. UIDs should have the form: ‘uid://A002/X391d0b/X7b’

cache : bool

Whether to cache the downloads.

Returns:
downloaded_files : list

A list of the downloaded file paths

stage_data(uids)[source]

Stage ALMA data

Parameters:
uids : list or str

A list of valid UIDs or a single UID. UIDs should have the form: ‘uid://A002/X391d0b/X7b’

Returns:
data_file_table : Table

A table containing 3 columns: the UID, the file URL (for future downloading), and the file size

validate_query(payload, cache=True)[source]

Use the ALMA query validator service to check whether the keywords are valid