AlmaClass

class astroquery.alma.AlmaClass[source]

Bases: QueryWithLogin

Attributes Summary

SIA2_PARAMETERS_DESC

TIMEOUT

USERNAME

archive_url

auth

cycle0_table

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

datalink

datalink_url

sia

sia_url

tap

tap_url

var

Methods Summary

download_and_extract_files(urls, *[, ...])

Given a list of tarball URLs, it extracts all the FITS files (or whatever matches the regex)

download_files(files, *[, savedir, cache, ...])

Given a list of file URLs, download them

get_adhoc_service_access_url(adhoc_service)

get_adhoc_service_parameter(adhoc_service, ...)

get_cycle0_uid_contents(uid)

List the file contents of a UID from Cycle 0.

get_data_info(uids, *[, expand_tarfiles, ...])

Return information about the data associated with ALMA uid(s)

get_files_from_tarballs(downloaded_files, *)

Given a list of successfully downloaded tarballs, extract files with names matching a specified regular expression.

get_project_metadata(projectid, *[, cache])

Get the metadata - specifically, the project abstract - for a given project ID.

help([cache])

Return the valid query parameters

help_tap()

is_datalink_adhoc_service(adhoc_service)

is_proprietary(uid)

Given an ALMA UID, query the servers to determine whether it is proprietary or not.

login([username, store_password, ...])

Login to the ALMA Science Portal.

query(*args, **kwargs)

Queries the service and returns a table object.

query_async(payload, *[, public, science, ...])

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, *[, public, ...])

Query the archive for 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

query_sia(*[, pos, band, time, pol, ...])

Use standard SIA2 attributes to query the ALMA SIA service.

query_tap(query[, maxrec])

Send query to the ALMA TAP.

retrieve_data_from_uid(uids, *[, cache])

Stage & Download ALMA data.

Attributes Documentation

SIA2_PARAMETERS_DESC = "\npos : single or list of tuples\n    angle units (default: deg)\n    the positional region(s) to be searched for data. Each region can\n    be expressed as a tuple representing a CIRCLE, RANGE or POLYGON as\n    follows:\n    (ra, dec, radius) - for CIRCLE. (angle units - defaults to)\n    (long1, long2, lat1, lat2) - for RANGE (angle units required)\n    (ra, dec, ra, dec, ra, dec ... ) ra/dec points for POLYGON all\n    in angle units\nband : scalar, tuple(interval) or list of tuples\n    (spectral units (default: meter)\n    the energy interval(s) to be searched for data.\ntime : single or list of `~astropy.time.Time` or compatible strings\n    the time interval(s) to be searched for data.\npol : single or list of str from pyvo.dam.obscore.POLARIZATION_STATES\n    the polarization state(s) to be searched for data.\nfield_of_view : single or list of tuples\n    angle units (default arcsec)\n    the range(s) of field of view (size) to be searched for data\nspatial_resolution : single or list of tuples\n    angle units required\n    the range(s) of spatial resolution to be searched for data\nspectral_resolving_power : single or list of tuples\n    the range(s) of spectral resolving power to be searched for data\nexptime : single or list of tuples\n    time units (default: second)\n    the range(s) of exposure times to be searched for data\ntimeres : single of list of tuples\n    time units (default: second)\n    the range(s) of temporal resolution to be searched for data\npublisher_did : single or list of str\n    specifies the unique identifier of dataset(s). It is global because\n    it must include information regarding the publisher\n    (obs_publisher_did in ObsCore)\ncollection : single or list of str\n    name of the collection that the data belongs to\nfacility : single or list of str\n    specifies the name of the facility (usually telescope) where\n    the data was acquired.\ninstrument : single or list of str\n    specifies the name of the instrument with which the data was\n    acquired.\ndata_type : 'image'|'cube'\n    specifies the type of the data\ncalib_level : single or list from enum\n    pyvo.dam.obscore.CALIBRATION_LEVELS\n    specifies the calibration level of the data. Can be a single value\n    or a list of values\ntarget_name : single or list of str\n    specifies the name of the target (e.g. the intention of the\n    original science program or observation)\nres_format : single or list of strings\n    specifies response format(s).\nmax_records : int\n    allows the client to limit the number or records in the response\n**kwargs : custom query parameters\n    single or a list of values (or tuples for intervals) custom query\n    parameters that a specific service accepts. The values of the\n    parameters need to follow the SIA2 format and represent the\n    appropriate quantities (where applicable).\n"
TIMEOUT = 60
USERNAME = ''
archive_url = 'https://almascience.org'
auth
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.

