From ed36a2f6e34567a14887cf2811ec7787f124f062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20P=C3=A9rez?= Date: Tue, 2 Apr 2024 19:04:25 +0200 Subject: [PATCH] Rename PlanetaryEphemerisSerialization -> TaylorInterpolantSerialization (#37) --- Project.toml | 2 +- src/PlanetaryEphemeris.jl | 2 +- .../TaylorInterpolantNSerialization.jl | 2 +- ...n.jl => TaylorInterpolantSerialization.jl} | 19 +++++++++++-------- test/propagation.jl | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) rename src/interpolation/{PlanetaryEphemerisSerialization.jl => TaylorInterpolantSerialization.jl} (69%) diff --git a/Project.toml b/Project.toml index b56cf65..f45b8bd 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/PlanetaryEphemeris.jl b/src/PlanetaryEphemeris.jl index bb67b67..dfd73aa 100644 --- a/src/PlanetaryEphemeris.jl +++ b/src/PlanetaryEphemeris.jl @@ -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") diff --git a/src/interpolation/TaylorInterpolantNSerialization.jl b/src/interpolation/TaylorInterpolantNSerialization.jl index 33c6c2d..df8b8bc 100644 --- a/src/interpolation/TaylorInterpolantNSerialization.jl +++ b/src/interpolation/TaylorInterpolantNSerialization.jl @@ -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 \ No newline at end of file diff --git a/src/interpolation/PlanetaryEphemerisSerialization.jl b/src/interpolation/TaylorInterpolantSerialization.jl similarity index 69% rename from src/interpolation/PlanetaryEphemerisSerialization.jl rename to src/interpolation/TaylorInterpolantSerialization.jl index cc5df78..d9da52e 100644 --- a/src/interpolation/PlanetaryEphemerisSerialization.jl +++ b/src/interpolation/TaylorInterpolantSerialization.jl @@ -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. @@ -12,7 +12,7 @@ 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 @@ -20,13 +20,16 @@ struct PlanetaryEphemerisSerialization{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 @@ -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 @@ -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 \ No newline at end of file diff --git a/test/propagation.jl b/test/propagation.jl index 1cdb093..708f012 100644 --- a/test/propagation.jl +++ b/test/propagation.jl @@ -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")