Functions and classes to access online astronomical data resources
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Data archives from major ground-based and space-based observatories providing access to processed observations, raw data, calibration files, and metadata. These archives enable researchers to access telescope observations across multiple wavelengths and epochs.
ALMA archive provides access to interferometric observations in the millimeter and submillimeter wavelength range, including both processed data products and raw visibility data.
from astroquery.alma import Alma
def query_object(object_name: str, public: bool = True, science: bool = True,
payload: bool = False, **kwargs) -> Table:
"""
Query ALMA archive for observations of a specific object.
Parameters:
- object_name: Name of the astronomical object
- public: Include public observations only
- science: Include science observations only
- payload: Return query payload instead of executing
- **kwargs: Additional query parameters
Returns:
Table with ALMA observation metadata
"""
def query_region(coordinates: Union[SkyCoord, str], radius: Union[Quantity, str] = None,
public: bool = True, science: bool = True) -> Table:
"""
Query ALMA archive for observations in a sky region.
Parameters:
- coordinates: Center coordinates as SkyCoord or string
- radius: Search radius (default: 1 arcmin)
- public: Include public observations only
- science: Include science observations only
Returns:
Table with ALMA observations in the region
"""
def query_sia(pos: Union[SkyCoord, str] = None, band: Union[int, List[int]] = None,
time: str = None, pol: str = None) -> Table:
"""
Simple Image Access (SIA) query for ALMA images.
Parameters:
- pos: Position for spatial constraint
- band: ALMA band number(s) to search
- time: Time constraint
- pol: Polarization constraint
Returns:
Table with available image products
"""
def download_and_extract_files(urls: List[str], delete: bool = True,
regex: str = r'.*\.fits$') -> List[str]:
"""
Download and extract ALMA data files.
Parameters:
- urls: List of download URLs from query results
- delete: Delete downloaded tar files after extraction
- regex: Regular expression to filter extracted files
Returns:
List of paths to extracted files
"""
def get_data_info(uids: Union[List[str], str], *, expand_tarfiles: bool = False,
with_auxiliary: bool = True, with_rawdata: bool = True) -> Table:
"""
Get detailed information about ALMA observations by UID.
Parameters:
- uids: List of valid UIDs or a single UID (format: 'uid://A002/X391d0b/X7b')
- expand_tarfiles: Include information about files within tar archives
- with_auxiliary: Include auxiliary data files
- with_rawdata: Include raw data files
Returns:
Table with detailed file information for the specified UIDs
"""
# Configuration
from astroquery.alma import conf
conf.server: str # ALMA archive server
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.alma import Alma
import astropy.units as u
from astropy.coordinates import SkyCoord
# Query for public observations of a source
result = Alma.query_object('NGC 1068', public=True)
print(f"Found {len(result)} ALMA observations")
print(result['obs_id', 'target_name', 'frequency'])
# Region query with specific constraints
coords = SkyCoord('12h30m43.2s', '+12d23m28s', frame='icrs')
result = Alma.query_region(coords, radius=30*u.arcsec)
# Get download URLs and retrieve data
download_urls = Alma.get_data_urls(result)
files = Alma.download_and_extract_files(download_urls[:5])
print(f"Downloaded {len(files)} FITS files")MAST provides access to data from NASA's space-based observatories including Hubble, Webb, Kepler, TESS, and other missions, with both observation data and source catalogs.
from astroquery.mast import Observations, Catalogs, Tesscut, Zcut
# Observations service
def query_object(objectname: str, radius: Union[Quantity, str] = None,
pagesize: int = None, page: int = None) -> Table:
"""
Query MAST for observations of a specific object.
Parameters:
- objectname: Name of the astronomical object
- radius: Search radius around object
- pagesize: Number of results per page
- page: Page number for paginated results
Returns:
Table with observation metadata
"""
def query_region(coordinates: Union[SkyCoord, str], radius: Union[Quantity, str] = None) -> Table:
"""
Query MAST observations in a sky region.
Parameters:
- coordinates: Center coordinates
- radius: Search radius
Returns:
Table with observations in the region
"""
def query_criteria(**criteria) -> Table:
"""
Query observations with specific criteria.
Parameters:
- **criteria: Search criteria (instrument_name=, proposal_id=, etc.)
Returns:
Table with observations matching criteria
"""
# Catalogs service
def query_object(objectname: str, radius: Union[Quantity, str] = None,
catalog: str = "Gsc", pagesize: int = None) -> Table:
"""
Query MAST catalogs for sources around an object.
Parameters:
- objectname: Object name for search
- radius: Search radius
- catalog: Catalog name ("Gsc", "TIC", "Ctl", etc.)
- pagesize: Results per page
Returns:
Table with catalog sources
"""
def query_region(coordinates: Union[SkyCoord, str], radius: Union[Quantity, str] = None,
catalog: str = "Gsc") -> Table:
"""
Query MAST catalogs in a region.
Parameters:
- coordinates: Center coordinates
- radius: Search radius
- catalog: Catalog to search
Returns:
Table with catalog sources in region
"""
# TESS cutouts
def get_cutouts(coordinates: Union[SkyCoord, str], size: Union[int, Quantity] = None,
sector: int = None) -> List:
"""
Get TESS Full Frame Image cutouts.
Parameters:
- coordinates: Target coordinates
- size: Cutout size in pixels or angular units
- sector: Specific TESS sector
Returns:
List of HDUList objects with cutout data
"""
# Configuration
from astroquery.mast import conf
conf.server: str # MAST server URL
conf.timeout: int = 600 # Connection timeoutUsage examples:
from astroquery.mast import Observations, Catalogs, Tesscut
import astropy.units as u
from astropy.coordinates import SkyCoord
# Query Hubble observations
obs_table = Observations.query_object("M83", radius=0.02*u.deg)
hubble_obs = obs_table[obs_table['obs_collection'] == 'HST']
print(f"Found {len(hubble_obs)} Hubble observations")
# Query Guide Star Catalog
coords = SkyCoord('12h30m43s', '+12d23m28s', frame='icrs')
sources = Catalogs.query_region(coords, radius=2*u.arcmin, catalog="Gsc")
print(f"Found {len(sources)} guide stars")
# Get TESS cutouts
cutouts = Tesscut.get_cutouts(coords, size=20)
for cutout in cutouts:
print(f"Cutout shape: {cutout[1].data.shape}")
# Download observation data products
data_products = Observations.get_product_list(obs_table[:5])
download_table = Observations.download_products(data_products[:10])ESO archive provides access to observations from ESO's ground-based telescopes including VLT, ALMA (as partner), and La Silla facilities, with both raw and processed data products.
from astroquery.eso import Eso
def query_object(name: str, cache: bool = True) -> Table:
"""
Query ESO archive for observations of a specific object.
Parameters:
- name: Name of the astronomical object
- cache: Enable result caching
Returns:
Table with ESO observation records
"""
def query_region(coordinates: Union[SkyCoord, str], radius: Union[Quantity, str] = None) -> Table:
"""
Query ESO archive for observations in a sky region.
Parameters:
- coordinates: Center coordinates
- radius: Search radius
Returns:
Table with observations in the specified region
"""
def query_instrument(instrument: str, **kwargs) -> Table:
"""
Query ESO archive by instrument name.
Parameters:
- instrument: ESO instrument name (e.g., 'FORS2', 'XSHOOTER')
- **kwargs: Additional instrument-specific parameters
Returns:
Table with observations from the specified instrument
"""
def get_headers(data_files: List[str]) -> List[Dict]:
"""
Retrieve FITS headers for ESO data files.
Parameters:
- data_files: List of ESO data file identifiers
Returns:
List of dictionaries containing FITS header information
"""
def login(username: str = None, password: str = None, store_password: bool = False) -> None:
"""
Login to ESO archive for accessing proprietary data.
Parameters:
- username: ESO archive username
- password: ESO archive password
- store_password: Store password securely
"""
# Configuration
from astroquery.eso import conf
conf.server: str # ESO archive server
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.eso import Eso
import astropy.units as u
from astropy.coordinates import SkyCoord
# Query for observations of a target
result = Eso.query_object('NGC 1365')
print(f"Found {len(result)} ESO observations")
print(result['target', 'instrument', 'exptime'])
# Query by instrument
fors2_obs = Eso.query_instrument('FORS2', target='NGC*')
print(f"Found {len(fors2_obs)} FORS2 observations")
# Region query
coords = SkyCoord('03h33m36s', '-36d08m25s', frame='icrs')
region_obs = Eso.query_region(coords, radius=5*u.arcmin)
# Login and access proprietary data (requires ESO account)
# Eso.login() # Prompts for credentials
# proprietary_obs = Eso.query_object('my_target')CASDA provides access to data from the Australian Square Kilometre Array Pathfinder (ASKAP) radio telescope, including continuum and spectral line observations.
from astroquery.casda import Casda
def query_region(coordinates: Union[SkyCoord, str], radius: Union[Quantity, str] = None,
cache: bool = True) -> Table:
"""
Query CASDA for observations in a sky region.
Parameters:
- coordinates: Center coordinates
- radius: Search radius
- cache: Enable result caching
Returns:
Table with ASKAP observations in the region
"""
def query_object(object_name: str, radius: Union[Quantity, str] = None) -> Table:
"""
Query CASDA for observations of a specific object.
Parameters:
- object_name: Name of the astronomical object
- radius: Search radius around object
Returns:
Table with ASKAP observation metadata
"""
# Configuration
from astroquery.casda import conf
conf.server: str # CASDA server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.casda import Casda
import astropy.units as u
from astropy.coordinates import SkyCoord
# Query ASKAP observations in a region
coords = SkyCoord('21h30m00s', '-30d00m00s', frame='icrs')
result = Casda.query_region(coords, radius=1*u.deg)
print(f"Found {len(result)} ASKAP observations")
# Query by object name
result = Casda.query_object('SMC', radius=2*u.deg)from astropy.table import Table
from astropy.coordinates import SkyCoord
from astropy.units import Quantity
from astropy.io.fits import HDUList
from typing import Union, List, Dict, Optional
# Input types
coordinates: Union[SkyCoord, str] # Sky coordinates
object_name: str # Astronomical object name
radius: Union[Quantity, str, None] # Search radius with units
instrument: str # Instrument name
# Query parameters
public: bool = True # Include public data only
science: bool = True # Science observations only
cache: bool = True # Enable caching
pagesize: int # Results per page
# Return types
Table # Observation metadata
List[str] # File paths
List[HDUList] # FITS data
List[Dict] # Header informationInstall with Tessl CLI
npx tessl i tessl/pypi-astroquery