Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Orbit Determination #31

Merged
merged 177 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
1b18aa8
Add QueryExt.jl
LuEdRaMo Jul 13, 2023
989681f
Minor fix in QueryExt.jl
LuEdRaMo Jul 13, 2023
b9dcfc5
Gauss initial conditions
LuEdRaMo Jul 14, 2023
9a62ff4
Remove show
LuEdRaMo Jul 14, 2023
23ddfdc
Change Query for DataFrames approach
LuEdRaMo Jul 15, 2023
82ccf9e
Minor fix in gauss_idxs
LuEdRaMo Jul 17, 2023
95d61ed
Change to Interpolations.jl
LuEdRaMo Jul 18, 2023
c17e016
Modify gauss_idxs
LuEdRaMo Jul 18, 2023
e19e0c6
Document new functions
LuEdRaMo Jul 19, 2023
8a53daf
Change gauss_idxs for gauss_triplets
LuEdRaMo Jul 19, 2023
9060e67
Fix gauss_triplets
LuEdRaMo Jul 19, 2023
4ec4fe8
Add Q_max kwarg to gaussinitcond
LuEdRaMo Jul 19, 2023
0ae1e2b
Minor fix
LuEdRaMo Jul 19, 2023
4edf7ba
Fix documentation typo
LuEdRaMo Jul 19, 2023
3855609
Fix propagate_root return
LuEdRaMo Jul 21, 2023
a3ccc88
Heliocentric energy
LuEdRaMo Aug 4, 2023
4ab88fb
Modify gauss_triplets
LuEdRaMo Aug 5, 2023
0346d4d
Change min delta
LuEdRaMo Aug 5, 2023
6c86a85
Minor fix
LuEdRaMo Aug 5, 2023
e1c7a88
Add tryls
LuEdRaMo Aug 5, 2023
605654d
Adaptative time delta
LuEdRaMo Aug 6, 2023
72dff6a
Minor correction
LuEdRaMo Aug 6, 2023
e7efe24
Modify gauss_triplets
LuEdRaMo Aug 6, 2023
f08c445
Relaxation factor
LuEdRaMo Aug 7, 2023
152dd47
Fix infinite while
LuEdRaMo Aug 8, 2023
30f7cd4
Fix M_
LuEdRaMo Aug 10, 2023
26a47c2
Change reduce from Date to TimeOfDay
LuEdRaMo Aug 12, 2023
45e1b6b
Add preliminary docstrings
LuEdRaMo Aug 13, 2023
3b8c42f
Try fit Gauss to full radec
LuEdRaMo Aug 14, 2023
501c5a5
Upgrade DF to fulldep
LuEdRaMo Aug 19, 2023
043ae2b
Minor fix
LuEdRaMo Aug 19, 2023
aa24c77
Equality of OrbitFit
LuEdRaMo Aug 20, 2023
e73bf72
Adaptative maxsteps
LuEdRaMo Aug 22, 2023
f50772e
HTTP/JSON for get_radec_mpc
LuEdRaMo Aug 22, 2023
6314e5e
Fix get_radec_mpc
LuEdRaMo Aug 23, 2023
95c232d
Fix adaptative maxsteps
LuEdRaMo Aug 25, 2023
9c995c9
Fix ra discontinuity
LuEdRaMo Aug 28, 2023
bfcc9de
Softer _gaussinitcond Val(2) condition
LuEdRaMo Aug 28, 2023
6daf1c8
Fix unfold and nrms
LuEdRaMo Aug 30, 2023
1a195cc
Fix Val(2) _gaussinitcond
LuEdRaMo Sep 2, 2023
4a4e323
New adaptative maxsteps
LuEdRaMo Sep 2, 2023
326d79c
Yet another adaptative maxsteps
LuEdRaMo Sep 3, 2023
b24c9af
Avoid loading debiasing table more than once
LuEdRaMo Sep 3, 2023
6a6b27d
Fix signatures
LuEdRaMo Sep 3, 2023
547adf6
Fix more signatures
LuEdRaMo Sep 3, 2023
361edd9
Update CatalogueMPC to new observations API
LuEdRaMo Sep 6, 2023
6f793ca
Update ObservatoryMPC to new observations API
LuEdRaMo Sep 8, 2023
43c4fbd
Minor fix
LuEdRaMo Sep 8, 2023
2dfa5d1
Update RadecMPC to new observations API
LuEdRaMo Sep 8, 2023
a867ede
Minor fixes
LuEdRaMo Sep 8, 2023
9ba3513
Try previous maxsteps
LuEdRaMo Sep 9, 2023
09bc141
Fix reduce_nights
LuEdRaMo Sep 10, 2023
5444d64
Yet another adaptative maxsteps
LuEdRaMo Sep 10, 2023
5a414e8
Fix tests
LuEdRaMo Sep 11, 2023
230c9a8
Fix obstech
LuEdRaMo Sep 13, 2023
5053558
Fix reduce_nights
LuEdRaMo Sep 18, 2023
22d7235
Fix discontinuity in reduce_nights
LuEdRaMo Sep 19, 2023
a963862
Fix residuals computation
LuEdRaMo Sep 20, 2023
a695584
Try adaptative triplets
LuEdRaMo Sep 20, 2023
9cb184c
Fix tests
LuEdRaMo Sep 22, 2023
50411b2
Add residual rejection
LuEdRaMo Sep 27, 2023
7efb86f
Remove nyears as orbitdet args
LuEdRaMo Sep 28, 2023
c0c5f92
Retry residual rejection
LuEdRaMo Sep 29, 2023
0cb68d2
Fix tests
LuEdRaMo Sep 29, 2023
44b20f6
Fix more tests
LuEdRaMo Sep 29, 2023
46d2526
Add preliminary gauss tests
LuEdRaMo Sep 30, 2023
6d0b20e
Fix Gauss tests
LuEdRaMo Sep 30, 2023
d5f3983
Comment out residual rejection
LuEdRaMo Oct 1, 2023
5222eec
Outlier rejection by mean point
LuEdRaMo Oct 3, 2023
5b5ae2a
Minor fixes
LuEdRaMo Oct 3, 2023
e110ce8
Another minor fix
LuEdRaMo Oct 4, 2023
b2ea7e8
Clustering outlier rejection criteria
LuEdRaMo Oct 8, 2023
5babc95
K-means clustering
LuEdRaMo Oct 8, 2023
8f75b60
Minor fix
LuEdRaMo Oct 8, 2023
5a1f3b9
Too Short Arc
Nov 25, 2023
ca76e8a
issinglearc
LuEdRaMo Nov 26, 2023
162d8ef
Fixes to tooshortarc
LuEdRaMo Dec 1, 2023
d670d64
Automatic scaling
LuEdRaMo Dec 4, 2023
b479dfa
Tiny object boundary
LuEdRaMo Dec 6, 2023
12e36e9
Minor fixes
LuEdRaMo Dec 9, 2023
914fe3b
Rebase to main
LuEdRaMo Dec 15, 2023
c360026
ObservationNight
LuEdRaMo Dec 19, 2023
7f37ac9
Fixes to Gauss Method
LuEdRaMo Dec 21, 2023
365b7d6
Minor fix
LuEdRaMo Dec 21, 2023
5ff0784
Update Gauss Method tests
LuEdRaMo Dec 21, 2023
fe9d054
Update Too Short Arc
LuEdRaMo Dec 22, 2023
7237c66
Update TSA tests
LuEdRaMo Dec 22, 2023
476e1ee
Update Outlier Rejection
LuEdRaMo Dec 23, 2023
924502c
Update Outlier Rejection tests
LuEdRaMo Dec 23, 2023
820e4e3
Minor fix
LuEdRaMo Dec 23, 2023
5cef34b
tsanightorder & naive maxsteps
LuEdRaMo Dec 26, 2023
12dbf5d
Fixes to TSA
LuEdRaMo Jan 2, 2024
0860144
Fix istsa
LuEdRaMo Jan 2, 2024
af451b6
Fix boundary_projection
LuEdRaMo Jan 2, 2024
0c10530
Add init to kmeans
LuEdRaMo Jan 3, 2024
0fc33c4
Minor fixes
LuEdRaMo Jan 4, 2024
fe7f6da
Polynomial fit
LuEdRaMo Jan 5, 2024
1d36ab1
Heel anomaly in tsa
LuEdRaMo Jan 6, 2024
074372e
Minor fix
LuEdRaMo Jan 7, 2024
db73ab3
Another minor fix
LuEdRaMo Jan 8, 2024
bf58bac
unsuccessful_propagation
LuEdRaMo Jan 10, 2024
ad9471a
Try reset CI.yml to origin/main
LuEdRaMo Jan 18, 2024
6b0307b
Reset .github/ and data/ to origin/main
LuEdRaMo Jan 18, 2024
9c10cee
Reset dev/ and notebooks/ to origin/main
LuEdRaMo Jan 18, 2024
d1d1829
Reset pha/ and scripts/ to origin/main
LuEdRaMo Jan 18, 2024
2b6f174
Reset NEOs.jl/ to origin/main
LuEdRaMo Jan 18, 2024
98d910e
Reset test/ to origin/main
LuEdRaMo Jan 18, 2024
5e04e42
Reset src/ to origin/main
LuEdRaMo Jan 18, 2024
add09b1
Remove .DS_Store
LuEdRaMo Jan 18, 2024
a8762e7
Merge main into lerm/gaussinitcond
LuEdRaMo Jan 19, 2024
635c4d8
OrbitFit -> LeastSquaresFit
LuEdRaMo Jan 23, 2024
eb903e8
Parameters -> NEOParameters
LuEdRaMo Jan 23, 2024
02190a4
issuccessfulprop
LuEdRaMo Jan 24, 2024
d416843
Merge branch 'main' into lerm/gaussinitcond
LuEdRaMo Jan 26, 2024
c81d6c4
ObservationNight -> Tracklet
LuEdRaMo Jan 26, 2024
5157a2f
Change all night refs to tracklet
LuEdRaMo Jan 26, 2024
78a873c
Add 2014 AA test
LuEdRaMo Jan 26, 2024
7207cb0
Add 2008 TC3 test
LuEdRaMo Jan 26, 2024
5052462
Minor fix
LuEdRaMo Jan 26, 2024
baeca58
Reduce fwdoffset in 2008 TC3 test
LuEdRaMo Jan 28, 2024
eb65604
Minor fix in constants.jl
LuEdRaMo Jan 28, 2024
2ec4c57
Update HORIZONS and TS
LuEdRaMo Feb 1, 2024
e285565
Update TaylorInterpolant
LuEdRaMo Feb 1, 2024
6fbd578
Minor fix
LuEdRaMo Feb 1, 2024
531c638
Add eph_su(ea) to NEOParameters
LuEdRaMo Feb 1, 2024
42a8243
Merge branch 'main' into lerm/gaussinitcond
LuEdRaMo Feb 1, 2024
7954699
Float64 -> T in AdmissibleRegion
LuEdRaMo Feb 1, 2024
b31f8ba
Minor fixes
LuEdRaMo Feb 4, 2024
5406a49
Light-time correction
LuEdRaMo Feb 4, 2024
62ef4fb
Minor fix
LuEdRaMo Feb 4, 2024
a13df5a
Incremental radec in TSA
LuEdRaMo Feb 5, 2024
dc6b02b
Minor fixes
LuEdRaMo Feb 7, 2024
f17c87c
Add Newtonian model as default dynamics for preliminary orbit determi…
PerezHz Feb 7, 2024
9aef38e
fetch_radec_mpc
LuEdRaMo Feb 7, 2024
7bc8349
H_max to NEOParameters
LuEdRaMo Feb 7, 2024
3a74d5b
nms(::NEOSolution)
LuEdRaMo Feb 8, 2024
71f7d51
log adam
LuEdRaMo Feb 11, 2024
93c743d
Isolate outlier_rejection
LuEdRaMo Feb 12, 2024
c8818f9
Qmax -> NEOParameters
LuEdRaMo Feb 12, 2024
a928d57
ecef_to_geocentric(::Vector{TaylorN}})
LuEdRaMo Feb 12, 2024
a1cebd7
Require julia v1.9+
LuEdRaMo Feb 13, 2024
c549877
Bump minor version
LuEdRaMo Feb 13, 2024
01ca829
Minor fixes
LuEdRaMo Feb 16, 2024
75ba60d
Add a_max to NEOParameters
LuEdRaMo Feb 24, 2024
d97c7b5
Minor fix
LuEdRaMo Feb 24, 2024
1db313f
Another minor fix
LuEdRaMo Feb 24, 2024
aebe00f
Yet more minor fixes
LuEdRaMo Feb 24, 2024
ac69f0e
Levenberg-Marquardt
LuEdRaMo Feb 24, 2024
b07d4f3
Update OD tests
LuEdRaMo Feb 25, 2024
1b8ae10
Minor fix
LuEdRaMo Feb 25, 2024
e8bf9bb
Some aesthetic fixes (#54)
PerezHz Feb 25, 2024
362331d
Update to TaylorSeries 0.17 (#58)
PerezHz Feb 27, 2024
c9099e4
Fix tests
PerezHz Feb 28, 2024
2643a10
Custom print for AdmissibleRegion
LuEdRaMo Mar 8, 2024
66c3e8b
Change Gauss/TSA order in OD
LuEdRaMo Mar 8, 2024
2957a5d
jplcompare
LuEdRaMo Mar 8, 2024
c025b76
Update Apophis script
PerezHz Mar 10, 2024
d9b9671
Custom print for NEOParameters
LuEdRaMo Mar 10, 2024
733a468
Update .gitignore
PerezHz Mar 20, 2024
3008fbd
Update some comments and docstrings
PerezHz Mar 20, 2024
a5d2680
Fix initial guess in LS
LuEdRaMo Mar 20, 2024
25c4c17
Allow jd0::U in tooshortarc
LuEdRaMo Mar 20, 2024
abf9496
Allow jdo::U in propagation
LuEdRaMo Mar 20, 2024
814d1e1
Fix first guess in LS
LuEdRaMo Mar 20, 2024
a54cf8f
propagate_params(..., ::NEOParameters{T})
LuEdRaMo Mar 20, 2024
b67b85e
Add some internal variables as kwargs in methods
PerezHz Mar 22, 2024
f623d92
Adapt diffcorr for idxs
LuEdRaMo Mar 23, 2024
3389d37
Reduce integrations in adam
LuEdRaMo Mar 23, 2024
640a065
Minor fix
LuEdRaMo Mar 23, 2024
d80b298
orbitdetermination(::Vector{RadecMPC}, ::NEOSolution,...)
LuEdRaMo Mar 23, 2024
74156be
Minor fix
LuEdRaMo Mar 23, 2024
5c206df
Test 2008 TC3 sigmas(sol1)
LuEdRaMo Mar 25, 2024
30762da
Spelling corrections in test/orbit_determination.jl
LuEdRaMo Mar 25, 2024
d7972f1
test/extensions.jl -> test/dataframe.jl
LuEdRaMo Mar 25, 2024
7902080
Rename test/dataframe.jl -> test/dataframes.jl
PerezHz Mar 26, 2024
8886cc4
Add commented test and TODO
PerezHz Mar 26, 2024
a0408eb
Remove dep (Tables) in tests environment
PerezHz Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ on:
paths-ignore:
- 'LICENSE.md'
- 'README.md'
pull_request:
branches:
- main
tags: '*'
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
Expand All @@ -27,7 +23,6 @@ jobs:
- 'nightly'
os:
- ubuntu-latest
- macos-latest
- windows-latest
arch:
- x64
Expand All @@ -43,9 +38,10 @@ jobs:
env:
JULIA_NUM_THREADS: 2
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- uses: coverallsapp/github-action@v2
with:
path-to-lcov: lcov.info
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ jldeph/
notebooks/figs
EOP_IAU*.TXT
Manifest.toml
*.DS_Store
.vscode
37 changes: 14 additions & 23 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name = "NEOs"
uuid = "b41c07a2-2abb-11e9-070a-c3c1b239e7df"
authors = ["Jorge A. Pérez Hernández", "Luis Benet", "Luis Eduardo Ramírez Montoya"]
version = "0.7.5"
version = "0.8.0"

[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand All @@ -14,55 +16,44 @@ HORIZONS = "5a3ac768-beb4-554a-9c98-3342fe3377f5"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Healpix = "9f4e344d-96bc-545a-84a3-ae6b9e1b672b"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
IntervalRootFinding = "d2bf35a9-74e0-55ec-b149-d360ff49b807"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
PlanetaryEphemeris = "d83715d0-7e5f-11e9-1a59-4137b20d8363"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Quadmath = "be4d8f0f-7fa4-5f49-b795-2f01399ab2dd"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
SPICE = "5bab7191-041a-5c2e-a744-024b9c3a5062"
SatelliteToolboxTransformations = "6b019ec1-7a1e-4f04-96c7-a9db1ca5514d"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TaylorIntegration = "92b13dbe-c966-51a2-8445-caca9f8a7d42"
TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[weakdeps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[extensions]
DataFramesExt = ["DataFrames", "Tables"]

[compat]
Artifacts = "1"
AutoHashEquals = "0.2"
Clustering = "0.15"
DataFrames = "1.5"
DelimitedFiles = "1"
Downloads = "1"
HORIZONS = "0.3"
HORIZONS = "0.4"
HTTP = "1.9.5"
Healpix = "4"
IntervalArithmetic = "0.20, 0.22"
IntervalRootFinding = "0.5.11"
JLD2 = "0.4"
JSON = "0.21"
LazyArtifacts = "1"
PlanetaryEphemeris = "0.7"
PlanetaryEphemeris = "0.8"
Quadmath = "0.5"
Requires = "0.5.2, 1"
SPICE = "0.2"
SatelliteToolboxTransformations = "0.1"
Scratch = "1.2"
StatsBase = "0.33, 0.34"
Tables = "1.10"
TaylorIntegration = "0.14"
TaylorSeries = "0.16"
julia = "1.6"

[extras]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
TaylorIntegration = "0.15"
TaylorSeries = "0.17"
julia = "1.9"
33 changes: 0 additions & 33 deletions ext/DataFramesExt.jl

This file was deleted.

2 changes: 1 addition & 1 deletion pha/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
TaylorIntegration = "92b13dbe-c966-51a2-8445-caca9f8a7d42"

[compat]
NEOs = "0.7"
NEOs = "0.8"
86 changes: 58 additions & 28 deletions pha/apophis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,41 +124,37 @@ function main(dynamics::D, maxsteps::Int, jd0_datetime::DateTime, nyears_bwd::T,
jd0 = datetime2julian(jd0_datetime)

print_header("Integrator warmup", 2)
_ = NEOs.propagate(dynamics, 1, jd0, nyears_fwd, q0, Val(true);
order, abstol, parse_eqs)
_ = NEOs.propagate_root(dynamics, 1, jd0, nyears_fwd, q0, Val(true);
order, abstol, parse_eqs)
params = NEOParameters(;maxsteps=1, order, abstol, parse_eqs)
_ = NEOs.propagate(dynamics, jd0, nyears_fwd, q0, params)
_ = NEOs.propagate_root(dynamics, jd0, nyears_fwd, q0, params)
println()

print_header("Main integration", 2)
tmax = nyears_bwd*yr
println("• Initial time of integration: ", string(jd0_datetime))
println("• Final time of integration: ", julian2datetime(jd0 + tmax))

sol_bwd = NEOs.propagate(dynamics, maxsteps, jd0, nyears_bwd, q0, Val(true);
order, abstol, parse_eqs)
params = NEOParameters(;maxsteps, order, abstol, parse_eqs)
sol_bwd = NEOs.propagate(dynamics, jd0, nyears_bwd, q0, params)
jldsave("Apophis_bwd.jld2"; sol_bwd)
# sol_bwd = JLD2.load("Apophis_bwd.jld2", "sol_bwd")

tmax = nyears_fwd*yr
println("• Initial time of integration: ", string(jd0_datetime))
println("• Final time of integration: ", julian2datetime(jd0 + tmax))

sol_fwd, tvS, xvS, gvS = NEOs.propagate_root(dynamics, maxsteps, jd0, nyears_fwd, q0, Val(true);
order, abstol, parse_eqs)
sol_fwd, tvS, xvS, gvS = NEOs.propagate_root(dynamics, jd0, nyears_fwd, q0, params)
jldsave("Apophis_fwd.jld2"; sol_fwd, tvS, xvS, gvS)
# sol_fwd = JLD2.load("Apophis_fwd.jld2", "sol_bwd")
println()

# load Solar System ephemeris
sseph::TaylorInterpolant{Float64,Float64,2} = loadpeeph(NEOs.sseph, sol_bwd.t0+sol_bwd.t[end], sol_fwd.t0+sol_fwd.t[end])
eph_su::TaylorInterpolant{Float64,Float64,2} = selecteph(sseph, su)
eph_ea::TaylorInterpolant{Float64,Float64,2} = selecteph(sseph, ea)
# Load Sun ephemeris
eph_su = selecteph(NEOs.sseph, su, sol_bwd.t0+sol_bwd.t[end], sol_fwd.t0+sol_fwd.t[end])
# Load Earth ephemeris
eph_ea = selecteph(NEOs.sseph, ea, sol_bwd.t0+sol_bwd.t[end], sol_fwd.t0+sol_fwd.t[end])

# NEO
# Apophis
# Change t, x, v units, resp., from days, au, au/day to sec, km, km/sec
xva_bwd(et) = auday2kmsec(sol_bwd(et/daysec)[1:6])
xva_fwd(et) = auday2kmsec(sol_fwd(et/daysec)[1:6])
xva(et) = bwdfwdeph(et, sol_bwd, sol_fwd)
# Earth
# Change x, v units, resp., from au, au/day to km, km/sec
Expand All @@ -177,7 +173,8 @@ function main(dynamics::D, maxsteps::Int, jd0_datetime::DateTime, nyears_bwd::T,
deldop = vcat(deldop_2005_2013,deldop_2021)

# Compute optical residuals
res_radec_all, w_radec_all = NEOs.residuals(radec; xvs, xve, xva)
_res_radec_all_ = NEOs.residuals(radec; xvs, xve, xva)
res_radec_all, w_radec_all = NEOs.unfold(_res_radec_all_)
jldsave("Apophis_res_w_radec.jld2"; res_radec_all, w_radec_all)
# JLD2.@load "Apophis_res_w_radec.jld2"

Expand Down Expand Up @@ -233,9 +230,9 @@ function main(dynamics::D, maxsteps::Int, jd0_datetime::DateTime, nyears_bwd::T,
res = vcat(res_radec, res_del, res_dop)
w = vcat(w_radec, w_del, w_dop)

success, δx_OR8, Γ_OR8 = newtonls(res, w, zeros(get_numvars()), 10)
x_OR8 = sol_fwd(sol_fwd.t0)(δx_OR8)
σ_OR8 = sqrt.(diag(Γ_OR8)).*scalings
fit_OR8 = newtonls(res, w, zeros(get_numvars()), 10)
x_OR8 = sol_fwd(sol_fwd.t0)(fit_OR8.x)
σ_OR8 = sqrt.(diag(fit_OR8.Γ)).*scalings

nradec = length(res_radec)
res_ra = view(res_radec, 1:nradec÷2)
Expand All @@ -248,19 +245,19 @@ function main(dynamics::D, maxsteps::Int, jd0_datetime::DateTime, nyears_bwd::T,
print_header("Orbital fit (8-DOF) and post-fit statistics", 2)

# orbital fit
println("Success flag : ", success, "\n")
println("Success flag : ", fit_OR8.success, "\n")
println("Nominal solution [au,au,au,au/d,au/d,au/d,au/d²,au/d²]: ", x_OR8, "\n")
println("1-sigma formal uncertainties [au,au,au,au/d,au/d,au/d,au/d²,au/d²]: ", σ_OR8, "\n")

# post-fit statistics
println("Normalized RMS (optical-only) [adimensional] : ", nrms(res_radec(δx_OR8),w_radec))
println("Normalized RMS (radar-only) [adimensional] : ", nrms(vcat(res_del,res_dop)(δx_OR8),vcat(w_del,w_dop)))
println("Normalized RMS (combined optical and radar) [adimensional] : ", nrms(res(δx_OR8),w), "\n")
println("Mean weighted right-ascension residual [arcseconds] : ", mean(res_ra(δx_OR8), weights(w_ra)))
println("Mean weighted declination residual [arcseconds] : ", mean(res_dec(δx_OR8), weights(w_dec)))
println("Mean weighted time-delay residual [micro-seconds]: ", mean(res_del(δx_OR8), weights(w_del)))
println("Mean weighted Doppler-shift residual [Hz] : ", mean(res_dop(δx_OR8), weights(w_dop)), "\n")
println("Chi-squared statistic (χ²): [adimensional] : ", chi2(res(δx_OR8),w))
println("Normalized RMS (optical-only) [adimensional] : ", nrms(res_radec(fit_OR8.x),w_radec))
println("Normalized RMS (radar-only) [adimensional] : ", nrms(vcat(res_del,res_dop)(fit_OR8.x),vcat(w_del,w_dop)))
println("Normalized RMS (combined optical and radar) [adimensional] : ", nrms(res(fit_OR8.x),w), "\n")
println("Mean weighted right-ascension residual [arcseconds] : ", mean(res_ra(fit_OR8.x), weights(w_ra)))
println("Mean weighted declination residual [arcseconds] : ", mean(res_dec(fit_OR8.x), weights(w_dec)))
println("Mean weighted time-delay residual [micro-seconds]: ", mean(res_del(fit_OR8.x), weights(w_del)))
println("Mean weighted Doppler-shift residual [Hz] : ", mean(res_dop(fit_OR8.x), weights(w_dop)), "\n")
println("Chi-squared statistic (χ²): [adimensional] : ", chi2(res(fit_OR8.x),w))

return sol_bwd, sol_fwd, res_radec, res_del, res_dop, w_radec, w_del, w_dop
end
Expand Down Expand Up @@ -316,3 +313,36 @@ function main()
end

main()

#=
-0.18034827489412805
0.9406910783153754
0.3457360118643932
-0.016265940057745887
4.3915296805381036e-5
-0.0003952032399008921
-2.883842658925719e-14
-1.6977850502837174e-11


6.991681792970175e-9
3.3210758500485412e-9
8.763895947794195e-9
5.485729074188412e-11
9.846074910774499e-11
1.3782767177665416e-10
2.525644870489942e-16
3.2193289354129716e-12

Normalized RMS (optical-only) [adimensional] : 0.4365429773707507
Normalized RMS (radar-only) [adimensional] : 0.5421268387032326
Normalized RMS (combined optical and radar) [adimensional] : 0.43685679642513925

Mean weighted right-ascension residual [arcseconds] : -0.002787272519210798
Mean weighted declination residual [arcseconds] : -0.003376099885054764
Mean weighted time-delay residual [micro-seconds]: -0.0007329351962194035
Mean weighted Doppler-shift residual [Hz] : -0.03025601266756564

Chi-squared statistic (χ²): [adimensional] : 3597.4067719864497

=#
Loading
Loading