|
1 | | -using Dierckx |
| 1 | +using Dierckx, DelimitedFiles |
2 | 2 |
|
3 | 3 | # Convenience function for wavelength conversion |
4 | 4 | @inline aa_to_invum(wave::Real) = 10000 / wave |
@@ -453,16 +453,74 @@ function f04_invum(x::Real, Rv::Real) |
453 | 453 | ) |
454 | 454 | end |
455 | 455 |
|
| 456 | +""" |
| 457 | + F19(;Rv=3.1) |
| 458 | +
|
| 459 | +Fitzpatrick (2019) dust law. |
| 460 | +
|
| 461 | +Returns E(B-V) in magnitudes at the given wavelength relative to the |
| 462 | +extinction. This model applies to the UV and optical to NIR spectral range. |
| 463 | +The default support is [1149, 33333] Å. Outside of that range this will return |
| 464 | +0. Rv is the selective extinction and is valid over [2, 6]. A typical value for |
| 465 | +the Milky Way is 3.1. |
| 466 | +
|
| 467 | +Fitzpatrick, Massa, Gordon et al. (2019, ApJ, 886, 108) model. Based on a |
| 468 | +sample of stars observed spectroscopically in the optical with HST/STIS. |
| 469 | +
|
| 470 | +# References |
| 471 | +[Fitzpatrick (2019)](https://ui.adsabs.harvard.edu/abs/2019ApJ...886..108F/) |
| 472 | +""" |
| 473 | +@with_kw struct F19 <: ExtinctionLaw |
| 474 | + Rv::Float64 = 3.1 |
| 475 | +end |
| 476 | + |
| 477 | +function (law::F19)(wave::T) where T |
| 478 | + checkbounds(law, wave) || return zero(float(T)) |
| 479 | + x = aa_to_invum(wave) |
| 480 | + return f19_invum(x, law.Rv) |
| 481 | +end |
| 482 | + |
| 483 | +bounds(::Type{F19}) = (1149.4, 33333.3) |
| 484 | + |
| 485 | +""" |
| 486 | + DustExtinction.f19_invum(x, Rv) |
| 487 | +
|
| 488 | +The algorithm used for the [`F19`](@ref) extinction law, given inverse microns |
| 489 | +and Rv. For more information, seek the original paper. |
| 490 | +""" |
| 491 | +function f19_invum(x::Real, Rv::Real) |
| 492 | + # read and unpack tabulated data |
| 493 | + data_x, data_k, data_delta_k, data_sigma_k = let data = readdlm(joinpath(datadep"F19", "F19_tabulated.dat"), skipstart=1) |
| 494 | + (data[:, i] for i in 1:4) |
| 495 | + end |
| 496 | + |
| 497 | + if !(0.3 <= x <= 8.7) |
| 498 | + error("out of bounds of F19, support is over $(bounds(F19)) angstrom") |
| 499 | + end |
| 500 | + |
| 501 | + # compute E(lambda-55)/E(B-55) on the tabulated x points |
| 502 | + k_rV_tab_x = @. data_k + data_delta_k * (Rv - 3.10) * 0.990 |
| 503 | + |
| 504 | + # setup spline interpolation |
| 505 | + spl = Spline1D(collect(data_x), collect(k_rV_tab_x), k=3) |
| 506 | + |
| 507 | + # use spline interpolation to evaluate the curve for the input x values |
| 508 | + k_rV = spl(x) |
| 509 | + |
| 510 | + # convert to A(x)/A(55) from E(x-55)/E(44-55) |
| 511 | + a_rV = k_rV / Rv + 1.0 |
| 512 | + |
| 513 | + return a_rV |
| 514 | +end |
| 515 | + |
456 | 516 | # Optical |
457 | 517 | const m14_x1 = (1.0) |
458 | 518 | const m14_xi1 = first(m14_x1) |
459 | 519 | const m14_x2 = (1.15, 1.81984, 2.1, 2.27015, 2.7) |
460 | 520 | const m14_x3 = (3.5, 3.9, 4.0, 4.1, 4.2) |
461 | 521 | const m14_xi3 = last(m14_x3) |
462 | 522 | const m14_a1v = 0.574 * m14_x1^1.61 |
463 | | -#const m14_a1d = 0.574 * 1.61 * m14_xi1^0.61 |
464 | 523 | const m14_b1v = -0.527 * m14_x1^1.61 |
465 | | -#const m14_b1d = -0.527 * 1.61 * m14_xi1^0.61 |
466 | 524 | const m14_x2_diff = m14_x2 .- 1.82 |
467 | 525 | const m14_a2v = @. ( |
468 | 526 | 1 |
@@ -491,14 +549,12 @@ const m14_a3v = @. ( |
491 | 549 | - 0.104 / ((m14_x3 - 4.67)^2 + 0.341) |
492 | 550 | + (0.442, 0.341, 0.130, 0.020, 0.000) |
493 | 551 | ) |
494 | | -#const m14_a3d = -0.316 + 0.104 * 2.0 * (m14_xi3 - 4.67) / ((m14_xi3 - 4.67)^2 + 0.341)^2 |
495 | 552 | const m14_b3v = @. ( |
496 | 553 | -3.090 |
497 | 554 | + 1.825 * m14_x3 |
498 | 555 | + 1.206 / ((m14_x3 - 4.62)^2 + 0.263) |
499 | 556 | - (1.256, 1.021, 0.416, 0.064, 0.000) |
500 | 557 | ) |
501 | | -#const m14_b3d = 1.825 - 1.206 * 2 * (m14_xi3 - 4.62) / ((m14_xi3 - 4.62)^2 + 0.263)^2 |
502 | 558 | const m14_xn = collect((m14_x1..., m14_x2..., m14_x3...)) |
503 | 559 | const m14_anv = collect((m14_a1v..., m14_a2v..., m14_a3v...)) |
504 | 560 | const m14_bnv = collect((m14_b1v..., m14_b2v..., m14_b3v...)) |
|
0 commit comments