Functions and classes to access online astronomical data resources
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Specialized databases for atomic, molecular, and spectroscopic data used in astronomical spectroscopy and laboratory astrophysics. These services provide essential reference data for identifying spectral lines, understanding molecular processes, and interpreting astronomical spectra.
Splatalogue provides access to spectral line data for radio, millimeter, and submillimeter astronomy, containing molecular transition frequencies and quantum numbers essential for spectral analysis.
from astroquery.splatalogue import Splatalogue
def query_lines(min_frequency: Union[float, Quantity], max_frequency: Union[float, Quantity],
chemical_name: str = None, molecular_tag: int = None,
line_lists: List[str] = None, line_strengths: List[str] = None,
energy_max: float = None, energy_type: str = 'eu_k',
transition: str = None, version: str = 'v3.0',
exclude: List[str] = None, only_NRAO_recommended: bool = None,
export: bool = True, export_limit: int = 10000,
noHFS: bool = False, displayHFS: bool = False,
show_upper_degeneracy: bool = False) -> Table:
"""
Query Splatalogue for spectral lines in a frequency range.
Parameters:
- min_frequency: Minimum frequency (Hz, MHz, GHz)
- max_frequency: Maximum frequency (Hz, MHz, GHz)
- chemical_name: Chemical formula or name to search
- molecular_tag: Molecular identification tag number
- line_lists: List of line list names to include
- line_strengths: Minimum line strength categories
- energy_max: Maximum upper state energy
- energy_type: Energy unit type ('eu_k', 'eu_cm', 'el_cm')
- transition: Specific transition to search
- version: Splatalogue version
- exclude: Line lists to exclude
- only_NRAO_recommended: Include only NRAO recommended frequencies
- export: Export results
- export_limit: Maximum number of results to export
- noHFS: Exclude hyperfine structure
- displayHFS: Display hyperfine structure
- show_upper_degeneracy: Show upper state degeneracy
Returns:
Table with spectral line data
"""
def get_species_table() -> Table:
"""
Get table of available molecular species.
Returns:
Table with species names, molecular tags, and metadata
"""
def query_lines_async(min_frequency: Union[float, Quantity],
max_frequency: Union[float, Quantity], **kwargs) -> JobResults:
"""
Submit asynchronous query for spectral lines.
Parameters:
- min_frequency: Minimum frequency
- max_frequency: Maximum frequency
- **kwargs: Additional query parameters
Returns:
JobResults object for retrieving results
"""
# Configuration
from astroquery.splatalogue import conf
conf.server: str # Splatalogue server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.splatalogue import Splatalogue
import astropy.units as u
# Query CO lines in 3mm band
co_lines = Splatalogue.query_lines(80*u.GHz, 120*u.GHz,
chemical_name='CO')
print(f"Found {len(co_lines)} CO transitions")
print(co_lines['Species', 'Freq', 'Transition'])
# Search for methanol lines with energy constraints
ch3oh_lines = Splatalogue.query_lines(200*u.GHz, 250*u.GHz,
chemical_name='CH3OH',
energy_max=50.0,
line_strengths=['ls1', 'ls2'])
# Get all available species
species = Splatalogue.get_species_table()
organic_species = species[species['Species'].str.contains('C')]
print(f"Found {len(organic_species)} carbon-bearing species")
# Query specific molecular tag (for H2O)
h2o_lines = Splatalogue.query_lines(100*u.GHz, 200*u.GHz,
molecular_tag=18003,
only_NRAO_recommended=True)LAMDA provides collisional excitation data for atoms and molecules used in non-LTE radiative transfer modeling and molecular astrophysics calculations.
from astroquery.lamda import Lamda
def query(molecule: str = None, **kwargs) -> Table:
"""
Query LAMDA database for molecular data.
Parameters:
- molecule: Molecule name or formula
- **kwargs: Additional query parameters
Returns:
Table with molecular data and collision rates
"""
def get_datafile(molecule: str, cache: bool = True) -> str:
"""
Download LAMDA data file for a molecule.
Parameters:
- molecule: Molecule name
- cache: Enable file caching
Returns:
Path to downloaded data file
"""
def list_molecules() -> List[str]:
"""
Get list of available molecules in LAMDA.
Returns:
List of molecule names
"""
# Configuration
from astroquery.lamda import conf
conf.server: str # LAMDA server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.lamda import Lamda
# Query CO molecule data
co_data = Lamda.query(molecule='co')
print(f"CO has {len(co_data)} energy levels")
# Download full data file for detailed analysis
co_file = Lamda.get_datafile('co')
print(f"Downloaded CO data to: {co_file}")
# List all available molecules
molecules = Lamda.list_molecules()
print(f"LAMDA contains {len(molecules)} molecules")
sulfur_molecules = [m for m in molecules if 'S' in m]
print(f"Sulfur-bearing molecules: {sulfur_molecules}")
# Query specific molecule for radiative transfer modeling
h2co_data = Lamda.query(molecule='h2co-h2')NIST Atomic Spectra Database provides comprehensive atomic spectral line data including wavelengths, transition probabilities, and energy levels for all elements.
from astroquery.nist import Nist
def query(linename: str, wavelength_range: Tuple[float, float] = None,
wavelength_type: str = 'vacuum', wavelength_unit: str = 'Angstrom',
energy_level_unit: str = 'eV', output_order: str = 'wavelength',
get_query_payload: bool = False) -> Table:
"""
Query NIST atomic spectral line database.
Parameters:
- linename: Element name or ion (e.g., 'H I', 'Fe II', 'Ca')
- wavelength_range: Wavelength range as (min, max) tuple
- wavelength_type: 'vacuum' or 'air'
- wavelength_unit: Wavelength unit ('Angstrom', 'nm', 'um')
- energy_level_unit: Energy unit ('eV', 'cm-1', 'Ry')
- output_order: Sort order ('wavelength', 'multiplet')
- get_query_payload: Return query parameters instead of executing
Returns:
Table with atomic spectral line data
"""
def query_async(linename: str, **kwargs) -> JobResults:
"""
Submit asynchronous query for atomic spectral lines.
Parameters:
- linename: Element name or ion
- **kwargs: Additional query parameters
Returns:
JobResults object for retrieving results
"""
# Configuration
from astroquery.nist import conf
conf.server: str # NIST server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.nist import Nist
import astropy.units as u
# Query hydrogen Balmer lines
h_lines = Nist.query('H I', wavelength_range=(3000, 7000),
wavelength_unit='Angstrom')
print(f"Found {len(h_lines)} hydrogen lines")
print(h_lines['Wavelength', 'Aki', 'Lower Level', 'Upper Level'])
# Query iron lines in specific wavelength range
fe_lines = Nist.query('Fe II', wavelength_range=(4000, 5000),
wavelength_type='air')
strong_fe = fe_lines[fe_lines['Aki'] > 1e8] # Strong transitions
print(f"Found {len(strong_fe)} strong Fe II lines")
# Query calcium lines with energy level information
ca_lines = Nist.query('Ca I', wavelength_range=(3900, 4500),
energy_level_unit='cm-1')HITRAN provides high-resolution molecular absorption data essential for atmospheric and stellar spectroscopy, containing line parameters for greenhouse gases and other molecules.
from astroquery.hitran import Hitran
def query_lines(molecule_number: int, isotopologue_number: int,
min_frequency: float, max_frequency: float,
**kwargs) -> Table:
"""
Query HITRAN molecular absorption lines.
Parameters:
- molecule_number: HITRAN molecule number
- isotopologue_number: Isotopologue number
- min_frequency: Minimum frequency (cm-1)
- max_frequency: Maximum frequency (cm-1)
- **kwargs: Additional line parameters
Returns:
Table with molecular absorption line data
"""
def query_lines_async(molecule_number: int, isotopologue_number: int,
min_frequency: float, max_frequency: float,
**kwargs) -> JobResults:
"""
Submit asynchronous query for molecular lines.
Parameters:
- molecule_number: HITRAN molecule number
- isotopologue_number: Isotopologue number
- min_frequency: Minimum frequency (cm-1)
- max_frequency: Maximum frequency (cm-1)
- **kwargs: Additional parameters
Returns:
JobResults object for retrieving results
"""
def get_molecule_identifier(molecule_name: str) -> Dict[str, int]:
"""
Get HITRAN molecule and isotopologue numbers.
Parameters:
- molecule_name: Molecule name (e.g., 'CO2', 'H2O')
Returns:
Dictionary with molecule and isotopologue numbers
"""
# Configuration
from astroquery.hitran import conf
conf.server: str # HITRAN server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.hitran import Hitran
# Query CO2 absorption lines (molecule_number=2, isotopologue=1)
co2_lines = Hitran.query_lines(molecule_number=2, isotopologue_number=1,
min_frequency=2000.0, max_frequency=2100.0)
print(f"Found {len(co2_lines)} CO2 lines")
print(co2_lines['nu', 'sw', 'gamma_air']) # frequency, intensity, broadening
# Query water vapor lines
h2o_lines = Hitran.query_lines(molecule_number=1, isotopologue_number=1,
min_frequency=1500.0, max_frequency=1600.0)
# Get molecule identifiers
molecule_ids = Hitran.get_molecule_identifier('CH4')
print(f"Methane: molecule={molecule_ids['molecule']}, "
f"isotopologue={molecule_ids['isotopologue']}")Additional atomic and ionic line databases for X-ray and UV spectroscopy, particularly useful for hot plasma diagnostics and stellar atmosphere modeling.
from astroquery.atomic import AtomicLineList
def query_lines(wavelength_range: Tuple[float, float] = None,
element: str = None, minimal_abundance: float = None,
wavelength_unit: str = 'Angstrom', wavelength_type: str = 'air') -> Table:
"""
Query atomic line databases for spectral lines.
Parameters:
- wavelength_range: Wavelength range as (min, max) tuple
- element: Element symbol or name
- minimal_abundance: Minimum abundance threshold
- wavelength_unit: Wavelength unit
- wavelength_type: 'air' or 'vacuum'
Returns:
Table with atomic line data
"""
# Configuration
from astroquery.atomic import conf
conf.server: str # Atomic database server URL
conf.timeout: int = 60 # Connection timeoutUsage examples:
from astroquery.atomic import AtomicLineList
# Query UV lines of various elements
uv_lines = AtomicLineList.query_lines(wavelength_range=(1000, 3000),
wavelength_unit='Angstrom')
print(f"Found {len(uv_lines)} UV atomic lines")
# Query specific element lines
oxygen_lines = AtomicLineList.query_lines(element='O',
wavelength_range=(5000, 6000))from astropy.table import Table
from astropy.units import Quantity
from typing import Union, List, Tuple, Dict, Optional
# Input types
min_frequency: Union[float, Quantity] # Minimum frequency
max_frequency: Union[float, Quantity] # Maximum frequency
wavelength_range: Tuple[float, float] # Wavelength range
chemical_name: str # Chemical formula/name
molecule_number: int # HITRAN molecule ID
isotopologue_number: int # Isotopologue ID
# Query parameters
energy_max: float # Maximum energy
line_strengths: List[str] # Line strength categories
wavelength_unit: str = 'Angstrom' # Wavelength unit
wavelength_type: str = 'vacuum' # Air or vacuum wavelengths
energy_level_unit: str = 'eV' # Energy unit
# Return types
Table # Spectral line data
JobResults # Asynchronous results
List[str] # Available molecules/species
Dict[str, int] # Molecule identifiers
str # Downloaded file pathInstall with Tessl CLI
npx tessl i tessl/pypi-astroquery