Skip to content

Commit

Permalink
Merge pull request #116 from karllark/add_F19_2
Browse files Browse the repository at this point in the history
Adding in F20 model
  • Loading branch information
karllark committed Jun 15, 2019
2 parents 1b9aa89 + a2a5ad3 commit a118e6b
Show file tree
Hide file tree
Showing 10 changed files with 601 additions and 219 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Expand Up @@ -57,8 +57,7 @@ env:

# If you want to ignore certain flake8 errors, you can list them
# in FLAKE8_OPT, for example:
# - FLAKE8_OPT='--ignore=E501'
- FLAKE8_OPT=''
- FLAKE8_OPT='--ignore=E501'

matrix:
# Make sure that egg_info works without dependencies
Expand Down
7 changes: 5 additions & 2 deletions docs/dust_extinction/choose_model.rst
Expand Up @@ -49,8 +49,9 @@ model encompasses the average measured behavior of extinction curves in the MW,
LMC, and SMC. The :class:`~dust_extinction.parameter_averages.G16` model reduces
to the :class:`~dust_extinction.parameter_averages.F99` model with f\ :sub:`A`\ =
1.0. If only MW type extinction is expected, then the
:class:`~dust_extinction.parameter_averages.F04` model should be considered as it
is based on significantly more extinction curves than the
:class:`~dust_extinction.parameter_averages.F20` model should be considered as it
is based on spectroscopic extinction curves in the optical and ultraviolet and
significantly more extinction curves than the
:class:`~dust_extinction.parameter_averages.CCM89` or
:class:`~dust_extinction.parameter_averages.O94` models.

Expand All @@ -72,6 +73,8 @@ is based on significantly more extinction curves than the
+----------+-------------+-------------+------------------+--------------+
| G16 | R(V)_A, f_A | 0.3 - 10.0 | 0.1 - 3.3 | MW, LMC, SMC |
+----------+-------------+-------------+------------------+--------------+
| F99, F04 | R(V) | 0.3 - 8.7 | 0.115 - 3.3 | MW |
+----------+-------------+-------------+------------------+--------------+

Notes
-----
Expand Down
10 changes: 5 additions & 5 deletions docs/dust_extinction/extinguish.rst
Expand Up @@ -23,11 +23,11 @@ Example: Extinguish a Blackbody
import astropy.units as u
from astropy.modeling.blackbody import blackbody_lambda

from dust_extinction.parameter_averages import F99
from dust_extinction.parameter_averages import F20

# generate wavelengths between 0.1 and 3 microns
# within the valid range for the F99 R(V) dependent relationship
lam = np.logspace(np.log10(0.1), np.log10(3.0), num=1000)
# generate wavelengths between 0.12 and 3 microns
# within the valid range for the F20 R(V) dependent relationship
lam = np.logspace(np.log10(0.12), np.log10(3.0), num=1000)

# setup the inputs for the blackbody function
wavelengths = lam*1e4*u.AA
Expand All @@ -37,7 +37,7 @@ Example: Extinguish a Blackbody
flux = blackbody_lambda(wavelengths, temperature)

# initialize the model
ext = F99(Rv=3.1)
ext = F20(Rv=3.1)

# get the extinguished blackbody flux for different amounts of dust
flux_ext_av05 = flux*ext.extinguish(wavelengths, Av=0.5)
Expand Down
12 changes: 6 additions & 6 deletions docs/dust_extinction/model_flavors.rst
Expand Up @@ -77,7 +77,7 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14)
VCG04, GCC09, M14, F20)

fig, ax = plt.subplots()

Expand All @@ -86,7 +86,7 @@ R(V) (+ other variables) dependent prediction models

Rv = 3.1

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F20]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand All @@ -112,7 +112,7 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14)
VCG04, GCC09, M14, F20)

fig, ax = plt.subplots()

Expand All @@ -121,7 +121,7 @@ R(V) (+ other variables) dependent prediction models

Rv = 2.0

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F20]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand All @@ -148,7 +148,7 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14)
VCG04, GCC09, M14, F20)

fig, ax = plt.subplots()

Expand All @@ -157,7 +157,7 @@ R(V) (+ other variables) dependent prediction models

Rv = 5.5

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F20]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand Down
78 changes: 44 additions & 34 deletions dust_extinction/baseclasses.py
@@ -1,19 +1,19 @@
from __future__ import (absolute_import, print_function, division)
from __future__ import absolute_import, print_function, division

import numpy as np

from astropy.modeling import (Model, Parameter, InputParameterError)
from astropy.modeling import Model, Parameter, InputParameterError

