Skip to content

Commit

Permalink
Rename PlanetaryEphemerisSerialization -> TaylorInterpolantSerializat…
Browse files Browse the repository at this point in the history
…ion (#37)
  • Loading branch information
PerezHz authored Apr 2, 2024
1 parent ed4165e commit ed36a2f
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

2 comments on commit ed36a2f

@PerezHz
Copy link
Owner Author

@PerezHz PerezHz commented on ed36a2f Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/104086

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.3 -m "<description of version>" ed36a2f6e34567a14887cf2811ec7787f124f062
git push origin v0.8.3

Please sign in to comment.