Skip to main content

Extinction laws, maps and corrections

Project description

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

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.

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

extinctions-0.1.1.tar.gz (22.7 kB view details)

Uploaded Source

File details

Details for the file extinctions-0.1.1.tar.gz.

File metadata

  • Download URL: extinctions-0.1.1.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for extinctions-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1b7605e7515181ab5c6db3d09499e335083bc4e7adde53c8829242f281ed0da4
MD5 7c85191d08228810663a1e562b729129
BLAKE2b-256 454ff2f3d11c96d856a380068f2ffa39179ebe400a8ca2e3000184e013feaaa1

See more details on using hashes here.

Supported by

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