__all__ = ['BaseExtModel', 'BaseExtAveModel',
'BaseExtRvModel', 'BaseExtRvAfAModel']
__all__ = ["BaseExtModel", "BaseExtAveModel", "BaseExtRvModel", "BaseExtRvAfAModel"]


class BaseExtModel(Model):
"""
Base Extinction Model. Do not use.
"""
inputs = ('x',)
outputs = ('axav',)

inputs = ("x",)
outputs = ("axav",)

def extinguish(self, x, Av=None, Ebv=None):
"""
Expand Down Expand Up @@ -45,22 +45,23 @@ def extinguish(self, x, Av=None, Ebv=None):

# check that av or ebv is set
if (Av is None) and (Ebv is None):
raise InputParameterError('neither Av or Ebv passed, one required')
raise InputParameterError("neither Av or Ebv passed, one required")

# if Av is not set and Ebv set, convert to Av
if Av is None:
Av = self.Rv*Ebv
Av = self.Rv * Ebv

# return fractional extinction
return np.power(10.0, -0.4*axav*Av)
return np.power(10.0, -0.4 * axav * Av)


class BaseExtAveModel(Model):
"""
Base Extinction Average. Do not use.
"""
inputs = ('x',)
outputs = ('axav',)

inputs = ("x",)
outputs = ("axav",)

def extinguish(self, x, Av=None, Ebv=None):
"""
Expand Down Expand Up @@ -92,23 +93,25 @@ def extinguish(self, x, Av=None, Ebv=None):

# check that av or ebv is set
if (Av is None) and (Ebv is None):
raise InputParameterError('neither Av or Ebv passed, one required')
raise InputParameterError("neither Av or Ebv passed, one required")

# if Av is not set and Ebv set, convert to Av
if Av is None:
Av = self.Rv*Ebv
Av = self.Rv * Ebv

# return fractional extinction
return np.power(10.0, -0.4*axav*Av)
return np.power(10.0, -0.4 * axav * Av)


class BaseExtRvModel(BaseExtModel):
"""
Base Extinction R(V)-dependent Model. Do not use.
"""
Rv = Parameter(description="R(V) = A(V)/E(B-V) = "
+ "total-to-selective extinction",
default=3.1)

Rv = Parameter(
description="R(V) = A(V)/E(B-V) = " + "total-to-selective extinction",
default=3.1,
)

@Rv.validator
def Rv(self, value):
Expand All @@ -126,22 +129,25 @@ def Rv(self, value):
Input Rv values outside of defined range
"""
if not (self.Rv_range[0] <= value <= self.Rv_range[1]):
raise InputParameterError("parameter Rv must be between "
+ str(self.Rv_range[0])
+ " and "
+ str(self.Rv_range[1]))
raise InputParameterError(
"parameter Rv must be between "
+ str(self.Rv_range[0])
+ " and "
+ str(self.Rv_range[1])
)


class BaseExtRvAfAModel(BaseExtModel):
"""
Base Extinction R(V)_A, f_A -dependent Model. Do not use.
"""

RvA = Parameter(description="R_A(V) = A(V)/E(B-V) = "
+ "total-to-selective extinction of component A",
default=3.1)
fA = Parameter(description="f_A = mixture coefficent of component A",
default=1.0)
RvA = Parameter(
description="R_A(V) = A(V)/E(B-V) = "
+ "total-to-selective extinction of component A",
default=3.1,
)
fA = Parameter(description="f_A = mixture coefficent of component A", default=1.0)

@RvA.validator
def RvA(self, value):
Expand All @@ -159,10 +165,12 @@ def RvA(self, value):
Input R_A(V) values outside of defined range
"""
if not (self.RvA_range[0] <= value <= self.RvA_range[1]):
raise InputParameterError("parameter RvA must be between "
+ str(self.RvA_range[0])
+ " and "
+ str(self.RvA_range[1]))
raise InputParameterError(
"parameter RvA must be between "
+ str(self.RvA_range[0])
+ " and "
+ str(self.RvA_range[1])
)

