Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate away from Dierckx.jl #54

Merged
merged 7 commits into from
Feb 13, 2025
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ license = "MIT"
version = "0.11.2"

[deps]
BSplineKit = "093aae92-e908-43d7-9660-e50ee39d5a0a"
DataDeps = "124859b0-ceae-595e-8997-d05f6a7a8dfe"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
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"
DataDeps = "0.7"
icweaver marked this conversation as resolved.
Show resolved Hide resolved
DelimitedFiles = "1"
Dierckx = "0.4, 0.5"
FITSIO = "0.13.0, 0.14, 0.15, 0.16.1, 0.17"
Parameters = "0.12"
Unitful = "0.17.0, 1"
Expand Down
11 changes: 0 additions & 11 deletions src/DustExtinction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ function __init__()
"84891a59054adab44a7be54051e4dcf0e66e3f13eee0d845ce3739242f553b83"]
)
)
register(
DataDep(
"F19",
"""
Tabulated data from Fitzpatrick et al (2019) extinction model calculation
Paper: https://ui.adsabs.harvard.edu/abs/2019ApJ...886..108F
""",
["https://raw.githubusercontent.com/karllark/dust_extinction/master/dust_extinction/data/F19_tabulated.dat"],
["34011693065bba25396085823ab1df43c058336a95da7d4fdb567f03103b35bc"]
)
)
end

end # module
2 changes: 1 addition & 1 deletion src/color_laws.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dierckx
using BSplineKit: interpolate, BSplineOrder, Natural
using DelimitedFiles

# Convenience function for wavelength conversion
Expand Down
119 changes: 111 additions & 8 deletions src/color_laws/fitzpatrick.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function _curve_F99_method(
y_splineval_optir = (0.0, optnir_axav_y...)
spline_x = (x_splineval_optir..., f99_x_splineval_uv...)
spline_y = (y_splineval_optir..., y_splineval_uv...)
spl = Spline1D(collect(spline_x), collect(spline_y), k=3)
spl = interpolate(collect(spline_x), collect(spline_y), BSplineOrder(4))
axav = spl(x)
end

Expand Down Expand Up @@ -254,28 +254,131 @@ end

bounds(::Type{F19}) = (1149.4252873563219, 33333.333333333336)

# read and unpack tabulated data
# from https://raw.githubusercontent.com/karllark/dust_extinction/refs/heads/master/dust_extinction/data/F19_tabulated.dat
# TODO: Consider other places to store and track this dataset. See discussion in https://github.com/JuliaAstro/DustExtinction.jl/pull/54
const f99_x, f99_k, f99_delta_k, _ = eachcol([
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
])

"""
DustExtinction.f19_invum(x, Rv)

The algorithm used for the [`F19`](@ref) extinction law, given inverse microns
and Rv. For more information, seek the original paper.
"""
function f19_invum(x::Real, Rv::Real)
# read and unpack tabulated data
data_x, data_k, data_delta_k, data_sigma_k = let data = readdlm(joinpath(datadep"F19", "F19_tabulated.dat"), skipstart=1)
(data[:, i] for i in 1:4)
end

if !(0.3 <= x <= 8.7)
throw(DomainError(
x, "out of bounds of F19, support is over $(bounds(F19)) angstrom"))
end

# compute E(lambda-55)/E(B-55) on the tabulated x points
k_rV_tab_x = @. data_k + data_delta_k * (Rv - 3.10) * 0.990
k_rV_tab_x = @. f99_k + f99_delta_k * (Rv - 3.10) * 0.990

# setup spline interpolation
spl = Spline1D(collect(data_x), collect(k_rV_tab_x), k=3)
spl = interpolate(f99_x, k_rV_tab_x, BSplineOrder(4))

# use spline interpolation to evaluate the curve for the input x values
k_rV = spl(x)
Expand Down
4 changes: 2 additions & 2 deletions src/color_laws/m14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const m14_b3v = @. (
const m14_xn = collect((m14_x1..., m14_x2..., m14_x3...))
const m14_anv = collect((m14_a1v..., m14_a2v..., m14_a3v...))
const m14_bnv = collect((m14_b1v..., m14_b2v..., m14_b3v...))
const m14_a_spl = Spline1D(m14_xn, m14_anv, bc="nearest")
const m14_b_spl = Spline1D(m14_xn, m14_bnv, bc="nearest")
const m14_a_spl = interpolate(m14_xn, m14_anv, BSplineOrder(4), Natural())
const m14_b_spl = interpolate(m14_xn, m14_bnv, BSplineOrder(4), Natural())

"""
M14(;Rv=3.1)
Expand Down
Loading