Skip to content

Commit

Permalink
Merge eec1bcb into cc1a3dd
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Jan 13, 2018
2 parents cc1a3dd + eec1bcb commit e4b1fb2
Show file tree
Hide file tree
Showing 15 changed files with 582 additions and 647 deletions.
33 changes: 16 additions & 17 deletions docs/dust_extinction/choose_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
How to Choose a Model
#####################

The ``dust_extinction`` package provides a suite of dust extinction models.
The ``dust_extinction`` package provides a suite of dust extinction models.
Which model to use can depend on the wavelength range of interest, the expected
type of extinction, or some other property.
type of extinction, or some other property.

Average Models
==============
Expand All @@ -14,7 +14,7 @@ Simple Average Curves

These are straightforward averages of observed extinction curves. They are the
simpliest models and include models for the MW
(:class:`~dust_extinction.dust_extinction.G09_MWAvg`), the LMC
(:class:`~dust_extinction.dust_extinction.GCC09_MWAvg`), the LMC
(:class:`~dust_extinction.dust_extinction.G03_LMCAvg`,
:class:`~dust_extinction.dust_extinction.G03_LMC2`) and the SMC
(:class:`~dust_extinction.dust_extinction.G03_SMCBar`).
Expand All @@ -23,17 +23,17 @@ One often used alternative to these straight average models is to use one of
the parameter dependent models with the average R(V) value. For the Milky
Way, the usual average used is R(V) = 3.1.

+------------+-------------+------------------+--------------+
| Model | x range | wavelength range | galaxy |
+============+=============+==================+==============+
| G09_MWAvg | 0.3 - 10.96 | 0.0912 - 3.3 | MW |
+------------+-------------+------------------+--------------+
| G03_LMCAvg | 0.3 - 10.0 | 0.1 - 3.3 | LMC |
+------------+-------------+------------------+--------------+
| G03_LMC2 | 0.3 - 10.0 | 0.1 - 3.3 | LMC (30 Dor) |
+------------+-------------+------------------+--------------+
| G03_SMCBar | 0.3 - 10.0 | 0.1 - 3.3 | SMC |
+------------+-------------+------------------+--------------+
+--------------+-------------+------------------+--------------+
| Model | x range | wavelength range | galaxy |
+==============+=============+==================+==============+
| GCC09_MWAvg | 0.3 - 10.96 | 0.0912 - 3.3 | MW |
+--------------+-------------+------------------+--------------+
| G03_LMCAvg | 0.3 - 10.0 | 0.1 - 3.3 | LMC |
+--------------+-------------+------------------+--------------+
| G03_LMC2 | 0.3 - 10.0 | 0.1 - 3.3 | LMC (30 Dor) |
+--------------+-------------+------------------+--------------+
| G03_SMCBar | 0.3 - 10.0 | 0.1 - 3.3 | SMC |
+--------------+-------------+------------------+--------------+


Parameter Dependent Average Curves
Expand All @@ -55,14 +55,14 @@ is based on signifincatly more extinction curves than the
:class:`~dust_extinction.dust_extinction.O94` models.

+---------+-------------+-------------+------------------+--------------+
| Model | Parameters | x range | wavelength range | galaxy |
| Model | Parameters | x range | wavelength range | galaxy |
| | | [1/micron] | [micron] | |
+=========+=============+=============+==================+==============+
| CCM89 | R(V) | 0.3 - 10.0 | 0.1 - 3.3 | MW |
+---------+-------------+-------------+------------------+--------------+
| O94 | R(V) | 0.3 - 10.0 | 0.1 - 3.3 | MW |
+---------+-------------+-------------+------------------+--------------+
| F99 | R(V) | 0.3 - 10.0 | 0.1 - 3.3 | MW |
| F99 | R(V) | 0.3 - 10.0 | 0.1 - 3.3 | MW |
+---------+-------------+-------------+------------------+--------------+
| G16 | R(V)_A, f_A | 0.3 - 10.0 | 0.1 - 3.3 | MW, LMC, SMC |
+---------+-------------+-------------+------------------+--------------+
Expand All @@ -85,4 +85,3 @@ but only covers the UV wavelength range.
+------------+--------------+------------------+-------------------+
| P92 | 0.001 - 1000 | 0.001 - 1000 | 19 (24 possible) |
+------------+--------------+------------------+-------------------+

