Uniform interface for multiple dust reddening maps
npx @tessl/cli install tessl/pypi-dustmaps@1.0.0A comprehensive Python library for accessing and working with 2D and 3D maps of interstellar dust reddening and extinction across the sky. dustmaps provides a uniform interface for querying multiple dust map datasets from various astronomical surveys and studies, standardizing access to over 15 different dust maps with automatic coordinate transformations and units.
pip install dustmapsConfiguration management:
from dustmaps.config import configSpecific dust maps (examples):
from dustmaps.sfd import SFDQuery
from dustmaps.bayestar import BayestarQuery
from dustmaps.planck import PlanckQueryNote: The main dustmaps package has no public exports in __init__.py. Always import from specific submodules.
from dustmaps.sfd import SFDQuery
from astropy.coordinates import SkyCoord
# Configure data directory (first-time setup)
from dustmaps.config import config
config['data_dir'] = '/path/to/data/directory'
# Download SFD map data (first-time setup)
import dustmaps.sfd
dustmaps.sfd.fetch()
# Initialize SFD dust map query
sfd = SFDQuery()
# Query single coordinate
coord = SkyCoord(ra=75.0, dec=10.0, unit='deg', frame='icrs')
extinction = sfd(coord)
print(f"E(B-V): {extinction:.4f}")
# Query multiple coordinates
coords = SkyCoord(
ra=[75.0, 130.0, 200.0],
dec=[10.0, -20.0, 45.0],
unit='deg',
frame='icrs'
)
extinctions = sfd(coords)
print(f"E(B-V) values: {extinctions}")
# Query using Galactic coordinates
gal_coord = SkyCoord(l=180.0, b=30.0, unit='deg', frame='galactic')
extinction_gal = sfd(gal_coord)dustmaps implements a modular architecture centered around standardized dust map queries:
DustMap and WebDustMap classes define common query interfacesThis design provides a consistent API across all dust maps while allowing specialized functionality for different map types and coordinate systems.
Line-of-sight integrated extinction maps that provide total dust column density measurements. These maps cover the full sky with varying resolution and accuracy.
class SFDQuery(DustMap):
def __init__(self, map_dir=None): ...
def query(self, coords, order=1): ...
class PlanckQuery(DustMap):
def __init__(self, map_fname=None, component='extragalactic'): ...
def query(self, coords, **kwargs): ...
class CSFDQuery(DustMap):
def __init__(self, map_dir=None): ...
def query(self, coords, **kwargs): ...Distance-resolved extinction maps providing dust density as a function of distance along lines of sight. These maps enable 3D extinction corrections and dust distribution studies.
class BayestarQuery(DustMap):
def __init__(self, map_fname=None, max_samples=None, version='bayestar2019'): ...
def query(self, coords, mode='random_sample', return_flags=False, pct=None): ...
class MarshallQuery(DustMap):
def __init__(self, map_fname=None): ...
def query(self, coords, return_sigma=False): ...System for managing dust map data storage, downloading map files, and configuring package behavior.
class Configuration:
def __init__(self, fname): ...
def __getitem__(self, key): ...
def __setitem__(self, key, value): ...
def get(self, key, default=None): ...
def fetch(): ... # Available in each map moduleFoundation classes and utility functions for coordinate transformations, data loading, and map querying.
class DustMap:
def query(self, coords, **kwargs): ...
def query_gal(self, l, b, d=None, **kwargs): ...
def query_equ(self, ra, dec, d=None, frame='icrs', **kwargs): ...
class WebDustMap:
def query(self, coords, **kwargs): ...from astropy.coordinates import SkyCoord
from astropy.units import Quantity
import numpy as np
# Core coordinate type
SkyCoord: # astropy.coordinates.SkyCoord objects
# Return types
ExtinctionValue: float | np.ndarray # E(B-V) extinction values
ExtinctionWithUncertainty: tuple[float | np.ndarray, float | np.ndarray] # (value, sigma)
# Configuration types
ConfigDict: dict[str, str | float | bool] # Configuration options
FilePath: str # File system paths