Skip to content

Commit 5df577f

Browse files
feat(EarthProps): add convert.jl for type conversion utilities
1 parent f0c23c3 commit 5df577f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/EarthProps/convert.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Base.convert(::Type{EarthLayer{T}}, L::EarthLayer) where {T<:REALSCALAR} =
2+
EarthLayer{T}(
3+
_coerce_scalar_to_T(L.base_rho_g, T),
4+
_coerce_scalar_to_T(L.base_epsr_g, T),
5+
_coerce_scalar_to_T(L.base_mur_g, T),
6+
_coerce_scalar_to_T(L.t, T),
7+
_coerce_array_to_T(L.rho_g, T),
8+
_coerce_array_to_T(L.eps_g, T),
9+
_coerce_array_to_T(L.mu_g, T),
10+
)
11+
12+
Base.convert(::Type{EarthModel{T}}, M::EarthModel) where {T<:REALSCALAR} =
13+
EarthModel{T}(M.freq_dependence, M.vertical_layers, convert.(EarthLayer{T}, M.layers))
14+
15+
Base.convert(::Type{EarthModel{T}}, M::EarthModel{T}) where {T<:REALSCALAR} = M
16+
Base.convert(::Type{EarthLayer{T}}, L::EarthLayer{T}) where {T<:REALSCALAR} = L

0 commit comments

Comments
 (0)