@fA.validator
def fA(self, value):
Expand All @@ -180,7 +188,9 @@ def fA(self, value):
Input fA values outside of defined range
"""
if not (self.fA_range[0] <= value <= self.fA_range[1]):
raise InputParameterError("parameter fA must be between "
+ str(self.fA_range[0])
+ " and "
+ str(self.fA_range[1]))
raise InputParameterError(
"parameter fA must be between "
+ str(self.fA_range[0])
+ " and "
+ str(self.fA_range[1])
)
103 changes: 103 additions & 0 deletions dust_extinction/data/F20_tabulated.dat
@@ -0,0 +1,103 @@
x k_3.02 deltak sigmak
0.000 -3.020 -1.000 0.000
0.455 -2.747 -0.842 0.000
0.606 -2.528 -0.728 0.068
0.800 -2.222 -0.531 0.070
1.000 -1.757 -0.360 0.184
1.100 -1.567 -0.284 0.100
1.200 -1.300 -0.223 0.085
1.250 -1.216 -0.198 0.072
1.300 -1.070 -0.173 0.073
1.350 -0.973 -0.150 0.061
1.400 -0.868 -0.130 0.053
1.450 -0.750 -0.110 0.052
1.500 -0.629 -0.096 0.048
1.550 -0.509 -0.081 0.041
1.600 -0.407 -0.063 0.044
1.650 -0.320 -0.048 0.037
1.700 -0.221 -0.032 0.033
1.750 -0.133 -0.017 0.030
1.800 -0.048 -0.005 0.022
1.818 0.000 0.000 0.022
1.850 0.071 0.007 0.018
1.900 0.188 0.013 0.021
1.950 0.319 0.012 0.026
2.000 0.438 0.010 0.032
2.050 0.575 0.004 0.034
2.100 0.665 0.003 0.027
2.150 0.744 0.000 0.024
2.200 0.838 0.002 0.017
2.250 0.951 0.001 0.017
2.273 1.000 0.000 0.016
2.300 1.044 -0.000 0.020
2.350 1.113 0.001 0.022
2.400 1.181 0.001 0.027
2.450 1.269 -0.002 0.034
2.500 1.346 0.000 0.041
2.550 1.405 -0.002 0.048
2.600 1.476 -0.002 0.063
2.650 1.558 -0.006 0.075
2.700 1.632 -0.009 0.085
2.750 1.723 -0.011 0.094
2.800 1.791 -0.017 0.103
2.850 1.869 -0.025 0.112
2.900 1.948 -0.029 0.118
2.950 2.009 -0.037 0.122
3.000 2.090 -0.043 0.127
3.100 2.253 -0.064 0.132
3.200 2.408 -0.092 0.139
3.300 2.565 -0.122 0.152
3.400 2.746 -0.161 0.164
3.500 2.933 -0.201 0.176
3.600 3.124 -0.249 0.189
3.700 3.328 -0.303 0.205
3.800 3.550 -0.366 0.224
3.900 3.815 -0.437 0.247
4.000 4.139 -0.517 0.277
4.100 4.534 -0.603 0.318
4.200 5.012 -0.692 0.374
4.300 5.560 -0.774 0.454
4.400 6.118 -0.843 0.559
4.500 6.565 -0.888 0.665
4.600 6.767 -0.908 0.714
4.700 6.681 -0.903 0.675
4.800 6.394 -0.880 0.596
4.900 6.038 -0.849 0.524
5.000 5.704 -0.816 0.475
5.100 5.432 -0.785 0.445
5.200 5.226 -0.760 0.431
5.300 5.078 -0.741 0.426
5.400 4.978 -0.729 0.428
5.500 4.913 -0.722 0.436
5.600 4.877 -0.722 0.447
5.700 4.862 -0.726 0.461
5.800 4.864 -0.734 0.477
5.900 4.879 -0.745 0.496
6.000 4.904 -0.760 0.516
6.100 4.938 -0.778 0.538
6.200 4.982 -0.798 0.562
6.300 5.038 -0.820 0.587
6.400 5.105 -0.845 0.613
6.500 5.181 -0.870 0.640
6.600 5.266 -0.898 0.668
6.700 5.359 -0.926 0.698
6.800 5.460 -0.956 0.728
6.900 5.569 -0.988 0.760
7.000 5.684 -1.020 0.793
7.100 5.805 -1.053 0.827
7.200 5.933 -1.087 0.861
7.300 6.067 -1.122 0.897
7.400 6.207 -1.158 0.934
7.500 6.352 -1.195 0.972
7.600 6.502 -1.232 1.011
7.700 6.657 -1.270 1.051
7.800 6.817 -1.309 1.091
7.900 6.981 -1.349 1.133
8.000 7.150 -1.389 1.176
8.100 7.323 -1.429 1.220
8.200 7.500 -1.471 1.264
8.300 7.681 -1.513 1.310
8.400 7.866 -1.555 1.357
8.500 8.054 -1.598 1.404
8.600 8.246 -1.641 1.453
8.700 8.441 -1.685 1.502

0 comments on commit a118e6b

Please sign in to comment.