Skip to content

Commit 2072118

Browse files
author
icweaver
committed
merged in master/M14 (01be6da)
2 parents f8e7574 + 01be6da commit 2072118

File tree

9 files changed

+997
-6
lines changed

9 files changed

+997
-6
lines changed

docs/plots.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Plots, LaTeXStrings
2-
import DustExtinction: ccm89_ca, ccm89_cb, od94_ca, od94_cb, cal00_invum, ccm89_invum, vcg04_invum, gcc09_invum, f99_invum, f04_invum, f19_invum, FM90, G16
2+
import DustExtinction: ccm89_ca, ccm89_cb, od94_ca, od94_cb, cal00_invum, ccm89_invum, vcg04_invum, gcc09_invum, f99_invum, f04_invum, f19_invum, m14_invum, FM90, G16
33

44
dir = joinpath(@__DIR__, "src", "assets")
55

@@ -119,6 +119,19 @@ xlabel!(L"x\ \left[\mu m ^{-1}\right]")
119119
ylabel!(L"A(x)/A(V)")
120120
savefig(joinpath(dir, "F19_plot.svg"))
121121

122+
#--------------------------------------------------------------------------------
123+
# M14
124+
125+
w = range(0.3, 3.3, length=1000)
126+
plot()
127+
for rv in [2.0, 3.1, 4.0, 5.0, 6.0]
128+
m = m14_invum.(w, rv)
129+
plot!(w, m, label="Rv=$rv")
130+
end
131+
xlabel!(L"x\ \left[\mu m ^{-1}\right]")
132+
ylabel!(L"A(x)/A(V)")
133+
savefig(joinpath(dir, "M14_plot.svg"))
134+
122135
#--------------------------------------------------------------------------------
123136
# FM90
124137

@@ -166,5 +179,3 @@ end
166179
xlabel!(L"x\ \left[\mu m ^{-1}\right]")
167180
ylabel!(L"A(x)/A(V)")
168181
savefig(joinpath(dir, "G16_fixed_Rv_plot.svg"))
169-
170-

docs/src/assets/M14_plot.svg

Lines changed: 807 additions & 0 deletions
Loading

