Skip to content

Commit

Permalink
Rename PlanetaryEphemerisSerialization -> TaylorInterpolantSerialization
Browse files Browse the repository at this point in the history
  • Loading branch information
PerezHz committed Apr 2, 2024
1 parent ed4165e commit aff4a36
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PlanetaryEphemeris"
uuid = "d83715d0-7e5f-11e9-1a59-4137b20d8363"
authors = ["Jorge A. Pérez Hernández", "Luis Benet", "Luis Eduardo Ramírez Montoya"]
version = "0.8.2"
version = "0.8.3"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
2 changes: 1 addition & 1 deletion src/PlanetaryEphemeris.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include("constants.jl")
include("jpl-de-430-431-earth-orientation-model.jl")
include("initial_conditions.jl")
include("interpolation/TaylorInterpolant.jl")
include("interpolation/PlanetaryEphemerisSerialization.jl")
include("interpolation/TaylorInterpolantSerialization.jl")
include("interpolation/TaylorInterpolantNSerialization.jl")
include("propagation.jl")
include("osculating.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/interpolation/TaylorInterpolantNSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ function convert(::Type{TaylorInterpolant{T, TaylorN{T}, 2, Vector{T}, Matrix{Ta
return TaylorInterpolant{T, TaylorN{T}, 2}(eph.t0, eph.t, x)
end

function convert(::Type{TaylorInterpolant{T, TaylorN{T}, 2}}, eph::PlanetaryEphemerisSerialization{T}) where {T<:Real}
function convert(::Type{TaylorInterpolant{T, TaylorN{T}, 2}}, eph::TaylorInterpolantSerialization{T}) where {T<:Real}
return convert(TaylorInterpolant{T, TaylorN{T}, 2, Vector{T}, Matrix{Taylor1{TaylorN{T}}}}, eph)
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Custom serialization

@doc raw"""
PlanetaryEphemerisSerialization{T}
TaylorInterpolantSerialization{T}
Custom serialization struct to save a `TaylorInterpolant{T, T, 2}` to a `.jld2` file.
Expand All @@ -12,21 +12,24 @@ Custom serialization struct to save a `TaylorInterpolant{T, T, 2}` to a `.jld2`
- `t::Vector{T}`: vector of times.
- `x::Vector{T}`: vector of coefficients.
"""
struct PlanetaryEphemerisSerialization{T}
struct TaylorInterpolantSerialization{T}
order::Int
dims::Tuple{Int, Int}
t0::T
t::Vector{T}
x::Vector{T}
end

# Tell JLD2 to save TaylorInterpolant{T, T, 2} as PlanetaryEphemerisSerialization{T}
# backwards-compatibility alias
const PlanetaryEphemerisSerialization{T} = TaylorInterpolantSerialization{T} where {T}

# Tell JLD2 to save TaylorInterpolant{T, T, 2} as TaylorInterpolantSerialization{T}
function writeas(::Type{<:TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}}) where {T<:Real}
return PlanetaryEphemerisSerialization{T}
return TaylorInterpolantSerialization{T}
end

# Convert method to write .jld2 files
function convert(::Type{PlanetaryEphemerisSerialization{T}}, eph::TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}) where {T <: Real}
function convert(::Type{TaylorInterpolantSerialization{T}}, eph::TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}) where {T <: Real}
# Taylor polynomials order
order = eph.x[1, 1].order
# Number of coefficients in each polynomial
Expand All @@ -42,11 +45,11 @@ function convert(::Type{PlanetaryEphemerisSerialization{T}}, eph::TaylorInterpol
x[(i-1)*k+1 : i*k] = eph.x[i].coeffs
end

return PlanetaryEphemerisSerialization{T}(order, dims, eph.t0, eph.t, x)
return TaylorInterpolantSerialization{T}(order, dims, eph.t0, eph.t, x)
end

# Convert method to read .jld2 files
function convert(::Type{TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}}, eph::PlanetaryEphemerisSerialization{T}) where {T<:Real}
function convert(::Type{TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}}, eph::TaylorInterpolantSerialization{T}) where {T<:Real}
# Taylor polynomials order
order = eph.order
# Number of coefficients in each polynomial
Expand All @@ -65,6 +68,6 @@ function convert(::Type{TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}
return TaylorInterpolant{T, T, 2}(eph.t0, eph.t, x)
end

function convert(::Type{TaylorInterpolant{T, T, 2}}, eph::PlanetaryEphemerisSerialization{T}) where {T<:Real}
function convert(::Type{TaylorInterpolant{T, T, 2}}, eph::TaylorInterpolantSerialization{T}) where {T<:Real}
return convert(TaylorInterpolant{T, T, 2, Vector{T}, Matrix{Taylor1{T}}}, eph)
end
4 changes: 2 additions & 2 deletions test/propagation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ using LinearAlgebra: norm
sol1N = TaylorInterpolant(sol.t0, sol.t, sol.x .+ Taylor1(dq[1], 25))
@test sol1N(sol.t0)() == sol(sol.t0)
@test sol1N(tmid)() == sol(tmid)
# Test PlanetaryEphemerisSerialization
@test JLD2.writeas(typeof(sol)) == PlanetaryEphemeris.PlanetaryEphemerisSerialization{Float64}
# Test TaylorInterpolantSerialization
@test JLD2.writeas(typeof(sol)) == PlanetaryEphemeris.TaylorInterpolantSerialization{Float64}
jldsave("test.jld2"; sol)
sol_file = JLD2.load("test.jld2", "sol")
rm("test.jld2")
Expand Down

0 comments on commit aff4a36

Please sign in to comment.