Functions and classes to access online astronomical data resources
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Services for accessing astronomical survey data, image cutouts, and all-sky survey information across multiple wavelengths. These services provide essential imaging data for source identification, morphological studies, and multi-wavelength analysis.
SkyView provides access to images from numerous all-sky surveys spanning radio to gamma-ray wavelengths, enabling comprehensive multi-wavelength studies of astronomical objects and regions.
from astroquery.skyview import SkyView
def get_images(position: Union[SkyCoord, str], survey: Union[str, List[str]],
coordinates: str = 'J2000', projection: str = 'Tan',
pixels: Union[int, List[int]] = 300, scaling: str = 'Linear',
sampler: str = 'Spline', resolver: str = 'SIMBAD-NED',
deedger: str = 'skyview.geometry.Deedger',
lut: str = 'colortables/b-w-linear.bin',
grid: bool = False, gridlabels: bool = True,
radius: Union[Quantity, str] = None, width: Union[Quantity, str] = None,
height: Union[Quantity, str] = None) -> List:
"""
Download survey images for a sky position.
Parameters:
- position: Target position as SkyCoord or string
- survey: Survey name(s) to query
- coordinates: Coordinate system ('J2000', 'B1950', 'Galactic')
- projection: Map projection ('Tan', 'Sin', 'Arc', etc.)
- pixels: Image size in pixels (int or [width, height])
- scaling: Intensity scaling ('Linear', 'Log', 'Sqrt', 'HistEq')
- sampler: Resampling algorithm ('Spline', 'NN', 'Clip')
- resolver: Name resolver service
- deedger: Edge removal algorithm
- lut: Color lookup table
- grid: Overlay coordinate grid
- gridlabels: Show grid labels
- radius: Image radius (circular)
- width: Image width (rectangular)
- height: Image height (rectangular)
Returns:
List of HDUList objects with survey images
"""
def get_images_async(position: Union[SkyCoord, str], survey: Union[str, List[str]],
**kwargs) -> JobResults:
"""
Submit asynchronous request for survey images.
Parameters:
- position: Target position
- survey: Survey name(s)
- **kwargs: Additional image parameters
Returns:
JobResults object for retrieving images
"""
def list_surveys() -> List[str]:
"""
Get list of available surveys.
Returns:
List of survey names
"""
def survey_dict() -> Dict[str, Dict]:
"""
Get detailed information about available surveys.
Returns:
Dictionary with survey metadata
"""
# Configuration
from astroquery.skyview import conf
conf.server: str # SkyView server URL
conf.timeout: int = 600 # Connection timeout (images can be large)Usage examples:
from astroquery.skyview import SkyView
import astropy.units as u
from astropy.coordinates import SkyCoord
# Get optical image of M31
coords = SkyCoord('00h42m44s', '+41d16m09s', frame='icrs')
images = SkyView.get_images(coords, survey='DSS', pixels=800)
optical_image = images[0] # First (and only) image
print(f"Image shape: {optical_image[0].data.shape}")
# Multi-wavelength images
surveys = ['DSS', '2MASS-J', 'WISE 3.4', 'ROSAT']
multi_images = SkyView.get_images('NGC 1068', survey=surveys,
pixels=400, radius=10*u.arcmin)
for i, survey in enumerate(surveys):
print(f"{survey}: {multi_images[i][0].data.shape}")
# Radio survey image with custom parameters
radio_image = SkyView.get_images('Cas A', survey='1420MHz (Bonn)',
pixels=[512, 512], scaling='Log',
width=2*u.deg, height=2*u.deg)
# List available surveys
surveys = SkyView.list_surveys()
print(f"Available surveys: {len(surveys)}")
optical_surveys = [s for s in surveys if 'optical' in s.lower()]
# Get survey metadata
survey_info = SkyView.survey_dict()
print("DSS info:", survey_info['DSS'])HiPS2FITS converts Hierarchical Progressive Survey (HiPS) data to FITS format, enabling access to large-scale survey data with arbitrary field sizes and resolutions.
from astroquery.hips2fits import Hips2fitsClass
def query_with_wcs(hips: str, wcs, get_query_payload: bool = False,
format: str = 'fits', min_cut: float = 0.5,
max_cut: float = 99.5, stretch: str = 'linear',
colormap: str = 'grayscale', **kwargs) -> HDUList:
"""
Query HiPS data using a World Coordinate System specification.
Parameters:
- hips: HiPS survey identifier or URL
- wcs: World Coordinate System object defining the output projection
- get_query_payload: Return query parameters instead of executing
- format: Output format ('fits', 'jpg', 'png')
- min_cut: Minimum intensity percentile for scaling
- max_cut: Maximum intensity percentile for scaling
- stretch: Intensity scaling ('linear', 'log', 'sqrt', 'asinh')
- colormap: Color mapping for non-FITS formats
- **kwargs: Additional query parameters
Returns:
HDUList with HiPS data in requested projection
"""
def query_with_circle(hips: str, center: Union[SkyCoord, str],
radius: Union[Quantity, str], resolution: int = 512,
get_query_payload: bool = False, **kwargs) -> HDUList:
"""
Query circular region from HiPS survey.
Parameters:
- hips: HiPS survey identifier
- center: Center coordinates
- radius: Circle radius
- resolution: Output image resolution in pixels
- get_query_payload: Return query parameters instead of executing
- **kwargs: Additional parameters
Returns:
HDUList with circular HiPS cutout
"""
def query_with_polygon(hips: str, polygon: List[Tuple[float, float]],
resolution: int = 512, **kwargs) -> HDUList:
"""
Query polygonal region from HiPS survey.
Parameters:
- hips: HiPS survey identifier
- polygon: List of (ra, dec) coordinate pairs defining polygon
- resolution: Output resolution
- **kwargs: Additional parameters
Returns:
HDUList with polygonal HiPS region
"""
# Configuration
from astroquery.hips2fits import conf
conf.server: str # HiPS2FITS server URL
conf.timeout: int = 600 # Connection timeoutUsage examples:
from astroquery.hips2fits import Hips2fitsClass
from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
import astropy.units as u
# Create custom WCS for large field
wcs = WCS(naxis=2)
wcs.wcs.crpix = [256, 256]
wcs.wcs.cdelt = [-0.01, 0.01] # 0.01 degree pixels
wcs.wcs.crval = [180.0, 0.0] # Center at (180, 0)
wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
# Get DSS image with custom projection
dss_image = Hips2fitsClass.query_with_wcs('DSS', wcs, format='fits')
print(f"Custom DSS image: {dss_image[0].data.shape}")
# Circular cutout from 2MASS
coords = SkyCoord('12h30m43s', '+12d23m28s', frame='icrs')
twomass_cutout = Hips2fitsClass.query_with_circle(
'2MASS:H', center=coords, radius=30*u.arcmin, resolution=1024)
# Large field from WISE survey
wise_field = Hips2fitsClass.query_with_circle(
'WISE:W1', center='Orion Nebula', radius=2*u.deg, resolution=2048,
stretch='asinh', min_cut=1, max_cut=99)Generic image cutout services for extracting subregions from large survey datasets, supporting various missions and surveys.
from astroquery.image_cutouts import ImageCutoutService
def get_cutout(coordinates: Union[SkyCoord, str], size: Union[Quantity, str],
survey: str, **kwargs) -> HDUList:
"""
Get image cutout from survey data.
Parameters:
- coordinates: Target coordinates
- size: Cutout size (square) or (width, height)
- survey: Survey name
- **kwargs: Survey-specific parameters
Returns:
HDUList with cutout image
"""
def get_cutouts(coordinates: Union[SkyCoord, List[SkyCoord]],
size: Union[Quantity, str], survey: str, **kwargs) -> List[HDUList]:
"""
Get multiple image cutouts.
Parameters:
- coordinates: List of target coordinates
- size: Cutout size for all targets
- survey: Survey name
- **kwargs: Additional parameters
Returns:
List of HDUList objects with cutouts
"""
# Configuration
from astroquery.image_cutouts import conf
conf.timeout: int = 300 # Connection timeoutUsage examples:
from astroquery.image_cutouts import ImageCutoutService
from astropy.coordinates import SkyCoord
import astropy.units as u
# Single cutout
coords = SkyCoord('12h30m43s', '+12d23m28s', frame='icrs')
cutout = ImageCutoutService.get_cutout(coords, size=5*u.arcmin,
survey='SDSS-r')
# Multiple cutouts for source list
source_coords = [SkyCoord('12h30m43s', '+12d23m28s', frame='icrs'),
SkyCoord('13h15m22s', '+27d42m31s', frame='icrs')]
cutouts = ImageCutoutService.get_cutouts(source_coords, size=2*u.arcmin,
survey='PanSTARRS-g')
print(f"Retrieved {len(cutouts)} cutouts")from astropy.io.fits import HDUList
from astropy.coordinates import SkyCoord
from astropy.units import Quantity
from astropy.wcs import WCS
from typing import Union, List, Dict, Tuple, Optional
# Input types
position: Union[SkyCoord, str] # Sky position
coordinates: Union[SkyCoord, str] # Target coordinates
survey: Union[str, List[str]] # Survey name(s)
radius: Union[Quantity, str, None] # Search/cutout radius
size: Union[Quantity, str] # Image size
# Image parameters
pixels: Union[int, List[int]] = 300 # Image size in pixels
projection: str = 'Tan' # Map projection
scaling: str = 'Linear' # Intensity scaling
resolution: int = 512 # Output resolution
format: str = 'fits' # Output format
# Coordinate specifications
width: Union[Quantity, str, None] # Image width
height: Union[Quantity, str, None] # Image height
polygon: List[Tuple[float, float]] # Polygon vertices
wcs: WCS # World coordinate system
# Return types
List[HDUList] # Survey images
HDUList # Single image
JobResults # Asynchronous results
List[str] # Survey names
Dict[str, Dict] # Survey metadataInstall with Tessl CLI
npx tessl i tessl/pypi-astroquery