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

Read SPK files directly #36

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
1151f54
Add exhaustive CSPICE test on de438s
ChristopherRabotin Oct 21, 2022
e4d260c
Add an exhaustive test using Greg's rust-spice
ChristopherRabotin Oct 21, 2022
f9c8bfd
Testing out different designs for frames
ChristopherRabotin Oct 28, 2022
e162892
Add Cartesian state computation, orbit, and geodetic orbit
ChristopherRabotin Nov 4, 2022
974e304
Trying to copy the tests from Nyx but I need to add frame data first :-/
ChristopherRabotin Nov 4, 2022
5f2c2f0
Rename asn1 module
ChristopherRabotin Nov 4, 2022
1100917
Add planetary constants to match text PCK
ChristopherRabotin Nov 5, 2022
297a6f1
Rename module again
ChristopherRabotin Nov 5, 2022
e499124
Cleanup orientation
ChristopherRabotin Nov 5, 2022
7c2b32f
Refactor frames and add inertia tensor
ChristopherRabotin Nov 5, 2022
4d0d63d
Well this sucks. The new struct is too big
ChristopherRabotin Nov 5, 2022
870695f
Reduced size of structure by changing placement of Option<_>s
ChristopherRabotin Nov 5, 2022
04b719f
Productive co-engineering session!
ChristopherRabotin Nov 6, 2022
e5ab976
Array<'a, T> solves the issues with SequenceOf
ChristopherRabotin Nov 7, 2022
f1731b0
Converting LUT to DataArray fails
ChristopherRabotin Nov 7, 2022
62c31a7
Rewriting the DAF parser with zerocopy
ChristopherRabotin Nov 8, 2022
908b263
Good chunk of refactoring from last night
ChristopherRabotin Nov 12, 2022
55cf9de
Ha, fixed the unloading issue!
ChristopherRabotin Nov 12, 2022
4738e7f
Minor cleanup
ChristopherRabotin Nov 12, 2022
d129371
Clean up tests of SPK loading
ChristopherRabotin Nov 12, 2022
150acf1
Make DAF first-class container -- tests fail
ChristopherRabotin Nov 16, 2022
b81a912
Fixed the ephem paths issue(s?)
ChristopherRabotin Nov 16, 2022
d3a8c08
Rewrote Context to use SPK files as is without needing ASN1
ChristopherRabotin Nov 18, 2022
5d40788
Add Polynominal from Nyx, and made it alloc free.
ChristopherRabotin Nov 19, 2022
b205322
Co-engineering session
ChristopherRabotin Nov 19, 2022
636a5f2
Hermite Type 13 _almost_ works
ChristopherRabotin Nov 21, 2022
9a4deff
I need to rewrite this as divided differences I think
ChristopherRabotin Nov 22, 2022
4722063
Finally just using the SPICE algo
ChristopherRabotin Nov 27, 2022
b690eea
Cleanup the variables
ChristopherRabotin Nov 27, 2022
d0c11b7
More cleanup (not done yet)
ChristopherRabotin Nov 27, 2022
a49c27a
Add C hrmint file for reference
ChristopherRabotin Nov 27, 2022
1991ba2
Almost done cleaning up
ChristopherRabotin Nov 27, 2022
3524393
Clippy action
ChristopherRabotin Nov 28, 2022
1cadb63
Moaaar refactoring
ChristopherRabotin Nov 28, 2022
c84c124
Woop woop
ChristopherRabotin Nov 28, 2022
6183f71
Format + clippy
ChristopherRabotin Nov 28, 2022
ac4952b
Format + clippy
ChristopherRabotin Nov 28, 2022
bcfd7d4
Merge branch '30-spice-bsp-files-should-be-usable-without-needing-the…
ChristopherRabotin Nov 28, 2022
51b8cb6
Add CSPICE installation in tests
ChristopherRabotin Nov 28, 2022
2b430a3
Rename benches
ChristopherRabotin Nov 28, 2022
6f29db9
Expand benchmarks and add those to the tests
ChristopherRabotin Nov 30, 2022
c98c6ec
Add CSPICE build to benchmarks
ChristopherRabotin Nov 30, 2022
b958c0e
Maybe add coverage?
ChristopherRabotin Nov 30, 2022
14b0ac5
Add LFS to benchmark
ChristopherRabotin Nov 30, 2022
9073336
Remove DER requirement for now
ChristopherRabotin Nov 30, 2022
b1f583d
Review changes
ChristopherRabotin Nov 30, 2022
46107eb
Removed specs submodule
ChristopherRabotin Nov 30, 2022
11e5206
Update requirements.txt for analysis
ChristopherRabotin Dec 1, 2022
16fa548
Merge branch '30-spice-bsp-files-should-be-usable-without-needing-the…
ChristopherRabotin Dec 1, 2022
42c4862
Rename analysis script and add analysis for Hermite test
ChristopherRabotin Dec 2, 2022
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
CSPICE_DIR = {value = "./cspice/", relative = true}
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data/*.bsp filter=lfs diff=lfs merge=lfs -text
data/earth_old_high_prec.bpc filter=lfs diff=lfs merge=lfs -text
data/*.bpc filter=lfs diff=lfs merge=lfs -text
data/de421.anise filter=lfs diff=lfs merge=lfs -text
data/de430.anise filter=lfs diff=lfs merge=lfs -text
data/de438s.anise filter=lfs diff=lfs merge=lfs -text
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Benchmarks

on:
push:
branches:
- master
tags:
- "*"
pull_request:
workflow_dispatch:

jobs:
type2_chebyshev:
name: JPL DE Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench
run: cargo bench --bench "*_jpl_ephemerides"

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
with:
name: jpl-development-ephemerides-benchmark
path: target/criterion/**/report/*

type13_hermite:
name: Hermite Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench
run: cargo bench --bench "*_spacecraft_ephemeris"

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
with:
name: spacecraft-ephemeris-benchmark
path: target/criterion/**/report/*
115 changes: 96 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ jobs:
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

spice-convert-and-test:
name: Converts SPICE BSP files into ANISE files and runs the tests
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -46,17 +49,8 @@ jobs:
toolchain: stable
override: true

- name: Build
run: cargo build --release

- name: Convert DE438s and verify every coefficient (slow)
run: cargo run --release -- convert ./data/de438s.bsp --check

- name: Convert DE421, DE430, DE440
run: |
cargo run --release -- convert ./data/de421.bsp
cargo run --release -- convert ./data/de430.bsp
cargo run --release -- convert ./data/de440.bsp
- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Test debug (default features) # This has overflow checks etc.
run: cargo test
Expand All @@ -70,12 +64,6 @@ jobs:
- name: Test (no default features and release)
run: cargo test --no-default-features --release

- name: Create DE ANISE artifacts # At this stage, all of the tests have passed, so let's store these artifacts
uses: actions/upload-artifact@v3
with:
name: anise-jpl-development-ephemerides
path: data/*.anise

lints:
name: Lints
runs-on: ubuntu-latest
Expand All @@ -102,3 +90,92 @@ jobs:
with:
command: clippy
args: -- -D warnings

validation:
name: Validation
runs-on: ubuntu-latest
needs: [check, test, lints]
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: CLI SPK
run: |
cargo run -- inspect data/gmat-hermite.bsp
cargo run -- inspect data/de440.bsp

- name: Rust-SPICE JPL DE validation
run: RUST_BACKTRACE=full RUST_LOG=debug cargo test validate_jplde_translation --features validation --release -- --nocapture

- name: Rust-SPICE hermite validation
run: RUST_BACKTRACE=full RUST_LOG=debug cargo test validate_hermite_translation --features validation --release -- --nocapture

# Now analyze the results and create pretty plots
- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Validation analysis
run: |
cd analysis
pip install -r requirements.txt
python spk_type2_jplde_val_err.py
python spk_type13_val_err.py

- name: Save validation artifacts
uses: actions/upload-artifact@v3
with:
name: validation-artifacts
path: target/*.html

coverage:
name: Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install CSPICE
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate coverage report
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov test --no-report --features=std -- --test-threads=1
cargo llvm-cov test --no-report --tests --features=std -- compile_fail
cargo llvm-cov report --lcov > lcov.txt
env:
RUSTFLAGS: --cfg __ui_tests

- name: Upload coverage report
uses: codecov/codecov-action@v3
env:
TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./lcov.txt
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/target
Cargo.lock
*.anis*
*.anis*
cspice
*.parquet
*.svg
perf.data*
analysis/.venv
cspice.tar.Z
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "specs"]
path = specs
url = https://github.com/anise-toolkit/specs.git
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "yapf"
}
5 changes: 5 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Authors

+ Christopher Rabotin <chris.rabotin@protonmail.com>
+ Chris de Claverie <c.de-claverie@protonmail.com>
+ Grégoire Henry <greg.henry@mail.com>
41 changes: 35 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,49 @@ keywords = ["attitude","navigation","instrument", "spacecraft", "ephemeris"]
categories = ["science", "simulation"]
readme = "README.md"
license = "MPL-2.0"
exclude = ["cspice"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# hifitime = {version = "3.4.0", features = ["asn1der"]}
hifitime = {git = "https://github.com/nyx-space/hifitime", rev= "042599948499086ea4e854727eac885f6cab5d89"} # TODO: Switch to 3.4.1 when published.
memmap2 = "0.5.7"
hifitime = {version = "3.7.0", features = []}
memmap2 = "0.5.8"
crc32fast = "1.3.0"
der = {version = "0.6.0", features = ["derive", "alloc", "real"]}
# der = {version = "0.6.0", features = ["derive", "alloc", "real"]} # Disabled until DER is needed again.
clap = {version = "3.1", features = ["derive"]}
thiserror = "1.0"
log = "0.4"
pretty_env_logger = "0.4"
tabled = "0.8"
tabled = "0.10"
const_format = "0.2"
nalgebra = "0.31"
approx = "0.5.1"
approx = "0.5.1"
zerocopy = "0.6.1"

[dev-dependencies]
rust-spice = "0.7.4"
parquet = "25.0.0"
arrow = "25.0.0"
criterion = "0.3"
iai = "0.1"
polars = {version = "0.25", features = ["lazy", "parquet"]}

[features]
default = ["std"]
std = []
validation = [] # Enabling this flag significantly reduces compilation times due to Arrow and Polars.

[profile.bench]
debug = true

[[bench]]
name = "iai_jpl_ephemerides"
harness = false

[[bench]]
name = "crit_jpl_ephemerides"
harness = false

[[bench]]
name = "iai_spacecraft_ephemeris"
harness = false
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Solar System barycenter
# Development
## Requirements
1. `rustc` version `1.64` or higher (required for the 2021 edition): https://rust-lang.org/ (TODO: Set a minimum compatible rust version)
2. `git`
2. `git`
1. `rust-spice` is used for exhaustive testing of the SPICE interoperability. It requires the cspice library.
10 changes: 10 additions & 0 deletions analysis/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
hifitime==3.7.0
numpy==1.23.4
pandas==1.5.1
plotly==5.10.0
polars==0.14.21
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.5
six==1.16.0
tenacity==8.1.0
36 changes: 36 additions & 0 deletions analysis/spk_type13_val_err.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pandas as pd
import plotly.express as px
from os.path import abspath, join, dirname

if __name__ == '__main__':

target_folder = join(abspath(dirname(__file__)), '..', 'target')

for name, filename in [("validation", "type13-validation-test-results"),
("outliers", "type13-validation-outliers")]:

# Load the parquet file
df = pd.read_parquet(f"{target_folder}/{filename}.parquet")

if name == 'validation':
y = 'relative error'
else:
y = 'absolute error'

for kind, columns in [("Position", ["X", "Y", "Z"]),
("Velocity", ["VX", "VY", "VZ"])]:

print(f"== {kind} {name} ==")

subset = df.loc[df.component.isin(columns)]

print(subset.describe())

plt = px.scatter(subset,
x='File delta T (s)',
y=y,
color='source frame')

plt.write_html(
f"{target_folder}/{name}-{kind}-validation.html")
plt.show()
Loading