sia
sia_url
tap
tap_url
var = 'CALIBRATION_LEVELS'

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, it extracts all the FITS files (or whatever matches the regex)

Parameters:
urlsstr or list

A single URL or a list of URLs

include_asdmbool

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, skip_unauthorized=True, verify_only=False)[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

Parameters:
fileslist

List of URLs to download

savedirNone or str

The directory to save to. Default is the cache location.

cachebool

Cache the download?

continuationbool

Attempt to continue where the download left off (if it was broken)

skip_unauthorizedbool

If you receive “unauthorized” responses for some of the download requests, skip over them. If this is False, an exception will be raised.

verify_onlybool

Option to go through the process of checking the files to see if they’re the right size, but not actually download them. This option may be useful if a previous download run failed partway.

get_adhoc_service_access_url(adhoc_service)[source]
get_adhoc_service_parameter(adhoc_service, parameter_id)[source]
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 https://almascience.org/documents-and-tools/cycle-2/ALMAQA2Productsv1.01.pdf for details.

get_data_info(uids, *, expand_tarfiles=False, with_auxiliary=True, with_rawdata=True)[source]

Return information about the data associated with ALMA uid(s)

Parameters:
uidslist or str

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

expand_tarfilesbool

False to return information on the tarfiles packages containing the data or True to return information about individual files in these packages

with_auxiliarybool

True to include the auxiliary packages, False otherwise

with_rawdatabool

True to include raw data, False otherwise

Returns:
Table with results or None. Table has the following columns: id (UID),
access_url (URL to access data), service_def, content_length, content_type (MIME
type), semantics, description (optional), error_message (optional)
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

NOTE: alma now supports direct listing and downloads of tarballs. See get_data_info and download_and_extract_files

Parameters:
downloaded_fileslist

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

regexstr

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:
filelistlist

A list of the extracted file locations on disk

get_project_metadata(projectid, *, cache=True)[source]

Get the metadata - specifically, the project abstract - for a given project ID.

help(cache=True)[source]

Return the valid query parameters

help_tap()[source]
is_proprietary(uid)[source]

Given an ALMA UID, query the servers to determine whether it is proprietary or not.

login(username=None, store_password=False, reenter_password=False, auth_urls=['asa.alma.cl', 'rh-cas.alma.cl'])

Login to the ALMA Science Portal.

Parameters:
usernamestr, optional

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

store_passwordbool, optional

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

reenter_passwordbool, 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:
payloaddictionary

Please consult the help method

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

legacy_columnsbool

True to return the columns from the obsolete ALMA advanced query, otherwise return the current columns based on ObsCore model.

get_query_payloadbool

Flag to indicate whether to simply return the payload.

maxrecinteger

Cap on the amount of records returned. Default is no limit.

Table with results. Columns are those in the ALMA ObsCore model
(see ``help_tap``) unless ``legacy_columns`` argument is set to True.
Returns:
tableA Table object.
query_async(payload, *, public=True, science=True, legacy_columns=False, get_query_payload=False, maxrec=None, **kwargs)[source]

Perform a generic query with user-specified payload

Parameters:
payloaddictionary

Please consult the help method

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

legacy_columnsbool

True to return the columns from the obsolete ALMA advanced query, otherwise return the current columns based on ObsCore model.

get_query_payloadbool

Flag to indicate whether to simply return the payload.

maxrecinteger

Cap on the amount of records returned. Default is no limit.

Returns:
Table with results. Columns are those in the ALMA ObsCore model
(see help_tap) unless legacy_columns argument is set to True.
query_object(*args, **kwargs)

Queries the service and returns a table object.

Query the archive for a source name.

Parameters:
object_namestr

The object name. Will be resolved by astropy.coord.SkyCoord

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

payloaddict

Dictionary of additional keywords. See help.

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

Query the archive for a source name.

Parameters:
object_namestr

The object name. Will be resolved by astropy.coord.SkyCoord

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

payloaddict

Dictionary of additional keywords. See help.

query_region(*args, **kwargs)

Queries the service and returns a table object.

Query the ALMA archive with a source name and radius

Parameters:
coordinatesstr / astropy.coordinates

the identifier or coordinates around which to query.

radiusstr / Quantity, optional

the radius of the region

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

payloaddict

Dictionary of additional keywords. See help.

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

Query the ALMA archive with a source name and radius

Parameters:
coordinatesstr / astropy.coordinates

the identifier or coordinates around which to query.

radiusstr / Quantity, optional

the radius of the region

publicbool

True to return only public datasets, False to return private only, None to return both

sciencebool

True to return only science datasets, False to return only calibration, None to return both

payloaddict

Dictionary of additional keywords. See help.

query_sia(*, pos=None, band=None, time=None, pol=None, field_of_view=None, spatial_resolution=None, spectral_resolving_power=None, exptime=None, timeres=None, publisher_did=None, facility=None, collection=None, instrument=None, data_type=None, calib_level=None, target_name=None, res_format=None, maxrec=None, **kwargs)[source]

Use standard SIA2 attributes to query the ALMA SIA service.

Parameters:
possingle or list of tuples

angle units (default: deg) the positional region(s) to be searched for data. Each region can be expressed as a tuple representing a CIRCLE, RANGE or POLYGON as follows: (ra, dec, radius) - for CIRCLE. (angle units - defaults to) (long1, long2, lat1, lat2) - for RANGE (angle units required) (ra, dec, ra, dec, ra, dec … ) ra/dec points for POLYGON all in angle units

bandscalar, tuple(interval) or list of tuples

(spectral units (default: meter) the energy interval(s) to be searched for data.

timesingle or list of Time or compatible strings

the time interval(s) to be searched for data.

polsingle or list of str from pyvo.dam.obscore.POLARIZATION_STATES

the polarization state(s) to be searched for data.

field_of_viewsingle or list of tuples

angle units (default arcsec) the range(s) of field of view (size) to be searched for data

spatial_resolutionsingle or list of tuples

angle units required the range(s) of spatial resolution to be searched for data

spectral_resolving_powersingle or list of tuples

the range(s) of spectral resolving power to be searched for data

exptimesingle or list of tuples

time units (default: second) the range(s) of exposure times to be searched for data

timeressingle of list of tuples

time units (default: second) the range(s) of temporal resolution to be searched for data

publisher_didsingle or list of str

specifies the unique identifier of dataset(s). It is global because it must include information regarding the publisher (obs_publisher_did in ObsCore)

collectionsingle or list of str

name of the collection that the data belongs to

facilitysingle or list of str

specifies the name of the facility (usually telescope) where the data was acquired.

instrumentsingle or list of str

specifies the name of the instrument with which the data was acquired.

data_type‘image’|’cube’

specifies the type of the data

calib_levelsingle or list from enum

pyvo.dam.obscore.CALIBRATION_LEVELS specifies the calibration level of the data. Can be a single value or a list of values

target_namesingle or list of str

specifies the name of the target (e.g. the intention of the original science program or observation)

res_formatsingle or list of strings

specifies response format(s).

max_recordsint

allows the client to limit the number or records in the response

**kwargscustom query parameters

single or a list of values (or tuples for intervals) custom query parameters that a specific service accepts. The values of the parameters need to follow the SIA2 format and represent the appropriate quantities (where applicable).

Returns:
Results in pyvo.dal.sia2.SIA2Results format.
result.table in Astropy table format
query_tap(query, maxrec=None)[source]

Send query to the ALMA TAP. Results in pyvo.dal.TapResult format. result.table in Astropy table format

Parameters:
maxrecint

maximum number of records to return

retrieve_data_from_uid(uids, *, cache=True)[source]

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

Parameters:
uidslist or str

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

cachebool

Whether to cache the downloads.

Returns:
downloaded_fileslist

A list of the downloaded file paths