Skip to main content
Documentation Status Code Health Travis CI build status (Linux) https://codecov.io/gh/nicolaschotard/extinctions/branch/master/graph/badge.svg

extinctions

Python package including different extinction laws and dust maps. Useful to

Installation

To install:

git clone https://github.com/nicolaschotard/extinctions.git
pip install extinctions/

To install in a local directory mypath, use:

pip install --prefix='mypath' extinctions/

and do not forget to add it to your PYTHONPATH.

To upgrade to a new version (after a git pull or a local modification), use:

pip install --upgrade (--prefix='mypath') extinctions/

To install a release version (no release version available yet):

pip install http://github.com/nicolaschotard/extinctions/archive/v0.1.tar.gz

Also works with the master:

pip install (--upgrade) https://github.com/nicolaschotard/extinctions/archive/master.zip

In the future, release versions will be listed at this location.

Dependencies

extinctions has a few python dependencies listed in the requirements file. To install them all, use:

pip install -r requirements.txt

Requirements are:

  • numpy==1.11.2

  • scipy==0.17.1

  • matplotlib==1.5.1

  • seaborn==0.7.0

  • pyyaml==3.11

  • astropy==1.2.1

  • requests==2.10.0

  • astroquery==0.3.1

  • wget==2.2

  • healpy==1.9.1

Dust map setup

You can automatically download the dust maps listed in the maps.yaml file using the script get_maps.py. It will, by default, put them in $HOME/.extinction/maps, but other locations are of course possible (option –outdir). If you choose to store them in an other diretory, you must set a $MAPSDIR environment variable pointing to it. Already existing maps in the output directory will not be downloaded again.

The available dust maps are:

Download the maps

To download the extinction maps listed above, use the script get_maps.py. The following options are available:

get_maps.py -h
usage: get_maps.py [-h] [--outdir OUTDIR] [--update] [--list]
                 [--select SELECT] [--exclude EXCLUDE]

optional arguments:
   -h, --help         show this help message and exit
   --outdir OUTDIR    Output directory in where to put the dust maps
   --update           Update the maps directory in case of changes of maps.yaml
   --list             List of available maps and exit
   --select SELECT    Select maps to download (coma separated)
   --exclude EXCLUDE  Exclude map(s) (coma separated).If the select option is
                      used, the exclude option will be ignored.

Usage

Get E(B-V)

Here is an example of how to get the value of E(B-V) for a set of coordinates (RA,DEC):

In [1]: ra, dec = 340.83, -9.59 # could also be arrays or list of ra/dec
In [2]: from extinctions import reddening
In [3]: red = reddening.Reddening(ra, dec) # ra dec can also be lists of coordinates
INFO: Loading the maps from local directory /home/chotard/.extinction/maps/
- green is loaded
- schlafly is loaded
- sfd is loaded
- planck is loaded

You can then get E(B-V) from different sources:

# from the local maps
In [4]: red.query_local_map(dustmap='sfd')
Out[4]: 0.047723956233310674
In [5]: red.query_local_map(dustmap='schlafly')
Out[5]: 0.062566755984547445
In [6]: red.query_local_map(dustmap='planck')
Out[6]: 0.052058338535565914
In [7]: red.query_local_map(dustmap='green')
Out[7]: 0.035786284169101318


# from the SFD98 north/south maps using `sncosmo`
In [8]: red.from_sncosmo()
Out[8]: array([ 0.0473752])

# Using astroquery
In [9]: red.from_astroquery()
Downloading http://irsa.ipac.caltech.edu//workspace/TMP_XG1Joz_30445/DUST/340.8300_-9.5900.v0001/extinction.tbl
|==============================================================================================| 4.3k/4.3k (100.00%)         0s
Out[9]: [0.047377326565143825]

Make some plots

To have a look at the different extinction laws amd dust maps, you can use the script extinction_plots.py.

Metadata

Release files for extinctions 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extinctions 0.1.11
File Size Uploaded
extinctions-0.1.11.tar.gz 23.8 kB Details

Release files / extinctions-0.1.11.tar.gz

Download URL extinctions-0.1.11.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ebe44def7a85202dfe7a74db64aa150f31f029df26d6446a7d8e4daca362b953
BLAKE2b-256 checksum
How to use checksums
fcd545cc83a055084adb51e072d9b1fee0f36f3f9921ed28c75f4292926c70d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.11 This release

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page