20 changes: 10 additions & 10 deletions docs/dust_extinction/fit_extinction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ The ``dust_extinction`` package is built on the `astropy.modeling
<http://docs.astropy.org/en/stable/modeling/>`_ package. Fitting is
done in the standard way for this package where the model is initialized
with a starting point (either the default or user input), the fitter
is choosen, and the fit performed.
is choosen, and the fit performed.

Example: FM90 Fit
=================

In this example, the FM90 model is used to fit the observed average
extinction curve for the LMC outside of the LMC2 supershell region
(G03_LMCAvg ``dust_extinction`` model).
extinction curve for the LMC outside of the LMC2 supershell region
(G03_LMCAvg ``dust_extinction`` model).

.. plot::
:include-source:
Expand Down Expand Up @@ -50,7 +50,7 @@ extinction curve for the LMC outside of the LMC2 supershell region
ax.plot(x, y, 'ko', label='Observed Curve')
ax.plot(x[gindxs], fm90_init(x[gindxs]), label='Initial guess')
ax.plot(x[gindxs], g03_fit(x[gindxs]), label='Fitted model')

ax.set_xlabel('$x$ [$\mu m^{-1}$]')
ax.set_ylabel('$E(x-V)/E(B-V)$')

Expand All @@ -64,7 +64,7 @@ Example: P92 Fit
================

In this example, the P92 model is used to fit the observed average
extinction curve for the MW (G09_MWAvg ``dust_extinction`` model).
extinction curve for the MW (GCC09_MWAvg ``dust_extinction`` model).
The fit is done using the observed uncertainties that are passed
as weights. The weights assume the noise is Gaussian and not correlated
between data points.
Expand All @@ -80,10 +80,10 @@ between data points.

from astropy.modeling.fitting import LevMarLSQFitter

from dust_extinction.dust_extinction import (P92, G09_MWAvg)
from dust_extinction.dust_extinction import (P92, GCC09_MWAvg)

# get an observed extinction curve to fit
g09_model = G09_MWAvg()
g09_model = GCC09_MWAvg()

# get an observed extinction curve to fit
x = g09_model.obsdata_x
Expand All @@ -106,14 +106,14 @@ between data points.
p92_init.FIR_amp.fixed = True
p92_init.FIR_lambda.fixed = True
p92_init.FIR_b.fixed = True

# pick the fitter
fit = LevMarLSQFitter()

# set to avoid the "fit may have been unsuccessful" warning
# fit is fine, but this means the build of the docs fails
warnings.simplefilter('ignore', category=AstropyWarning)

# fit the data to the P92 model using the fitter
# use the initialized model as the starting point
# accuracy set to avoid warning the fit may have failed
Expand All @@ -129,7 +129,7 @@ between data points.
ax.set_xlabel('$x$ [$\mu m^{-1}$]')
ax.set_ylabel('$A(x)/A(V)$')

ax.set_title('Example P92 Fit to MW average curve')
ax.set_title('Example P92 Fit to GCC09_MWAvg average curve')

ax.legend(loc='best')
plt.tight_layout()
Expand Down
48 changes: 22 additions & 26 deletions docs/dust_extinction/model_flavors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Model Flavors
#############

There are three differnet types of models: average, R(V)+ dependent prediction,
There are three different types of models: average, R(V)+ dependent prediction,
and shape fitting.

Average models
Expand All @@ -21,51 +21,50 @@ Average models
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
from dust_extinction.dust_extinction import (G09_MWAvg,

from dust_extinction.dust_extinction import (GCC09_MWAvg,
G03_SMCBar,
G03_LMCAvg,
G03_LMC2)
G03_LMC2)

