From 5cef34b239e2f3db54d1045b05a5fd6414a5fe2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Eduardo=20Ram=C3=ADrez=20Montoya?= Date: Tue, 26 Dec 2023 11:51:43 -0600 Subject: [PATCH] tsanightorder & naive maxsteps --- src/orbit_determination/gauss_method.jl | 19 ----------------- .../orbit_determination.jl | 21 +++++++++++++++++++ src/orbit_determination/tooshortarc.jl | 18 ++++++++++++---- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/orbit_determination/gauss_method.jl b/src/orbit_determination/gauss_method.jl index 64cbe22e..51bb1d73 100755 --- a/src/orbit_determination/gauss_method.jl +++ b/src/orbit_determination/gauss_method.jl @@ -413,25 +413,6 @@ function gauss_triplets(dates::Vector{DateTime}, max_triplets::Int = 10, max_ite return triplets[1:n] end -@doc raw""" - adaptative_maxsteps(radec::Vector{RadecMPC{T}}) where {T <: AbstractFloat} - -Empirical upper bound for the number of steps used for propagation. -""" -function adaptative_maxsteps(radec::Vector{RadecMPC{T}}) where {T <: AbstractFloat} - # Time difference [ms] - Δ_ms = getfield(date(radec[end]) - date(radec[1]), :value) - # Time difference [days] - Δ_day = Δ_ms / 86_400_000 - # Adaptative maxsteps - if Δ_day <= 30 - return 55 - floor(Int, 5*Δ_day/6) - else - return ceil(Int, (Δ_day + 360)/13) - end -end - - @doc raw""" gaussinitcond(radec::Vector{RadecMPC{T}}, nights::Vector{ObservationNight{T}}, params::Parameters{T}) where {T <: AbstractFloat} diff --git a/src/orbit_determination/orbit_determination.jl b/src/orbit_determination/orbit_determination.jl index 4fc424a7..8665f585 100644 --- a/src/orbit_determination/orbit_determination.jl +++ b/src/orbit_determination/orbit_determination.jl @@ -26,6 +26,27 @@ function istsa(sol::NEOSolution{T, T}) where {T <: AbstractFloat} return length(sol.nights) < 3 || numberofdays(sol.nights) < 1 end +@doc raw""" + adaptative_maxsteps(radec::Vector{RadecMPC{T}}) where {T <: AbstractFloat} + +Empirical upper bound for the number of steps used for propagation. +""" +function adaptative_maxsteps(radec::Vector{RadecMPC{T}}) where {T <: AbstractFloat} + #= + # Time difference [ms] + Δ_ms = getfield(date(radec[end]) - date(radec[1]), :value) + # Time difference [days] + Δ_day = Δ_ms / 86_400_000 + # Adaptative maxsteps + if Δ_day <= 30 + return 55 - floor(Int, 5*Δ_day/6) + else + return ceil(Int, (Δ_day + 360)/13) + end + =# + return 100 +end + @doc raw""" orbitdetermination(radec::Vector{RadecMPC{T}}, params::Parameters{T}) where {T <: AbstractFloat} diff --git a/src/orbit_determination/tooshortarc.jl b/src/orbit_determination/tooshortarc.jl index 9b2c7f1c..0b58c538 100644 --- a/src/orbit_determination/tooshortarc.jl +++ b/src/orbit_determination/tooshortarc.jl @@ -420,6 +420,15 @@ function tryls(radec::Vector{RadecMPC{T}}, nights::Vector{ObservationNight{T}}, end +# Order in which to check nights in tooshortarc +function tsanightorder(x::ObservationNight{T}, y::ObservationNight{T}) where {T <: AbstractFloat} + if x.nobs == y.nobs + return x.date > y.date + else + return x.nobs > y.nobs + end +end + @doc raw""" tooshortarc(radec::Vector{RadecMPC{T}}, nights::Vector{ObservationNight{T}}, params::Parameters{T}) where {T <: AbstractFloat} @@ -438,13 +447,14 @@ over the admissible region. """ function tooshortarc(radec::Vector{RadecMPC{T}}, nights::Vector{ObservationNight{T}}, params::Parameters{T}) where {T <: AbstractFloat} - - + # Allocate memory for output sol = zero(NEOSolution{T, T}) + # Sort nights by tsanightorder + idxs = sortperm(nights, lt = tsanightorder) - # Iterate observation nights (in reverse temporal order) - for i in reverse(eachindex(nights)) + # Iterate observation nights + for i in idxs # Admissible region A = AdmissibleRegion(nights[i]) # Center