Skip to content

Commit

Permalink
small fixes to scatteringmodels and kzetafinders
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna Tartaglia committed Jul 27, 2023
1 parent ae76807 commit 7d74808
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/kzetafinders/periodicboxcar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ end

# Equation 47 of Psaltis et al. 2018.
@inline function kzetafinder_equation(kzeta, finder::PeriodicBoxCar_KzetaFinder)
k̃zeta .= π ./ (1 .+ kzeta)
return sin(k̃zeta) ./ k̃zeta .- finder.ζ0
k̃zeta = π ./ (1 .+ kzeta)
return sin.(k̃zeta) ./ k̃zeta .- finder.ζ0
end
6 changes: 3 additions & 3 deletions src/scatteringmodels/models/dipole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The default numbers are based on the best-fit parameters presented in Johnson et
- `D_pc::Number`: The distance from the observer to the scattering screen in pc.
- `R_pc::Number`: The distance from the source to the scattering screen in pc.
"""
struct DipoleScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
struct DipoleScatteringModel{T<:Number} <: AbstractScatteringModel
# Mandatory fields for AbstractScatteringModel
# fundamental parameters
α::T
Expand All @@ -27,8 +27,8 @@ struct DipoleScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
θmin::T
ϕpa::T
λ0::T
R::T
D::T
R::T

# precomputed constants
M::T
Expand Down Expand Up @@ -78,7 +78,7 @@ struct DipoleScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
Bmaj = calc_Bmaj(α, ϕ0, Pϕfunc, B_prefac)
Bmin = calc_Bmin(α, ϕ0, Pϕfunc, B_prefac)

return new{typeof(α),Function}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, R_pc, D_pc, M, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
return new{typeof(α)}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, D_pc, R_pc, M, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
end
end

Expand Down
9 changes: 5 additions & 4 deletions src/scatteringmodels/models/periodicboxcar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The default numbers are based on the best-fit parameters presented in Johnson et
- `D_pc::Number`: The distance from the observer to the scattering screen in pc.
- `R_pc::Number`: The distance from the source to the scattering screen in pc.
"""
struct PeriodicBoxCarScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
struct PeriodicBoxCarScatteringModel{T<:Number} <: AbstractScatteringModel
# Mandatory fields for AbstractScatteringModel
# fundamental parameters
α::T
Expand All @@ -26,8 +26,9 @@ struct PeriodicBoxCarScatteringModel{T<:Number,F<:Function} <: AbstractScatterin
θmin::T
ϕpa::T
λ0::T
R::T
D::T
R::T

# precomputed constants
M::T
ζ0::T
Expand All @@ -41,7 +42,7 @@ struct PeriodicBoxCarScatteringModel{T<:Number,F<:Function} <: AbstractScatterin
Amin::T
ϕ0::T

function PeriodicBoxCarScatteringModel(; α=1.38, rin_cm=800e5, θmaj_mas=1.380, θmin_mas=0.703, ϕpa_deg=81.9, λ0_cm=1.0, D_pc=2.82, R_pc=5.53)
function PeriodicBoxCarScatteringModel(; α=1.38, rin_cm=800e5, θmaj_mas=1.380, θmin_mas=0.703, ϕpa_deg=81.9, λ0_cm=1.0, R_pc=5.53, D_pc=2.82)
# compute asymmetry parameters and magnification parameter
A = calc_A(θmaj_mas, θmin_mas)
ζ0 = calc_ζ0(A)
Expand Down Expand Up @@ -74,7 +75,7 @@ struct PeriodicBoxCarScatteringModel{T<:Number,F<:Function} <: AbstractScatterin
Bmaj = calc_Bmaj(α, ϕ0, Pϕfunc, B_prefac)
Bmin = calc_Bmin(α, ϕ0, Pϕfunc, B_prefac)

return new{typeof(α),Function}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, M, R, D, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
return new{typeof(α)}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, D_pc, R_pc, M, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
end
end

Expand Down
9 changes: 5 additions & 4 deletions src/scatteringmodels/models/vonmises.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The default numbers are based on the best-fit parameters presented in Johnson et
- `D_pc::Number`: The distance from the observer to the scattering screen in pc.
- `R_pc::Number`: The distance from the source to the scattering screen in pc.
"""
struct vonMisesScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
struct vonMisesScatteringModel{T<:Number} <: AbstractScatteringModel
# Mandatory fields for AbstractScatteringModel
# fundamental parameters
α::T
Expand All @@ -26,8 +26,9 @@ struct vonMisesScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
θmin::T
ϕpa::T
λ0::T
R::T
D::T
R::T

# precomputed constants
M::T
ζ0::T
Expand All @@ -41,7 +42,7 @@ struct vonMisesScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
Amin::T
ϕ0::T

function vonMisesScatteringModel(; α=1.38, rin_cm=800e5, θmaj_mas=1.380, θmin_mas=0.703, ϕpa_deg=81.9, λ0_cm=1.0, D_pc=2.82, R_pc=5.53)
function vonMisesScatteringModel(; α=1.38, rin_cm=800e5, θmaj_mas=1.380, θmin_mas=0.703, ϕpa_deg=81.9, λ0_cm=1.0, R_pc=5.53, D_pc=2.82)
# compute asymmetry parameters and magnification parameter
A = calc_A(θmaj_mas, θmin_mas)
ζ0 = calc_ζ0(A)
Expand Down Expand Up @@ -74,7 +75,7 @@ struct vonMisesScatteringModel{T<:Number,F<:Function} <: AbstractScatteringModel
Bmaj = calc_Bmaj(α, ϕ0, Pϕfunc, B_prefac)
Bmin = calc_Bmin(α, ϕ0, Pϕfunc, B_prefac)

return new{typeof(α),Function}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, M, R, D, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
return new{typeof(α)}(α, rin_cm, θmaj_mas, θmin_mas, ϕpa_deg, λ0_cm, D_pc, R_pc, M, ζ0, A, kζ, Bmaj, Bmin, Qbar, C, Amaj, Amin, ϕ0)
end
end

Expand Down

0 comments on commit 7d74808

Please sign in to comment.