fig, ax = plt.subplots()

# generate the curves and plot them
x = np.arange(0.3,10.0,0.1)/u.micron
ext_model = GCC09_MWAvg()
ax.plot(x,ext_model(x),label='GCC09 MWAvg')

ext_model = G09_MWAvg()
ax.plot(x,ext_model(x),label='G09 MWAvg')

ext_model = G03_SMCBar()
ax.plot(x,ext_model(x),label='G03 SMCBar')

ext_model = G03_LMCAvg()
ax.plot(x,ext_model(x),label='G03 LMCAvg')

ext_model = G03_LMC2()
ax.plot(x,ext_model(x),label='G03 LMC2')

ax.set_xlabel('$x$ [$\mu m^{-1}$]')
ax.set_ylabel('$A(x)/A(V)$')

ax.legend(loc='best')
plt.tight_layout()
plt.show()

R(V) (+ other variables) dependent prediction models
====================================================

These models provide predictions of the shape of the dust extinction
given input variable(s).
given input variable(s).

The R(V) dependent models include CCM89 the original such model
(Cardelli, Clayton, and Mathis 1989), the O94 model that updates the
optical portion of the CCM89 model (O'Donnell 1994), and F99 model
(Fitzpatrick 1999). These models are based on the average
behavior of extinction in the Milky Way as a function of R(V).

In addition, the (R(V), f_A) two parameter relationship from
In addition, the (R(V), f_A) two parameter relationship from
Gordon et al. (2016) is included. This model is based on the average
behavior of extinction in the Milky Way, Large Magellanic Cloud, and
behavior of extinction in the Milky Way, Large Magellanic Cloud, and
Small Magellanic Cloud.

.. plot::
Expand Down Expand Up @@ -121,7 +120,7 @@ R(V) (+ other variables) dependent prediction models
ax.legend(loc='best')
plt.tight_layout()
plt.show()

.. plot::

import numpy as np
Expand Down Expand Up @@ -219,7 +218,7 @@ Shape fitting models
These models are used to fit the detailed shape of dust extinction curves.
The FM90 (Fitzpatrick & Mass 1990) model uses 6 parameters to fit the
shape of the ultraviolet extinction.
The P92 (Pei 1992) uses 19 parameters to fit the shape of the X-ray to
The P92 (Pei 1992) uses 19 parameters to fit the shape of the X-ray to
far-infrared extinction.

.. plot::
Expand Down Expand Up @@ -273,27 +272,27 @@ Shape fitting models
ext_model = P92()
ax.plot(1/x,ext_model(x),label='total')

ext_model = P92(FUV_amp=0., NUV_amp=0.0,
ext_model = P92(FUV_amp=0., NUV_amp=0.0,
SIL1_amp=0.0, SIL2_amp=0.0, FIR_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG only')

ext_model = P92(NUV_amp=0.0,
ext_model = P92(NUV_amp=0.0,
SIL1_amp=0.0, SIL2_amp=0.0, FIR_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG+FUV only')

ext_model = P92(FUV_amp=0.,
SIL1_amp=0.0, SIL2_amp=0.0, FIR_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG+NUV only')

ext_model = P92(FUV_amp=0., NUV_amp=0.0,
ext_model = P92(FUV_amp=0., NUV_amp=0.0,
SIL2_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG+FIR+SIL1 only')

ext_model = P92(FUV_amp=0., NUV_amp=0.0,
ext_model = P92(FUV_amp=0., NUV_amp=0.0,
SIL1_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG+FIR+SIL2 only')

ext_model = P92(FUV_amp=0., NUV_amp=0.0,
ext_model = P92(FUV_amp=0., NUV_amp=0.0,
SIL1_amp=0.0, SIL2_amp=0.0)
ax.plot(1./x,ext_model(x),label='BKG+FIR only')

Expand All @@ -310,6 +309,3 @@ Shape fitting models
ax.legend(loc='best')
plt.tight_layout()
plt.show()



0 comments on commit e4b1fb2

Please sign in to comment.