Skip to main content

An all-sky 3D dust map based on Gaia and LAMOST.

Project description

Read this in: English | 中文

dustmaps3d

🌌 An all-sky 3D dust extinction map based on Gaia and LAMOST

📄 Wang et al. (2025), An all-sky 3D dust map based on Gaia and LAMOST
📌 DOI: 10.12149/101620

📦 A Python package for easy access to the 3D dust map
📌 DOI: 10.12149/101619


📦 Installation

Install via pip:

pip install dustmaps3d

📦 Data File Instructions

⚠️ The package does not include the data file. A ~400MB model file will be automatically downloaded on first use from GitHub or NADC.

🚀 Auto Download Mechanism

  • When dustmaps3d() is called, it will try to download data_v3.fits.gz;

  • After download, it will automatically extract the file to data_v3.fits and cache it locally;

  • On future runs, the file will be read from the local cache without re-downloading.

  • ✅ For international users, the primary source is: GitHub Releases

  • 🌀 If GitHub download fails, it will automatically fallback to: NADC Data Center

On Chinese systems, the order is reversed — NADC is used as the primary source.


🌐 What if download fails?

If download fails (e.g. connect timeout), you can manually download and place the file in the cache directory:

  1. Visit one of the following links:
    🇨🇳 NADC Data Center (for China)
    🌍 GitHub Releases (global)

  2. Download: data_v3.fits.gz

  3. Extract to: data_v3.fits

  4. Place the extracted file in the local cache directory (the location is printed on first use)

Example path (Windows):
C:\Users\<username>\AppData\Local\dustmaps3d\data_v3.fits

Example path (Linux/macOS):
/home/<username>/.local/share/dustmaps3d/data_v3.fits


🚀 Usage

from dustmaps3d import dustmaps3d

l = [120.0]
b = [30.0]
d = [1.5]

EBV, dust, sigma, max_d = dustmaps3d(l, b, d)
print(f"EBV: {EBV.values[0]:.4f} [mag]")
print(f"Dust: {dust.values[0]:.4f} [mag/kpc]")
print(f"Sigma: {sigma.values[0]:.4f} [mag]")
print(f"Max distance: {max_d.values[0]:.4f} kpc")

Batch example with FITS:

import numpy as np
from astropy.table import Table
from dustmaps3d import dustmaps3d

data = Table.read('input.fits')   
l = data['l'].astype(float)
b = data['b'].astype(float)
d = data['d'].astype(float)

EBV, dust, sigma, max_d = dustmaps3d(l, b, d)

data['EBV_3d'] = EBV
data['dust'] = dust
data['sigma'] = sigma
data['max_distance'] = max_d
data.write('output.fits', overwrite=True)

⚙️ Tips for Advanced Users

To ensure broad compatibility and ease of use, the official dustmaps3d package makes certain design trade-offs that may come at the cost of peak performance.

If you have higher performance needs — such as support for multi-processing, command-line usage, or faster data loading and I/O — consider using the alternative implementation by SunnyHina:

👉 High-performance version: SunnyHina/dustmaps3d

This version adopts a more modern data loading architecture and is better suited for advanced users working with large-scale or batch processing workflows.


🧠 Function Description

dustmaps3d(l, b, d, n_process=None)

Estimates 3D dust extinction and related quantities for given galactic coordinates and distances.

Input Type Description Unit
l np.ndarray Galactic longitude degrees
b np.ndarray Galactic latitude degrees
d np.ndarray Distance kpc

Returns:

Output Type Description Unit
EBV np.ndarray E(B–V) extinction mag
dust np.ndarray Dust density (d(EBV)/dx) mag/kpc
sigma np.ndarray Estimated uncertainty in E(B–V) mag
max_d np.ndarray Maximum reliable distance kpc

If d contains NaN, it will be automatically replaced by the maximum reliable distance along that line of sight (max_d).

If the input d exceeds max_d, it indicates the point lies beyond the model's reliable range. The returned values in this case are extrapolated and not guaranteed to be accurate.


⚡ Performance

  • Fully vectorized and optimized with NumPy
  • On a modern personal computer, evaluating 100 million stars takes only ~100 seconds

📜 Citation

If you use this model or the Python package, please cite both:

  • Wang, T. (2025), An all-sky 3D dust map based on Gaia and LAMOST. DOI: 10.12149/101620
  • dustmaps3d: A Python package for easy access to the 3D dust map. DOI: 10.12149/101619

🛠️ License

This project is open-source and distributed under the MIT License.


📫 Contact

If you have any questions, suggestions, or encounter issues using this package,
please feel free to contact the authors via GitHub issues or email.

🔗 GitHub Repository

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dustmaps3d-2.2.12.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dustmaps3d-2.2.12-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file dustmaps3d-2.2.12.tar.gz.

File metadata

  • Download URL: dustmaps3d-2.2.12.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for dustmaps3d-2.2.12.tar.gz
Algorithm Hash digest
SHA256 4643f560ce99bc6c7a3138751e75044fbb8f0c541dd4533e4bf8eadcc40ab9c2
MD5 0668213f83fd3cf1216a11222c1f7b6f
BLAKE2b-256 d16f4559b37892b3e2b2ac3bc204433130574067cb91416bce5fe26ae6b15a29

See more details on using hashes here.

File details

Details for the file dustmaps3d-2.2.12-py3-none-any.whl.

File metadata

  • Download URL: dustmaps3d-2.2.12-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for dustmaps3d-2.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 e77c80ed9cab5444979e538838d58a704a0cfec40fd92f3658c319e289985bb3
MD5 d57c42e359426f48d10f7e753813785d
BLAKE2b-256 91a5c1d854d5a7b465eacf3a1d02bf0969e6bdb53985b6ed3249fd6c967cbde0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page