docs/src/assets/m14.bib

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@ARTICLE{2014A&A...564A..63M,
2+
author = {{Ma{\'\i}z Apell{\'a}niz}, J. and {Evans}, C.~J. and {Barb{\'a}}, R.~H. and
3+
{Gr{\"a}fener}, G. and {Bestenlehner}, J.~M. and {Crowther}, P.~A. and
4+
{Garc{\'\i}a}, M. and {Herrero}, A. and {Sana}, H. and
5+
{Sim{\'o}n-D{\'\i}az}, S. and {Taylor}, W.~D. and {van Loon}, J. Th. and
6+
{Vink}, J.~S. and {Walborn}, N.~R.},
7+
title = "{The VLT-FLAMES Tarantula Survey. XVI. The optical and NIR extinction laws in 30 Doradus and the photometric determination of the effective temperatures of OB stars}",
8+
journal = {\aap},
9+
keywords = {open clusters and associations: individual: 30 Doradus, dust, extinction, Magellanic Clouds, stars: early-type, stars: fundamental parameters, Astrophysics - Astrophysics of Galaxies, Astrophysics - Cosmology and Nongalactic Astrophysics, Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - Solar and Stellar Astrophysics},
10+
year = 2014,
11+
month = apr,
12+
volume = {564},
13+
eid = {A63},
14+
pages = {A63},
15+
doi = {10.1051/0004-6361/201423439},
16+
archivePrefix = {arXiv},
17+
eprint = {1402.3062},
18+
primaryClass = {astro-ph.GA},
19+
adsurl = {https://ui.adsabs.harvard.edu/abs/2014A&A...564A..63M},
20+
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
21+
}

docs/src/color_laws.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ F04
201201
F19
202202
```
203203

204+
### Maiz Apellaniz et al. (2014)
205+
206+
![](assets/m14_plot.svg)
207+
208+
```@docs
209+
M14
210+
```
211+
204212
## API/Reference
205213

206214
```@docs

docs/src/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ There are various citations relevant to this work. Please be considerate when us
4343
| [`F99`](@ref) | [Fitzpatrick (1999)](https://ui.adsabs.harvard.edu/abs/1999PASP..111...63F) | [download](assets/f99.bib) |
4444
| [`F04`](@ref) | [Fitzpatrick (2004)](https://ui.adsabs.harvard.edu/abs/2004ASPC..309...33F) | [download](assets/f04.bib) |
4545
| [`F19`](@ref) | [Fitzpatrick (2019)](https://ui.adsabs.harvard.edu/abs/2019ApJ...886..108F) | [download](assets/f19.bib) |
46+
| [`M14`](@ref) | [Maiz Apellaniz et al. (2014)](https://ui.adsabs.harvard.edu/abs/2014A%26A...564A..63M) | [download](assets/m14.bib) |
4647

4748
## Index
4849

src/DustExtinction.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export redden,
1616
F99,
1717
F04,
1818
F19,
19+
M14,
1920
# Fittable laws
2021
FM90,
2122
# Mixture laws
@@ -151,7 +152,7 @@ include("mixture_laws.jl")
151152
# at which point adding `(l::ExtinctionLaw)(wave::Quantity)` is possible, until then
152153
# using this code-gen does the trick but requires manually editing
153154
# instead of providing support for all <: ExtinctionLaw
154-
for law in [CCM89, OD94, CAL00, GCC09, VCG04, FM90, G16, G03_SMCBar, F99, F04, F19]
155+
for law in [CCM89, OD94, CAL00, GCC09, VCG04, FM90, G16, G03_SMCBar, F99, F04, F19, M14]
155156
(l::law)(wavelength::Quantity) = l(ustrip(u"Å", wavelength)) * u"mag"
156157
end
157158

src/color_laws.jl

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,107 @@ function f19_invum(x::Real, Rv::Real)
512512

513513
return a_rV
514514
end
515+
516+
# Optical
517+
const m14_x1 = (1.0)
518+
const m14_xi1 = first(m14_x1)
519+
const m14_x2 = (1.15, 1.81984, 2.1, 2.27015, 2.7)
520+
const m14_x3 = (3.5, 3.9, 4.0, 4.1, 4.2)
521+
const m14_xi3 = last(m14_x3)
522+
const m14_a1v = 0.574 * m14_x1^1.61
523+
const m14_b1v = -0.527 * m14_x1^1.61
524+
const m14_x2_diff = m14_x2 .- 1.82
525+
const m14_a2v = @. (
526+
1
527+
+ 0.17699 * (m14_x2_diff)
528+
- 0.50447 * (m14_x2_diff)^2
529+
- 0.02427 * (m14_x2_diff)^3
530+
+ 0.72085 * (m14_x2_diff)^4
531+
+ 0.01979 * (m14_x2_diff)^5
532+
- 0.77530 * (m14_x2_diff)^6
533+
+ 0.32999 * (m14_x2_diff)^7
534+
+ (0.0, 0.0, -0.011, 0.0, 0.0)
535+
)
536+
const m14_b2v = @. (
537+
1.41338 * (m14_x2 - 1.82)
538+
+ 2.28305 * (m14_x2 - 1.82)^2
539+
+ 1.07233 * (m14_x2 - 1.82)^3
540+
- 5.38434 * (m14_x2 - 1.82)^4
541+
- 0.62251 * (m14_x2 - 1.82)^5
542+
+ 5.30260 * (m14_x2 - 1.82)^6
543+
- 2.09002 * (m14_x2 - 1.82)^7
544+
+ (0.0, 0.0, 0.091, 0.0, 0.0)
545+
)
546+
const m14_a3v = @. (
547+
1.752
548+
- 0.316 * m14_x3
549+
- 0.104 / ((m14_x3 - 4.67)^2 + 0.341)
550+
+ (0.442, 0.341, 0.130, 0.020, 0.000)
551+
)
552+
const m14_b3v = @. (
553+
-3.090
554+
+ 1.825 * m14_x3
555+
+ 1.206 / ((m14_x3 - 4.62)^2 + 0.263)
556+
- (1.256, 1.021, 0.416, 0.064, 0.000)
557+
)
558+
const m14_xn = collect((m14_x1..., m14_x2..., m14_x3...))
559+
const m14_anv = collect((m14_a1v..., m14_a2v..., m14_a3v...))
560+
const m14_bnv = collect((m14_b1v..., m14_b2v..., m14_b3v...))
561+
const m14_a_spl = Spline1D(m14_xn, m14_anv, bc="nearest")
562+
const m14_b_spl = Spline1D(m14_xn, m14_bnv, bc="nearest")
563+
564+
"""
565+
M14(;Rv=3.1)
566+
567+
Maiz Apellaniz et al (2014) Milky Way & LMC R(V) dependent model.
568+
569+
Returns E(B-V) in magnitudes at the given wavelength relative to the
570+
extinction. The published UV extinction curve is identical to Clayton,
571+
Cardelli, and Mathis (1989, CCM). Forcing the optical section to match smoothly
572+
with CCM introduces a non-physical feature at high values of R5495 around 3.9
573+
inverse microns; see section 5 in Maiz Apellaniz et al. (2014) for more
574+
discussion. For that reason, we provide the M14 model only through 3.3 inverse
575+
microns, the limit of the optical in CCM. Outside of that range this will
576+
return 0. Rv is the selective extinction and is valid over [2, 6]. A typical
577+
value for the Milky Way is 3.1. R5495 = A(5485)/E(4405-5495) Spectral
578+
equivalent to photometric R(V).
579+
580+
# References
581+
[Maiz Apellaniz et al. (2014)](https://ui.adsabs.harvard.edu/abs/2014A%26A...564A..63M/)
582+
"""
583+
@with_kw struct M14 <: ExtinctionLaw
584+
Rv::Float64 = 3.1
585+
end
586+
587+
function (law::M14)(wave::T) where T
588+
checkbounds(law, wave) || return zero(float(T))
589+
x = aa_to_invum(wave)
590+
return m14_invum(x, law.Rv)
591+
end
592+
593+
bounds(::Type{M14}) = (3030.3, 33333.3)
594+
595+
"""
596+
DustExtinction.m14_invum(x, Rv)
597+
598+
The algorithm used for the [`M14`](@ref) extinction law, given inverse microns and Rv. For more information, seek the original paper.
599+
"""
600+
function m14_invum(x::Real, Rv::Real)
601+
if !(0.3 <= x <= 3.3)
602+
error("out of bounds of M14, support is over $(bounds(M14)) angstrom")
603+
end
604+
605+
a = zero(x)
606+
b = zero(x)
607+
if x < m14_xi1
608+
# Infrared
609+
a = 0.574 * x^1.61
610+
b = -0.527 * x^1.61
611+
elseif x < m14_xi3
612+
# Optical
613+
a = m14_a_spl(x)
614+
b = m14_b_spl(x)
615+
end
616+
617+
return a + b / Rv
618+
end

test/color_laws.jl

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ using DustExtinction: ccm89_invum,
88
ccm89_cb,
99
f99_invum,
1010
f04_invum,
11-
f19_invum
11+
f19_invum,
12+
m14_invum
1213

1314
@testset "helper" begin
1415
@test aa_to_invum(10000) 1
@@ -363,3 +364,40 @@ end
363364
@test ustrip.(reddening) ref_values[rv] rtol = 0.016
364365
end
365366
end
367+
368+
@testset "M14" begin
369+
# using R5495 = 3.1
370+
371+
x_inv_microns = [0.5, 2.0]
372+
wave = 1e4 ./ x_inv_microns
373+
374+
ref_values = Dict(
375+
3.1 => [0.1323, 1.141]
376+
)
377+
378+
# test defaults
379+
@test M14().(wave) ref_values[3.1] rtol = 0.016
380+
381+
for rv in keys(ref_values)
382+
law = M14(Rv = rv)
383+
output = @inferred map(law, wave)
384+
@test output ref_values[rv] rtol = 0.016
385+
386+
bad_waves = [100, 4e4]
387+
@test @inferred(map(law, bad_waves)) == zeros(length(bad_waves))
388+
@test_throws ErrorException m14_invum(aa_to_invum(bad_waves[1]), rv)
389+
@test_throws ErrorException m14_invum(aa_to_invum(bad_waves[2]), rv)
390+
391+
# uncertainties
392+
noise = rand(length(wave)) .* 0.01
393+
wave_unc = wave noise
394+
reddening = map(w -> @uncertain(law(w)), wave_unc)
395+
@test Measurements.value.(reddening) ref_values[rv] rtol = 1e-3
396+
397+
# Unitful
398+
wave_u = wave * u"angstrom"
399+
reddening = @inferred map(law, wave_u)
400+
@test eltype(reddening) <: Gain
401+
@test ustrip.(reddening) ref_values[rv] rtol = 0.016
402+
end
403+
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ include("fittable_laws.jl")
1111
include("mixture_laws.jl")
1212

1313
@testset "interfaces" begin
14-
for LAW in [CCM89, OD94, CAL00, GCC09, VCG04, FM90, G16, F99, F04, F19]
14+
for LAW in [CCM89, OD94, CAL00, GCC09, VCG04, FM90, G16, F99, F04, F19, M14]
1515
@test bounds(LAW) == bounds(LAW())
1616
@test checkbounds(LAW, 1000) == checkbounds(LAW(), 1000)
1717
low, high = bounds(LAW)

0 commit comments

Comments
 (0)