Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ version = "0.11.2"
BSplineKit = "093aae92-e908-43d7-9660-e50ee39d5a0a"
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
FITSIO = "525bcba6-941b-5504-bd06-fd0dc1a4d2eb"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
UnitfulAstro = "6112ee07-acf9-5e0f-b108-d242c714bf9f"

[compat]
BSplineKit = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19"
DataDeps = "0.7"
FITSIO = "0.13.0, 0.14, 0.15, 0.16.1, 0.17"
Parameters = "0.12"
Unitful = "0.17.0, 1"
UnitfulAstro = "0.3.0, 0.4, 1"
julia = "1.6"
4 changes: 1 addition & 3 deletions src/DustExtinction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module DustExtinction
import Unitful as U
using UnitfulAstro: UnitfulAstro
import DataDeps
import Parameters
import FITSIO as FITS
import BSplineKit as BSK

Expand Down Expand Up @@ -40,8 +39,7 @@ The abstract supertype for dust extinction laws. See the extended help
## Interface

Here's how to make a new extinction law, called `MyLaw`
* Create your struct. We strongly recommend using `Parameters.jl` to facilitate
creating keyword argument constructors if your model is parameterized, which
* Create your struct. We strongly recommend using keyword arguments if your model is parameterized, which
allows convenient usage with [`redden`](@ref) and [`deredden`](@ref).
```julia
struct MyLaw <: DustExtinction.ExtinctionLaw end
Expand Down
4 changes: 2 additions & 2 deletions src/color_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for different coefficients used in the optical (3030.3 Å to 9090.9 Å).
# See Also
[`CCM89`](@ref)
"""
Parameters.@with_kw struct OD94 <: ExtinctionLaw
Base.@kwdef struct OD94 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down Expand Up @@ -47,7 +47,7 @@ fit value for such galaxies was 4.05±0.80.
# References
[Calzetti et al. (2000)](https://ui.adsabs.harvard.edu/abs/2000ApJ...533..682C)
"""
Parameters.@with_kw struct CAL00 <: ExtinctionLaw
Base.@kwdef struct CAL00 <: ExtinctionLaw
Rv::Float64 = 4.05
end
function (law::CAL00)(wave::T) where T
Expand Down
2 changes: 1 addition & 1 deletion src/color_laws/ccm89.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A typical value for the Milky Way is 3.1.
# References
[Clayton,Cardelli and Mathis (1989)](https://ui.adsabs.harvard.edu/abs/1989ApJ...345..245C)
"""
Parameters.@with_kw struct CCM89 <: ExtinctionLaw
Base.@kwdef struct CCM89 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down
6 changes: 3 additions & 3 deletions src/color_laws/fitzpatrick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ A typical value for the Milky Way is 3.1.
# References
[Fitzpatrick (1999)](https://ui.adsabs.harvard.edu/abs/1999PASP..111...63F/)
"""
Parameters.@with_kw struct F99 <: ExtinctionLaw
Base.@kwdef struct F99 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down Expand Up @@ -165,7 +165,7 @@ See also Fitzpatrick & Massa (2007, ApJ, 663, 320)
# References
[Fitzpatrick (2004)](https://ui.adsabs.harvard.edu/abs/2004ASPC..309...33F/)
"""
Parameters.@with_kw struct F04 <: ExtinctionLaw
Base.@kwdef struct F04 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down Expand Up @@ -242,7 +242,7 @@ sample of stars observed spectroscopically in the optical with HST/STIS.
# References
[Fitzpatrick (2019)](https://ui.adsabs.harvard.edu/abs/2019ApJ...886..108F/)
"""
Parameters.@with_kw struct F19 <: ExtinctionLaw
Base.@kwdef struct F19 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down
2 changes: 1 addition & 1 deletion src/color_laws/gcc09.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This model was not derived for the optical or NIR.
# References
[Gordon, Cartledge, & Clayton (2009)](https://ui.adsabs.harvard.edu/abs/2009ApJ...705.1320G/)
"""
Parameters.@with_kw struct GCC09 <: ExtinctionLaw
Base.@kwdef struct GCC09 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down
2 changes: 1 addition & 1 deletion src/color_laws/m14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ equivalent to photometric R(V).
# References
[Maiz Apellaniz et al. (2014)](https://ui.adsabs.harvard.edu/abs/2014A%26A...564A..63M/)
"""
Parameters.@with_kw struct M14 <: ExtinctionLaw
Base.@kwdef struct M14 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down
2 changes: 1 addition & 1 deletion src/color_laws/vcg04.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This model was not derived for the optical or NIR.
# References
[Valencic, Clayton, & Gordon (2004)](https://ui.adsabs.harvard.edu/abs/2004ApJ...616..912V/)
"""
Parameters.@with_kw struct VCG04 <: ExtinctionLaw
Base.@kwdef struct VCG04 <: ExtinctionLaw
Rv::Float64 = 3.1
end

Expand Down
24 changes: 13 additions & 11 deletions src/fittable_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ changing the expected behavior of reddening via the parameter ``A_V``.
## References
[Fitzpatrick & Massa (1990)](https://ui.adsabs.harvard.edu/abs/1990ApJS...72..163F)
"""
Parameters.@with_kw struct FM90{T<:Number} <: ExtinctionLaw @deftype T
c1 = 0.10
c2 = 0.70
c3 = 3.23
c4 = 0.41
x0 = 4.60
gamma = 0.99
@assert x0 ≥ 0 "`x0` must be ≥ 0, got $x0"
@assert gamma ≥ 0 "`gamma` must be ≥ 0, got $gamma"
Base.@kwdef struct FM90{T<:Number} <: ExtinctionLaw
c1::T = 0.10
c2::T = 0.70
c3::T = 3.23
c4::T = 0.41
x0::T = 4.60
gamma::T = 0.99
function FM90(c1, c2, c3, c4, x0, gamma)
x0 < 0 && error("`x0` must be ≥ 0, got ", x0)
gamma < 0 && error("`gamma` must be ≥ 0, got ", gamma)
params = promote(c1, c2, c3, c4, x0, gamma)
return new{eltype(params)}(params...)
end
end

FM90(c1, c2, c3, c4, x0, gamma) = FM90(promote(c1, c2, c3, c4, x0, gamma)...)
FM90(coeffs, x0=4.60, gamma=0.99) = FM90(coeffs..., x0, gamma)

bounds(::Type{<:FM90}) = (912, 3200)
Expand Down
8 changes: 4 additions & 4 deletions src/mixture_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ provide smooth interpolation as noted in Gordon et al. (2016, ApJ, 826, 104)
# Reference
[Gordon et al. (2003)](https://ui.adsabs.harvard.edu/abs/2003ApJ...594..279G/)
"""
Parameters.@with_kw struct G03_SMCBar <: ExtinctionLaw
Base.@kwdef struct G03_SMCBar <: DustExtinction.ExtinctionLaw
Rv::Float64 = 2.74
obsdata_x = g03_obsdata_x
obsdata_axav = g03_obsdata_axav
Expand All @@ -82,7 +82,7 @@ Gordon et al. (2003) LMCAve Average Extinction Curve.
# Reference
[Gordon et al. (2003)](https://ui.adsabs.harvard.edu/abs/2003ApJ...594..279G/)
"""
Parameters.@with_kw struct G03_LMCAve <: ExtinctionLaw
Base.@kwdef struct G03_LMCAve <: DustExtinction.ExtinctionLaw
Rv::Float64 = 3.41
obsdata_x = g03lmc_obsdata_x
obsdata_axav = g03lmc_obsdata_axav
Expand Down Expand Up @@ -170,9 +170,9 @@ A typical value for the Milky Way is 3.1.
# References
[Gordon et al. (2016)](https://ui.adsabs.harvard.edu/abs/2016ApJ...826..104G/)
"""
Parameters.@with_kw struct G16{T<:Number} <: ExtinctionLaw @deftype T
Base.@kwdef struct G16{T<:Number} <: ExtinctionLaw
Rv::Float64 = 3.1
f_A = 1.0
f_A::T = 1.0
end

#G16(Rv, f_A) = G16(promote(Rv, f_A)...)
Expand Down
3 changes: 3 additions & 0 deletions test/fittable_laws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
x_inv_microns = [3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 9.0, 10.0]
wave = 1e4 ./ x_inv_microns

# Construction
model = FM90()
model1 = FM90([0.10 0.70 3.23 0.41])
@test_throws ErrorException("`x0` must be ≥ 0, got -2.0") FM90(x0=-2.0)
@test_throws ErrorException("`gamma` must be ≥ 0, got -2.0") FM90(gamma=-2.0)

# Test out of bounds
bad_waves = [100, 4e4]
Expand Down
Loading